]>
Commit | Line | Data |
---|---|---|
8d876415 DK |
1 | #!/bin/sh -- # no runable script, just for vi |
2 | ||
5d76cee1 | 3 | EXIT_CODE=0 |
8c1dd12c | 4 | |
8d876415 | 5 | # we all like colorful messages |
a09f6eb8 | 6 | if [ "$MSGCOLOR" != 'NO' ] && [ "$MSGCOLOR" != 'ALWAYS' ]; then |
27cb4f6c | 7 | if [ ! -t 1 ]; then # but check that we output to a terminal |
1290422a DK |
8 | export MSGCOLOR='NO' |
9 | fi | |
10 | fi | |
11 | ||
12 | ||
13 | if [ "$MSGCOLOR" != 'NO' ]; then | |
14 | CERROR="\033[1;31m" # red | |
15 | CWARNING="\033[1;33m" # yellow | |
16 | CMSG="\033[1;32m" # green | |
17 | CINFO="\033[1;96m" # light blue | |
18 | CDEBUG="\033[1;94m" # blue | |
19 | CNORMAL="\033[0;39m" # default system console color | |
20 | CDONE="\033[1;32m" # green | |
21 | CPASS="\033[1;32m" # green | |
22 | CFAIL="\033[1;31m" # red | |
23 | CCMD="\033[1;35m" # pink | |
682a3bf7 | 24 | fi |
8d876415 | 25 | |
de81b2e2 DK |
26 | msgprintf() { |
27 | local START="$1" | |
28 | local MIDDLE="$2" | |
29 | local END="$3" | |
30 | shift 3 | |
31 | if [ -n "$1" ]; then | |
32 | printf "$START " "$1" | |
d73840dc | 33 | shift |
de81b2e2 | 34 | while [ -n "$1" ]; do |
03aa0847 | 35 | printf "$MIDDLE " "$(echo "$1" | sed -e 's#^apt\([cfghs]\)#apt-\1#')" |
de81b2e2 DK |
36 | shift |
37 | done | |
38 | fi | |
39 | printf "${END}" | |
2a2a7ef4 | 40 | } |
de81b2e2 DK |
41 | msgdie() { msgprintf "${CERROR}E: %s" '%s' "${CNORMAL}\n" "$@" >&2; exit 1; } |
42 | msgwarn() { msgprintf "${CWARNING}W: %s" '%s' "${CNORMAL}\n" "$@" >&2; } | |
43 | msgmsg() { msgprintf "${CMSG}%s" '%s' "${CNORMAL}\n" "$@"; } | |
44 | msginfo() { msgprintf "${CINFO}I: %s" '%s' "${CNORMAL}\n" "$@"; } | |
45 | msgdebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}\n" "$@"; } | |
46 | msgdone() { msgprintf "${CDONE}DONE" '%s' "${CNORMAL}\n" "$@"; } | |
47 | msgnwarn() { msgprintf "${CWARNING}W: %s" '%s' "${CNORMAL}" "$@" >&2; } | |
48 | msgnmsg() { msgprintf "${CMSG}%s" '%s' "${CNORMAL}" "$@"; } | |
49 | msgninfo() { msgprintf "${CINFO}I: %s" '%s' "${CNORMAL}" "$@"; } | |
50 | msgndebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}" "$@"; } | |
51 | msgtest() { msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@"; } | |
3c528b91 | 52 | msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; } |
68ba0b7f DK |
53 | msgskip() { |
54 | if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2; | |
55 | else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi | |
56 | } | |
5229b285 | 57 | msgfail() { |
3c528b91 MO |
58 | if [ $# -gt 0 ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2; |
59 | else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi | |
03aa0847 DK |
60 | if [ -n "$APT_DEBUG_TESTS" ]; then |
61 | $SHELL | |
62 | fi | |
5229b285 DK |
63 | EXIT_CODE=$((EXIT_CODE+1)); |
64 | } | |
8d876415 DK |
65 | |
66 | # enable / disable Debugging | |
fc89263e DK |
67 | MSGLEVEL=${MSGLEVEL:-3} |
68 | if [ $MSGLEVEL -le 0 ]; then | |
69 | msgdie() { true; } | |
70 | fi | |
71 | if [ $MSGLEVEL -le 1 ]; then | |
72 | msgwarn() { true; } | |
73 | msgnwarn() { true; } | |
74 | fi | |
75 | if [ $MSGLEVEL -le 2 ]; then | |
76 | msgmsg() { true; } | |
77 | msgnmsg() { true; } | |
39cc8228 | 78 | msgtest() { true; } |
3c528b91 | 79 | msgpass() { printf " ${CPASS}P${CNORMAL}"; } |
fc89263e DK |
80 | fi |
81 | if [ $MSGLEVEL -le 3 ]; then | |
82 | msginfo() { true; } | |
83 | msgninfo() { true; } | |
84 | fi | |
85 | if [ $MSGLEVEL -le 4 ]; then | |
86 | msgdebug() { true; } | |
87 | msgndebug() { true; } | |
88 | fi | |
89 | msgdone() { | |
90 | if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] || | |
91 | [ "$1" = "info" -a $MSGLEVEL -le 3 ] || | |
92 | [ "$1" = "msg" -a $MSGLEVEL -le 2 ] || | |
93 | [ "$1" = "warn" -a $MSGLEVEL -le 1 ] || | |
94 | [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then | |
95 | true; | |
96 | else | |
3c528b91 | 97 | printf "${CDONE}DONE${CNORMAL}\n"; |
fc89263e DK |
98 | fi |
99 | } | |
e43a426e MV |
100 | getaptconfig() { |
101 | if [ -f ./aptconfig.conf ]; then | |
102 | echo "./aptconfig.conf" | |
103 | elif [ -f ../aptconfig.conf ]; then | |
104 | echo "../aptconfig.conf" | |
105 | fi | |
106 | } | |
8d876415 DK |
107 | runapt() { |
108 | msgdebug "Executing: ${CCMD}$*${CDEBUG} " | |
846856f4 DK |
109 | local CMD="$1" |
110 | shift | |
3b8eb3bc | 111 | case $CMD in |
a311fb96 | 112 | sh|aptitude|*/*|command) ;; |
3b8eb3bc DK |
113 | *) CMD="${BUILDDIRECTORY}/$CMD";; |
114 | esac | |
a311fb96 | 115 | MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH=${LIBRARYPATH} $CMD "$@" |
8d876415 | 116 | } |
846856f4 DK |
117 | aptconfig() { runapt apt-config "$@"; } |
118 | aptcache() { runapt apt-cache "$@"; } | |
119 | aptcdrom() { runapt apt-cdrom "$@"; } | |
120 | aptget() { runapt apt-get "$@"; } | |
121 | aptftparchive() { runapt apt-ftparchive "$@"; } | |
122 | aptkey() { runapt apt-key "$@"; } | |
123 | aptmark() { runapt apt-mark "$@"; } | |
4f6d26b4 | 124 | aptsortpkgs() { runapt apt-sortpkgs "$@"; } |
796673c3 | 125 | apt() { runapt apt "$@"; } |
3b8eb3bc DK |
126 | apthelper() { runapt "${APTHELPERBINDIR}/apt-helper" "$@"; } |
127 | aptwebserver() { runapt "${APTWEBSERVERBINDIR}/aptwebserver" "$@"; } | |
128 | aptitude() { runapt aptitude "$@"; } | |
8d50b63f | 129 | aptextracttemplates() { runapt apt-extracttemplates "$@"; } |
3082603f | 130 | aptinternalsolver() { runapt "${APTINTERNALSOLVER}" "$@"; } |
ad7e0941 | 131 | aptdumpsolver() { runapt "${APTDUMPSOLVER}" "$@"; } |
3b8eb3bc | 132 | |
158fda31 | 133 | dpkg() { |
b0be0e09 | 134 | "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "$@" |
158fda31 | 135 | } |
ce7f128c DK |
136 | dpkgcheckbuilddeps() { |
137 | command dpkg-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg "$@" | |
b6b5a542 | 138 | } |
3fa950f1 | 139 | gdb() { |
a311fb96 | 140 | local CMD="$1" |
ce928105 | 141 | shift |
a311fb96 | 142 | runapt command gdb --quiet -ex run "${BUILDDIRECTORY}/$CMD" --args "${BUILDDIRECTORY}/$CMD" "$@" |
ae99ce2e | 143 | } |
8d876415 | 144 | |
8c1dd12c | 145 | exitwithstatus() { |
f91bd741 MV |
146 | # error if we about to overflow, but ... |
147 | # "255 failures ought to be enough for everybody" | |
5d76cee1 MV |
148 | if [ $EXIT_CODE -gt 255 ]; then |
149 | msgdie "Total failure count $EXIT_CODE too big" | |
f91bd741 | 150 | fi |
5d76cee1 | 151 | exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255)); |
8c1dd12c MV |
152 | } |
153 | ||
804d4a0d DK |
154 | shellsetedetector() { |
155 | local exit_status=$? | |
156 | if [ "$exit_status" != '0' ]; then | |
3c528b91 | 157 | printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n" |
804d4a0d DK |
158 | if [ "$EXIT_CODE" = '0' ]; then |
159 | EXIT_CODE="$exit_status" | |
160 | fi | |
161 | fi | |
162 | } | |
163 | ||
b720d0bd | 164 | addtrap() { |
8437b7d4 DK |
165 | if [ "$1" = 'prefix' ]; then |
166 | CURRENTTRAP="$2 $CURRENTTRAP" | |
167 | else | |
168 | CURRENTTRAP="$CURRENTTRAP $1" | |
169 | fi | |
804d4a0d | 170 | trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM |
b720d0bd | 171 | } |
8d876415 DK |
172 | |
173 | setupenvironment() { | |
0d303f17 DK |
174 | # privilege dropping and testing doesn't work if /tmp isn't world-writeable (as e.g. with libpam-tmpdir) |
175 | if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$(stat --format '%a' "$TMPDIR")" != '1777' ]; then | |
176 | unset TMPDIR | |
177 | fi | |
75954ae2 | 178 | TMPWORKINGDIRECTORY=$(mktemp -d) |
5684f71f | 179 | addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;" |
3cbbda3c | 180 | msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… " |
5c0dd6fc | 181 | |
03aa0847 | 182 | mkdir -m 700 "${TMPWORKINGDIRECTORY}/downloaded" |
68ba0b7f DK |
183 | if [ "$(id -u)" = '0' ]; then |
184 | # relax permissions so that running as root with user switching works | |
185 | umask 022 | |
03aa0847 DK |
186 | chmod 711 "$TMPWORKINGDIRECTORY" |
187 | chown _apt:root "${TMPWORKINGDIRECTORY}/downloaded" | |
68ba0b7f DK |
188 | fi |
189 | ||
5684f71f | 190 | TESTDIRECTORY=$(readlink -f $(dirname $0)) |
5c0dd6fc MV |
191 | # allow overriding the default BUILDDIR location |
192 | BUILDDIRECTORY=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"} | |
3b8eb3bc | 193 | LIBRARYPATH=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"} |
5c0dd6fc | 194 | METHODSDIR=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"} |
e43a426e | 195 | APTHELPERBINDIR=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"} |
c035b655 | 196 | APTWEBSERVERBINDIR=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"} |
3082603f | 197 | APTINTERNALSOLVER=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"} |
ad7e0941 | 198 | APTDUMPSOLVER=${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${BUILDDIRECTORY}/apt-dump-solver"} |
8d876415 | 199 | test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" |
5c0dd6fc MV |
200 | # ----- |
201 | ||
8d876415 | 202 | cd $TMPWORKINGDIRECTORY |
cd725954 | 203 | mkdir rootdir aptarchive keys |
8d876415 | 204 | cd rootdir |
b29c3712 | 205 | mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d |
8fe964f1 | 206 | mkdir -p usr/bin var/cache var/lib var/log tmp |
cffea9af | 207 | mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers |
cd725954 | 208 | touch var/lib/dpkg/available |
8d876415 | 209 | mkdir -p usr/lib/apt |
9082a1fc | 210 | ln -s ${METHODSDIR} usr/lib/apt/methods |
1f6cf9e7 DK |
211 | if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then |
212 | mkdir -p usr/lib/apt/solvers | |
213 | ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr/lib/apt/solvers/dump | |
214 | ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr/lib/apt/solvers/apt | |
215 | echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc/apt/apt.conf.d/externalsolver.conf | |
216 | fi | |
291a386f MV |
217 | # use the autoremove from the BUILDDIRECTORY if its there, otherwise |
218 | # system | |
219 | if [ -e ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove ]; then | |
220 | ln -s ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove etc/apt/apt.conf.d/01autoremove | |
221 | else | |
222 | ln -s /etc/apt/apt.conf.d/01autoremove etc/apt/apt.conf.d/01autoremove | |
223 | fi | |
8d876415 | 224 | cd .. |
2c6baa5a | 225 | local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/') |
53ea1b56 DK |
226 | if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then |
227 | cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages | |
8f8169ac | 228 | fi |
4a4ea26c | 229 | local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/') |
53ea1b56 DK |
230 | if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then |
231 | cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive/Sources | |
8f8169ac | 232 | fi |
53ea1b56 | 233 | cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys/ |
5684f71f | 234 | chmod 644 $(find keys -name '*.pub' -o -name '*.sec') |
cd725954 | 235 | ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg |
d6cf2345 | 236 | |
cffea9af | 237 | echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf |
94eb3bee | 238 | echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf |
8d876415 | 239 | echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf |
5c0dd6fc | 240 | echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf |
68ba0b7f DK |
241 | # store apt-key were we can access it, even if we run it as a different user |
242 | # destroys coverage reporting though, so just do it for root for now | |
243 | if [ "$(id -u)" = '0' ]; then | |
244 | cp "${BUILDDIRECTORY}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/" | |
245 | chmod o+rx "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key" | |
246 | echo "Dir::Bin::apt-key \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key\";" >> aptconfig.conf | |
247 | else | |
248 | echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf | |
249 | fi | |
b0be0e09 | 250 | |
d61960d9 | 251 | cat << EOF > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" |
b0be0e09 DK |
252 | #!/bin/sh |
253 | set -e | |
254 | if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then | |
255 | if [ -n "\$LD_PRELOAD" ]; then | |
256 | export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so \${LD_PRELOAD}" | |
257 | else | |
258 | export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so" | |
259 | fi | |
260 | fi | |
261 | exec fakeroot dpkg --root="${TMPWORKINGDIRECTORY}/rootdir" \\ | |
262 | --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\ | |
263 | --force-not-root --force-bad-path "\$@" | |
264 | EOF | |
b0be0e09 DK |
265 | chmod +x "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" |
266 | echo "Dir::Bin::dpkg \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg\";" > rootdir/etc/apt/apt.conf.d/99dpkg | |
267 | ||
846856f4 | 268 | if ! command dpkg --assert-multi-arch >/dev/null 2>&1; then |
53ea1b56 DK |
269 | echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it… |
270 | fi | |
2c085486 | 271 | echo 'quiet::NoUpdate "true";' >> aptconfig.conf |
0c8171d7 | 272 | echo 'quiet::NoStatistic "true";' >> aptconfig.conf |
d6cf2345 DK |
273 | # too distracting for users, but helpful to detect changes |
274 | echo 'Acquire::Progress::Ignore::ShowErrorText "true";' >> aptconfig.conf | |
0045df3f DK |
275 | # in testcases, it can appear as if localhost has a rotation setup, |
276 | # hide this as we can't really deal with it properly | |
277 | echo 'Acquire::Failure::ShowIP "false";' >> aptconfig.conf | |
d6cf2345 | 278 | |
68ba0b7f DK |
279 | cp "${TESTDIRECTORY}/apt.pem" "${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem" |
280 | if [ "$(id -u)" = '0' ]; then | |
281 | chown _apt:root "${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem" | |
282 | fi | |
283 | echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir/etc/apt/apt.conf.d/99https | |
d6cf2345 | 284 | echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary |
276e51dd | 285 | configcompression '.' 'gz' #'bz2' 'lzma' 'xz' |
77a45beb | 286 | |
4bb006d1 DK |
287 | # create some files in /tmp and look at user/group to get what this means |
288 | TEST_DEFAULT_USER="$USER" | |
289 | if [ "$(uname)" = 'GNU/kFreeBSD' ]; then | |
290 | TEST_DEFAULT_GROUP='root' | |
291 | else | |
292 | TEST_DEFAULT_GROUP="$USER" | |
293 | fi | |
294 | ||
d4f4bcf7 MV |
295 | # Acquire::AllowInsecureRepositories=false is not yet the default |
296 | # but we want it to be the default soon | |
297 | configallowinsecurerepositories "false"; | |
298 | ||
ce7f128c | 299 | # cleanup the environment a bit |
8c617819 MV |
300 | # prefer our apt binaries over the system apt binaries |
301 | export PATH="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin" | |
be233796 | 302 | export LC_ALL=C.UTF-8 |
3b8eb3bc | 303 | unset LANGUAGE APT_CONFIG |
ce7f128c DK |
304 | unset GREP_OPTIONS DEB_BUILD_PROFILES |
305 | ||
8d876415 DK |
306 | msgdone "info" |
307 | } | |
308 | ||
ea65d079 DK |
309 | getarchitecture() { |
310 | if [ "$1" = "native" -o -z "$1" ]; then | |
311 | eval `aptconfig shell ARCH APT::Architecture` | |
312 | if [ -n "$ARCH" ]; then | |
313 | echo $ARCH | |
314 | else | |
5834d7a1 | 315 | dpkg --print-architecture |
ea65d079 DK |
316 | fi |
317 | else | |
318 | echo $1 | |
319 | fi | |
320 | } | |
321 | ||
53ea1b56 | 322 | getarchitectures() { |
081c9d44 | 323 | aptconfig dump --no-empty --format '%v%n' APT::Architecture APT::Architectures | sort -u | tr '\n' ' ' |
53ea1b56 DK |
324 | } |
325 | ||
3dcdc1f9 DK |
326 | getarchitecturesfromcommalist() { |
327 | echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/" | |
328 | } | |
329 | ||
8d876415 | 330 | configarchitecture() { |
18908589 DK |
331 | { |
332 | echo "APT::Architecture \"$(getarchitecture $1)\";" | |
333 | while [ -n "$1" ]; do | |
334 | echo "APT::Architectures:: \"$(getarchitecture $1)\";" | |
335 | shift | |
336 | done | |
337 | } >rootdir/etc/apt/apt.conf.d/01multiarch.conf | |
53ea1b56 DK |
338 | configdpkg |
339 | } | |
340 | ||
341 | configdpkg() { | |
342 | if [ ! -e rootdir/var/lib/dpkg/status ]; then | |
343 | local STATUSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/') | |
344 | if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then | |
345 | cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status | |
346 | else | |
347 | echo -n > rootdir/var/lib/dpkg/status | |
348 | fi | |
349 | fi | |
18908589 | 350 | rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg |
846856f4 | 351 | if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then |
53ea1b56 DK |
352 | local ARCHS="$(getarchitectures)" |
353 | if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then | |
354 | DPKGARCH="$(dpkg --print-architecture)" | |
355 | for ARCH in ${ARCHS}; do | |
feae193b | 356 | if [ "${ARCH}" != "${DPKGARCH}" ]; then |
18908589 | 357 | if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then |
feae193b | 358 | # old-style used e.g. in Ubuntu-P – and as it seems travis |
18908589 DK |
359 | echo "DPKG::options:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg |
360 | echo "DPKG::options:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg | |
feae193b DK |
361 | fi |
362 | fi | |
53ea1b56 DK |
363 | done |
364 | if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then | |
05343a22 DK |
365 | # dpkg doesn't really check the version as long as it is fully installed, |
366 | # but just to be sure we choose one above the required version | |
367 | insertinstalledpackage 'dpkg' "all" '1.16.2+fake' | |
53ea1b56 DK |
368 | fi |
369 | fi | |
370 | fi | |
8d876415 DK |
371 | } |
372 | ||
0c787570 DK |
373 | configdpkgnoopchroot() { |
374 | # create a library to noop chroot() and rewrite maintainer script executions | |
375 | # via execvp() as used by dpkg as we don't want our rootdir to be a fullblown | |
376 | # chroot directory dpkg could chroot into to execute the maintainer scripts | |
377 | msgtest 'Building library to preload to make maintainerscript work in' 'dpkg' | |
378 | cat << EOF > noopchroot.c | |
379 | #define _GNU_SOURCE | |
380 | #include <stdio.h> | |
381 | #include <stdlib.h> | |
382 | #include <string.h> | |
383 | #include <dlfcn.h> | |
384 | ||
385 | static char * chrootdir = NULL; | |
386 | ||
387 | int chroot(const char *path) { | |
388 | printf("WARNING: CHROOTing to %s was ignored!\n", path); | |
389 | free(chrootdir); | |
390 | chrootdir = strdup(path); | |
391 | return 0; | |
392 | } | |
393 | int execvp(const char *file, char *const argv[]) { | |
394 | static int (*func_execvp) (const char *, char * const []) = NULL; | |
395 | if (func_execvp == NULL) | |
396 | func_execvp = (int (*) (const char *, char * const [])) dlsym(RTLD_NEXT, "execvp"); | |
397 | if (chrootdir == NULL || strncmp(file, "/var/lib/dpkg/", strlen("/var/lib/dpkg/")) != 0) | |
398 | return func_execvp(file, argv); | |
399 | printf("REWRITE execvp call %s into %s\n", file, chrootdir); | |
400 | char newfile[strlen(chrootdir) + strlen(file)]; | |
401 | strcpy(newfile, chrootdir); | |
402 | strcat(newfile, file); | |
b0be0e09 DK |
403 | char const * const baseadmindir = "/var/lib/dpkg"; |
404 | char admindir[strlen(chrootdir) + strlen(baseadmindir)]; | |
405 | strcpy(admindir, chrootdir); | |
406 | strcat(admindir, baseadmindir); | |
407 | setenv("DPKG_ADMINDIR", admindir, 1); | |
0c787570 DK |
408 | return func_execvp(newfile, argv); |
409 | } | |
410 | EOF | |
411 | testsuccess --nomsg gcc -fPIC -shared -o noopchroot.so noopchroot.c -ldl | |
0c787570 DK |
412 | } |
413 | ||
d4f4bcf7 MV |
414 | configallowinsecurerepositories() { |
415 | echo "Acquire::AllowInsecureRepositories \"$1\";" > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf | |
416 | ||
417 | } | |
418 | ||
276e51dd DK |
419 | configcompression() { |
420 | while [ -n "$1" ]; do | |
421 | case "$1" in | |
3c528b91 MO |
422 | '.') printf ".\t.\tcat\n";; |
423 | 'gz') printf "gzip\tgz\tgzip\n";; | |
424 | 'bz2') printf "bzip2\tbz2\tbzip2\n";; | |
425 | 'lzma') printf "lzma\tlzma\txz --format=lzma\n";; | |
426 | 'xz') printf "xz\txz\txz\n";; | |
427 | *) printf "$1\t$1\t$1\n";; | |
276e51dd DK |
428 | esac |
429 | shift | |
430 | done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | |
431 | } | |
432 | ||
5f982b9d DK |
433 | forcecompressor() { |
434 | COMPRESSOR="$1" | |
435 | COMPRESSOR_CMD="$1" | |
436 | case $COMPRESSOR in | |
437 | gzip) COMPRESS='gz';; | |
438 | bzip2) COMPRESS='bz2';; | |
439 | lzma) COMPRESS='lzma';; | |
440 | xz) COMPRESS='xz';; | |
441 | *) msgdie "Compressor $COMPRESSOR is unknown to framework, so can't be forced by forcecompressor!";; | |
442 | esac | |
443 | local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor" | |
444 | echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; }; | |
445 | Dir::Bin::uncompressed \"/does/not/exist\"; | |
446 | Dir::Bin::gzip \"/does/not/exist\"; | |
447 | Dir::Bin::bzip2 \"/does/not/exist\"; | |
448 | Dir::Bin::lzma \"/does/not/exist\"; | |
449 | Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE" | |
450 | if [ -e "/bin/${COMPRESSOR}" ]; then | |
451 | echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE" | |
452 | elif [ -e "/usr/bin/${COMPRESSOR}" ]; then | |
453 | echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE" | |
454 | elif [ "${COMPRESSOR}" = 'lzma' ]; then | |
455 | echo 'Dir::Bin::xz "/usr/bin/xz";' >> "$CONFFILE" | |
456 | COMPRESSOR_CMD='xz --format=lzma' | |
457 | else | |
458 | msgtest 'Test for availability of compressor' "${COMPRESSOR}" | |
459 | msgfail | |
460 | fi | |
461 | } | |
462 | ||
75954ae2 | 463 | setupsimplenativepackage() { |
ce9864a8 DK |
464 | local NAME="$1" |
465 | local ARCH="$2" | |
466 | local VERSION="$3" | |
467 | local RELEASE="${4:-unstable}" | |
468 | local DEPENDENCIES="$5" | |
14109555 | 469 | local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} |
18908589 DK |
470 | If you find such a package installed on your system, |
471 | something went horribly wrong! They are autogenerated | |
472 | und used only by testcases and surf no other propose…"}" | |
473 | ||
b7899b00 DK |
474 | local SECTION="${7:-others}" |
475 | local DISTSECTION | |
476 | if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then | |
477 | DISTSECTION="main" | |
478 | else | |
479 | DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)" | |
480 | fi | |
ce9864a8 DK |
481 | local BUILDDIR=incoming/${NAME}-${VERSION} |
482 | mkdir -p ${BUILDDIR}/debian/source | |
483 | cd ${BUILDDIR} | |
484 | echo "* most suckless software product ever" > FEATURES | |
b7899b00 DK |
485 | test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright |
486 | test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low | |
ce9864a8 DK |
487 | |
488 | * Initial release | |
489 | ||
b7899b00 DK |
490 | -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog |
491 | test -e debian/control || echo "Source: $NAME | |
492 | Section: $SECTION | |
ce9864a8 DK |
493 | Priority: optional |
494 | Maintainer: Joe Sixpack <joe@example.org> | |
495 | Build-Depends: debhelper (>= 7) | |
496 | Standards-Version: 3.9.1 | |
497 | ||
875bcb36 DK |
498 | Package: $NAME" > debian/control |
499 | if [ "$ARCH" = 'all' ]; then | |
500 | echo "Architecture: all" >> debian/control | |
501 | else | |
502 | echo "Architecture: any" >> debian/control | |
503 | fi | |
ce9864a8 | 504 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control |
18908589 DK |
505 | echo "Description: $DESCRIPTION" >> debian/control |
506 | ||
b7899b00 DK |
507 | test -e debian/compat || echo "7" > debian/compat |
508 | test -e debian/source/format || echo "3.0 (native)" > debian/source/format | |
ce9864a8 | 509 | test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules |
75954ae2 DK |
510 | cd - > /dev/null |
511 | } | |
512 | ||
513 | buildsimplenativepackage() { | |
514 | local NAME="$1" | |
515 | local ARCH="$2" | |
516 | local VERSION="$3" | |
517 | local RELEASE="${4:-unstable}" | |
518 | local DEPENDENCIES="$5" | |
14109555 | 519 | local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} |
18908589 DK |
520 | If you find such a package installed on your system, |
521 | something went horribly wrong! They are autogenerated | |
522 | und used only by testcases and surf no other propose…"}" | |
523 | ||
75954ae2 | 524 | local SECTION="${7:-others}" |
d67004e0 | 525 | local PRIORITY="${8:-optional}" |
42c1513b | 526 | local FILE_TREE="$9" |
adff049d | 527 | local COMPRESS_TYPE="${10:-gzip}" |
75954ae2 DK |
528 | local DISTSECTION |
529 | if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then | |
530 | DISTSECTION="main" | |
531 | else | |
532 | DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)" | |
533 | fi | |
5a635ee4 | 534 | local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION} |
b761356f | 535 | |
0c787570 | 536 | msgtest "Build source package in version ${VERSION} for ${RELEASE} in ${DISTSECTION}" "$NAME" |
b761356f DK |
537 | mkdir -p $BUILDDIR/debian/source |
538 | echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES | |
539 | echo "#!/bin/sh | |
540 | echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME} | |
541 | ||
542 | echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright | |
543 | echo "$NAME ($VERSION) $RELEASE; urgency=low | |
544 | ||
545 | * Initial release | |
546 | ||
547 | -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog | |
548 | echo "Source: $NAME | |
549 | Section: $SECTION | |
d67004e0 | 550 | Priority: $PRIORITY |
b761356f | 551 | Maintainer: Joe Sixpack <joe@example.org> |
01f520ce DK |
552 | Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control |
553 | local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')" | |
554 | test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control | |
555 | echo " | |
556 | Package: $NAME" >> ${BUILDDIR}/debian/control | |
b761356f | 557 | |
875bcb36 DK |
558 | if [ "$ARCH" = 'all' ]; then |
559 | echo "Architecture: all" >> ${BUILDDIR}/debian/control | |
560 | else | |
561 | echo "Architecture: any" >> ${BUILDDIR}/debian/control | |
562 | fi | |
01f520ce DK |
563 | local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')" |
564 | test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control | |
18908589 | 565 | echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control |
01f520ce | 566 | |
b761356f | 567 | echo '3.0 (native)' > ${BUILDDIR}/debian/source/format |
0c787570 DK |
568 | cd ${BUILDDIR}/.. |
569 | testsuccess --nomsg dpkg-source -b ${NAME}-${VERSION} | |
570 | cd - >/dev/null | |
571 | sed -n 's#^dpkg-source: info: building [^ ]\+ in ##p' ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output \ | |
f1828b69 | 572 | | while read SRC; do |
5a635ee4 | 573 | echo "pool/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist |
f1828b69 | 574 | # if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then |
33a22672 | 575 | # aptkey --keyring ./keys/joesixpack.pub --secret-keyring ./keys/joesixpack.sec --quiet --readonly \ |
bd7fb5aa | 576 | # adv --yes --default-key 'Joe Sixpack' \ |
f1828b69 DK |
577 | # --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC" |
578 | # mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC" | |
579 | # fi | |
b761356f | 580 | done |
84aa13f4 | 581 | |
3dcdc1f9 | 582 | for arch in $(getarchitecturesfromcommalist "$ARCH"); do |
0c787570 | 583 | msgtest "Build binary package for ${RELEASE} in ${SECTION}" "$NAME" |
84aa13f4 DK |
584 | rm -rf ${BUILDDIR}/debian/tmp |
585 | mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin | |
586 | cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} | |
587 | cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch} | |
42c1513b MV |
588 | if [ -n "$FILE_TREE" ]; then |
589 | cp -ar "$FILE_TREE" ${BUILDDIR}/debian/tmp | |
590 | fi | |
42c1513b | 591 | |
84aa13f4 DK |
592 | (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch) |
593 | (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums) | |
846856f4 | 594 | local LOG="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log" |
eb9dee96 DK |
595 | # ensure the right permissions as dpkg-deb ensists |
596 | chmod 755 ${BUILDDIR}/debian/tmp/DEBIAN | |
0c787570 | 597 | testsuccess --nomsg dpkg-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. |
84aa13f4 DK |
598 | echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist |
599 | done | |
600 | ||
13845042 DK |
601 | mkdir -p ${BUILDDIR}/../${NAME}_${VERSION} |
602 | cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/ | |
603 | cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog | |
5a635ee4 | 604 | rm -rf "${BUILDDIR}" |
b761356f | 605 | msgdone "info" |
75954ae2 DK |
606 | } |
607 | ||
608 | buildpackage() { | |
609 | local BUILDDIR=$1 | |
610 | local RELEASE=$2 | |
611 | local SECTION=$3 | |
ea65d079 | 612 | local ARCH=$(getarchitecture $4) |
846856f4 DK |
613 | local PKGNAME="$(echo "$BUILDDIR" | grep -o '[^/]*$')" |
614 | local BUILDLOG="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")" | |
0c787570 | 615 | msgtest "Build package for ${RELEASE} in ${SECTION}" "$PKGNAME" |
75954ae2 DK |
616 | cd $BUILDDIR |
617 | if [ "$ARCH" = "all" ]; then | |
618 | ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)" | |
619 | fi | |
0c787570 DK |
620 | testsuccess --nomsg dpkg-buildpackage -uc -us -a$ARCH |
621 | cp ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output $BUILDLOG | |
846856f4 DK |
622 | local PKGS="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")" |
623 | local SRCS="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')" | |
ce9864a8 | 624 | cd - > /dev/null |
b7899b00 | 625 | for PKG in $PKGS; do |
75954ae2 | 626 | echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist |
b7899b00 DK |
627 | done |
628 | for SRC in $SRCS; do | |
75954ae2 | 629 | echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist |
b7899b00 | 630 | done |
ce9864a8 DK |
631 | } |
632 | ||
633 | buildaptarchive() { | |
ce9864a8 | 634 | if [ -d incoming ]; then |
846856f4 | 635 | buildaptarchivefromincoming "$@" |
ce9864a8 | 636 | else |
846856f4 | 637 | buildaptarchivefromfiles "$@" |
ce9864a8 DK |
638 | fi |
639 | } | |
640 | ||
641 | createaptftparchiveconfig() { | |
276e51dd | 642 | local COMPRESSORS="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')" |
016bea82 DK |
643 | local COMPRESSORS="${COMPRESSORS%* }" |
644 | local ARCHS="$(getarchitectures)" | |
ce9864a8 DK |
645 | echo -n 'Dir { |
646 | ArchiveDir "' >> ftparchive.conf | |
647 | echo -n $(readlink -f .) >> ftparchive.conf | |
648 | echo -n '"; | |
649 | CacheDir "' >> ftparchive.conf | |
650 | echo -n $(readlink -f ..) >> ftparchive.conf | |
651 | echo -n '"; | |
b7899b00 DK |
652 | FileListDir "' >> ftparchive.conf |
653 | echo -n $(readlink -f pool/) >> ftparchive.conf | |
654 | echo -n '"; | |
655 | }; | |
656 | Default { | |
276e51dd DK |
657 | Packages::Compress "'"$COMPRESSORS"'"; |
658 | Sources::Compress "'"$COMPRESSORS"'"; | |
659 | Contents::Compress "'"$COMPRESSORS"'"; | |
660 | Translation::Compress "'"$COMPRESSORS"'"; | |
18331adf | 661 | LongDescription "false"; |
ce9864a8 DK |
662 | }; |
663 | TreeDefault { | |
664 | Directory "pool/"; | |
665 | SrcDirectory "pool/"; | |
666 | }; | |
667 | APT { | |
668 | FTPArchive { | |
669 | Release { | |
670 | Origin "joesixpack"; | |
671 | Label "apttestcases"; | |
672 | Suite "unstable"; | |
673 | Description "repository with dummy packages"; | |
674 | Architectures "' >> ftparchive.conf | |
675 | echo -n "$ARCHS" >> ftparchive.conf | |
676 | echo 'source"; | |
677 | }; | |
678 | }; | |
679 | };' >> ftparchive.conf | |
b7899b00 DK |
680 | for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do |
681 | echo -n 'tree "dists/' >> ftparchive.conf | |
682 | echo -n "$DIST" >> ftparchive.conf | |
683 | echo -n '" { | |
ce9864a8 DK |
684 | Architectures "' >> ftparchive.conf |
685 | echo -n "$ARCHS" >> ftparchive.conf | |
b7899b00 DK |
686 | echo -n 'source"; |
687 | FileList "' >> ftparchive.conf | |
688 | echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf | |
689 | echo -n '"; | |
690 | SourceFileList "' >> ftparchive.conf | |
691 | echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf | |
692 | echo -n '"; | |
693 | Sections "' >> ftparchive.conf | |
694 | echo -n "$(find ./pool/ -maxdepth 1 -name "${DIST}.*.pkglist" -type f | cut -d'/' -f 3 | cut -d'.' -f 2 | sort | uniq | tr '\n' ' ')" >> ftparchive.conf | |
695 | echo '"; | |
ce9864a8 | 696 | };' >> ftparchive.conf |
b7899b00 | 697 | done |
ce9864a8 DK |
698 | } |
699 | ||
700 | buildaptftparchivedirectorystructure() { | |
b7899b00 DK |
701 | local DISTS="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')" |
702 | for DIST in $DISTS; do | |
703 | local SECTIONS="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)" | |
704 | for SECTION in $SECTIONS; do | |
705 | local ARCHS="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')" | |
706 | for ARCH in $ARCHS; do | |
707 | mkdir -p dists/${DIST}/${SECTION}/binary-${ARCH} | |
708 | done | |
709 | mkdir -p dists/${DIST}/${SECTION}/source | |
710 | mkdir -p dists/${DIST}/${SECTION}/i18n | |
711 | done | |
ce9864a8 | 712 | done |
ce9864a8 DK |
713 | } |
714 | ||
9b78cda6 | 715 | insertpackage() { |
10e100e5 | 716 | local RELEASES="$1" |
9b78cda6 DK |
717 | local NAME="$2" |
718 | local ARCH="$3" | |
719 | local VERSION="$4" | |
720 | local DEPENDENCIES="$5" | |
d67004e0 | 721 | local PRIORITY="${6:-optional}" |
10e100e5 | 722 | local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASES} |
18908589 DK |
723 | If you find such a package installed on your system, |
724 | something went horribly wrong! They are autogenerated | |
725 | und used only by testcases and surf no other propose…"}" | |
d67004e0 | 726 | local ARCHS="" |
10e100e5 DK |
727 | for RELEASE in $(printf '%s' "$RELEASES" | tr ',' '\n'); do |
728 | if [ "$RELEASE" = 'installed' ]; then | |
729 | insertinstalledpackage "$2" "$3" "$4" "$5" "$6" "$7" | |
730 | continue | |
d67004e0 | 731 | fi |
10e100e5 DK |
732 | for arch in $(getarchitecturesfromcommalist "$ARCH"); do |
733 | if [ "$arch" = 'all' -o "$arch" = 'none' ]; then | |
734 | ARCHS="$(getarchitectures)" | |
735 | else | |
736 | ARCHS="$arch" | |
737 | fi | |
738 | for BUILDARCH in $ARCHS; do | |
739 | local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}" | |
740 | mkdir -p $PPATH | |
741 | local FILE="${PPATH}/Packages" | |
742 | echo "Package: $NAME | |
d67004e0 | 743 | Priority: $PRIORITY |
9b78cda6 | 744 | Section: other |
2c085486 | 745 | Installed-Size: 42 |
c919ad6e | 746 | Maintainer: Joe Sixpack <joe@example.org>" >> $FILE |
10e100e5 DK |
747 | test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE |
748 | echo "Version: $VERSION | |
d67004e0 | 749 | Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE |
10e100e5 DK |
750 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE |
751 | echo "Description: $(printf '%s' "$DESCRIPTION" | head -n 1)" >> $FILE | |
752 | echo "Description-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)" >> $FILE | |
753 | echo >> $FILE | |
754 | done | |
d67004e0 | 755 | done |
10e100e5 DK |
756 | mkdir -p aptarchive/dists/${RELEASE}/main/source aptarchive/dists/${RELEASE}/main/i18n |
757 | touch aptarchive/dists/${RELEASE}/main/source/Sources | |
758 | echo "Package: $NAME | |
0e0d9919 DK |
759 | Description-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1) |
760 | Description-en: $DESCRIPTION | |
761 | " >> aptarchive/dists/${RELEASE}/main/i18n/Translation-en | |
10e100e5 | 762 | done |
9b78cda6 DK |
763 | } |
764 | ||
234675b7 DK |
765 | insertsource() { |
766 | local RELEASE="$1" | |
767 | local NAME="$2" | |
768 | local ARCH="$3" | |
769 | local VERSION="$4" | |
770 | local DEPENDENCIES="$5" | |
771 | local ARCHS="" | |
772 | local SPATH="aptarchive/dists/${RELEASE}/main/source" | |
773 | mkdir -p $SPATH | |
774 | local FILE="${SPATH}/Sources" | |
775 | echo "Package: $NAME | |
776 | Binary: $NAME | |
777 | Version: $VERSION | |
778 | Maintainer: Joe Sixpack <joe@example.org> | |
779 | Architecture: $ARCH" >> $FILE | |
780 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE | |
781 | echo "Files: | |
782 | d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc | |
d5dea0be DK |
783 | d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz |
784 | " >> $FILE | |
234675b7 DK |
785 | } |
786 | ||
dfc2b1be DK |
787 | insertinstalledpackage() { |
788 | local NAME="$1" | |
789 | local ARCH="$2" | |
790 | local VERSION="$3" | |
791 | local DEPENDENCIES="$4" | |
d67004e0 | 792 | local PRIORITY="${5:-optional}" |
d4b4e5ea | 793 | local STATUS="${6:-install ok installed}" |
14109555 | 794 | local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed |
18908589 DK |
795 | If you find such a package installed on your system, |
796 | something went horribly wrong! They are autogenerated | |
797 | und used only by testcases and surf no other propose…"}" | |
798 | ||
53ea1b56 DK |
799 | local FILE='rootdir/var/lib/dpkg/status' |
800 | local INFO='rootdir/var/lib/dpkg/info' | |
3dcdc1f9 | 801 | for arch in $(getarchitecturesfromcommalist "$ARCH"); do |
d67004e0 | 802 | echo "Package: $NAME |
d4b4e5ea | 803 | Status: $STATUS |
d67004e0 | 804 | Priority: $PRIORITY |
dfc2b1be DK |
805 | Section: other |
806 | Installed-Size: 42 | |
807 | Maintainer: Joe Sixpack <joe@example.org> | |
dfc2b1be | 808 | Version: $VERSION" >> $FILE |
c919ad6e | 809 | test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE |
d67004e0 | 810 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE |
18908589 DK |
811 | echo "Description: $DESCRIPTION" >> $FILE |
812 | echo >> $FILE | |
53ea1b56 DK |
813 | if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then |
814 | echo -n > ${INFO}/${NAME}:${arch}.list | |
815 | else | |
816 | echo -n > ${INFO}/${NAME}.list | |
817 | fi | |
d67004e0 | 818 | done |
dfc2b1be DK |
819 | } |
820 | ||
821 | ||
ce9864a8 | 822 | buildaptarchivefromincoming() { |
3cbbda3c | 823 | msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…" |
ce9864a8 DK |
824 | cd aptarchive |
825 | [ -e pool ] || ln -s ../incoming pool | |
826 | [ -e ftparchive.conf ] || createaptftparchiveconfig | |
827 | [ -e dists ] || buildaptftparchivedirectorystructure | |
b7899b00 | 828 | msgninfo "\tGenerate Packages, Sources and Contents files… " |
31be38d2 | 829 | testsuccess aptftparchive generate ftparchive.conf |
ce9864a8 DK |
830 | cd - > /dev/null |
831 | msgdone "info" | |
4dbfe436 | 832 | generatereleasefiles "$@" |
ce9864a8 DK |
833 | } |
834 | ||
835 | buildaptarchivefromfiles() { | |
3cbbda3c | 836 | msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…" |
0e0d9919 | 837 | find aptarchive -name 'Packages' -o -name 'Sources' -o -name 'Translation-*' | while read line; do |
9b78cda6 | 838 | msgninfo "\t${line} file… " |
276e51dd | 839 | compressfile "$line" "$1" |
8d876415 | 840 | msgdone "info" |
9b78cda6 | 841 | done |
e3c62328 | 842 | generatereleasefiles "$@" |
9b78cda6 DK |
843 | } |
844 | ||
276e51dd DK |
845 | compressfile() { |
846 | cat ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | while read compressor extension command; do | |
847 | if [ "$compressor" = '.' ]; then | |
848 | if [ -n "$2" ]; then | |
849 | touch -d "$2" "$1" | |
850 | fi | |
851 | continue | |
852 | fi | |
853 | cat "$1" | $command > "${1}.${extension}" | |
854 | if [ -n "$2" ]; then | |
855 | touch -d "$2" "${1}.${extension}" | |
856 | fi | |
857 | done | |
858 | } | |
859 | ||
a3bbbab7 | 860 | # can be overridden by testcases for their pleasure |
bf9e7447 DK |
861 | getcodenamefromsuite() { |
862 | case "$1" in | |
863 | unstable) echo 'sid';; | |
864 | *) echo -n "$1";; | |
865 | esac | |
866 | } | |
a3bbbab7 | 867 | getreleaseversionfromsuite() { true; } |
718f797c | 868 | getlabelfromsuite() { true; } |
a3bbbab7 | 869 | |
9b78cda6 | 870 | generatereleasefiles() { |
884a4c0a DK |
871 | # $1 is the Date header and $2 is the ValidUntil header to be set |
872 | # both should be given in notation date/touch can understand | |
9b78cda6 DK |
873 | msgninfo "\tGenerate Release files… " |
874 | if [ -e aptarchive/dists ]; then | |
875 | for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do | |
a3bbbab7 DK |
876 | local SUITE="$(echo "$dir" | cut -d'/' -f 4)" |
877 | local CODENAME="$(getcodenamefromsuite $SUITE)" | |
878 | local VERSION="$(getreleaseversionfromsuite $SUITE)" | |
718f797c | 879 | local LABEL="$(getlabelfromsuite $SUITE)" |
884a4c0a | 880 | if [ -n "$VERSION" ]; then |
718f797c DK |
881 | VERSION="-o APT::FTPArchive::Release::Version=${VERSION}" |
882 | fi | |
883 | if [ -n "$LABEL" ]; then | |
884 | LABEL="-o APT::FTPArchive::Release::Label=${LABEL}" | |
a3bbbab7 | 885 | fi |
884a4c0a DK |
886 | aptftparchive -qq release $dir \ |
887 | -o APT::FTPArchive::Release::Suite="${SUITE}" \ | |
888 | -o APT::FTPArchive::Release::Codename="${CODENAME}" \ | |
718f797c | 889 | ${LABEL} \ |
884a4c0a DK |
890 | ${VERSION} \ |
891 | | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference | |
a3bbbab7 | 892 | if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then |
35faae11 DK |
893 | sed -i '/^Date: / a\ |
894 | NotAutomatic: yes' $dir/Release | |
895 | fi | |
884a4c0a DK |
896 | if [ -n "$1" -a "$1" != "now" ]; then |
897 | sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release | |
898 | fi | |
899 | if [ -n "$2" ]; then | |
900 | sed -i "/^Date: / a\ | |
901 | Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release | |
902 | fi | |
9b78cda6 DK |
903 | done |
904 | else | |
905 | aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference | |
8d876415 | 906 | fi |
884a4c0a | 907 | if [ -n "$1" -a "$1" != "now" ]; then |
fe0f7911 DK |
908 | for release in $(find ./aptarchive -name 'Release'); do |
909 | touch -d "$1" $release | |
910 | done | |
8d876415 | 911 | fi |
b7899b00 | 912 | msgdone "info" |
8d876415 DK |
913 | } |
914 | ||
b7899b00 DK |
915 | setupdistsaptarchive() { |
916 | local APTARCHIVE=$(readlink -f ./aptarchive) | |
917 | rm -f root/etc/apt/sources.list.d/apt-test-*-deb.list | |
918 | rm -f root/etc/apt/sources.list.d/apt-test-*-deb-src.list | |
919 | for DISTS in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do | |
920 | SECTIONS=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ') | |
921 | msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… " | |
922 | echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list | |
923 | echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list | |
924 | msgdone "info" | |
925 | done | |
926 | } | |
927 | ||
928 | setupflataptarchive() { | |
ce9864a8 | 929 | local APTARCHIVE=$(readlink -f ./aptarchive) |
8d876415 DK |
930 | if [ -f ${APTARCHIVE}/Packages ]; then |
931 | msgninfo "\tadd deb sources.list line… " | |
932 | echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list | |
933 | msgdone "info" | |
934 | else | |
935 | rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list | |
936 | fi | |
937 | if [ -f ${APTARCHIVE}/Sources ]; then | |
938 | msgninfo "\tadd deb-src sources.list line… " | |
939 | echo "deb-src file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list | |
940 | msgdone "info" | |
941 | else | |
942 | rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list | |
943 | fi | |
b7899b00 DK |
944 | } |
945 | ||
946 | setupaptarchive() { | |
4dbfe436 DK |
947 | local NOUPDATE=0 |
948 | if [ "$1" = '--no-update' ]; then | |
949 | NOUPDATE=1 | |
950 | shift | |
951 | fi | |
952 | buildaptarchive "$@" | |
b7899b00 DK |
953 | if [ -e aptarchive/dists ]; then |
954 | setupdistsaptarchive | |
955 | else | |
956 | setupflataptarchive | |
957 | fi | |
9d653a6d | 958 | signreleasefiles 'Joe Sixpack' |
4dbfe436 | 959 | if [ "1" != "$NOUPDATE" ]; then |
5684f71f | 960 | testsuccess aptget update -o Debug::pkgAcquire::Worker=true -o Debug::Acquire::gpgv=true |
b2ea1a47 | 961 | fi |
8d876415 DK |
962 | } |
963 | ||
f213b6ea DK |
964 | signreleasefiles() { |
965 | local SIGNER="${1:-Joe Sixpack}" | |
07cb47e7 | 966 | local REPODIR="${2:-aptarchive}" |
f1e1abd8 | 967 | local KEY="keys/$(echo "$SIGNER" | tr 'A-Z' 'a-z' | sed 's# ##g')" |
33a22672 | 968 | local GPG="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes" |
f1e1abd8 | 969 | msgninfo "\tSign archive with $SIGNER key $KEY… " |
29a59c46 DK |
970 | local REXKEY='keys/rexexpired' |
971 | local SECEXPIREBAK="${REXKEY}.sec.bak" | |
972 | local PUBEXPIREBAK="${REXKEY}.pub.bak" | |
973 | if [ "${SIGNER}" = 'Rex Expired' ]; then | |
974 | # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time | |
975 | # option doesn't exist anymore (and using faketime would add a new obscure dependency) | |
976 | # therefore we 'temporary' make the key not expired and restore a backup after signing | |
977 | cp ${REXKEY}.sec $SECEXPIREBAK | |
978 | cp ${REXKEY}.pub $PUBEXPIREBAK | |
979 | local SECUNEXPIRED="${REXKEY}.sec.unexpired" | |
980 | local PUBUNEXPIRED="${REXKEY}.pub.unexpired" | |
981 | if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then | |
982 | cp $SECUNEXPIRED ${REXKEY}.sec | |
983 | cp $PUBUNEXPIRED ${REXKEY}.pub | |
984 | else | |
f1e1abd8 DK |
985 | if ! printf "expire\n1w\nsave\n" | $GPG --default-key "$SIGNER" --command-fd 0 --edit-key "${SIGNER}" >setexpire.gpg 2>&1; then |
986 | cat setexpire.gpg | |
987 | exit 1 | |
988 | fi | |
29a59c46 DK |
989 | cp ${REXKEY}.sec $SECUNEXPIRED |
990 | cp ${REXKEY}.pub $PUBUNEXPIRED | |
991 | fi | |
992 | fi | |
07cb47e7 | 993 | for RELEASE in $(find ${REPODIR}/ -name Release); do |
29a59c46 | 994 | $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg ${RELEASE} |
e3c62328 | 995 | local INRELEASE="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')" |
29a59c46 | 996 | $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE |
e3c62328 DK |
997 | # we might have set a specific date for the Release file, so copy it |
998 | touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg ${INRELEASE} | |
f213b6ea | 999 | done |
29a59c46 DK |
1000 | if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then |
1001 | mv -f $SECEXPIREBAK ${REXKEY}.sec | |
1002 | mv -f $PUBEXPIREBAK ${REXKEY}.pub | |
1003 | fi | |
f213b6ea DK |
1004 | msgdone "info" |
1005 | } | |
1006 | ||
f2c0ec8b | 1007 | webserverconfig() { |
ba6b79bd | 1008 | local WEBSERVER="${3:-http://localhost:8080}" |
b0314abb DK |
1009 | local NOCHECK=false |
1010 | if [ "$1" = '--no-check' ]; then | |
1011 | NOCHECK=true | |
1012 | shift | |
1013 | fi | |
0d58c26a | 1014 | local DOWNLOG='rootdir/tmp/download-testfile.log' |
b0314abb | 1015 | local STATUS='downloaded/webserverconfig.status' |
0d58c26a | 1016 | rm -f "$STATUS" "$DOWNLOG" |
b0314abb DK |
1017 | local URI |
1018 | if [ -n "$2" ]; then | |
1019 | msgtest "Set webserver config option '${1}' to" "$2" | |
ba6b79bd | 1020 | URI="${WEBSERVER}/_config/set/${1}/${2}" |
b0314abb DK |
1021 | else |
1022 | msgtest 'Clear webserver config option' "${1}" | |
ba6b79bd | 1023 | URI="${WEBSERVER}/_config/clear/${1}" |
b0314abb DK |
1024 | fi |
1025 | if downloadfile "$URI" "$STATUS" > "$DOWNLOG"; then | |
f2c0ec8b DK |
1026 | msgpass |
1027 | else | |
b0314abb | 1028 | cat "$DOWNLOG" "$STATUS" || true |
0d58c26a | 1029 | msgfail |
f2c0ec8b | 1030 | fi |
b0314abb | 1031 | $NOCHECK || testwebserverlaststatuscode '200' |
f2c0ec8b DK |
1032 | } |
1033 | ||
fd46d305 DK |
1034 | rewritesourceslist() { |
1035 | local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")" | |
1036 | for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do | |
b0314abb | 1037 | sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#https://localhost:4433/#${1}#" |
fd46d305 DK |
1038 | done |
1039 | } | |
1040 | ||
5572f6bd MV |
1041 | # wait for up to 10s for a pid file to appear to avoid possible race |
1042 | # when a helper is started and dosn't write the PID quick enough | |
1043 | waitforpidfile() { | |
1044 | local PIDFILE="$1" | |
1045 | for i in $(seq 10); do | |
1046 | if test -s "$PIDFILE"; then | |
1047 | return 0 | |
1048 | fi | |
1049 | sleep 1 | |
1050 | done | |
1051 | msgdie "waiting for $PIDFILE failed" | |
1052 | return 1 | |
1053 | } | |
1054 | ||
f213b6ea | 1055 | changetowebserver() { |
23af9f40 DK |
1056 | if [ "$1" != '--no-rewrite' ]; then |
1057 | rewritesourceslist 'http://localhost:8080/' | |
1058 | else | |
1059 | shift | |
1060 | fi | |
5c0dd6fc | 1061 | if test -x ${APTWEBSERVERBINDIR}/aptwebserver; then |
fbd29dd6 | 1062 | cd aptarchive |
a0db467c DK |
1063 | local LOG="webserver.log" |
1064 | if ! aptwebserver -o aptwebserver::fork=1 "$@" >$LOG 2>&1 ; then | |
bee0670b DK |
1065 | cat $LOG |
1066 | false | |
1067 | fi | |
5572f6bd | 1068 | waitforpidfile aptwebserver.pid |
e3c62328 DK |
1069 | local PID="$(cat aptwebserver.pid)" |
1070 | if [ -z "$PID" ]; then | |
1071 | msgdie 'Could not fork aptwebserver successfully' | |
1072 | fi | |
1073 | addtrap "kill $PID;" | |
fbd29dd6 | 1074 | cd - > /dev/null |
c5bcc607 | 1075 | else |
fbd29dd6 | 1076 | msgdie 'You have to build aptwerbserver or install a webserver' |
f213b6ea | 1077 | fi |
fd46d305 DK |
1078 | } |
1079 | ||
1080 | changetohttpswebserver() { | |
1081 | if ! which stunnel4 >/dev/null; then | |
1082 | msgdie 'You need to install stunnel4 for https testcases' | |
1083 | fi | |
1084 | if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then | |
dc95fee1 | 1085 | changetowebserver --no-rewrite "$@" |
fd46d305 DK |
1086 | fi |
1087 | echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid | |
68ba0b7f | 1088 | cert = ${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem |
23af9f40 | 1089 | output = /dev/null |
fd46d305 DK |
1090 | |
1091 | [https] | |
1092 | accept = 4433 | |
1093 | connect = 8080 | |
1094 | " > ${TMPWORKINGDIRECTORY}/stunnel.conf | |
1095 | stunnel4 "${TMPWORKINGDIRECTORY}/stunnel.conf" | |
5572f6bd | 1096 | waitforpidfile "${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid" |
fd46d305 | 1097 | local PID="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)" |
5572f6bd MV |
1098 | if [ -z "$PID" ]; then |
1099 | msgdie 'Could not fork stunnel4 successfully' | |
1100 | fi | |
fd46d305 DK |
1101 | addtrap 'prefix' "kill ${PID};" |
1102 | rewritesourceslist 'https://localhost:4433/' | |
f213b6ea DK |
1103 | } |
1104 | ||
c45233ea DK |
1105 | changetocdrom() { |
1106 | mkdir -p rootdir/media/cdrom/.disk | |
1107 | local CD="$(readlink -f rootdir/media/cdrom)" | |
a0975c8d DK |
1108 | echo "acquire::cdrom::mount \"${CD}\"; |
1109 | acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\"; | |
1110 | acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\"; | |
1111 | acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom | |
c45233ea DK |
1112 | echo -n "$1" > ${CD}/.disk/info |
1113 | if [ ! -d aptarchive/dists ]; then | |
1114 | msgdie 'Flat file archive cdroms can not be created currently' | |
1115 | return 1 | |
1116 | fi | |
a0975c8d | 1117 | mv aptarchive/dists "$CD" |
c45233ea DK |
1118 | ln -s "$(readlink -f ./incoming)" $CD/pool |
1119 | find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list' -delete | |
a0975c8d DK |
1120 | # start with an unmounted disk |
1121 | mv "${CD}" "${CD}-unmounted" | |
1122 | # we don't want the disk to be modifiable | |
1123 | addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;" | |
b0314abb | 1124 | chmod -R 555 rootdir/media/cdrom-unmounted/dists |
c45233ea DK |
1125 | } |
1126 | ||
fd46d305 | 1127 | downloadfile() { |
ed793a19 | 1128 | local PROTO="${1%%:*}" |
27925d82 DK |
1129 | if ! apthelper -o Debug::Acquire::${PROTO}=1 -o Debug::pkgAcquire::Worker=1 \ |
1130 | download-file "$1" "$2" 2>&1 ; then | |
1131 | return 1 | |
1132 | fi | |
fd46d305 | 1133 | # only if the file exists the download was successful |
b0314abb | 1134 | if [ -r "$2" ]; then |
fd46d305 DK |
1135 | return 0 |
1136 | else | |
1137 | return 1 | |
1138 | fi | |
1139 | } | |
1140 | ||
f213b6ea | 1141 | checkdiff() { |
03aa0847 | 1142 | local DIFFTEXT="$(command diff -u "$@" 2>&1 | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')" |
8d876415 | 1143 | if [ -n "$DIFFTEXT" ]; then |
0d58c26a DK |
1144 | echo >&2 |
1145 | echo >&2 "$DIFFTEXT" | |
8d876415 DK |
1146 | return 1 |
1147 | else | |
1148 | return 0 | |
1149 | fi | |
1150 | } | |
1151 | ||
75954ae2 DK |
1152 | testfileequal() { |
1153 | local FILE="$1" | |
1154 | shift | |
1155 | msgtest "Test for correctness of file" "$FILE" | |
1156 | if [ -z "$*" ]; then | |
f213b6ea | 1157 | echo -n "" | checkdiff $FILE - && msgpass || msgfail |
75954ae2 | 1158 | else |
f213b6ea | 1159 | echo "$*" | checkdiff $FILE - && msgpass || msgfail |
75954ae2 DK |
1160 | fi |
1161 | } | |
1162 | ||
b855a400 DK |
1163 | testempty() { |
1164 | msgtest "Test for no output of" "$*" | |
859093da | 1165 | local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile" |
ab25bf1f | 1166 | if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then |
859093da DK |
1167 | msgpass |
1168 | else | |
061ee5f0 | 1169 | echo |
859093da DK |
1170 | cat $COMPAREFILE |
1171 | msgfail | |
1172 | fi | |
ab25bf1f | 1173 | aptautotest 'testempty' "$@" |
b855a400 DK |
1174 | } |
1175 | ||
f74a6fa1 DK |
1176 | testequal() { |
1177 | local MSG='Test of equality of' | |
1178 | if [ "$1" = '--nomsg' ]; then | |
1179 | MSG='' | |
1180 | shift | |
1181 | fi | |
1182 | ||
03938280 | 1183 | local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile" |
8d876415 DK |
1184 | echo "$1" > $COMPAREFILE |
1185 | shift | |
d2d68aaf | 1186 | |
f74a6fa1 DK |
1187 | if [ -n "$MSG" ]; then |
1188 | msgtest "$MSG" "$*" | |
1189 | fi | |
ab25bf1f DK |
1190 | "$@" 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail |
1191 | aptautotest 'testequal' "$@" | |
8d876415 DK |
1192 | } |
1193 | ||
685625bd | 1194 | testequalor2() { |
03938280 DK |
1195 | local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1" |
1196 | local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2" | |
1197 | local COMPAREAGAINST="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst" | |
685625bd DK |
1198 | echo "$1" > $COMPAREFILE1 |
1199 | echo "$2" > $COMPAREFILE2 | |
1200 | shift 2 | |
1201 | msgtest "Test for equality OR of" "$*" | |
ab25bf1f | 1202 | "$@" >$COMPAREAGAINST 2>&1 || true |
0d58c26a DK |
1203 | if checkdiff $COMPAREFILE1 $COMPAREAGAINST >/dev/null 2>&1 || \ |
1204 | checkdiff $COMPAREFILE2 $COMPAREAGAINST >/dev/null 2>&1 | |
1205 | then | |
0caa5a4c DK |
1206 | msgpass |
1207 | else | |
1208 | echo -n "\n${CINFO}Diff against OR 1${CNORMAL}" | |
1209 | checkdiff $COMPAREFILE1 $COMPAREAGAINST || true | |
1210 | echo -n "${CINFO}Diff against OR 2${CNORMAL}" | |
1211 | checkdiff $COMPAREFILE2 $COMPAREAGAINST || true | |
1212 | msgfail | |
1213 | fi | |
ab25bf1f | 1214 | aptautotest 'testequalor2' "$@" |
685625bd DK |
1215 | } |
1216 | ||
8d876415 | 1217 | testshowvirtual() { |
edc0ef10 | 1218 | local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual" |
8d876415 DK |
1219 | local PACKAGE="$1" |
1220 | shift | |
1221 | while [ -n "$1" ]; do | |
1222 | VIRTUAL="${VIRTUAL} | |
edc0ef10 | 1223 | N: Can't select versions from package '$1' as it is purely virtual" |
8d876415 DK |
1224 | PACKAGE="${PACKAGE} $1" |
1225 | shift | |
1226 | done | |
1227 | msgtest "Test for virtual packages" "apt-cache show $PACKAGE" | |
1228 | VIRTUAL="${VIRTUAL} | |
4bec02c2 | 1229 | N: No packages found" |
03938280 | 1230 | local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile" |
ea65d079 | 1231 | local ARCH="$(getarchitecture 'native')" |
8d876415 | 1232 | echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE |
e8379ba3 | 1233 | aptcache show -q=0 $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail |
8d876415 DK |
1234 | } |
1235 | ||
1236 | testnopackage() { | |
1237 | msgtest "Test for non-existent packages" "apt-cache show $*" | |
846856f4 | 1238 | local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')" |
8d876415 | 1239 | if [ -n "$SHOWPKG" ]; then |
0d58c26a DK |
1240 | echo >&2 |
1241 | echo >&2 "$SHOWPKG" | |
8d876415 | 1242 | msgfail |
0d58c26a DK |
1243 | else |
1244 | msgpass | |
8d876415 | 1245 | fi |
8d876415 | 1246 | } |
01a6e24c | 1247 | |
ecb777dd DK |
1248 | testdpkgstatus() { |
1249 | local STATE="$1" | |
1250 | local NR="$2" | |
1251 | shift 2 | |
1252 | msgtest "Test that $NR package(s) are in state $STATE with" "dpkg -l $*" | |
1253 | local PKGS="$(dpkg -l "$@" 2>/dev/null | grep "^${STATE}" | wc -l)" | |
1254 | if [ "$PKGS" != $NR ]; then | |
0d58c26a DK |
1255 | echo >&2 $PKGS |
1256 | dpkg -l "$@" | grep '^[a-z]' >&2 | |
01a6e24c | 1257 | msgfail |
0d58c26a DK |
1258 | else |
1259 | msgpass | |
01a6e24c | 1260 | fi |
01a6e24c DK |
1261 | } |
1262 | ||
ecb777dd DK |
1263 | testdpkginstalled() { |
1264 | testdpkgstatus 'ii' "$#" "$@" | |
1265 | } | |
1266 | ||
5cf733e1 | 1267 | testdpkgnotinstalled() { |
ecb777dd | 1268 | testdpkgstatus 'ii' '0' "$@" |
01a6e24c | 1269 | } |
ec7f904e DK |
1270 | |
1271 | testmarkedauto() { | |
03938280 | 1272 | local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile" |
ec7f904e DK |
1273 | if [ -n "$1" ]; then |
1274 | msgtest 'Test for correctly marked as auto-installed' "$*" | |
1275 | while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE | |
1276 | else | |
1277 | msgtest 'Test for correctly marked as auto-installed' 'no package' | |
c98fb5e0 | 1278 | echo -n > $COMPAREFILE |
ec7f904e DK |
1279 | fi |
1280 | aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail | |
1281 | } | |
89a1aa5d | 1282 | |
e52aad52 DK |
1283 | msgfailoutput() { |
1284 | local MSG="$1" | |
1285 | local OUTPUT="$2" | |
1286 | shift 2 | |
1287 | echo >&2 | |
1288 | if [ "$1" = 'grep' ]; then | |
1289 | while [ -n "$2" ]; do shift; done | |
1290 | echo "#### Complete file: $1 ####" | |
1291 | cat >&2 "$1" || true | |
1292 | echo '#### grep output ####' | |
1293 | elif [ "$1" = 'test' ]; then | |
1294 | # doesn't support ! or non-file flags | |
1295 | msgfailoutputstatfile() { | |
1296 | local FILEFLAGS='^-[bcdefgGhkLOprsStuwx]$' | |
1297 | if expr match "$1" "$FILEFLAGS" >/dev/null; then | |
1298 | echo "#### stat(2) of file: $2 ####" | |
1299 | stat "$2" || true | |
1300 | fi | |
1301 | } | |
1302 | msgfailoutputstatfile "$2" "$3" | |
1303 | while [ -n "$5" ] && [ "$4" = '-o' -o "$4" = '-a' ]; do | |
1304 | shift 3 | |
1305 | msgfailoutputstatfile "$2" "$3" | |
1306 | done | |
1307 | echo '#### test output ####' | |
1308 | fi | |
1309 | cat >&2 $OUTPUT | |
1310 | msgfail "$MSG" | |
1311 | } | |
1312 | ||
0440d936 DK |
1313 | testsuccess() { |
1314 | if [ "$1" = '--nomsg' ]; then | |
1315 | shift | |
1316 | else | |
1317 | msgtest 'Test for successful execution of' "$*" | |
1318 | fi | |
03938280 | 1319 | local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" |
4fa34122 DK |
1320 | if "$@" >${OUTPUT} 2>&1; then |
1321 | if expr match "$1" '^apt.*' >/dev/null; then | |
e52aad52 DK |
1322 | if grep -q -E ' runtime error: ' "$OUTPUT"; then |
1323 | msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@" | |
1324 | elif grep -q -E '^[WE]: ' "$OUTPUT"; then | |
1325 | msgfailoutput 'successful run, but output contains warnings/errors' "$OUTPUT" "$@" | |
4fa34122 DK |
1326 | else |
1327 | msgpass | |
1328 | fi | |
1329 | else | |
1330 | msgpass | |
1331 | fi | |
1332 | else | |
1333 | local EXITCODE=$? | |
e52aad52 | 1334 | msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@" |
4fa34122 DK |
1335 | fi |
1336 | aptautotest 'testsuccess' "$@" | |
1337 | } | |
1338 | testwarning() { | |
1339 | if [ "$1" = '--nomsg' ]; then | |
1340 | shift | |
1341 | else | |
1342 | msgtest 'Test for successful execution with warnings of' "$*" | |
1343 | fi | |
25b86db1 | 1344 | local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" |
1df24acf DK |
1345 | if "$@" >${OUTPUT} 2>&1; then |
1346 | if expr match "$1" '^apt.*' >/dev/null; then | |
e52aad52 DK |
1347 | if grep -q -E ' runtime error: ' "$OUTPUT"; then |
1348 | msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@" | |
1349 | elif grep -q -E '^E: ' "$OUTPUT"; then | |
1350 | msgfailoutput 'successful run, but output contains errors' "$OUTPUT" "$@" | |
4fa34122 | 1351 | elif ! grep -q -E '^W: ' "$OUTPUT"; then |
e52aad52 | 1352 | msgfailoutput 'successful run, but output contains no warnings' "$OUTPUT" "$@" |
1df24acf DK |
1353 | else |
1354 | msgpass | |
1355 | fi | |
1356 | else | |
1357 | msgpass | |
1358 | fi | |
0440d936 | 1359 | else |
07cb47e7 | 1360 | local EXITCODE=$? |
0d58c26a DK |
1361 | echo >&2 |
1362 | cat >&2 $OUTPUT | |
07cb47e7 | 1363 | msgfail "exitcode $EXITCODE" |
0440d936 | 1364 | fi |
4fa34122 | 1365 | aptautotest 'testwarning' "$@" |
0440d936 | 1366 | } |
0440d936 DK |
1367 | testfailure() { |
1368 | if [ "$1" = '--nomsg' ]; then | |
1369 | shift | |
1370 | else | |
889b0072 | 1371 | msgtest 'Test for failure in execution of' "$*" |
0440d936 | 1372 | fi |
03938280 | 1373 | local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" |
1df24acf | 1374 | if "$@" >${OUTPUT} 2>&1; then |
07cb47e7 | 1375 | local EXITCODE=$? |
e52aad52 | 1376 | msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@" |
0440d936 | 1377 | else |
1df24acf DK |
1378 | local EXITCODE=$? |
1379 | if expr match "$1" '^apt.*' >/dev/null; then | |
e52aad52 DK |
1380 | if grep -q -E ' runtime error: ' "$OUTPUT"; then |
1381 | msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@" | |
1382 | elif ! grep -q -E '^E: ' "$OUTPUT"; then | |
1383 | msgfailoutput "run failed with exitcode ${EXITCODE}, but with no errors" "$OUTPUT" "$@" | |
1df24acf DK |
1384 | else |
1385 | msgpass | |
1386 | fi | |
1387 | else | |
1388 | msgpass | |
1389 | fi | |
0440d936 | 1390 | fi |
ab25bf1f | 1391 | aptautotest 'testfailure' "$@" |
0440d936 DK |
1392 | } |
1393 | ||
25b86db1 DK |
1394 | testsuccessequal() { |
1395 | local CMP="$1" | |
1396 | shift | |
1397 | testsuccess "$@" | |
1398 | testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" "$CMP" | |
1399 | } | |
1400 | testwarningequal() { | |
1401 | local CMP="$1" | |
1402 | shift | |
1403 | testwarning "$@" | |
1404 | testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" "$CMP" | |
1405 | } | |
1406 | testfailureequal() { | |
1407 | local CMP="$1" | |
1408 | shift | |
1409 | testfailure "$@" | |
1410 | testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" "$CMP" | |
1411 | } | |
1412 | ||
27925d82 DK |
1413 | testfailuremsg() { |
1414 | local CMP="$1" | |
1415 | shift | |
1416 | testfailure "$@" | |
1417 | msgtest 'Check that the output of the previous failed command has expected' 'failures and warnings' | |
1418 | grep '^\(W\|E\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailureequal.output" 2>&1 || true | |
1419 | if echo "$CMP" | checkdiff - "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailureequal.output"; then | |
1420 | msgpass | |
1421 | else | |
1422 | echo '### Complete output ###' | |
1423 | cat "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" | |
1424 | msgfail | |
1425 | fi | |
1426 | } | |
25b86db1 | 1427 | |
de81b2e2 DK |
1428 | testfilestats() { |
1429 | msgtest "Test that file $1 has $2 $3" "$4" | |
1430 | if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then | |
5684f71f DK |
1431 | msgpass |
1432 | else | |
1433 | echo >&2 | |
8fe964f1 | 1434 | ls -ld >&2 "$1" |
de81b2e2 DK |
1435 | echo -n >&2 "stat(1) reports for $2: " |
1436 | stat --format "$2" "$1" | |
5684f71f DK |
1437 | msgfail |
1438 | fi | |
1439 | } | |
de81b2e2 DK |
1440 | testaccessrights() { |
1441 | testfilestats "$1" '%a' '=' "$2" | |
1442 | } | |
5684f71f | 1443 | |
0d58c26a DK |
1444 | testwebserverlaststatuscode() { |
1445 | local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log' | |
03aa0847 | 1446 | local STATUS='downloaded/webserverstatus-statusfile.log' |
0d58c26a DK |
1447 | rm -f "$DOWNLOG" "$STATUS" |
1448 | msgtest 'Test last status code from the webserver was' "$1" | |
b0314abb | 1449 | if downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" && [ "$(cat "$STATUS")" = "$1" ]; then |
0d58c26a DK |
1450 | msgpass |
1451 | else | |
1452 | echo >&2 | |
1453 | if [ -n "$2" ]; then | |
1454 | shift | |
1455 | echo >&2 '#### Additionally provided output files contain:' | |
1456 | cat >&2 "$@" | |
1457 | fi | |
1458 | echo >&2 '#### Download log of the status code:' | |
1459 | cat >&2 "$DOWNLOG" | |
1460 | msgfail "Status was $(cat "$STATUS")" | |
1461 | fi | |
1462 | } | |
1463 | ||
89a1aa5d DK |
1464 | pause() { |
1465 | echo "STOPPED execution. Press enter to continue" | |
1466 | local IGNORE | |
1467 | read IGNORE | |
1468 | } | |
ab25bf1f | 1469 | |
846bc058 | 1470 | listcurrentlistsdirectory() { |
ba6b79bd DK |
1471 | { |
1472 | find rootdir/var/lib/apt/lists -maxdepth 1 -type d | while read line; do | |
1473 | stat --format '%U:%G:%a:%n' "$line" | |
1474 | done | |
1475 | find rootdir/var/lib/apt/lists -maxdepth 1 \! -type d | while read line; do | |
1476 | stat --format '%U:%G:%a:%s:%y:%n' "$line" | |
1477 | done | |
1478 | } | sort | |
846bc058 DK |
1479 | } |
1480 | ||
8fe964f1 DK |
1481 | ### convinience hacks ### |
1482 | mkdir() { | |
1483 | # creating some directories by hand is a tedious task, so make it look simple | |
1484 | if [ "$*" = '-p rootdir/var/lib/apt/lists' ] || [ "$*" = "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" ] || | |
1485 | [ "$*" = '-p rootdir/var/lib/apt/lists/partial' ] || [ "$*" = "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" ]; then | |
1486 | # only the last directory created by mkdir is effected by the -m ! | |
1487 | command mkdir -m 755 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt" | |
1488 | command mkdir -m 755 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" | |
1489 | command mkdir -m 700 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" | |
1490 | touch "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/lock" | |
1491 | if [ "$(id -u)" = '0' ]; then | |
1492 | chown _apt:root "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" | |
1493 | fi | |
1494 | else | |
1495 | command mkdir "$@" | |
1496 | fi | |
1497 | } | |
1498 | ||
ab25bf1f DK |
1499 | ### The following tests are run by most test methods automatically to check |
1500 | ### general things about commands executed without writing the test every time. | |
1501 | ||
1502 | aptautotest() { | |
1503 | local TESTCALL="$1" | |
1504 | local CMD="$2" | |
1505 | local FIRSTOPT="$3" | |
1506 | local AUTOTEST="aptautotest_$(basename "$CMD" | tr -d '-')_$(echo "$FIRSTOPT" | tr -d '-')" | |
1507 | if command -v $AUTOTEST >/dev/null; then | |
1508 | shift 3 | |
1509 | # save and restore the *.output files from other tests | |
1510 | # as we might otherwise override them in these automatic tests | |
03aa0847 DK |
1511 | rm -rf ${TMPWORKINGDIRECTORY}/rootdir/tmp-before |
1512 | mv ${TMPWORKINGDIRECTORY}/rootdir/tmp ${TMPWORKINGDIRECTORY}/rootdir/tmp-before | |
1513 | mkdir ${TMPWORKINGDIRECTORY}/rootdir/tmp | |
ab25bf1f | 1514 | $AUTOTEST "$TESTCALL" "$@" |
03aa0847 DK |
1515 | rm -rf ${TMPWORKINGDIRECTORY}/rootdir/tmp-aptautotest |
1516 | mv ${TMPWORKINGDIRECTORY}/rootdir/tmp ${TMPWORKINGDIRECTORY}/rootdir/tmp-aptautotest | |
1517 | mv ${TMPWORKINGDIRECTORY}/rootdir/tmp-before ${TMPWORKINGDIRECTORY}/rootdir/tmp | |
ab25bf1f DK |
1518 | fi |
1519 | } | |
1520 | ||
1521 | aptautotest_aptget_update() { | |
1522 | if ! test -d "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"; then return; fi | |
4bb006d1 DK |
1523 | testfilestats "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:755" |
1524 | testfilestats "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:755" | |
ab25bf1f | 1525 | # all copied files are properly chmodded |
546dbfc8 | 1526 | for file in $(find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" -maxdepth 1 -type f ! -name 'lock'); do |
4bb006d1 | 1527 | testfilestats "$file" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644" |
ab25bf1f DK |
1528 | done |
1529 | } | |
1530 | aptautotest_apt_update() { aptautotest_aptget_update "$@"; } | |
d84da499 | 1531 | aptautotest_aptcdrom_add() { aptautotest_aptget_update "$@"; } |
016bea82 DK |
1532 | |
1533 | testaptautotestnodpkgwarning() { | |
1534 | local TESTCALL="$1" | |
1535 | while [ -n "$2" ]; do | |
25b86db1 | 1536 | if expr match "$2" '^-[a-z]*s' >/dev/null 2>&1; then return; fi |
016bea82 DK |
1537 | shift |
1538 | done | |
1539 | testfailure grep '^dpkg: warning:.*ignor.*' "${TMPWORKINGDIRECTORY}/rootdir/tmp-before/${TESTCALL}.output" | |
1540 | } | |
1541 | ||
1542 | aptautotest_aptget_install() { testaptautotestnodpkgwarning "$@"; } | |
1543 | aptautotest_aptget_remove() { testaptautotestnodpkgwarning "$@"; } | |
1544 | aptautotest_aptget_purge() { testaptautotestnodpkgwarning "$@"; } | |
1545 | aptautotest_apt_install() { testaptautotestnodpkgwarning "$@"; } | |
1546 | aptautotest_apt_remove() { testaptautotestnodpkgwarning "$@"; } | |
1547 | aptautotest_apt_purge() { testaptautotestnodpkgwarning "$@"; } |