Subject: Re: [PATCH] ipk ar/tar unpack To: bitbake-devel@lists.openembedded.org From: "Chris Minnoy" X-Originating-Location: Lommel, Flanders, BE (81.242.68.24) X-Originating-Platform: Linux Firefox 79 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Fri, 07 Aug 2020 04:54:37 -0700 References: <436e18f3d9dd0fd0ae23547f4172f907fed50dc9.camel@linuxfoundation.org> In-Reply-To: <436e18f3d9dd0fd0ae23547f4172f907fed50dc9.camel@linuxfoundation.org> Message-ID: <5687.1596801277895813527@lists.openembedded.org> Content-Type: multipart/alternative; boundary="c8C4TrTuEChOpBr0pDMq" --c8C4TrTuEChOpBr0pDMq Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From d21155c4b55ac96d3c13a3cef1f020df67b62641 Mon Sep 17 00:00:00 2001 From: Chris Minnoy Date: Fri, 7 Aug 2020 11:35:27 +0000 Subject: [PATCH 1/1] bitbake fetch2: fetcher can now unpack .ipk files fro= m ar and tar format Ipk packages can be formed with ar or tar. ar/tar can't read each others a= rchives. 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(-) diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__i= nit__.py index 2ada43befc..d66d677434 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py @@ -1467,7 +1467,40 @@ class FetchMethod(object): iterate_file =3D unpack_file else: cmd =3D 'rpm2cpio.sh %s | cpio -id' % (file) -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 elif f= ile.endswith('.deb') or file.endswith('.ipk'): +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 elif f= ile.endswith('.ipk'): +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 output =3D subprocess.check_output(['file', file], pree= xec_fn=3Dsubprocess_setup) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 if output: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if output.decode().find("curren= t ar archive") !=3D -1: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 output = = =3D subprocess.check_output(['ar', '-t', file], preexec_fn=3Dsubprocess_se= tup) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 datafil= e =3D None +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if outp= ut: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 for line in output.decode().split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2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise U= npackError("Unable to unpack ipk package - does not contain data.tar.* file= ", urldata.url) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 raise UnpackError("Unable to unpack ipk package - could= not list contents", urldata.url) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cmd =3D= 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile, da= tafile, datafile) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 elif output.decode().find("gzip= compressed data") !=3D -1: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 output = = =3D subprocess.check_output(['tar', '-tf', file], preexec_fn=3Dsubprocess_= setup) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=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=A0=C2=A0 break +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise U= npackError("Unable to unpack ipk package - does not contain data.tar.* file= ", urldata.url) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 raise UnpackError("Unable to unpack ipk package - could= not list contents", urldata.url) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cmd =3D= 'tar -xf %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, datafile,= datafile, datafile) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise U= npackError("Unable to unpack ipk package - unknown format", urldata.url) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 else: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise UnpackError("Unable to de= tect .ipk file format - unknown format", urldata.url) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 elif f= ile.endswith('.deb'): output =3D subprocess.check_output(['ar', '-t', file], preexec_fn=3Dsubpro= cess_setup) datafile =3D None if output: @@ -1476,9 +1509,9 @@ class FetchMethod(object): datafile =3D line break else: -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise U= npackError("Unable to unpack deb/ipk package - does not contain data.tar.* = file", urldata.url) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise U= npackError("Unable to unpack deb package - does not contain data.tar.* file= ", urldata.url) else: -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise UnpackError("Unable to un= pack deb/ipk package - could not list contents", urldata.url) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 raise UnpackError("Unable to un= pack deb package - could not list contents", urldata.url) cmd =3D 'ar x %s %s && tar --no-same-owner -xpf %s && rm %s' % (file, data= file, datafile, datafile) # If 'subdir' param exists, create a dir and use it as destination for unp= ack cmd -- 2.11.0 --c8C4TrTuEChOpBr0pDMq Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable From d21155c4b55ac96d3c13a3cef1f020df67b62641 Mon Sep 17 00:00:00 2001
From: Chris Minnoy <chris.minnoy_ext@softathome.com>
Date: Fri,= 7 Aug 2020 11:35:27 +0000
Subject: [PATCH 1/1] bitbake fetch2: fetche= r 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 deletio= ns(-)

diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/l= ib/bb/fetch2/__init__.py
index 2ada43befc..d66d677434 100644
--- = a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init= __.py
@@ -1467,7 +1467,40 @@ class FetchMethod(object):
 &nb= sp;            =        iterate_file =3D unpack_file
&nbs= p;            &= nbsp;   else:
       &nbs= p;             = cmd =3D 'rpm2cpio.sh %s | cpio -id' % (file)
-    =         elif file.endswith('.deb') or fi= le.endswith('.ipk'):
+        =     elif file.endswith('.ipk'):
+   &nbs= p;            output= =3D subprocess.check_output(['file', file], preexec_fn=3Dsubprocess_setup)=
+           &n= bsp;    if output:
+      = ;            &n= bsp; if output.decode().find("current ar archive") !=3D -1:
+ &nb= sp;            =           output =3D subproces= s.check_output(['ar', '-t', file], preexec_fn=3Dsubprocess_setup)
+&nb= sp;            =            datafile =3D N= one
+           = ;             i= f output:
+          = ;            &n= bsp;     for line in output.decode().splitlines():
+            &= nbsp;           &nbs= p;       if line.startswith('data.tar.'):
+            =             &nb= sp;           datafile = =3D line
+          = ;            &n= bsp;            = ; break
+          &= nbsp;           &nbs= p;         else:
+  =             &nb= sp;            =          raise UnpackError("Unable = to unpack ipk package - does not contain data.tar.* file", urldata.url)
+            =             else:+            = ;            &n= bsp;   raise UnpackError("Unable to unpack ipk package - could no= t list contents", urldata.url)
+      &n= bsp;            = ;     cmd =3D 'ar x %s %s && tar --no-same-owne= r -xpf %s && rm %s' % (file, datafile, datafile, datafile)
+&n= bsp;            = ;       elif output.decode().find("gzip compr= essed data") !=3D -1:
+        = ;            &n= bsp;   output =3D subprocess.check_output(['tar', '-tf', file], p= reexec_fn=3Dsubprocess_setup)
+      &nb= sp;            =      datafile =3D None
+    &n= bsp;            = ;       if output:
+   &n= bsp;            = ;            for lin= e in output.decode().splitlines():
+     &nbs= p;            &= nbsp;           &nbs= p; if line.startswith('./data.tar.'):
+     &= nbsp;           &nbs= p;            &= nbsp;     datafile =3D line
+   &nb= sp;            =             &nb= sp;       break
+    = ;            &n= bsp;            = ;   else:
+        &= nbsp;           &nbs= p;            &= nbsp;  raise UnpackError("Unable to unpack ipk package - does not cont= ain data.tar.* file", urldata.url)
+     &nbs= p;            &= nbsp;     else:
+     &nb= sp;            =           raise UnpackError("U= nable to unpack ipk package - could not list contents", urldata.url)
+=             &nb= sp;           cmd =3D 'ta= r -xf %s %s && tar --no-same-owner -xpf %s && rm %s' % (fil= e, datafile, datafile, datafile)
+      =             &nb= sp; else:
+          = ;            &n= bsp; raise UnpackError("Unable to unpack ipk package - unknown format", url= data.url)
+          = ;      else:
+     &= nbsp;           &nbs= p;  raise UnpackError("Unable to detect .ipk file format - unknown for= mat", urldata.url)
+        &n= bsp;   elif file.endswith('.deb'):
    &= nbsp;            out= put =3D subprocess.check_output(['ar', '-t', file], preexec_fn=3Dsubprocess= _setup)
          &n= bsp;      datafile =3D None
   = ;            &n= bsp; if output:
@@ -1476,9 +1509,9 @@ class FetchMethod(object):
=             &nb= sp;            =     datafile =3D line
     &nb= sp;            =            break
&nb= sp;            =         else:
-   &n= bsp;            = ;        raise UnpackError("Unable to un= pack deb/ipk package - does not contain data.tar.* file", urldata.url)
+            &= nbsp;           raise Unp= ackError("Unable to unpack deb package - does not contain data.tar.* file",= urldata.url)
         &n= bsp;       else:
-   &nbs= p;            &= nbsp;   raise UnpackError("Unable to unpack deb/ipk package - cou= ld not list contents", urldata.url)
+     &nb= sp;            =   raise UnpackError("Unable to unpack deb package - could not list con= tents", urldata.url)
        &= nbsp;        cmd =3D 'ar x %s %s &&a= mp; tar --no-same-owner -xpf %s && rm %s' % (file, datafile, datafi= le, datafile)
 
       &n= bsp; # If 'subdir' param exists, create a dir and use it as destination for= unpack cmd
--
2.11.0 --c8C4TrTuEChOpBr0pDMq--