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

Chris Larson clarson at kergoth.com
Mon Sep 6 19:50:59 UTC 2010


On Mon, Sep 6, 2010 at 11:48 AM, Eric Bénard <eric at eukrea.com> wrote:

> * 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'):
>         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,
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics



More information about the Openembedded-devel mailing list