Skip to contentSkip to conversation

ipk ar/tar unpack

PATCH In review [email protected] 2 participants 5 messages Jul 15, 2020 – Aug 24, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipk ar/tar unpack

From: Chris Minnoy <[email protected]>
Date: Wed, 15 Jul 2020 15:02:35 +0200
Subject: [PATCH] ipk packages can be formed with ar or tar. ar/tar can't read each other archives. This fixes the unpack to call the correct archiver based on the format.

---
 bitbake/lib/bb/fetch2/__init__.py | 40 ++++++++++++++++++++++++++++---

 1 file changed, 37 insertions(+), 3 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +0 -0
index 2ada43befc..e79149a208 100644
@@ -1467,7 +1467,41 @@ class FetchMethod(object):

                     iterate_file = unpack_file
                 else:
                     cmd = 'rpm2cpio.sh %s | cpio -id' % (file)
-            elif file.endswith('.deb') or file.endswith('.ipk'):
+            elif file.endswith('.ipk'):
+                output = subprocess.check_output(['file', file], preexec_fn=subprocess_setup)
+                if output:
+                    if output.decode().find("current ar archive") != -1:
+                        output = subprocess.check_output(['ar', '-t', file], preexec_fn=subprocess_setup)
+                        datafile = None
+                        if output:
+                            for line in output.decode().splitlines():
+                                if line.startswith('data.tar.'):
+                                    datafile = line
+                                    break
+                            else:
+                                raise UnpackError("Unable to unpack ipk package - does not contain data.tar.* file", urldata.url) +                        else:
+                            raise UnpackError("Unable to unpack ipk package - could not list contents", urldata.url) +                        cmd = 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile) +                    elif output.decode().find("gzip compressed data") != -1:
+                        output = subprocess.check_output(['tar', '-tf', file], preexec_fn=subprocess_setup) +                        datafile = None
+                        if output:
+                            for line in output.decode().splitlines():
+                                if line.startswith('./data.tar.'):
+                                    datafile = line
+                                    break
+                            else:
+                                raise UnpackError("Unable to unpack ipk package - does not contain data.tar.* file", urldata.url) +                        else:
+                            raise UnpackError("Unable to unpack ipk package - could not list contents", urldata.url) +                        cmd = 'tar -xf %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile) +
+                    else:
+                        raise UnpackError("Unable to unpack ipk package - unknown format", urldata.url)
+                else:
+                    raise UnpackError("Unable to detect .ipk file format - unknown format", urldata.url)
+            elif file.endswith('.deb'):
                 output = subprocess.check_output(['ar', '-t', file], preexec_fn=subprocess_setup)
                 datafile = None
                 if output:
@@ -1476,9 +1510,9 @@ class FetchMethod(object):
                             datafile = line
                             break
                     else:
-                        raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url) +                        raise UnpackError("Unable to unpack deb package - does not contain data.tar.* file", urldata.url) else:
-                    raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url) +                    raise UnpackError("Unable to unpack deb package - could not list contents", urldata.url) cmd = 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile)

         # If 'subdir' param exists, create a dir and use it as destination for unpack cmd

Signature · 1 line
2.17.1
#1 lore raw

Hi,

Quoted 20 lines · Chris Minnoy

From: Chris Minnoy <[email protected]>
Date: Wed, 15 Jul 2020 15:02:35 +0200
Subject: [PATCH] ipk packages can be formed with ar or tar. ar/tar can't
read
each other archives. This fixes the unpack to call the correct
archiver based
on the format.

---
  bitbake/lib/bb/fetch2/__init__.py | 40
++++++++++++++++++++++++++++---
  1 file changed, 37 insertions(+), 3 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +0 -0
index 2ada43befc..e79149a208 100644

bitbake/lib/bb/fetch2/__init__.py class FetchMethod(object): · line 1473

Quoted 8 lines
bitbake/lib/bb/fetch2/__init__.py +3 -1
@@ -1467,7 +1467,41 @@ class FetchMethod(object):
                      iterate_file = unpack_file
                  else:
                      cmd = 'rpm2cpio.sh %s | cpio -id' % (file)
-            elif file.endswith('.deb') or file.endswith('.ipk'):
+            elif file.endswith('.ipk'):
+                output = subprocess.check_output(['file', file], 
 preexec_fn=subprocess_setup)
+                if output:

Thanks for the patch. Unfortunately it came through line wrapped. The short/long commit message also doesn't match our patch format guidelines.

https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines

Could you fix those issues and resubmit please?

Cheers,

Richard

#2 lore raw

From d21155c4b55ac96d3c13a3cef1f020df67b62641 Mon Sep 17 00:00:00 2001
From: Chris Minnoy <[email protected]>
Date: Fri, 7 Aug 2020 11:35:27 +0000
Subject: [PATCH 1/1] bitbake fetch2: fetcher can now unpack .ipk files from ar and tar format

Ipk packages can be formed with ar or tar. ar/tar can't read each others archives. This fixes the unpack to call the correct archiver based on the format.
---
bitbake/lib/bb/fetch2/__init__.py | 39 ++++++++++++++++++++++++++++++++++++---

1 file changed, 36 insertions(+), 3 deletions(-)
bitbake/lib/bb/fetch2/__init__.py +0 -0
index 2ada43befc..d66d677434 100644
@@ -1467,7 +1467,40 @@ class FetchMethod(object):

iterate_file = unpack_file
else:
cmd = 'rpm2cpio.sh %s | cpio -id' % (file)
-            elif file.endswith('.deb') or file.endswith('.ipk'):
+            elif file.endswith('.ipk'):
+                output = subprocess.check_output(['file', file], preexec_fn=subprocess_setup)
+                if output:
+                    if output.decode().find("current ar archive") != -1:
+                        output = subprocess.check_output(['ar', '-t', file], preexec_fn=subprocess_setup)
+                        datafile = None
+                        if output:
+                            for line in output.decode().splitlines():
+                                if line.startswith('data.tar.'):
+                                    datafile = line
+                                    break
+                                else:
+                                    raise UnpackError("Unable to unpack ipk package - does not contain data.tar.* file", urldata.url) +                        else:
+                            raise UnpackError("Unable to unpack ipk package - could not list contents", urldata.url) +                        cmd = 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile) +                    elif output.decode().find("gzip compressed data") != -1:
+                        output = subprocess.check_output(['tar', '-tf', file], preexec_fn=subprocess_setup)
+                        datafile = None
+                        if output:
+                            for line in output.decode().splitlines():
+                                if line.startswith('./data.tar.'):
+                                    datafile = line
+                                    break
+                                else:
+                                    raise UnpackError("Unable to unpack ipk package - does not contain data.tar.* file", urldata.url) +                        else:
+                            raise UnpackError("Unable to unpack ipk package - could not list contents", urldata.url) +                        cmd = 'tar -xf %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile) +                    else:
+                        raise UnpackError("Unable to unpack ipk package - unknown format", urldata.url)
+                else:
+                    raise UnpackError("Unable to detect .ipk file format - unknown format", urldata.url)
+            elif file.endswith('.deb'):
output = subprocess.check_output(['ar', '-t', file], preexec_fn=subprocess_setup)
datafile = None
if output:
@@ -1476,9 +1509,9 @@ class FetchMethod(object):
datafile = line
break
else:
-                        raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url) +                        raise UnpackError("Unable to unpack deb package - does not contain data.tar.* file", urldata.url) else:
-                    raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url) +                    raise UnpackError("Unable to unpack deb package - could not list contents", urldata.url) cmd = 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafile, datafile)

# If 'subdir' param exists, create a dir and use it as destination for unpack cmd --
2.11.0

#3 lore raw
Quoted 11 lines · Chris Minnoy

From d21155c4b55ac96d3c13a3cef1f020df67b62641 Mon Sep 17 00:00:00 2001
From: Chris Minnoy <[email protected]>
Date: Fri, 7 Aug 2020 11:35:27 +0000
Subject: [PATCH 1/1] bitbake fetch2: fetcher can now unpack .ipk files from ar and tar format

Ipk packages can be formed with ar or tar. ar/tar can't read each others archives.
This fixes the unpack to call the correct archiver based on the format.

What is creating ipk files using tar instead of ar?

I know they did once exist but I've not seen real world use of those for many years?

Cheers,

Richard

#4 lore raw

We sometimes import ipk packages from OpenWRT into Yocto. Unfortunatly they use the other archiver; hence the patch.

Cheers,

Chris

Quoted 21 lines · Richard Purdie
Quoted 11 lines · Chris Minnoy

From d21155c4b55ac96d3c13a3cef1f020df67b62641 Mon Sep 17 00:00:00
2001
From: Chris Minnoy <[email protected]>
Date: Fri, 7 Aug 2020 11:35:27 +0000
Subject: [PATCH 1/1] bitbake fetch2: fetcher can now unpack .ipk files from ar and tar format

Ipk packages can be formed with ar or tar. ar/tar can't read each others archives.
This fixes the unpack to call the correct archiver based on the format.

What is creating ipk files using tar instead of ar?

I know they did once exist but I've not seen real world use of those for many years?

Cheers,

Richard

Signature · 3 lines
With kind regards,

Chris Minnoy