1 |
commit: a8d104aa0eda11f36aaa20256353bf6ce6543065 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Sep 25 07:49:06 2022 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Sep 27 20:28:06 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a8d104aa |
7 |
|
8 |
unpacker.eclass: Fix handling GNU ar archives in handwoven impl |
9 |
|
10 |
Fix the hand-weaved implementation of ar unpacking that is used |
11 |
on Prefix to handle slash-terminated filenames of GNU ar format |
12 |
correctly. |
13 |
|
14 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
15 |
|
16 |
eclass/tests/unpacker.sh | 4 ++++ |
17 |
eclass/unpacker.eclass | 2 ++ |
18 |
2 files changed, 6 insertions(+) |
19 |
|
20 |
diff --git a/eclass/tests/unpacker.sh b/eclass/tests/unpacker.sh |
21 |
index 40bde1bf30de..b15953966f65 100755 |
22 |
--- a/eclass/tests/unpacker.sh |
23 |
+++ b/eclass/tests/unpacker.sh |
24 |
@@ -134,6 +134,10 @@ test_deb() { |
25 |
|
26 |
test_unpack "test-${tool}_1.2.3_noarch.deb" test.in "ar tar ${tool}" \ |
27 |
"create_deb '${suffix}' '${tool_cmd}' \${archive} \${TESTFILE}" |
28 |
+ # also test with the handwoven implementation used on Prefix |
29 |
+ EPREFIX=/foo \ |
30 |
+ test_unpack "test_pfx-${tool}_1.2.3_noarch.deb" test.in "ar tar ${tool}" \ |
31 |
+ "create_deb '${suffix}' '${tool_cmd}' \${archive} \${TESTFILE}" |
32 |
} |
33 |
|
34 |
create_gpkg() { |
35 |
|
36 |
diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass |
37 |
index 370f00a83bba..100f11428622 100644 |
38 |
--- a/eclass/unpacker.eclass |
39 |
+++ b/eclass/unpacker.eclass |
40 |
@@ -282,6 +282,8 @@ unpack_deb() { |
41 |
local f timestamp uid gid mode size magic |
42 |
while read f timestamp uid gid mode size magic ; do |
43 |
[[ -n ${f} && -n ${size} ]] || continue # ignore empty lines |
44 |
+ # GNU ar uses / as filename terminator (and .deb permits that) |
45 |
+ f=${f%/} |
46 |
if [[ ${f} = "data.tar"* ]] ; then |
47 |
head -c "${size}" > "${f}" |
48 |
else |