Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 15/15] unpacker.eclass: Unpack .deb packages on-the-fly as well
Date: Sun, 25 Sep 2022 18:27:41
Message-Id: 20220925182317.1559529-16-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 00/15] unpacker.eclass: Tests, bugfixes and GPKG support by "Michał Górny"
1 Signed-off-by: Michał Górny <mgorny@g.o>
2 ---
3 eclass/unpacker.eclass | 60 +++++++++++++++++++++++-------------------
4 1 file changed, 33 insertions(+), 27 deletions(-)
5
6 diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
7 index 100f11428622..3d23151b636e 100644
8 --- a/eclass/unpacker.eclass
9 +++ b/eclass/unpacker.eclass
10 @@ -273,33 +273,39 @@ unpack_deb() {
11
12 unpack_banner "${deb}"
13
14 - # on AIX ar doesn't work out as their ar used a different format
15 - # from what GNU ar (and thus what .deb files) produce
16 - if [[ -n ${EPREFIX} ]] ; then
17 - {
18 - read # global header
19 - [[ ${REPLY} = "!<arch>" ]] || die "${deb} does not seem to be a deb archive"
20 - local f timestamp uid gid mode size magic
21 - while read f timestamp uid gid mode size magic ; do
22 - [[ -n ${f} && -n ${size} ]] || continue # ignore empty lines
23 - # GNU ar uses / as filename terminator (and .deb permits that)
24 - f=${f%/}
25 - if [[ ${f} = "data.tar"* ]] ; then
26 - head -c "${size}" > "${f}"
27 - else
28 - head -c "${size}" > /dev/null # trash it
29 - fi
30 - done
31 - } < "${deb}"
32 - else
33 - $(tc-getBUILD_AR) x "${deb}" || die
34 - fi
35 -
36 - unpacker ./data.tar*
37 -
38 - # Clean things up #458658. No one seems to actually care about
39 - # these, so wait until someone requests to do something else ...
40 - rm -f debian-binary {control,data}.tar*
41 + {
42 + # on AIX ar doesn't work out as their ar used a different format
43 + # from what GNU ar (and thus what .deb files) produce
44 + if [[ -n ${EPREFIX} ]] ; then
45 + {
46 + read # global header
47 + [[ ${REPLY} = "!<arch>" ]] || die "${deb} does not seem to be a deb archive"
48 + local f timestamp uid gid mode size magic
49 + while read f timestamp uid gid mode size magic ; do
50 + [[ -n ${f} && -n ${size} ]] || continue # ignore empty lines
51 + # GNU ar uses / as filename terminator (and .deb permits that)
52 + f=${f%/}
53 + if [[ ${f} = "data.tar"* ]] ; then
54 + local decomp=$(_unpacker_get_decompressor "${f}")
55 + head -c "${size}" | ${decomp:-cat}
56 + assert "unpacking ${f} from ${deb} failed"
57 + break
58 + else
59 + head -c "${size}" > /dev/null # trash it
60 + fi
61 + done
62 + } < "${deb}"
63 + else
64 + local f=$(
65 + $(tc-getBUILD_AR) t "${deb}" | grep ^data.tar
66 + assert "data not found in ${deb}"
67 + )
68 + local decomp=$(_unpacker_get_decompressor "${f}")
69 + $(tc-getBUILD_AR) p "${deb}" "${f}" | ${decomp:-cat}
70 + assert "unpacking ${f} from ${deb} failed"
71 + fi
72 + } | tar --no-same-owner -x
73 + assert "unpacking ${deb} failed"
74 }
75
76 # @FUNCTION: unpack_cpio
77 --
78 2.37.3