updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / pkgextract / pkgextract.sh
blob5504ae4022c7a8fe1d524fb138dc8abd2b087ed1
1 #!/bin/sh
2 extract_rpm ()
4 RPM=$1
5 leadsize=96
6 o=`expr $leadsize + 8`
7 set `od -j $o -N 8 -t u1 $pkg`
8 il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
9 dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
11 sigsize=`expr 8 + 16 \* $il + $dl`
12 o=`expr $o + $sigsize + \( 8 - \( $sigsize \% 8 \) \) \% 8 + 8`
13 set `od -j $o -N 8 -t u1 $pkg`
14 il=`expr 256 \* \( 256 \* \( 256 \* $2 + $3 \) + $4 \) + $5`
15 dl=`expr 256 \* \( 256 \* \( 256 \* $6 + $7 \) + $8 \) + $9`
16 hdrsize=`expr 8 + 16 \* $il + $dl`
17 o=`expr $o + $hdrsize`
18 dd if=$pkg ibs=$o skip=1 2>/dev/null | bsdtar -xf -
20 extract_deb ()
22 DEB=$1
23 bsdtar -xf ${DEB} data.tar.gz
24 bsdtar -xf data.tar.gz
25 rm data.tar.gz
27 pkg=$1
28 if [ "$pkg" = "" -o ! -e "$pkg" ]; then
29 echo "no package supplied" 1>&2
30 exit 1
32 ext=`echo $pkg | awk -F. '{ print $NF }'`
33 case "$ext" in
34 rpm|RPM)
35 extract_rpm $pkg
37 deb|DEB)
38 extract_deb $pkg
41 echo "Unknown package type: $pkg"
42 exit 1
43 esac