forked from fengguang/lkp-tests
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathdebian
executable file
·300 lines (245 loc) · 7 KB
/
debian
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/bash
shopt -s nullglob
. $LKP_SRC/lib/install.sh
. $LKP_SRC/distro/common
. $LKP_SRC/lib/debug.sh
update()
{
apt-get update
}
add_i386_package()
{
dpkg --add-architecture i386
}
download()
{
echo apt-get download $*
apt-get download $* || apt-get download $*
}
hardlink_to_symlink()
{
while read line
do
local hard_links=($line)
for i in {1..9}
do
[[ ${hard_links[$i]} ]] || break
echo \
ln -sf ${hard_links[0]#.} ${hard_links[$i]}
ln -sf ${hard_links[0]#.} ${hard_links[$i]}
done
done < <(for i in $(find . -type f -links +1); do find . -samefile $i | awk '{printf "%s ", $1}'; printf "\n"; done | sort | uniq)
}
install()
{
local deb_pkgname
local deb_filename
local deb_files
# sequence-deb content looks like:
# libreadline7
# libssl1.1
# gawk
[ -s "opt/deb/sequence-deb.$BM_NAME" ] && {
deb_files=$(find ./ -name "*.deb" -type f)
while read -r deb_pkgname
do
# deb package naming specification, the file name must contain '_'
deb_filename=$(echo "$deb_files" | grep "^\./${deb_pkgname}_")
if [ -n "${deb_filename}" ]; then
mv "$deb_filename" opt/deb
# keep-deb content looks like:
# libreadline7_7.0-1_amd64.deb
# libssl1.1_1.1.0d-2_amd64.deb
# gawk_1%3a4.1.3+dfsg-0.1+b1_amd64.deb
basename $deb_filename >> opt/deb/keep-deb.$BM_NAME
else
echo "error: $deb_pkgname is not exist." >&2
return 1
fi
done < opt/deb/sequence-deb.$BM_NAME
}
local deb
for deb in *.deb; do
dpkg-deb -x "$deb" . || return
rm "$deb"
done
hardlink_to_symlink
}
fixup_vim()
{
ln -sf vim.basic usr/bin/vim
}
fixup_lkp-eywa()
{
ln -sf /usr/bin/gnuplot-qt usr/bin/gnuplot
ln -sf /usr/bin/heirloom-mailx usr/bin/mailx
}
fixup_perf()
{
local real_perf=(usr/bin/perf_*)
[[ $real_perf ]] || return
# replace the perf wrapper script
ln -sf /$real_perf usr/bin/perf
}
fixup_kernel-selftests()
{
# 'apt install traceroute' will create .db binary in PATH
# manually create softlink to them
ln -sf /usr/bin/traceroute.db ./usr/bin/traceroute
ln -sf /usr/bin/traceroute6.db ./usr/bin/traceroute6
ln -sf /usr/bin/lft.db ./usr/bin/lft
ln -sf /usr/bin/traceproto.db ./usr/bin/traceproto
ln -sf /usr/sbin/tcptraceroute.db ./usr/sbin/tcptraceroute
}
fixup_ltp()
{
ln -sf /usr/sbin/in.telnetd ./usr/sbin/in.telnetd
}
pack()
{
local date=$(date +"%Y%m%d")
[[ $(type -t fixup_$BM_NAME) = 'function' ]] && fixup_$BM_NAME
{
find . -xdev |
grep -v -f $LKP_SRC/rootfs/rootfs-strip-list
local pkg_dir=$(get_pkg_dir $BM_NAME)
[[ -d $pkg_dir && -f $pkg_dir/allowlist ]] && cat $pkg_dir/allowlist
} |
cpio --quiet -o -H newc --owner=root.root |
gzip -n -9 > $pack_to/${BM_NAME}_$date.cgz || return
ln -sf ${BM_NAME}_$date.cgz \
$pack_to/${BM_NAME}.cgz || return
chown .lkp $pack_to/${BM_NAME}_$date.cgz \
$pack_to/${BM_NAME}.cgz || return
echo package installed to $pack_to/${BM_NAME}.cgz
}
resolve_depends()
{
local deps=$*
local command
command="apt-get --simulate --no-install-recommends install $deps"
# using "bash -c" to support wildcard in apt-get.
# if use wildcard in the package version variable,
# apt-get will treat the wildcard as a normal character.
bash -c "$command" || die "Failed to apt-get install $deps"
# apt-get will have below output
# Inst python-minimal [2.7.11-2] (2.7.13-2 Debian:testing, Debian:unstable [amd64])
# Inst mime-support (3.60 Debian:testing, Debian:unstable [all])
# Inst libsqlite3-0 (3.16.2-3 Debian:testing, Debian:unstable [amd64])
# PACKAGE_LIST='python-minimal mime-support libsqlite3-0'
PACKAGE_LIST=$(bash -c "$command" | awk '/^Inst / { print $2 }')
# PACKAGE_VERSION_LIST='python-minimal=2.7.13-2 mime-support=3.60 libsqlite3-0=3.16.2-3'
PACKAGE_VERSION_LIST=$(bash -c "$command" |
awk '/^Inst / { if (substr($3, 1, 1) != "[") { print $2$3 } else { print $2$4 } }' | tr '(' '=')
}
save_package_deps_info()
{
local benchmark=$1
mkdir -p opt/deb
# sequence-deb content looks like:
# libreadline7
# libssl1.1
# gawk
[ -n "$PACKAGE_LIST" ] && \
echo "$PACKAGE_LIST" | grep -F -f "$LKP_SRC/distro/keep-deb" > "opt/deb/sequence-deb.$benchmark"
[ -n "$PACKAGE_VERSION_LIST" ] && \
echo "$PACKAGE_VERSION_LIST" > "opt/deb/${benchmark}-deps.packages"
}
do_apt_install()
{
# chronic is provided by deps/pack.cgz, but nfs rootfs + run_on_local_disk environment,
# deps/pack.cgz will not be merged into the runtime rootfs currently.
if has_cmd chronic; then
chronic apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install -y $packages
else
apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install -y $packages
fi
}
distro_install_depends()
{
local script
local bm="$1"
local script=$(get_dependency_file $bm)
[[ -f $script ]] || {
echo "no depends file found for $bm"
return 0
}
local arch=$(get_system_arch)
export DEBIAN_FRONTEND=noninteractive
[ "$arch" = "x86_64" ] && add_i386_package
update
apt-get install -yf
packages=$(get_dependency_packages $DISTRO $bm)
[ -z "$packages" ] && return
echo install packages for $bm: $packages
# some apt mirrors may have issue and fail in the first time of apt install
# so try for a second time if the first time fails
do_apt_install || do_apt_install
}
pack_benchmark()
{
distro_install_depends lkp-dev
# Process each benchmark
for BM_NAME in $benchmark
do
distro_install_depends $BM_NAME-dev || continue
echo $LKP_SRC/sbin/pack -d $DISTRO -f -c -s $PKG_MNT/$pack_to $BM_NAME
(
setup_proxy
$LKP_SRC/sbin/pack -d $DISTRO -f -c -s $PKG_MNT/$pack_to $BM_NAME
)
done
}
fixup_distro_mirror()
{
# fix the problem:
# debconf: unable to initialize frontend: Dialog
# debconf: (TERM is not set, so the dialog frontend is not usable.)
export DEBIAN_FRONTEND=noninteractive
# add extra apt source into sources.list
# use (cat ...; echo) to append new line at last
(cat $LKP_SRC/distro/apt-sources-list; echo) >> /etc/apt/sources.list
# remove testing and unstable source
sed -i -e '/testing/d' -e '/unstable/d' /etc/apt/sources.list
}
fixup_preinstall()
{
apt-get install -yf
}
fixup_arch_install()
{
local pack_arch=$1
[ "$pack_arch" = "i386" ] || return
dpkg --add-architecture i386
update
apt -y --allow-remove-essential --fix-broken install -o=APT::Architecture="i386"
}
pack_benchmark_deps()
{
for BM_NAME in $benchmark
do
check_shared_package $BM_NAME
packages=$(get_dependency_packages $DISTRO $BM_NAME)
resolve_depends $packages
echo "original package list for $BM_NAME:" $packages
[[ $PACKAGE_LIST ]] || {
echo "empty PACKAGE_LIST for $BM_NAME"
continue
}
work_dir=$(mktemp -d /tmp/pack-deps-$BM_NAME-XXXXXXXX)
cd $work_dir || exit
save_package_deps_info $BM_NAME
# Fix the warning 'W: Download is performed unsandboxed as root as file...' in newest APT versions
if id "_apt" >/dev/null 2>&1; then
chown _apt .
fi
if download "$PACKAGE_VERSION_LIST"; then
install || exit 1
pack
echo "$PACKAGE_LIST" > $pack_to/.${BM_NAME}.packages
else
echo "failed to pack-deps $BM_NAME" >&2
fi
rm -fr "$work_dir"
done
}