Lakka/scripts/extract

54 lines
1.0 KiB
Plaintext
Raw Normal View History

2009-03-18 12:02:53 +00:00
#!/bin/sh
. config/options $1
2009-03-18 12:02:53 +00:00
if [ -z "$3" ]; then
echo "usage: $0 package_name file_pattern target_dir"
exit 1
fi
[ -z "$PKG_URL" ] && exit 1
[ ! -d "$SOURCES/$1" -o ! -d "$3" ] && exit 1
2009-03-18 12:02:53 +00:00
for i in $PKG_URL; do
FILE="`basename $i`"
case $FILE in
2009-03-18 12:02:53 +00:00
$2)
f="$SOURCES/$1/$FILE"
2009-03-18 12:02:53 +00:00
if [ ! -f $f ]; then
echo "error: File $FILE doesn't exists in package $1 sources directory"
2009-03-18 12:02:53 +00:00
echo "have you called scripts/extract before scripts/get ?"
exit 1
fi
case $FILE in
2009-03-18 12:02:53 +00:00
*.tar)
tar xf $f -C $3
;;
*.tar.bz2 | *.tbz)
tar xjf $f -C $3
;;
*.tar.gz | *.tgz)
tar xzf $f -C $3
;;
*.7z)
mkdir -p $3/$1
7z x -o$3/$1 $f
;;
2009-03-18 12:02:53 +00:00
*.diff | *.patch)
cat $f | patch -d $3 -p1
;;
*.diff.bz2 | *.patch.bz2 | patch-*.bz2)
bzcat $f | patch -d $3 -p1
;;
*.diff.gz | *.patch.gz | patch-*.gz)
zcat $f | patch -d $3 -p1
;;
*)
cp -pPR $f $3
;;
esac
;;
esac
done