[pacman-dev] [PATCH] makepkg: Extract from any file bsdtar can recognize

Dan McGee dan at archlinux.org
Wed Jun 2 20:40:38 EDT 2010


From: Nezmer <git at nezmer.info>

If "file -bizL" does not return a supported type, check if the file is
recognized by bsdtar and if yes extract from it.

Dan: use '-q' option to prevent needing to seek the entire archive.

Signed-off-by: Nezmer <git at nezmer.info>
Signed-off-by: Dan McGee <dan at archlinux.org>
---

I think I got the '-q' option working just fine as long as you order the
options correctly to bsdtar. This appears to work on random files I was
testing it on from the command line.

$ time bsdtar -tf /var/cache/makepkg/src/linux-2.6.34.tar.bz2 -q '*'; echo return: $?
linux-2.6.34/

real    0m0.079s
user    0m0.063s
sys     0m0.010s
return: 0

-Dan

 scripts/makepkg.sh.in |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 76b6183..28e550b 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -685,9 +685,12 @@ extract_sources() {
 					*) continue;;
 				esac ;;
 			*)
-				# Don't know what to use to extract this file,
-				# skip to the next file
-				continue;;
+				# See if bsdtar can recognize the file
+				if bsdtar -tf "$file" -q '*' &>/dev/null; then
+					cmd="bsdtar"
+				else
+					continue
+				fi ;;
 		esac
 
 		local ret=0
-- 
1.7.1



More information about the pacman-dev mailing list