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 14/15] unpacker.eclass: Fix handling GNU ar archives in hand-weaved impl
Date: Sun, 25 Sep 2022 18:27:23
Message-Id: 20220925182317.1559529-15-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 00/15] unpacker.eclass: Tests, bugfixes and GPKG support by "Michał Górny"
1 Fix the hand-weaved implementation of ar unpacking that is used
2 on Prefix to handle slash-terminated filenames of GNU ar format
3 correctly.
4
5 Signed-off-by: Michał Górny <mgorny@g.o>
6 ---
7 eclass/tests/unpacker.sh | 4 ++++
8 eclass/unpacker.eclass | 2 ++
9 2 files changed, 6 insertions(+)
10
11 diff --git a/eclass/tests/unpacker.sh b/eclass/tests/unpacker.sh
12 index bbbfa32623ab..e42e656756c4 100755
13 --- a/eclass/tests/unpacker.sh
14 +++ b/eclass/tests/unpacker.sh
15 @@ -134,6 +134,10 @@ test_deb() {
16
17 test_unpack "test-${tool}_1.2.3_noarch.deb" test.in "ar tar ${tool}" \
18 "create_deb '${suffix}' '${tool_cmd}' \${archive} \${TESTFILE}"
19 + # also test with the hand-weaved implementation used on Prefix
20 + EPREFIX=/foo \
21 + test_unpack "test_pfx-${tool}_1.2.3_noarch.deb" test.in "ar tar ${tool}" \
22 + "create_deb '${suffix}' '${tool_cmd}' \${archive} \${TESTFILE}"
23 }
24
25 create_gpkg() {
26 diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
27 index 370f00a83bba..100f11428622 100644
28 --- a/eclass/unpacker.eclass
29 +++ b/eclass/unpacker.eclass
30 @@ -282,6 +282,8 @@ unpack_deb() {
31 local f timestamp uid gid mode size magic
32 while read f timestamp uid gid mode size magic ; do
33 [[ -n ${f} && -n ${size} ]] || continue # ignore empty lines
34 + # GNU ar uses / as filename terminator (and .deb permits that)
35 + f=${f%/}
36 if [[ ${f} = "data.tar"* ]] ; then
37 head -c "${size}" > "${f}"
38 else
39 --
40 2.37.3