poise / poise-archive

A Chef cookbook to unpack file archives like TAR and ZIP files.
Apache License 2.0
10 stars 13 forks source link

Zip file directory structure is not retained #3

Closed jmaass closed 7 years ago

jmaass commented 7 years ago

When we unzip a zip file that itself contains other zip files, poise-archive does not retain the Directory structure:

From .kitchen/logs/kitchen.log:

         * poise_archive[http://mnetchef02.intern.m-net.de/tibco/TIB_ems_8.2.2_linux_x86.zip] action unpack
           * remote_file[/tmp/kitchen/cache/aHR0cDovL21uZXRjaGVmMDIuaW50ZXJuLm0tbmV0LmRlL3RpYmNvL1RJQl9lbXNfOC4yLjJfbGludXhfeDg2LnppcA_TIB_ems_8.2.2_linux_x86.zip] action create
             - create new file /tmp/kitchen/cache/aHR0cDovL21uZXRjaGVmMDIuaW50ZXJuLm0tbmV0LmRlL3RpYmNvL1RJQl9lbXNfOC4yLjJfbGludXhfeDg2LnppcA_TIB_ems_8.2.2_linux_x86.zip
             - update content in file /tmp/kitchen/cache/aHR0cDovL21uZXRjaGVmMDIuaW50ZXJuLm0tbmV0LmRlL3RpYmNvL1RJQl9lbXNfOC4yLjJfbGludXhfeDg2LnppcA_TIB_ems_8.2.2_linux_x86.zip from none to f7bfeb
             (file sizes exceed 10000000 bytes, diff output suppressed)
             - restore selinux security context
           * directory[/opt/app/tibco] action create (up to date)
           - unpack archive http://mnetchef02.intern.m-net.de/tibco/TIB_ems_8.2.2_linux_x86.zip to /opt/app/tibco

Login to converged node, let's see how it looks:

$ kitchen login tibco-server
[chefinit@centos7 ~]$ ls -l /opt/app/tibco
total 25860
-rw-r--r--. 1 root root   601223 Oct  4 18:10 assembly_tibco_com_tibco_jms_jmsclient_feature_8.2.2.003.zip
-rw-r--r--. 1 root root    36274 Oct  4 18:10 assembly_tibco_com_tibco_tpcl_javax_jms_feature_2.0.0.002.zip
-rw-r--r--. 1 root root  3646579 Oct  4 18:10 product_tibco_ems_32bit_client_runtime_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root  2404795 Oct  4 18:10 product_tibco_ems_32bit_development_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root  1488334 Oct  4 18:10 product_tibco_ems_32bit_runtime_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root  1790662 Oct  4 18:10 product_tibco_ems_32bit_thirdparty_runtime_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root  3070615 Oct  4 18:10 product_tibco_ems_64bit_client_runtime_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root  2808588 Oct  4 18:10 product_tibco_ems_64bit_development_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root  1594737 Oct  4 18:10 product_tibco_ems_64bit_runtime_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root  2063125 Oct  4 18:10 product_tibco_ems_64bit_thirdparty_runtime_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root     2664 Oct  4 18:10 product_tibco_ems_common_8.2.2.003.zip
-rw-r--r--. 1 root root    36150 Oct  4 18:10 product_tibco_ems_development_common_8.2.2.003.zip
-rw-r--r--. 1 root root  3686163 Oct  4 18:10 product_tibco_ems_runtime_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root    20709 Oct  4 18:10 product_tibco_ems_runtime_cfgcmgmt_common_8.2.2.003.zip
-rw-r--r--. 1 root root  2352406 Oct  4 18:10 product_tibco_ems_runtime_common_8.2.2.003.zip
-rw-r--r--. 1 root root    92286 Oct  4 18:10 product_tibco_ems_samples_8.2.2.003_linux_x86.zip
-rw-r--r--. 1 root root   217522 Oct  4 18:10 product_tibco_ems_samples_common_8.2.2.003.zip
-rwxr-xr-x. 1 root wheel    2706 Oct  4 18:10 TIBCOUniversalInstaller-ems.silent
-rw-r--r--. 1 root root   525371 Oct  4 18:10 TIB_ems_8.2.2_license.txt

OK, now let's delete the existing files and unzip the cached zip file from poise-archive's run by hand:

[chefinit@centos7 tibco]$ sudo rm -rf *
[chefinit@centos7 tibco]$ ls
[chefinit@centos7 tibco]$ sudo unzip /tmp/kitchen/cache/aHR0cDovL21uZXRjaGVmMDIuaW50ZXJuLm0tbmV0LmRlL3RpYmNvL1RJQl9lbXNfOC4yLjJfbGludXhfeDg2LnppcA_TIB_ems_8.2.2_linux_x86.zip
Archive:  /tmp/kitchen/cache/aHR0cDovL21uZXRjaGVmMDIuaW50ZXJuLm0tbmV0LmRlL3RpYmNvL1RJQl9lbXNfOC4yLjJfbGludXhfeDg2LnppcA_TIB_ems_8.2.2_linux_x86.zip
   creating: assemblies/
   creating: licenses/
  inflating: README.LINUX
  inflating: TIBCOUniversalInstaller-ems.silent
  inflating: TIB_ems_8.2.2_docinfo.html
  inflating: TIB_ems_8.2.2_license.pdf
  inflating: assemblies/assembly_tibco_com_tibco_jms_jmsclient_feature_8.2.2.003.zip
  inflating: assemblies/assembly_tibco_com_tibco_tpcl_javax_jms_feature_2.0.0.002.zip
  inflating: assemblies/product_tibco_ems_32bit_client_runtime_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_32bit_development_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_32bit_runtime_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_32bit_thirdparty_runtime_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_64bit_client_runtime_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_64bit_development_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_64bit_runtime_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_64bit_thirdparty_runtime_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_common_8.2.2.003.zip
  inflating: assemblies/product_tibco_ems_development_common_8.2.2.003.zip
  inflating: assemblies/product_tibco_ems_runtime_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_runtime_cfgcmgmt_common_8.2.2.003.zip
  inflating: assemblies/product_tibco_ems_runtime_common_8.2.2.003.zip
  inflating: assemblies/product_tibco_ems_samples_8.2.2.003_linux_x86.zip
  inflating: assemblies/product_tibco_ems_samples_common_8.2.2.003.zip
  inflating: licenses/TIB_ems_8.2.2_license.txt
  inflating: product_ems_8.2.2_FeatureConfig.xml
  inflating: TIBCOUniversalInstaller-lnx-x86.bin
[chefinit@centos7 tibco]$ ls -l
insgesamt 73944
drwxr-xr-x. 2 root root     4096 Sep 30  2015 assemblies
drwxr-xr-x. 2 root root     4096 Sep 30  2015 licenses
-rw-r--r--. 1 root root    13220 Sep 30  2015 product_ems_8.2.2_FeatureConfig.xml
-rw-r--r--. 1 root root     3060 Sep 30  2015 README.LINUX
-rw-r--r--. 1 root root     2720 Sep 30  2015 TIBCOUniversalInstaller-ems.silent
-rwxr-xr-x. 1 root root 74851328 Sep 30  2015 TIBCOUniversalInstaller-lnx-x86.bin
-rw-r--r--. 1 root root      323 Sep 30  2015 TIB_ems_8.2.2_docinfo.html
-rw-r--r--. 1 root root   826622 Sep  7  2015 TIB_ems_8.2.2_license.pdf

If you look at the different inflating results, you will notice that they are completely different. Since we are dependent on preserving the zipped directory structure, we are unable to use poise-archive at the moment, and we consider this behaviour of the cookbook a bug.

poise-archive should preserve the directory structure in the zip file when inflating it.

coderanger commented 7 years ago

Did you set strip_components 0? The archive resource follows the usual FOSS convention that everything in the zip will be in a top-level folder matching the name of the archive, a convention that your example file doesn't follow so you need to tell it. In the future it would be nice if it auto-detected this like some nicer archive tools (eg. The Unarchiver for macOS has some heuristics for deciding which mode to use) but for now it's manual.

jmaass commented 7 years ago

Hi Noah,

thanks for the quick reply! I just figured this out this morning, and everything’s running smoothly now, but I ran into another problem: Apparently, the cookbook just checks if the zip file is in the chef-client’s cache directory and if that’s the case, it will not try to inflate it again, even though the inflated files may have been deleted in the meantime. If you know that, the remedy is simple: you just delete the file in the cache. But if you don’t know it, then debugging just got a little more complicated.

I believe you can change this behavious by passing source_properties in the resource, but it would be good to mention it in the documentation, so noobs like me don’t run into this problem.

Thanks a lot for your great work!

Mit freundlichen Grüßen/Kind regards

Jörg Maaß Hays AG

Release Management Retail im Bereich IT

M-net Telekommunikations GmbH Emmy-Noether-Str. 2 | 80992 München

Von: Noah Kantrowitz [mailto:notifications@github.com] Gesendet: Mittwoch, 5. Oktober 2016 01:06 An: poise/poise-archive Cc: Maaß.Jörg; Author Betreff: Re: [poise/poise-archive] Zip file directory structure is not retained (#3)

Did you set strip_components 0? The archive resource follows the usual FOSS convention that everything in the zip will be in a top-level folder matching the name of the archive, a convention that your example file doesn't follow so you need to tell it. In the future it would be nice if it auto-detected this like some nicer archive tools (eg. The Unarchiver for macOS has some heuristics for deciding which mode to use) but for now it's manual.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/poise/poise-archive/issues/3#issuecomment-251539124, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKAyBF1OUaqvA6s5oRTY2EQLL5i5j7gLks5qwtvhgaJpZM4KN6HW.

coderanger commented 7 years ago

Yeah, I should probably make it clearer that using it with a URL is a very different mode of operation. If source is a normal path, it would re-unpack every time but that's almost never what you want soooo this is a compromise.

naveenkashyapdv commented 6 years ago

Thanks, this helped!!