forked from matrix1001/glibc-all-in-one
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract
40 lines (31 loc) · 729 Bytes
/
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
#!/bin/bash
cd "$(dirname "$0")"
die() {
echo >&2 $1
exit 1
}
usage() {
echo -e >&2 "Usage: $0 deb output"
exit 2
}
extract() {
local deb=$1
local out=$2
if [ ! -d "$out" ]; then
mkdir $out
fi
local tmp=`mktemp -d`
cp $deb $tmp/pkg.deb
pushd $tmp 1>/dev/null
ar x pkg.deb || die "ar failed"
tar xf data.tar.* || die "tar failed"
popd 1>/dev/null
cp $tmp/lib/*/* $out 2>/dev/null || cp $tmp/lib32/* $out 2>/dev/null \
|| cp $tmp/usr/lib/debug/lib/*/* $out 2>/dev/null || cp $tmp/usr/lib/debug/lib32/* $out 2>/dev/null \
|| die "Failed to save. Check it manually $tmp"
rm -rf $tmp
}
if [[ $# -ne 2 ]]; then
usage
fi
extract "$1" "$2"