diff mbox series

[v2,1/2] BootLinuxConsoleTest: Let extract_from_deb handle various compressions

Message ID 20190312234541.2887-2-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series Acceptance Tests: Test the Raspberry Pi 2 board | expand

Commit Message

Philippe Mathieu-Daudé March 12, 2019, 11:45 p.m. UTC
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).

List the archive files to have the 3rd name with the correct extension.

The function avocado.utils.archive.extract() will handle the different
compression format for us.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v2: Use process.run() (Cleber)
---
 tests/acceptance/boot_linux_console.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Cleber Rosa March 13, 2019, 12:05 a.m. UTC | #1
On Wed, Mar 13, 2019 at 12:45:40AM +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).
> 
> List the archive files to have the 3rd name with the correct extension.
> 
> The function avocado.utils.archive.extract() will handle the different
> compression format for us.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Cleber Rosa <crosa@redhat.com>
diff mbox series

Patch

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 23fca39422..0936589fd8 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -55,8 +55,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.run("ar t %s" % deb).stdout_text.split()[2]
+        process.run("ar x %s %s" % (deb, file_path))
+        archive.extract(file_path, self.workdir)
         os.chdir(cwd)
         return self.workdir + path