qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] BootLinuxConsoleTest: Let extract_from_deb hand


From: Cleber Rosa
Subject: Re: [Qemu-devel] [PATCH] BootLinuxConsoleTest: Let extract_from_deb handle various compressions
Date: Tue, 12 Mar 2019 14:51:24 -0400
User-agent: NeoMutt/20180716

On Sat, Mar 02, 2019 at 10:54:54PM +0100, Philippe Mathieu-Daudé wrote:
> Debian binary package format supports various compressions.
> 
> Per man deb(5):
> 
>   NAME
>     deb - Debian binary package format
> 
>   FORMAT
>     ...
>     The third, last required member is named data.tar.  It contains the
>     filesystem as a tar archive, either not compressed (supported since
>     dpkg 1.10.24), or compressed with gzip (with .gz extension),
>     xz (with .xz extension, supported since dpkg 1.15.6),
>     bzip2 (with .bz2 extension, supported since dpkg 1.10.24) or
>     lzma (with .lzma extension, supported since dpkg 1.13.25).
>

The man page does seem to indicate that ordering is respected (and not
that it just happens to be three of them).  I'm asking myself if it's
worth it to be extra paranoid an look for a "data.*" pattern anyway...

> List the archive files to have the 3rd name with the correct extension.
> 
> The method avocado.utils.archive.extract() will handle the different
> compression format for us.
>

Technically it's a function and not a method in Python lingo.

> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> Based-on: address@hidden
> 
>  tests/acceptance/boot_linux_console.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/acceptance/boot_linux_console.py 
> b/tests/acceptance/boot_linux_console.py
> index d866886067..b62b70bbde 100644
> --- a/tests/acceptance/boot_linux_console.py
> +++ b/tests/acceptance/boot_linux_console.py
> @@ -58,8 +58,9 @@ class BootLinuxConsole(Test):
>          """
>          cwd = os.getcwd()
>          os.chdir(self.workdir)
> -        process.run("ar x %s data.tar.gz" % deb)
> -        archive.extract("data.tar.gz", self.workdir)
> +        file_path = process.system_output("ar t %s" % 
> deb).split()[2].decode()

I'd recommend:

   file_path = process.run("ar t %s" % deb).stdout_text.split()[2]

Because of the more consistent style, and the lack of the explicit
decode().

> +        process.run("ar x %s %s" % (deb, file_path))
> +        archive.extract(file_path, self.workdir)
>          os.chdir(cwd)
>          return self.workdir + path
>  
> -- 
> 2.20.1
> 
> 

With and without the suggestions:

Tested-by: Cleber Rosa <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]