-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathupdate.zsh
More file actions
145 lines (124 loc) · 2.84 KB
/
update.zsh
File metadata and controls
145 lines (124 loc) · 2.84 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env zsh
function is_marked {
# If it's a deb-file, don't try to read it
if file "$1" | grep Debian > /dev/null;
then
false
return
fi
# Ensure the commit actually exists
commit="$(head -c40 $1)"
if [ "$(git cat-file -t $commit 2>/dev/null)" = "commit" ];
then
true
return
fi
false
return
}
function mark {
rm -f $1
echo $2 > $1
}
function check() {
for file in $1/**/*.deb(.);
do
if is_marked $file;
then
echo "$file OK"
continue
else
dpkg-sig --verify $file || rm -f $file
fi
done
}
function download() {
BASE_URLS=(
"http://security.ubuntu.com"
"http://old-releases.ubuntu.com"
"https://mirrors.kernel.org"
)
URLS=()
for URL in $BASE_URLS;
do
URLS+=("$URL/ubuntu/pool/main/g/glibc/"
"$URL/ubuntu/pool/main/e/eglibc/"
"$URL/ubuntu/pool/universe/d/dietlibc/"
"$URL/ubuntu/pool/main/a/arm64-cross-toolchain-base/"
"$URL/ubuntu/pool/main/a/armhf-cross-toolchain-base/"
"$URL/ubuntu/pool/main/a/armel-cross-toolchain-base/"
"$URL/ubuntu/pool/main/p/powerpc-cross-toolchain-base/"
)
done
for URL in $URLS;
do
wget \
--follow-ftp \
--no-parent \
-e robots=off \
--no-proxy \
--level=1 \
--no-parent \
--recursive \
--no-clobber \
--no-directories \
--accept "*libc*.deb" \
--reject "*-bin*" \
--reject "*-dbg*" \
--reject "*-doc*" \
--reject "*-prof*" \
--reject "*-udeb*" \
--reject "*-xen*" \
--reject "*-source*" \
--reject "*-pic*" \
--reject "*linux-libc-dev*"
--verbose \
-P $1 \
$URL
done
for URL in $URLS;
do
wait
done
}
function debextract {
input=$1
shift
dpkg-deb --fsys-tarfile "$input" | tar --wildcards --extract $*
}
function extract {
for deb in $1/**/*.deb(.);
do
echo $deb
dir="libc/${deb:t:r}"
echo "Checking $deb"
if is_marked "$deb" ;
then
echo "...skipping"
continue
fi
[[ -d $dir ]] || mkdir -p $dir
echo "Extracting $deb"
dpkg-deb \
--fsys-tarfile "$deb" \
| tar \
--directory "$dir" \
--wildcards \
--wildcards-match-slash \
--extract \
'*libc.so.*' \
'*libc-*.so*' \
'*libc.a' \
'*libc.so*'
echo "Committing $deb"
git add libc || continue
git commit -m "$deb"
mark $deb $(git rev-parse HEAD)
git add $deb
git commit -m "update .debs"
done
}
[[ -d debfiles ]] || mkdir debfiles
check debfiles
# download debfiles
# extract debfiles