From: Chris Alfonso Date: Mon, 21 May 2012 18:50:54 +0000 (-0400) Subject: Fixing _decompress to handle bundled and compressed X-Git-Tag: 2014.1~1809^2~1 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7d0a35030ae50d9405368d36519db712896841cd;p=openstack-build%2Fheat-build.git Fixing _decompress to handle bundled and compressed The api call to os.path.splitext returns the root and the ext; however, for a .tar.gz the ext would just be the .gz, which meant there was no handler for a file with a .gz extension. --- diff --git a/heat/cfntools/cfn_helper.py b/heat/cfntools/cfn_helper.py index 841938cb..0ca2503c 100644 --- a/heat/cfntools/cfn_helper.py +++ b/heat/cfntools/cfn_helper.py @@ -581,15 +581,28 @@ class SourcesHandler(object): def _decompress(self, archive, dest_dir): cmd_str = '' + logger.debug("Decompressing") (r, ext) = os.path.splitext(archive) - if ext == '.tar.gz' or ext == '.tgz': + if ext == '.tgz': cmd_str = 'tar -C %s -xzf %s' % (dest_dir, archive) - elif ext == '.tar.bz2' or ext == '.tbz2': + elif ext == '.tbz2': cmd_str = 'tar -C %s -xjf %s' % (dest_dir, archive) elif ext == '.zip': cmd_str = 'unzip -d %s %s' % (dest_dir, archive) elif ext == '.tar': cmd_str = 'tar -C %s -xf %s' % (dest_dir, archive) + elif ext == '.gz': + (r, ext) = os.path.splitext(r) + if ext: + cmd_str = 'tar -C %s -xzf %s' % (dest_dir, archive) + else: + cmd_str = 'gunzip -c %s > %s' % (archive, dest_dir) + elif ext == 'bz2': + (r, ext) = os.path.splitext(r) + if ext: + cmd_str = 'tar -C %s -xjf %s' % (dest_dir, archive) + else: + cmd_str = 'bunzip2 -c %s > %s' % (archive, dest_dir) else: pass return CommandRunner(cmd_str)