-
Notifications
You must be signed in to change notification settings - Fork 42
/
extract
executable file
·78 lines (70 loc) · 1.61 KB
/
extract
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
. config/options
if [ -z "$3" ]; then
echo "usage: $0 package_name file_pattern target_dir"
exit 1
fi
get_meta $1
[ ! -f "$PACKAGE_URL" ] && [ -z "$PKG_URL" ] && exit 1
[ ! -d "$SOURCES/$1" ] || [ ! -d "$3" ] && exit 1
if [ -n "$PKG_URL_PROTO" ]; then
REPO_BASENAME=$PKG_NAME-$PKG_VERSION
FILES=$REPO_BASENAME.tar.bz2
elif [ -n "$PKG_ARCHIVE_NAME" ]; then
REPO_BASENAME=$PKG_NAME-$PKG_VERSION
FILES=$PKG_ARCHIVE_NAME
else
[ -f "$PACKAGE_URL" ] && \
FILES=`sed 's%.*/\(.*\)\$%\1%' $PACKAGE_URL`
[ -n "$PKG_URL" ] && \
for url in $PKG_URL; do
FILES="$FILES `echo $url | sed 's%.*/\(.*\)\$%\1%'`"
done
fi
for s in $FILES; do
case $s in
$2)
f="$SOURCES/$1/$s"
if [ ! -f $f ]; then
echo "error: File $s doesn't exist in package $1 sources directory"
echo "have you called scripts/extract before scripts/get ?"
exit 1
fi
case $s in
*.tar)
tar xf $f -C $3
;;
*.tar.xz | *.txz)
tar xJf $f -C $3
;;
*.tar.bz* | *.tbz)
tar xjf $f -C $3
;;
*.tar.gz | *.tgz)
tar xzf $f -C $3
;;
*.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
;;
*.zip)
unzip $f -d $3
;;
*.deb)
DEB_DATA=data.tar.gz
ar x $f $DEB_DATA
tar xzf $DEB_DATA -C $3
rm $DEB_DATA
;;
*)
cp -pPR $f $3
;;
esac
;;
esac
done