[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] [PATCH 14/15] unpacker.eclass: Fix handling GNU ar archives in hand-weaved impl
From:       Michał Górny <mgorny () gentoo ! org>
Date:       2022-09-25 18:23:16
Message-ID: 20220925182317.1559529-15-mgorny () gentoo ! org
[Download RAW message or body]

Fix the hand-weaved implementation of ar unpacking that is used
on Prefix to handle slash-terminated filenames of GNU ar format
correctly.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/tests/unpacker.sh | 4 ++++
 eclass/unpacker.eclass   | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/eclass/tests/unpacker.sh b/eclass/tests/unpacker.sh
index bbbfa32623ab..e42e656756c4 100755
--- a/eclass/tests/unpacker.sh
+++ b/eclass/tests/unpacker.sh
@@ -134,6 +134,10 @@ test_deb() {
 
 	test_unpack "test-${tool}_1.2.3_noarch.deb" test.in "ar tar ${tool}" \
 		"create_deb '${suffix}' '${tool_cmd}' \${archive} \${TESTFILE}"
+	# also test with the hand-weaved implementation used on Prefix
+	EPREFIX=/foo \
+	test_unpack "test_pfx-${tool}_1.2.3_noarch.deb" test.in "ar tar ${tool}" \
+		"create_deb '${suffix}' '${tool_cmd}' \${archive} \${TESTFILE}"
 }
 
 create_gpkg() {
diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
index 370f00a83bba..100f11428622 100644
--- a/eclass/unpacker.eclass
+++ b/eclass/unpacker.eclass
@@ -282,6 +282,8 @@ unpack_deb() {
 			local f timestamp uid gid mode size magic
 			while read f timestamp uid gid mode size magic ; do
 				[[ -n ${f} && -n ${size} ]] || continue # ignore empty lines
+				# GNU ar uses / as filename terminator (and .deb permits that)
+				f=${f%/}
 				if [[ ${f} = "data.tar"* ]] ; then
 					head -c "${size}" > "${f}"
 				else
-- 
2.37.3


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic