Skip to content

Commit

Permalink
Merge pull request #472 from berndfinger/issue-470
Browse files Browse the repository at this point in the history
sap_install_media_detect: Fix SAPCAR extraction error for SAP ASE Client
  • Loading branch information
sean-freeman authored Sep 22, 2023
2 parents 69dd72c + e1d7634 commit 96145ee
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions roles/sap_install_media_detect/tasks/organize_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@
- line_item.archive_type == 'rarexe'
- line_item.extract_archive == 'y'

# SAP HANA sapcar archive files have a directory structure with a single directory (e.g. SAP_HANA_DATBASE) which contains all files.
# We want the extracted files to be placed in extraction_dir under this directory name, allowing multiple directories in extraction_dir.
# So we create a temporary directory, move the file SIGNATURE.SMF (which the sapcar command extracts to the level above) to this directory,
# and then move the single directory to the extraction_dir.
- name: SAP Install Media Detect - Organize all files - Create temp dir for sapcar archive files - {{ __sap_install_media_detect_software_main_directory }}/tmp_extract
ansible.builtin.file:
path: "{{ __sap_install_media_detect_software_main_directory }}/tmp_extract"
Expand All @@ -140,15 +144,15 @@
group: root
mode: '0755'

- name: SAP Install Media Detect - Organize all files - Extract sapcar archive files
- name: SAP Install Media Detect - Organize all files - Extract HANA sapcar archive files
ansible.builtin.shell: >-
{{ __sap_install_media_detect_fact_sapcar_path }}
-R {{ __sap_install_media_detect_software_main_directory }}/tmp_extract
-xvf {{ __sap_install_media_detect_software_main_directory }}/{{ line_item.file }}
-manifest SIGNATURE.SMF
&& extracted_dir=$(ls -d */)
&& mv SIGNATURE.SMF $extracted_dir
&& mkdir -p {{ __sap_install_media_detect_software_main_directory }}/{{ line_item.extraction_dir }}/$extracted_dir
&& mkdir -p {{ __sap_install_media_detect_software_main_directory }}/{{ line_item.extraction_dir }}
&& mv $extracted_dir {{ __sap_install_media_detect_software_main_directory }}/{{ line_item.extraction_dir }}/
args:
chdir: "{{ __sap_install_media_detect_software_main_directory }}/tmp_extract"
Expand All @@ -157,14 +161,35 @@
loop_var: line_item
when:
- sap_install_media_detect_extract_archives
- line_item.archive_type == 'sapcar'
- line_item.extract_archive == 'y'
- line_item.archive_type == 'sapcar'
- line_item.sap_file_type is search('saphana')

- name: SAP Install Media Detect - Organize all files - Remove temp dir - {{ __sap_install_media_detect_software_main_directory }}/tmp_extract
ansible.builtin.file:
path: "{{ __sap_install_media_detect_software_main_directory }}/tmp_extract"
state: absent

# Non-SAP HANA sapcar archive files can have various different directory structures: Can be all flat, or up to 13 directory levels.
# We want the extracted files to be placed in the extraction_dir for this file, each file tree having its own separate directory.
# So we can directly extract the sapcar files to the final extraction_dir.
- name: SAP Install Media Detect - Organize all files - Extract non-HANA sapcar archive files
ansible.builtin.command: >-
{{ __sap_install_media_detect_fact_sapcar_path }}
-R {{ __sap_install_media_detect_software_main_directory }}/{{ line_item.extraction_dir }}
-xvf {{ __sap_install_media_detect_software_main_directory }}/{{ line_item.file }}
-manifest SIGNATURE.SMF
args:
chdir: "{{ __sap_install_media_detect_software_main_directory }}/{{ line_item.extraction_dir }}"
loop: "{{ __sap_install_media_detect_fact_files_sapfile_results }}"
loop_control:
loop_var: line_item
when:
- sap_install_media_detect_extract_archives
- line_item.extract_archive == 'y'
- line_item.archive_type == 'sapcar'
- not line_item.sap_file_type is search('saphana')

- name: SAP Install Media Detect - Organize all files - Copy certain files to 'sap_hana' directory
ansible.builtin.copy:
src: "{{ __sap_install_media_detect_software_main_directory }}/{{ line_item.file }}"
Expand Down

0 comments on commit 96145ee

Please sign in to comment.