forked from matrix1001/glibc-all-in-one
-
Notifications
You must be signed in to change notification settings - Fork 0
/
download
executable file
·63 lines (52 loc) · 1.46 KB
/
download
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
#!/bin/bash
cd "$(dirname "$0")"
if [ ! -d "libs" ]; then
mkdir libs
fi
if [ ! -d "debs" ]; then
mkdir debs
fi
SOURCE="https://mirror.tuna.tsinghua.edu.cn/ubuntu/pool/main/g/glibc"
# Use the source below if you feel slow, or change it on your own.
# SOURCE="http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/"
LIBC_PREFIX="libc6_"
LIBC_DBG_PREFIX="libc6-dbg_"
die() {
echo >&2 $1
exit 1
}
usage() {
echo >&2 "Usage: $0 id"
exit 2
}
download_single() {
local id=$1
local deb_name=$LIBC_PREFIX$id.deb
local dbg_name=$LIBC_DBG_PREFIX$id.deb
echo "Getting $id"
if [ -d "libs/$id" ]; then
die " --> Downloaded before. Remove it to download again."
fi
# download binary package
local url="$SOURCE/$deb_name"
echo " -> Location: $url"
echo " -> Downloading libc binary package"
wget "$url" 2>/dev/null -O debs/$deb_name || die "Failed to download package from $url"
echo " -> Extracting libc binary package"
mkdir libs/$id
./extract debs/$deb_name libs/$id
echo " -> Package saved to libs/$id"
# download debug info package
local url="$SOURCE/$dbg_name"
echo " -> Location: $url"
echo " -> Downloading libc debug package"
wget "$url" 2>/dev/null -O debs/$dbg_name || die "Failed to download package from $url"
echo " -> Extracting libc debug package"
mkdir libs/$id/.debug
./extract debs/$dbg_name libs/$id/.debug
echo " -> Package saved to libs/$id/.debug"
}
if [[ $# != 1 ]]; then
usage
fi
download_single "$1"