-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdebian-build-sources-list
executable file
·153 lines (140 loc) · 3.7 KB
/
debian-build-sources-list
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
146
147
148
149
150
151
152
153
#!/bin/sh
#
# Build /etc/apt/sources.list with the help of netselect-apt.
if test "$(exec id -u)" -ne 0; then
echo 'damn. invoke me as root, please' 1>&2
exit 1
fi
cd /tmp ||
exit 1
command -- cp -fv /etc/apt/sources.list /etc/apt/sources.list.old
command -- cp -fv /etc/apt/preferences /etc/apt/preferences.old
command -- rm -frv /tmp/napt
trap exit\ 1 INT TERM QUIT
if test "$#" -eq 0; then
set -- stable testing unstable experimental
fi
for release in "$@"; do
command -- mkdir -p "/tmp/napt/$release"
i=0
while test "$i" -le 2; do
command -- netselect-apt -t 10 "$release" >"/tmp/napt/$release/$i"
i=$((i + 1))
done
server=$(
exec grep -o -h -e 'https\?.*$' "/tmp/napt/$release/"?* |
exec sort |
exec uniq -cd |
exec tac | {
read -r _ l
printf '%s' "$l"
}
)
case $release in
stable | bullseye)
command -- cat >>"/tmp/napt/01-$release-source.list" <<-IN
#
# $release
#
#deb $server $release main contrib non-free
#deb-src $server $release main contrib non-free
#
# $release-updates
#
#deb $server $release-updates main contrib non-free
#deb-src $server $release-updates main contrib non-free
#
# $release-security
#
#deb http://security.debian.org/ $release-security main contrib non-free
#deb-src http://security.debian.org/ $release-security main contrib non-free
#
# $release-backports
#
#deb $server $release-backports main contrib non-free
#deb-src $server $release-backports main contrib non-free
#
# $release-debug
#
#deb http://debug.mirrors.debian.org/debian-debug/ $release-debug main
#
IN
;;
testing)
command -- cat >>"/tmp/napt/02-$release-source.list" <<-IN
#
# $release
#
deb $server $release main contrib non-free
#deb-src $server $release main contrib non-free
#
# $release-updates
#
deb $server $release-updates main contrib non-free
#deb-src $server $release-updates main contrib non-free
#
# $release-security
#
deb http://security.debian.org/ $release-security main contrib non-free
#deb-src http://security.debian.org/ $release-security main contrib non-free
#
#
# $release-backports
#
#deb $server $release-backports main contrib non-free
#deb-src $server $release-backports main contrib non-free
#
# $release-debug
#
#deb http://debug.mirrors.debian.org/debian-debug/ $release-debug main
#
IN
;;
unstable)
command -- cat >>"/tmp/napt/03-$release-source.list" <<-IN
#
# $release
#
# deb $server $release main contrib non-free
#deb-src $server $release main contrib non-free
#
# $release-debug
#
#deb http://debug.mirrors.debian.org/debian-debug/ $release-debug main
#
IN
;;
experimental)
command -- cat >>"/tmp/napt/04-$release-source.list" <<-IN
#
# $release
#
#deb $server $release main contrib non-free
#deb-src $server $release main contrib non-free
#
# $release-debug
#
#deb http://debug.mirrors.debian.org/debian-debug/ $release-debug main
#
IN
;;
*)
printf 'unknown release: %s\n' "$release" 1>&2
exit 1
;;
esac
done
set -e
command -- cat /tmp/napt/*-source.list >/etc/apt/sources.list
command -- cat >/etc/apt/preferences <<IN
# Package: *
# Pin: release a=unstable
# Pin-Priority: 900
# Package: *
# Pin: release a=testing
# Pin-Priority: 800
# Package: *
# Pin: release o=Debian
# Pin-Priority: -10
IN
# vim: set ft=sh noexpandtab :