Skip to contentSkip to conversation

lib/oe/unpack.py: fix uncompressing .gz .bz2 or .xz

PATCH Superseded Eric Bénard 2 participants 6 messages Sep 6, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/oe/unpack.py: fix uncompressing .gz .bz2 or .xz

* Actually, the destination file has the full path (ie it's uncompressed in the download directory) as only the extension is removed.
* By also removing the path, this patch should fix this problem.
* An other fix could be to no uncompress to stdout but let gunzip|bunzip2| xz uncompress directly to the file.

---
 lib/oe/unpack.py |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
lib/oe/unpack.py +3 -0
index 34569aa..8fc329a 100644
@@ -64,14 +64,17 @@ def unpack_file(file, destdir, dos=False, env=None):
         cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
     elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
         base, ext = os.path.splitext(file)
+        ext, base = os.path.split(base)
         cmd = 'gzip -dc %s > %s' % (file, base)
     elif file.endswith('.bz2'):
         base, ext = os.path.splitext(file)
+        ext, base = os.path.split(base)
         cmd = 'bzip2 -dc %s > %s' % (file, base)
     elif file.endswith('.tar.xz'):
         cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
     elif file.endswith('.xz'):
         base, ext = os.path.splitext(file)
+        ext, base = os.path.split(base)
         cmd = 'xz -dc %s > %s' % (file, base)
     elif file.endswith('.zip') or file.endswith('.jar'):
         cmd = 'unzip -q -o'
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 6 lines · Eric Bénard

* Actually, the destination file has the full path (ie it's uncompressed in the download directory) as only the extension is removed.
* By also removing the path, this patch should fix this problem.
* An other fix could be to no uncompress to stdout but let gunzip|bunzip2| xz uncompress directly to the file.

Thanks for looking into this. I appreciate your putting together a fix. See code comments below.

Please improve the wording of the commit message here. "has the full path" is unclear. I'd suggest referring to the fact that it's currently writing into the *source* path rather than the *destination* path, to clarify a bit.

    elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
Quoted 3 lines

base, ext = os.path.splitext(file)
+ ext, base = os.path.split(base)

This variable naming is wrong and misleading. The leading portion of the split is not an extension, so 'ext' is not correct. Also, you just throw away the leading portion anyway, so there's no need to use os.path.split at all. Instead, I'd suggest changing this:

base, ext = os.path.splitext(file)
cmd = 'bzip2 -dc %s > %s' % (file, base)

to this:

root, ext = os.path.splitext(file)
cmd = 'bzip2 -dc %s > %s' % (file, os.path.basename(root))

Thanks again,

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#2 lore raw

PATCH v2 1/1 lib/oe/unpack.py: fix uncompressing .gz .bz2 or .xz

* Actually, the uncompressed file is written into the source path instead of the destination path.
* By also removing the source path, this patch should fix this problem.
* An other fix could be to not uncompress to stdout but let gunzip|bunzip2| xz uncompress directly to the file.

---
v2:
python part reworked as per Chris Larson's suggestion commit message rephrased to clarify it.

 lib/oe/unpack.py |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
lib/oe/unpack.py +6 -6
index 34569aa..6d24c5e 100644
@@ -63,16 +63,16 @@ def unpack_file(file, destdir, dos=False, env=None):
     elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
         cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
     elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
-        base, ext = os.path.splitext(file)
-        cmd = 'gzip -dc %s > %s' % (file, base)
+        root, ext = os.path.splitext(file)
+        cmd = 'gzip -dc %s > %s' % (file, os.path.basename(root))
     elif file.endswith('.bz2'):
-        base, ext = os.path.splitext(file)
-        cmd = 'bzip2 -dc %s > %s' % (file, base)
+        root, ext = os.path.splitext(file)
+        cmd = 'bzip2 -dc %s > %s' % (file, os.path.basename(root))
     elif file.endswith('.tar.xz'):
         cmd = 'xz -dc %s | tar x --no-same-owner -f -' % file
     elif file.endswith('.xz'):
-        base, ext = os.path.splitext(file)
-        cmd = 'xz -dc %s > %s' % (file, base)
+        root, ext = os.path.splitext(file)
+        cmd = 'xz -dc %s > %s' % (file, os.path.basename(root))
     elif file.endswith('.zip') or file.endswith('.jar'):
         cmd = 'unzip -q -o'
         if dos:
Signature · 1 line
1.6.3.3
Acked-by on v2 1/1
#3 lore raw
Quoted 9 lines · Eric Bénard

* Actually, the uncompressed file is written into the source path instead of the destination path.
* By also removing the source path, this patch should fix this problem.
* An other fix could be to not uncompress to stdout but let gunzip|bunzip2| xz uncompress directly to the file.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#4 lore raw
In reply to Chris Larson

Hi Chris,

Quoted 26 lines · Chris Larson
Quoted 6 lines · Eric Bénard

* Actually, the destination file has the full path (ie it's uncompressed in the download directory) as only the extension is removed.
* By also removing the path, this patch should fix this problem.
* An other fix could be to no uncompress to stdout but let gunzip|bunzip2| xz uncompress directly to the file.

Thanks for looking into this. I appreciate your putting together a fix. See code comments below.

Please improve the wording of the commit message here. "has the full path" is unclear. I'd suggest referring to the fact that it's currently writing into the *source* path rather than the *destination* path, to clarify a bit.

     elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
Quoted 3 lines

base, ext = os.path.splitext(file)
+ ext, base = os.path.split(base)

This variable naming is wrong and misleading. The leading portion of the split is not an extension, so 'ext' is not correct. Also, you just throw away the leading portion anyway, so there's no need to use os.path.split at all. Instead, I'd suggest changing this:

Quoted 8 lines

base, ext = os.path.splitext(file)
cmd = 'bzip2 -dc %s> %s' % (file, base)

to this:

root, ext = os.path.splitext(file)
cmd = 'bzip2 -dc %s> %s' % (file, os.path.basename(root))

thanks for the review. I've updated the patch following your comments.

Eric

#5 lore raw

PATCH 1/1 asterisk: replace termcap by tinfo

In reply to Chris Larson

* this fix the following configure problem :
checking for tgetent in -ltermcap... no
configure: ***
configure: *** The Termcap installation on this system appears to be broken.
configure: *** Either correct the installation, or run configure
configure: *** without explicitly specifying --with-termcap
* PR bumped

---
 recipes/asterisk/asterisk_1.4.23.1.bb |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
recipes/asterisk/asterisk_1.4.23.1.bb +3 -2
index af6967a..5869187 100644
@@ -5,8 +5,9 @@ HOMEPAGE = "http://www.asterisk.org"
 LICENSE = "GPLv2"
 PRIORITY = "optional"
 SECTION = "console/telephony"
-DEPENDS = "speex readline zlib openssl curl popt gnutls sqlite libogg libvorbis"
+DEPENDS = "speex readline zlib openssl curl popt gnutls sqlite libogg libvorbis ncurses"
 #RRECOMMENDS_${PN} = "logrotate"
+PR = "r1"
 
 SRC_URI="http://downloads.digium.com/pub/asterisk/releases/asterisk-${PV}.tar.gz \
 #	file://sounds.xml.patch \
@@ -28,7 +29,7 @@ inherit autotools update-rc.d
 EXTRA_OECONF =  "--with-ssl=${STAGING_EXECPREFIXDIR} \
 			--with-z=${STAGING_EXECPREFIXDIR} \
 			--with-curl=${STAGING_EXECPREFIXDIR} \
-			--with-termcap=${STAGING_EXECPREFIXDIR} \
+			--with-tinfo=${STAGING_EXECPREFIXDIR} \
 			--with-ogg=${STAGING_EXECPREFIXDIR} \
 			--with-vorbis=${STAGING_EXECPREFIXDIR} \
 			--with-sqlite=${STAGING_EXECPREFIXDIR} \
Signature · 1 line
1.6.3.3