1 #!/bin/sh -- # no runable script, just for vi
6 if [ "$1" = "-q" ]; then
8 elif [ "$1" = "-v" ]; then
10 elif [ "$1" = '--color=no' ]; then
13 echo >&2 "WARNING: Unknown parameter »$1« will be ignored"
17 export MSGLEVEL
="${MSGLEVEL:-3}"
19 # we all like colorful messages
20 if [ "$MSGCOLOR" != 'NO' ] && [ "$MSGCOLOR" != 'ALWAYS' ]; then
21 if [ ! -t 1 ]; then # but check that we output to a terminal
27 if [ "$MSGCOLOR" != 'NO' ]; then
28 CERROR
="\033[1;31m" # red
29 CWARNING
="\033[1;33m" # yellow
30 CMSG
="\033[1;32m" # green
31 CINFO
="\033[1;96m" # light blue
32 CDEBUG
="\033[1;94m" # blue
33 CNORMAL
="\033[0;39m" # default system console color
34 CDONE
="\033[1;32m" # green
35 CPASS
="\033[1;32m" # green
36 CFAIL
="\033[1;31m" # red
37 CCMD
="\033[1;35m" # pink
49 printf "$MIDDLE " "$(echo "$1" | sed -e 's#^apt\([cfghs]\)#apt-\1#')"
55 msgdie
() { msgprintf
"${CERROR}E: %s" '%s' "${CNORMAL}\n" "$@" >&2; exit 1; }
56 msgwarn
() { msgprintf
"${CWARNING}W: %s" '%s' "${CNORMAL}\n" "$@" >&2; }
57 msgmsg
() { msgprintf
"${CMSG}%s" '%s' "${CNORMAL}\n" "$@"; }
58 msginfo
() { msgprintf
"${CINFO}I: %s" '%s' "${CNORMAL}\n" "$@"; }
59 msgdebug
() { msgprintf
"${CDEBUG}D: %s" '%s' "${CNORMAL}\n" "$@"; }
60 msgdone
() { msgprintf
"${CDONE}DONE" '%s' "${CNORMAL}\n" "$@"; }
61 msgnwarn
() { msgprintf
"${CWARNING}W: %s" '%s' "${CNORMAL}" "$@" >&2; }
62 msgnmsg
() { msgprintf
"${CMSG}%s" '%s' "${CNORMAL}" "$@"; }
63 msgninfo
() { msgprintf
"${CINFO}I: %s" '%s' "${CNORMAL}" "$@"; }
64 msgndebug
() { msgprintf
"${CDEBUG}D: %s" '%s' "${CNORMAL}" "$@"; }
65 msgtest
() { msgprintf
"${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@"; }
66 msgpass
() { printf "${CPASS}PASS${CNORMAL}\n"; }
68 if [ -n "$MSGTEST_MSG" ]; then
69 test "$1" != 'msgfailoutput' || echo
70 if [ -n "$MSGTEST_MSGMSG" ]; then
71 echo "$MSGTEST_MSGMSG"
73 if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
74 echo "${CFAIL}Part of the test group: $MSGTEST_GRP"
76 echo -n "$MSGTEST_MSG"
81 msgreportheader
'msgskip'
82 if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2;
83 else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi
86 msgreportheader
'msgfail'
87 if [ $# -gt 0 ] && [ -n "$1" ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
88 else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
89 if [ -n "$APT_DEBUG_TESTS" ]; then
92 EXIT_CODE
=$((EXIT_CODE+1));
97 if [ $MSGGROUP_LEVEL = 0 ]; then
100 MSGGROUP_LEVEL
=$((MSGGROUP_LEVEL+1));
102 MSGGROUP_LEVEL
=$((MSGGROUP_LEVEL-1));
103 if [ $MSGGROUP_LEVEL = 0 ]; then
109 # enable / disable Debugging
110 if [ $MSGLEVEL -le 0 ]; then
113 if [ $MSGLEVEL -le 1 ]; then
117 if [ $MSGLEVEL -le 2 ]; then
119 MSGTEST_MSGMSG
="$(msgprintf "${CMSG}%s" '%s' "${CNORMAL}" "$@")"
123 MSGTEST_MSG
="$(msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@")"
124 if [ "$MSGTEST_GRP" = 'NEXT' ]; then
125 MSGTEST_GRP
="$MSGTEST_MSG"
128 msgpass
() { printf " ${CPASS}P${CNORMAL}"; }
130 if [ $MSGLEVEL -le 3 ]; then
134 if [ $MSGLEVEL -le 4 ]; then
136 msgndebug
() { true
; }
139 if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
140 [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
141 [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
142 [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
143 [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
146 printf "${CDONE}DONE${CNORMAL}\n";
150 if [ -f .
/aptconfig.conf
]; then
151 echo "$(readlink -f ./aptconfig.conf)"
152 elif [ -f ..
/aptconfig.conf
]; then
153 echo "$(readlink -f ../aptconfig.conf)"
154 elif [ -f ..
/..
/aptconfig.conf
]; then
155 echo "$(readlink -f ../../aptconfig.conf)"
156 elif [ -f "${TMPWORKINGDIRECTORY}/aptconfig.conf" ]; then
157 echo "$(readlink -f "${TMPWORKINGDIRECTORY}/aptconfig.conf")"
161 msgdebug
"Executing: ${CCMD}$*${CDEBUG} "
165 sh
|aptitude
|*/*|command) ;;
166 *) CMD
="${BUILDDIRECTORY}/$CMD";;
168 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 APT_CONFIG
="$(getaptconfig)" LD_LIBRARY_PATH
=${LIBRARYPATH} $CMD "$@"
170 aptconfig
() { runapt apt
-config "$@"; }
171 aptcache
() { runapt apt
-cache "$@"; }
172 aptcdrom
() { runapt apt
-cdrom "$@"; }
173 aptget
() { runapt apt
-get "$@"; }
174 aptftparchive
() { runapt apt
-ftparchive "$@"; }
175 aptkey
() { runapt apt
-key "$@"; }
176 aptmark
() { runapt apt
-mark "$@"; }
177 aptsortpkgs
() { runapt apt
-sortpkgs "$@"; }
178 apt
() { runapt apt
"$@"; }
179 apthelper
() { runapt
"${APTHELPERBINDIR}/apt-helper" "$@"; }
180 aptwebserver
() { runapt
"${APTWEBSERVERBINDIR}/aptwebserver" "$@"; }
181 aptitude
() { runapt aptitude
"$@"; }
182 aptextracttemplates
() { runapt apt
-extracttemplates "$@"; }
183 aptinternalsolver
() { runapt
"${APTINTERNALSOLVER}" "$@"; }
184 aptdumpsolver
() { runapt
"${APTDUMPSOLVER}" "$@"; }
187 "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "$@"
189 dpkgcheckbuilddeps
() {
190 command dpkg
-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir
/var
/lib
/dpkg
"$@"
195 aptget
) CMD
="apt-get";;
196 aptcache
) CMD
="apt-cache";;
197 aptcdrom
) CMD
="apt-cdrom";;
198 aptconfig
) CMD
="apt-config";;
199 aptmark
) CMD
="apt-mark";;
200 apthelper
) CMD
="apt-helper";;
201 aptftparchive
) CMD
="apt-ftparchive";;
205 runapt
command gdb
--quiet -ex run
"${BUILDDIRECTORY}/$CMD" --args "${BUILDDIRECTORY}/$CMD" "$@"
209 # error if we about to overflow, but ...
210 # "255 failures ought to be enough for everybody"
211 if [ $EXIT_CODE -gt 255 ]; then
212 msgdie
"Total failure count $EXIT_CODE too big"
214 exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
217 shellsetedetector
() {
219 if [ "$exit_status" != '0' ]; then
220 printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n"
221 if [ "$EXIT_CODE" = '0' ]; then
222 EXIT_CODE
="$exit_status"
228 if [ "$1" = 'prefix' ]; then
229 CURRENTTRAP
="$2 $CURRENTTRAP"
231 CURRENTTRAP
="$CURRENTTRAP $1"
233 trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
237 # privilege dropping and testing doesn't work if /tmp isn't world-writeable (as e.g. with libpam-tmpdir)
238 if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$(stat --format '%a' "$TMPDIR")" != '1777' ]; then
241 TMPWORKINGDIRECTORY
=$(mktemp -d)
242 addtrap
"cd /; rm -rf $TMPWORKINGDIRECTORY;"
243 msgninfo
"Preparing environment for $(basename $0) in ${TMPWORKINGDIRECTORY}…"
245 mkdir -m 700 "${TMPWORKINGDIRECTORY}/downloaded"
246 if [ "$(id -u)" = '0' ]; then
247 # relax permissions so that running as root with user switching works
249 chmod 711 "$TMPWORKINGDIRECTORY"
250 chown _apt
:root
"${TMPWORKINGDIRECTORY}/downloaded"
253 TESTDIRECTORY
=$(readlink -f $(dirname $0))
254 # allow overriding the default BUILDDIR location
255 SOURCEDIRECTORY
=${APT_INTEGRATION_TESTS_SOURCE_DIR:-"${TESTDIRECTORY}/../../"}
256 BUILDDIRECTORY
=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
257 LIBRARYPATH
=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
258 METHODSDIR
=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
259 APTHELPERBINDIR
=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
260 APTWEBSERVERBINDIR
=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
261 APTINTERNALSOLVER
=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"}
262 APTDUMPSOLVER
=${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${BUILDDIRECTORY}/apt-dump-solver"}
263 test -x "${BUILDDIRECTORY}/apt-get" || msgdie
"You need to build tree first"
266 cd $TMPWORKINGDIRECTORY
267 mkdir rootdir aptarchive keys
269 mkdir -p etc
/apt
/apt.conf.d etc
/apt
/sources.list.d etc
/apt
/trusted.gpg.d etc
/apt
/preferences.d
270 mkdir -p usr
/bin var
/cache var
/lib var
/log tmp
271 mkdir -p var
/lib
/dpkg
/info var
/lib
/dpkg
/updates var
/lib
/dpkg
/triggers
272 touch var
/lib
/dpkg
/available
274 ln -s ${METHODSDIR} usr
/lib
/apt
/methods
275 if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
276 mkdir -p usr
/lib
/apt
/solvers
277 ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr
/lib
/apt
/solvers
/dump
278 ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr
/lib
/apt
/solvers
/apt
279 echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc
/apt
/apt.conf.d
/externalsolver.conf
281 # use the autoremove from the BUILDDIRECTORY if its there, otherwise
283 if [ -e ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove
]; then
284 ln -s ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove etc
/apt
/apt.conf.d
/01autoremove
286 ln -s /etc
/apt
/apt.conf.d
/01autoremove etc
/apt
/apt.conf.d
/01autoremove
289 local PACKAGESFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
290 if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
291 cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
293 local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
294 if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
295 cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive
/Sources
297 cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys
/
298 chmod 644 $(find keys -name '*.pub' -o -name '*.sec')
299 ln -s ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
301 echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
302 echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
303 echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
304 echo "Dir::Bin::Methods \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods\";" >> aptconfig.conf
305 # store apt-key were we can access it, even if we run it as a different user
306 # destroys coverage reporting though, so just do it for root for now
307 if [ "$(id -u)" = '0' ]; then
308 cp "${BUILDDIRECTORY}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/"
309 chmod o
+rx
"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key"
310 echo "Dir::Bin::apt-key \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key\";" >> aptconfig.conf
312 echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
315 cat << EOF > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
318 if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then
319 if [ -n "\$LD_PRELOAD" ]; then
320 export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so \${LD_PRELOAD}"
322 export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so"
325 exec fakeroot dpkg --root="${TMPWORKINGDIRECTORY}/rootdir" \\
326 --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\
327 --force-not-root --force-bad-path "\$@"
329 chmod +x
"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
330 echo "Dir::Bin::dpkg \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg\";" > rootdir
/etc
/apt
/apt.conf.d
/99dpkg
333 if ! command dpkg
--assert-multi-arch >/dev
/null
2>&1; then
334 echo "DPKG::options:: \"--force-architecture\";" # Added to test multiarch before dpkg is ready for it…
336 echo 'quiet::NoUpdate "true";'
337 echo 'quiet::NoStatistic "true";'
338 # too distracting for users, but helpful to detect changes
339 echo 'Acquire::Progress::Ignore::ShowErrorText "true";'
340 echo 'Acquire::Progress::Diffpercent "true";'
341 # in testcases, it can appear as if localhost has a rotation setup,
342 # hide this as we can't really deal with it properly
343 echo 'Acquire::Failure::ShowIP "false";'
346 cp "${TESTDIRECTORY}/apt.pem" "${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
347 if [ "$(id -u)" = '0' ]; then
348 chown _apt
:root
"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
350 echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir
/etc
/apt
/apt.conf.d
/99https
351 echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir
/etc
/apt
/apt.conf.d
/apt
-binary
352 configcompression
'.' 'gz' #'bz2' 'lzma' 'xz'
354 # create some files in /tmp and look at user/group to get what this means
355 TEST_DEFAULT_USER
="$USER"
356 if [ "$(uname)" = 'GNU/kFreeBSD' ]; then
357 TEST_DEFAULT_GROUP
='root'
359 TEST_DEFAULT_GROUP
="$USER"
362 # Acquire::AllowInsecureRepositories=false is not yet the default
363 # but we want it to be the default soon
364 configallowinsecurerepositories
"false";
366 # cleanup the environment a bit
367 # prefer our apt binaries over the system apt binaries
368 export PATH
="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
369 export LC_ALL
=C.UTF
-8
370 unset LANGUAGE APT_CONFIG
371 unset GREP_OPTIONS DEB_BUILD_PROFILES
376 if [ "$1" = "native" -o -z "$1" ]; then
377 eval `aptconfig shell ARCH APT::Architecture`
378 if [ -n "$ARCH" ]; then
381 dpkg
--print-architecture
389 aptconfig dump
--no-empty --format '%v%n' APT
::Architecture APT
::Architectures
| sort -u | tr '\n' ' '
392 getarchitecturesfromcommalist
() {
393 echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
396 configarchitecture
() {
398 echo "APT::Architecture \"$(getarchitecture $1)\";"
399 while [ -n "$1" ]; do
400 echo "APT::Architectures:: \"$(getarchitecture $1)\";"
403 } >rootdir
/etc
/apt
/apt.conf.d
/01multiarch.conf
408 if [ ! -e rootdir
/var
/lib
/dpkg
/status
]; then
409 local STATUSFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
410 if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
411 cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
413 echo -n > rootdir/var/lib/dpkg/status
416 rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
417 if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
418 local ARCHS="$(getarchitectures)"
419 if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
420 DPKGARCH="$(dpkg --print-architecture)"
421 for ARCH in ${ARCHS}; do
422 if [ "${ARCH}" != "${DPKGARCH}" ]; then
423 if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
424 # old-style used e.g. in Ubuntu-P – and as it seems travis
425 echo "DPKG
::options
:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
426 echo "DPKG
::options
:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
430 if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
431 # dpkg doesn't really check the version as long as it is fully installed,
432 # but just to be sure we choose one above the required version
433 insertinstalledpackage 'dpkg' "all
" '1.16.2+fake'
439 configdpkgnoopchroot() {
440 # create a library to noop chroot() and rewrite maintainer script executions
441 # via execvp() as used by dpkg as we don't want our rootdir to be a fullblown
442 # chroot directory dpkg could chroot into to execute the maintainer scripts
443 msgtest 'Building library to preload to make maintainerscript work in' 'dpkg'
444 cat << EOF > noopchroot.c
451 static char * chrootdir = NULL;
453 int chroot(const char *path) {
454 printf("WARNING
: CHROOTing to
%s was ignored
!\n", path);
456 chrootdir = strdup(path);
459 int execvp(const char *file, char *const argv[]) {
460 static int (*func_execvp) (const char *, char * const []) = NULL;
461 if (func_execvp == NULL)
462 func_execvp = (int (*) (const char *, char * const [])) dlsym(RTLD_NEXT, "execvp
");
463 if (chrootdir == NULL || strncmp(file, "/var
/lib
/dpkg
/", strlen("/var
/lib
/dpkg
/")) != 0)
464 return func_execvp(file, argv);
465 printf("REWRITE execvp call
%s into
%s
\n", file, chrootdir);
466 char newfile[strlen(chrootdir) + strlen(file)];
467 strcpy(newfile, chrootdir);
468 strcat(newfile, file);
469 char const * const baseadmindir = "/var
/lib
/dpkg
";
470 char admindir[strlen(chrootdir) + strlen(baseadmindir)];
471 strcpy(admindir, chrootdir);
472 strcat(admindir, baseadmindir);
473 setenv("DPKG_ADMINDIR
", admindir, 1);
474 return func_execvp(newfile, argv);
477 testsuccess --nomsg gcc -fPIC -shared -o noopchroot.so noopchroot.c -ldl
480 configallowinsecurerepositories() {
481 echo "Acquire
::AllowInsecureRepositories
\"$1\";" > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf
485 configcompression() {
486 while [ -n "$1" ]; do
488 '.') printf ".
\t.
\tcat
\n";;
489 'gz') printf "gzip\tgz
\tgzip
\n";;
490 'bz2') printf "bzip2\tbz
2\tbzip
2\n";;
491 'lzma') printf "lzma
\tlzma
\txz
--format=lzma
\n";;
492 'xz') printf "xz
\txz
\txz
\n";;
493 *) printf "$1\t$1\t$1\n";;
496 done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
503 gzip) COMPRESS='gz';;
504 bzip2) COMPRESS='bz2';;
505 lzma) COMPRESS='lzma';;
507 *) msgdie "Compressor
$COMPRESSOR is unknown to framework
, so can
't be forced by forcecompressor!";;
509 local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
510 echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
511 Dir::Bin::uncompressed \"/does/not/exist\";
512 Dir::Bin::gzip \"/does/not/exist\";
513 Dir::Bin::bzip2 \"/does/not/exist\";
514 Dir::Bin::lzma \"/does/not/exist\";
515 Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
516 if [ -e "/bin/${COMPRESSOR}" ]; then
517 echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
518 elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
519 echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
520 elif [ "${COMPRESSOR}" = 'lzma
' ]; then
521 echo 'Dir
::Bin
::xz
"/usr/bin/xz";' >> "$CONFFILE"
522 COMPRESSOR_CMD='xz
--format=lzma
'
524 msgtest 'Test
for availability of compressor
' "${COMPRESSOR}"
525 msgfail "${COMPRESSOR} not available"
529 setupsimplenativepackage() {
533 local RELEASE="${4:-unstable}"
534 local DEPENDENCIES="$5"
535 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
536 If you find such a package installed on your system,
537 something went horribly wrong! They are autogenerated
538 und used only by testcases and surf no other propose…"}"
540 local SECTION="${7:-others}"
542 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
545 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
547 local BUILDDIR=incoming/${NAME}-${VERSION}
548 mkdir -p ${BUILDDIR}/debian/source
550 echo "* most suckless software product ever" > FEATURES
551 test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
552 test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
556 -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog
557 test -e debian/control || echo "Source: $NAME
560 Maintainer: Joe Sixpack <joe@example.org>
561 Build-Depends: debhelper (>= 7)
562 Standards-Version: 3.9.1
564 Package: $NAME" > debian/control
565 if [ "$ARCH" = 'all
' ]; then
566 echo "Architecture: all" >> debian/control
568 echo "Architecture: any" >> debian/control
570 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
571 echo "Description: $DESCRIPTION" >> debian/control
573 test -e debian/compat || echo "7" > debian/compat
574 test -e debian/source/format || echo "3.0 (native)" > debian/source/format
575 test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
579 buildsimplenativepackage() {
582 if [ "$(echo "$NAME" | cut -c 1-3)" = 'lib
' ]; then
583 NM="$(echo "$NAME" | cut -c 1-4)"
585 NM="$(echo "$NAME" | cut -c 1)"
589 local RELEASE="${4:-unstable}"
590 local DEPENDENCIES="$5"
591 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
592 If you find such a package installed on your system,
593 something went horribly wrong! They are autogenerated
594 und used only by testcases and surf no other propose…"}"
596 local SECTION="${7:-others}"
597 local PRIORITY="${8:-optional}"
599 local COMPRESS_TYPE="${10:-gzip}"
601 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
604 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
606 local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
608 msgtest "Build source package in version ${VERSION} for ${RELEASE} in ${DISTSECTION}" "$NAME"
609 mkdir -p $BUILDDIR/debian/source
610 echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
612 echo '$NAME says
\"Hello
!\"'" > ${BUILDDIR}/${NAME}
614 echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright
615 echo "$NAME ($VERSION) $RELEASE; urgency=low
619 -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog
622 Maintainer: Joe Sixpack <joe@example.org>
623 Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control
624 if [ "$SECTION" != '<none
>' ]; then
625 echo "Section: $SECTION" >> ${BUILDDIR}/debian/control
627 local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
628 test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
630 Package: $NAME" >> ${BUILDDIR}/debian/control
632 if [ "$ARCH" = 'all
' ]; then
633 echo "Architecture: all" >> ${BUILDDIR}/debian/control
635 echo "Architecture: any" >> ${BUILDDIR}/debian/control
637 local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
638 test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
639 echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control
641 echo '3.0 (native
)' > ${BUILDDIR}/debian/source/format
643 testsuccess --nomsg dpkg-source -b ${NAME}-${VERSION}
645 sed -n 's
#^dpkg-source: info: building [^ ]\+ in ##p' ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output \
647 echo "pool/${SRC}" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.srclist
648 # if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
649 # aptkey --keyring ./keys/joesixpack.pub --secret-keyring ./keys/joesixpack.sec --quiet --readonly \
650 # adv --yes --default-key 'Joe Sixpack' \
651 # --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
652 # mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
656 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
657 msgtest
"Build binary package for ${RELEASE} in ${SECTION}" "$NAME"
658 rm -rf ${BUILDDIR}/debian
/tmp
659 mkdir -p ${BUILDDIR}/debian
/tmp
/DEBIAN
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
660 cp ${BUILDDIR}/debian
/copyright
${BUILDDIR}/debian
/changelog
${BUILDDIR}/FEATURES
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME}
661 cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
/${NAME}-${arch}
662 if [ -n "$FILE_TREE" ]; then
663 cp -ar "$FILE_TREE" ${BUILDDIR}/debian
/tmp
666 (cd ${BUILDDIR}; dpkg
-gencontrol -DArchitecture=$arch)
667 (cd ${BUILDDIR}/debian
/tmp
; md5sum $(find usr/ -type f) > DEBIAN
/md5sums
)
668 local LOG
="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log"
669 # ensure the right permissions as dpkg-deb insists
670 chmod 755 ${BUILDDIR}/debian
/tmp
/DEBIAN
671 testsuccess
--nomsg dpkg
-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian
/tmp
${BUILDDIR}/..
672 echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.pkglist
675 local CHANGEPATH
="${BUILDDIR}/../${DISTSECTION}/${NM}/${NAME}/${NAME}_${VERSION}"
677 cp ${BUILDDIR}/debian
/changelog
$CHANGEPATH
686 local ARCH
=$(getarchitecture $4)
687 local PKGNAME
="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
688 local BUILDLOG
="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
689 msgtest
"Build package for ${RELEASE} in ${SECTION}" "$PKGNAME"
691 if [ "$ARCH" = "all" ]; then
692 ARCH
="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
694 testsuccess
--nomsg dpkg
-buildpackage -uc -us -a$ARCH
695 cp ${TMPWORKINGDIRECTORY}/rootdir
/tmp
/testsuccess.output
$BUILDLOG
696 local PKGS
="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
697 local SRCS
="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
700 echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.pkglist
703 echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.srclist
708 if [ -d incoming
]; then
709 buildaptarchivefromincoming
"$@"
711 buildaptarchivefromfiles
"$@"
715 createaptftparchiveconfig
() {
716 local COMPRESSORS
="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
717 local COMPRESSORS
="${COMPRESSORS%* }"
718 local ARCHS
="$(getarchitectures)"
720 ArchiveDir "' >> ftparchive.conf
721 echo -n $(readlink -f .) >> ftparchive.conf
723 CacheDir "' >> ftparchive.conf
724 echo -n $(readlink -f ..) >> ftparchive.conf
726 FileListDir "' >> ftparchive.conf
727 echo -n $(readlink -f pool/) >> ftparchive.conf
731 Packages::Compress "'"$COMPRESSORS"'";
732 Sources::Compress "'"$COMPRESSORS"'";
733 Contents::Compress "'"$COMPRESSORS"'";
734 Translation::Compress "'"$COMPRESSORS"'";
735 LongDescription "false";
739 SrcDirectory "pool/";
745 Label "apttestcases";
747 Description "repository with dummy packages";
748 Architectures "' >> ftparchive.conf
749 echo -n "$ARCHS" >> ftparchive.conf
753 };' >> ftparchive.conf
754 for DIST
in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
755 echo -n 'tree "dists/' >> ftparchive.conf
756 echo -n "$DIST" >> ftparchive.conf
758 Architectures "' >> ftparchive.conf
759 echo -n "$ARCHS" >> ftparchive.conf
761 FileList "' >> ftparchive.conf
762 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
764 SourceFileList "' >> ftparchive.conf
765 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
767 Sections "' >> ftparchive.conf
768 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
770 };' >> ftparchive.conf
774 buildaptftparchivedirectorystructure
() {
775 local DISTS
="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
776 for DIST
in $DISTS; do
777 local SECTIONS
="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
778 for SECTION
in $SECTIONS; do
779 local ARCHS
="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
780 for ARCH
in $ARCHS; do
781 mkdir -p dists
/${DIST}/${SECTION}/binary
-${ARCH}
783 mkdir -p dists
/${DIST}/${SECTION}/source
784 mkdir -p dists
/${DIST}/${SECTION}/i18n
794 local DEPENDENCIES
="$5"
795 local PRIORITY
="${6:-optional}"
796 local DESCRIPTION
="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASES}
797 If you find such a package installed on your system,
798 something went horribly wrong! They are autogenerated
799 und used only by testcases and surf no other propose…"}"
801 for RELEASE in $(printf '%s' "$RELEASES" | tr ',' '\n'); do
802 if [ "$RELEASE" = 'installed' ]; then
803 insertinstalledpackage "$2" "$3" "$4" "$5" "$6" "$7"
806 for arch in $(getarchitecturesfromcommalist "$ARCH"); do
807 if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
808 ARCHS="$(getarchitectures)"
812 for BUILDARCH in $ARCHS; do
813 local PPATH="aptarchive
/dists
/${RELEASE}/main
/binary
-${BUILDARCH}"
815 local FILE="${PPATH}/Packages
"
820 Maintainer
: Joe Sixpack
<joe@example.org
>" >> $FILE
821 test "$arch" = 'none' || echo "Architecture
: $arch" >> $FILE
822 echo "Version
: $VERSION
823 Filename
: pool
/main
/${NAME}/${NAME}_
${VERSION}_
${arch}.deb
" >> $FILE
824 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
825 echo "Description
: $(printf '%s' "$DESCRIPTION" | head -n 1)" >> $FILE
826 echo "Description
-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)" >> $FILE
830 mkdir -p aptarchive/dists/${RELEASE}/main/source aptarchive/dists/${RELEASE}/main/i18n
831 touch aptarchive/dists/${RELEASE}/main/source/Sources
833 Description
-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)
834 Description
-en: $DESCRIPTION
835 " >> aptarchive/dists/${RELEASE}/main/i18n/Translation-en
844 local DEPENDENCIES="$5"
845 local BINARY="${6:-$NAME}"
847 local SPATH="aptarchive
/dists
/${RELEASE}/main
/source"
849 local FILE="${SPATH}/Sources
"
850 local DSCFILE="${NAME}_
${VERSION}.dsc
"
851 local TARFILE="${NAME}_
${VERSION}.
tar.gz
"
855 Maintainer
: Joe Sixpack
<joe@example.org
>
856 Architecture
: $ARCH" >> $FILE
857 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
859 $(echo -n "$DSCFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) $DSCFILE
860 $(echo -n "$TARFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) $TARFILE
862 $(echo -n "$DSCFILE" | sha256sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) $DSCFILE
863 $(echo -n "$TARFILE" | sha256sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) $TARFILE
867 insertinstalledpackage() {
871 local DEPENDENCIES="$4"
872 local PRIORITY="${5:-optional}"
873 local STATUS="${6:-install ok installed}"
874 local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
875 If you
find such a package installed on your system
,
876 something went horribly wrong
! They are autogenerated
877 und used only by testcases and surf no other propose…
"}"
879 local FILE
='rootdir/var/lib/dpkg/status'
880 local INFO
='rootdir/var/lib/dpkg/info'
881 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
887 Maintainer: Joe Sixpack <joe@example.org>
888 Version: $VERSION" >> $FILE
889 test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
890 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
891 echo "Description: $DESCRIPTION" >> $FILE
893 if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
894 echo -n > ${INFO}/${NAME}:${arch}.list
896 echo -n > ${INFO}/${NAME}.list
902 buildaptarchivefromincoming
() {
903 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
905 [ -e pool
] || ln -s ..
/incoming pool
906 [ -e ftparchive.conf
] || createaptftparchiveconfig
907 [ -e dists
] || buildaptftparchivedirectorystructure
908 msgninfo
"\tGenerate Packages, Sources and Contents files… "
909 testsuccess aptftparchive generate ftparchive.conf
912 generatereleasefiles
"$@"
915 buildaptarchivefromfiles
() {
916 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
917 local DIR
='aptarchive'
918 if [ -d "${DIR}/dists" ]; then DIR
="${DIR}/dists"; fi
919 find "$DIR" -name 'Packages' -o -name 'Sources' -o -name 'Translation-*' | while read line
; do
920 msgninfo
"\t${line} file… "
921 compressfile
"$line" "$1"
924 generatereleasefiles
"$@"
928 cat ${TMPWORKINGDIRECTORY}/rootdir
/etc
/testcase
-compressor.conf
| while read compressor extension
command; do
929 if [ "$compressor" = '.' ]; then
935 cat "$1" | $command > "${1}.${extension}"
937 touch -d "$2" "${1}.${extension}"
942 # can be overridden by testcases for their pleasure
943 getcodenamefromsuite
() {
945 unstable
) echo 'sid';;
949 getreleaseversionfromsuite
() { true
; }
950 getlabelfromsuite
() { true
; }
951 getoriginfromsuite
() { true
; }
953 generatereleasefiles
() {
954 # $1 is the Date header and $2 is the ValidUntil header to be set
955 # both should be given in notation date/touch can understand
956 msgninfo
"\tGenerate Release files… "
957 if [ -e aptarchive
/dists
]; then
958 for dir
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
959 local SUITE
="$(echo "$dir" | cut -d'/' -f 4)"
960 local CODENAME
="$(getcodenamefromsuite $SUITE)"
961 local VERSION
="$(getreleaseversionfromsuite $SUITE)"
962 local LABEL
="$(getlabelfromsuite $SUITE)"
963 local ORIGIN
="$(getoriginfromsuite $SUITE)"
964 if [ -n "$VERSION" ]; then
965 VERSION
="-o APT::FTPArchive::Release::Version=${VERSION}"
967 if [ -n "$LABEL" ]; then
968 LABEL
="-o APT::FTPArchive::Release::Label=${LABEL}"
970 if [ -n "$ORIGIN" ]; then
971 ORIGIN
="-o APT::FTPArchive::Release::Origin=${ORIGIN}"
973 aptftparchive
-qq release
$dir \
974 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
975 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
979 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
980 if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
982 NotAutomatic: yes' $dir/Release
984 if [ -n "$1" -a "$1" != "now" ]; then
985 sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
989 Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
993 aptftparchive
-qq release .
/aptarchive
| sed -e '/0 Release$/ d' > aptarchive
/Release
# remove the self reference
995 if [ -n "$1" -a "$1" != "now" ]; then
996 for release
in $(find ./aptarchive -name 'Release'); do
997 touch -d "$1" $release
1003 setupdistsaptarchive
() {
1004 local APTARCHIVE
=$(readlink -f ./aptarchive)
1005 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb.list
1006 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb-src.list
1007 for DISTS
in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
1008 SECTIONS
=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
1009 msgninfo
"\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
1010 echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb.list
1011 echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb-src.list
1016 setupflataptarchive
() {
1017 local APTARCHIVE
=$(readlink -f ./aptarchive)
1018 if [ -f ${APTARCHIVE}/Packages
]; then
1019 msgninfo
"\tadd deb sources.list line… "
1020 echo "deb file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
1023 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
1025 if [ -f ${APTARCHIVE}/Sources
]; then
1026 msgninfo
"\tadd deb-src sources.list line… "
1027 echo "deb-src file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
1030 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
1036 if [ "$1" = '--no-update' ]; then
1040 buildaptarchive
"$@"
1041 if [ -e aptarchive
/dists
]; then
1042 setupdistsaptarchive
1046 signreleasefiles
'Joe Sixpack'
1047 if [ "1" != "$NOUPDATE" ]; then
1048 testsuccess aptget update
-o Debug
::pkgAcquire
::Worker
=true
-o Debug
::Acquire
::gpgv
=true
1052 signreleasefiles
() {
1053 local SIGNER
="${1:-Joe Sixpack}"
1054 local REPODIR
="${2:-aptarchive}"
1055 local KEY
="keys/$(echo "$SIGNER" | tr 'A-Z' 'a-z' | sed 's# ##g')"
1056 local GPG
="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes"
1057 msgninfo
"\tSign archive with $SIGNER key $KEY… "
1058 local REXKEY
='keys/rexexpired'
1059 local SECEXPIREBAK
="${REXKEY}.sec.bak"
1060 local PUBEXPIREBAK
="${REXKEY}.pub.bak"
1061 if [ "${SIGNER}" = 'Rex Expired' ]; then
1062 # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
1063 # option doesn't exist anymore (and using faketime would add a new obscure dependency)
1064 # therefore we 'temporary' make the key not expired and restore a backup after signing
1065 cp ${REXKEY}.sec
$SECEXPIREBAK
1066 cp ${REXKEY}.pub
$PUBEXPIREBAK
1067 local SECUNEXPIRED
="${REXKEY}.sec.unexpired"
1068 local PUBUNEXPIRED
="${REXKEY}.pub.unexpired"
1069 if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
1070 cp $SECUNEXPIRED ${REXKEY}.sec
1071 cp $PUBUNEXPIRED ${REXKEY}.pub
1073 if ! printf "expire\n1w\nsave\n" | $GPG --default-key "$SIGNER" --command-fd 0 --edit-key "${SIGNER}" >setexpire.gpg
2>&1; then
1077 cp ${REXKEY}.sec
$SECUNEXPIRED
1078 cp ${REXKEY}.pub
$PUBUNEXPIRED
1081 for RELEASE
in $(find ${REPODIR}/ -name Release); do
1082 $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg
${RELEASE}
1083 local INRELEASE
="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
1084 $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
1085 # we might have set a specific date for the Release file, so copy it
1086 touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg
${INRELEASE}
1088 if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
1089 mv -f $SECEXPIREBAK ${REXKEY}.sec
1090 mv -f $PUBEXPIREBAK ${REXKEY}.pub
1095 redatereleasefiles
() {
1096 local DATE
="$(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')"
1097 for release
in $(find aptarchive/ -name 'Release'); do
1098 sed -i "s/^Date: .*$/Date: ${DATE}/" $release
1099 touch -d "$DATE" $release
1101 signreleasefiles
"${2:-Joe Sixpack}"
1105 local WEBSERVER
="${3:-http://localhost:8080}"
1107 if [ "$1" = '--no-check' ]; then
1111 local DOWNLOG
='rootdir/tmp/download-testfile.log'
1112 local STATUS
='downloaded/webserverconfig.status'
1113 rm -f "$STATUS" "$DOWNLOG"
1115 if [ -n "$2" ]; then
1116 msgtest
"Set webserver config option '${1}' to" "$2"
1117 URI
="${WEBSERVER}/_config/set/${1}/${2}"
1119 msgtest
'Clear webserver config option' "${1}"
1120 URI
="${WEBSERVER}/_config/clear/${1}"
1122 if downloadfile
"$URI" "$STATUS" > "$DOWNLOG"; then
1125 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/webserverconfig.output"
1126 cat "$DOWNLOG" "$STATUS" >"$OUTPUT" 2>&1 || true
1127 msgfailoutput
'' "$OUTPUT"
1129 $NOCHECK || testwebserverlaststatuscode
'200'
1132 rewritesourceslist
() {
1133 local APTARCHIVE
="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
1134 for LIST
in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
1135 sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#https://localhost:4433/#${1}#"
1139 # wait for up to 10s for a pid file to appear to avoid possible race
1140 # when a helper is started and dosn't write the PID quick enough
1143 for i
in $(seq 10); do
1144 if test -s "$PIDFILE"; then
1149 msgdie
"waiting for $PIDFILE failed"
1153 changetowebserver
() {
1154 if [ "$1" != '--no-rewrite' ]; then
1155 rewritesourceslist
'http://localhost:8080/'
1159 if test -x ${APTWEBSERVERBINDIR}/aptwebserver
; then
1161 local LOG
="webserver.log"
1162 if ! aptwebserver
-o aptwebserver
::fork
=1 "$@" >$LOG 2>&1 ; then
1166 waitforpidfile aptwebserver.pid
1167 local PID
="$(cat aptwebserver.pid)"
1168 if [ -z "$PID" ]; then
1169 msgdie
'Could not fork aptwebserver successfully'
1171 addtrap
"kill $PID;"
1174 msgdie
'You have to build aptwerbserver or install a webserver'
1178 changetohttpswebserver
() {
1179 if ! which stunnel4
>/dev
/null
; then
1180 msgdie
'You need to install stunnel4 for https testcases'
1182 if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
1183 changetowebserver
--no-rewrite "$@"
1185 echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
1186 cert = ${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem
1192 " > ${TMPWORKINGDIRECTORY}/stunnel.conf
1193 stunnel4
"${TMPWORKINGDIRECTORY}/stunnel.conf"
1194 waitforpidfile
"${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
1195 local PID
="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
1196 if [ -z "$PID" ]; then
1197 msgdie
'Could not fork stunnel4 successfully'
1199 addtrap
'prefix' "kill ${PID};"
1200 rewritesourceslist
'https://localhost:4433/'
1204 mkdir -p rootdir
/media
/cdrom
/.disk
1205 local CD
="$(readlink -f rootdir/media/cdrom)"
1206 echo "acquire::cdrom::mount \"${CD}\";
1207 acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
1208 acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
1209 acquire::cdrom::autodetect 0;" > rootdir
/etc
/apt
/apt.conf.d
/00cdrom
1210 echo -n "$1" > ${CD}/.disk
/info
1211 if [ ! -d aptarchive
/dists
]; then
1212 msgdie
'Flat file archive cdroms can not be created currently'
1215 mv aptarchive
/dists
"$CD"
1216 ln -s "$(readlink -f ./incoming)" $CD/pool
1217 find rootdir
/etc
/apt
/sources.list.d
/ -name 'apt-test-*.list' -delete
1218 # start with an unmounted disk
1219 mv "${CD}" "${CD}-unmounted"
1220 # we don't want the disk to be modifiable
1221 addtrap
'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
1222 chmod -R 555 rootdir
/media
/cdrom
-unmounted/dists
1226 local PROTO
="${1%%:*}"
1227 if ! apthelper
-o Debug
::Acquire
::${PROTO}=1 -o Debug
::pkgAcquire
::Worker
=1 \
1228 download
-file "$1" "$2" "$3" 2>&1 ; then
1231 # only if the file exists the download was successful
1232 if [ -r "$2" ]; then
1240 local DIFFTEXT
="$(command diff -u "$@" 2>&1 | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
1241 if [ -n "$DIFFTEXT" ]; then
1243 echo >&2 "$DIFFTEXT"
1251 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testoutputequal.output"
1252 local COMPAREFILE
="$1"
1254 if "$@" 2>&1 | checkdiff
$COMPAREFILE - >"$OUTPUT" 2>&1; then
1257 echo "=== content of file we compared with (${COMPAREFILE}) ===" >>"${OUTPUT}"
1258 cat "$COMPAREFILE" >>"${OUTPUT}"
1259 msgfailoutput
'' "$OUTPUT" "$@"
1264 msggroup
'testfileequal'
1265 local MSG
='Test for correctness of file'
1266 if [ "$1" = '--nomsg' ]; then
1272 if [ -n "$MSG" ]; then
1273 msgtest
"$MSG" "$FILE"
1275 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfileequal.output"
1276 if [ -z "$*" ]; then
1277 testoutputequal
"$FILE" echo -n ''
1279 testoutputequal
"$FILE" echo "$*"
1285 msggroup
'testempty'
1286 msgtest
"Test for no output of" "$*"
1287 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
1288 if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
1291 msgfailoutput
'' "$COMPAREFILE" "$@"
1293 aptautotest
'testempty' "$@"
1298 msggroup
'testequal'
1299 local MSG
='Test of equality of'
1300 if [ "$1" = '--nomsg' ]; then
1305 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile"
1306 echo "$1" > $COMPAREFILE
1309 if [ -n "$MSG" ]; then
1312 testoutputequal
"$COMPAREFILE" "$@"
1313 aptautotest
'testequal' "$@"
1318 msggroup
'testequalor2'
1319 local COMPAREFILE1
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
1320 local COMPAREFILE2
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
1321 local COMPAREAGAINST
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
1322 echo "$1" > $COMPAREFILE1
1323 echo "$2" > $COMPAREFILE2
1325 msgtest
"Test for equality OR of" "$*"
1326 "$@" >$COMPAREAGAINST 2>&1 || true
1327 if checkdiff
$COMPAREFILE1 $COMPAREAGAINST >/dev
/null
2>&1 || \
1328 checkdiff
$COMPAREFILE2 $COMPAREAGAINST >/dev
/null
2>&1
1332 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.output"
1333 echo -n "\n${CINFO}Diff against OR 1${CNORMAL}" >"$OUTPUT" 2>&1
1334 checkdiff
"$COMPAREFILE1" "$COMPAREAGAINST" >"$OUTPUT" 2>&1 || true
1335 echo -n "${CINFO}Diff against OR 2${CNORMAL}" >"$OUTPUT" 2>&1
1336 checkdiff
"$COMPAREFILE2" "$COMPAREAGAINST" >"$OUTPUT" 2>&1 || true
1337 msgfailoutput
'' "$OUTPUT"
1339 aptautotest
'testequalor2' "$@"
1344 msggroup
'testshowvirtual'
1345 local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual"
1348 while [ -n "$1" ]; do
1350 N: Can't select versions from package '$1' as it is purely virtual"
1351 PACKAGE
="${PACKAGE} $1"
1354 msgtest
"Test for virtual packages" "apt-cache show $PACKAGE"
1356 N: No packages found"
1357 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile"
1358 local ARCH
="$(getarchitecture 'native')"
1359 echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' >"$COMPAREFILE"
1360 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.output"
1361 testoutputequal
"$COMPAREFILE" aptcache show
-q=0 "$PACKAGE"
1366 msggroup
'testnopackage'
1367 msgtest
"Test for non-existent packages" "apt-cache show $*"
1368 local SHOWPKG
="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
1369 if [ -n "$SHOWPKG" ]; then
1370 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testnopackage.output"
1371 echo "$SHOWPKG" >"$OUTPUT"
1372 msgfailoutput
'' "$OUTPUT"
1380 msggroup
'testdpkgstatus'
1384 msgtest
"Test that $NR package(s) are in state $STATE with" "dpkg -l $*"
1385 local PKGS
="$(dpkg -l "$@" 2>/dev/null | grep "^${STATE}" | wc -l)"
1386 if [ "$PKGS" != $NR ]; then
1387 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testnopackage.output"
1388 echo "$PKGS" >"$OUTPUT"
1389 dpkg
-l "$@" | grep '^[a-z]' >"$OUTPUT" >&2 || true
1390 msgfailoutput
'' "$OUTPUT"
1397 testdpkginstalled
() {
1398 msggroup
'testdpkginstalled'
1399 testdpkgstatus
'ii' "$#" "$@"
1403 testdpkgnotinstalled
() {
1404 msggroup
'testdpkgnotinstalled'
1405 testdpkgstatus
'ii' '0' "$@"
1410 msggroup
'testmarkedauto'
1411 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
1412 if [ -n "$1" ]; then
1413 msgtest
'Test for correctly marked as auto-installed' "$*"
1414 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1416 msgtest
'Test for correctly marked as auto-installed' 'no package'
1417 echo -n > $COMPAREFILE
1419 testoutputequal
"$COMPAREFILE" aptmark showauto
1422 testmarkedmanual
() {
1423 msggroup
'testmarkedmanual'
1424 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.comparefile"
1425 if [ -n "$1" ]; then
1426 msgtest
'Test for correctly marked as manually installed' "$*"
1427 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1429 msgtest
'Test for correctly marked as manually installed' 'no package'
1430 echo -n > $COMPAREFILE
1432 testoutputequal
"$COMPAREFILE" aptmark showmanual
1437 msgreportheader
'msgfailoutput'
1441 if [ "$1" = 'grep' ]; then
1443 while [ -n "$2" ]; do shift; done
1444 echo "#### Complete file: $1 ####"
1445 cat >&2 "$1" || true
1446 echo '#### grep output ####'
1447 elif [ "$1" = 'test' ]; then
1449 # doesn't support ! or non-file flags
1450 msgfailoutputstatfile
() {
1451 local FILEFLAGS
='^-[bcdefgGhkLOprsStuwx]$'
1452 if expr match
"$1" "$FILEFLAGS" >/dev
/null
; then
1453 echo "#### stat(2) of file: $2 ####"
1457 msgfailoutputstatfile
"$2" "$3"
1458 while [ -n "$5" ] && [ "$4" = '-o' -o "$4" = '-a' ]; do
1460 msgfailoutputstatfile
"$2" "$3"
1462 echo '#### test output ####'
1469 msggroup
'testsuccess'
1470 if [ "$1" = '--nomsg' ]; then
1473 msgtest
'Test for successful execution of' "$*"
1475 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
1476 if "$@" >${OUTPUT} 2>&1; then
1477 if expr match
"$1" '^apt.*' >/dev
/null
; then
1478 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1479 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1480 elif grep -E '^[WE]: ' "$OUTPUT" > "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" 2>&1; then
1481 if [ "$IGNORE_PTY_NOT_MOUNTED" = '1' ]; then
1482 if echo 'E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory)' \
1483 | cmp - "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" >/dev
/null
2>&1; then
1486 msgfailoutput
'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
1489 msgfailoutput
'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
1499 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1501 aptautotest
'testsuccess' "$@"
1505 msggroup
'testwarning'
1506 if [ "$1" = '--nomsg' ]; then
1509 msgtest
'Test for successful execution with warnings of' "$*"
1511 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output"
1512 if "$@" >${OUTPUT} 2>&1; then
1513 if expr match
"$1" '^apt.*' >/dev
/null
; then
1514 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1515 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1516 elif grep -q -E '^E: ' "$OUTPUT"; then
1517 msgfailoutput
'successful run, but output contains errors' "$OUTPUT" "$@"
1518 elif ! grep -q -E '^W: ' "$OUTPUT"; then
1519 msgfailoutput
'successful run, but output contains no warnings' "$OUTPUT" "$@"
1528 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1530 aptautotest
'testwarning' "$@"
1534 msggroup
'testfailure'
1535 if [ "$1" = '--nomsg' ]; then
1538 msgtest
'Test for failure in execution of' "$*"
1540 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
1541 if "$@" >${OUTPUT} 2>&1; then
1543 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1546 if expr match
"$1" '^apt.*' >/dev
/null
; then
1547 if [ "$1" = 'aptkey' ]; then
1548 if grep -q -E " Can't check signature: " "$OUTPUT" || \
1549 grep -q -E " BAD signature from " "$OUTPUT"; then
1552 msgfailoutput
"run failed with exitcode ${EXITCODE}, but no signature error" "$OUTPUT" "$@"
1555 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1556 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1557 elif grep -q -E '==ERROR' "$OUTPUT"; then
1558 msgfailoutput
'compiler sanitizers reported errors' "$OUTPUT" "$@"
1559 elif ! grep -q -E '^E: ' "$OUTPUT"; then
1560 msgfailoutput
"run failed with exitcode ${EXITCODE}, but with no errors" "$OUTPUT" "$@"
1569 aptautotest
'testfailure' "$@"
1573 testsuccessequal
() {
1574 msggroup
'testsuccessequal'
1578 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" "$CMP"
1581 testwarningequal
() {
1582 msggroup
'testwarningequal'
1586 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" "$CMP"
1589 testfailureequal
() {
1590 msggroup
'testfailureequal'
1594 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" "$CMP"
1599 msggroup
'testfailuremsg'
1603 msgtest
'Check that the output of the previous failed command has expected' 'failures and warnings'
1604 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailuremsg.comparefile"
1605 grep '^\(W\|E\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "$COMPAREFILE" 2>&1 || true
1606 testoutputequal
"$COMPAREFILE" echo "$CMP"
1611 msggroup
'testfilestats'
1612 msgtest
"Test that file $1 has $2 $3" "$4"
1613 if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
1616 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfilestats.output"
1619 echo -n "stat(1) reports for $2: "
1620 stat
--format "$2" "$1" || true
1622 msgfailoutput
'' "$OUTPUT"
1626 testaccessrights
() {
1627 msggroup
'testaccessrights'
1628 testfilestats
"$1" '%a' '=' "$2"
1632 testwebserverlaststatuscode
() {
1633 msggroup
'testwebserverlaststatuscode'
1634 local DOWNLOG
='rootdir/tmp/webserverstatus-testfile.log'
1635 local STATUS
='downloaded/webserverstatus-statusfile.log'
1636 rm -f "$DOWNLOG" "$STATUS"
1637 msgtest
'Test last status code from the webserver was' "$1"
1638 if downloadfile
"http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" && [ "$(cat "$STATUS")" = "$1" ]; then
1641 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwebserverlaststatuscode.output"
1643 if [ -n "$2" ]; then
1645 echo >&2 '#### Additionally provided output files contain:'
1648 echo >&2 '#### Download log of the status code:'
1651 msgfailoutput
"Status was $(cat "$STATUS")" "$OUTPUT"
1657 echo "STOPPED execution. Press enter to continue"
1662 listcurrentlistsdirectory
() {
1664 find rootdir
/var
/lib
/apt
/lists
-maxdepth 1 -type d
| while read line
; do
1665 stat
--format '%U:%G:%a:%n' "$line"
1667 find rootdir
/var
/lib
/apt
/lists
-maxdepth 1 \
! -type d
| while read line
; do
1668 stat
--format '%U:%G:%a:%s:%y:%n' "$line"
1673 ### convenience hacks ###
1675 # creating some directories by hand is a tedious task, so make it look simple
1676 if [ "$*" = '-p rootdir/var/lib/apt/lists' ] || [ "$*" = "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" ] ||
1677 [ "$*" = '-p rootdir/var/lib/apt/lists/partial' ] || [ "$*" = "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" ]; then
1678 # only the last directory created by mkdir is effected by the -m !
1679 command mkdir -m 755 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt"
1680 command mkdir -m 755 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"
1681 command mkdir -m 700 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial"
1682 touch "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/lock"
1683 if [ "$(id -u)" = '0' ]; then
1684 chown _apt
:root
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial"
1691 ### The following tests are run by most test methods automatically to check
1692 ### general things about commands executed without writing the test every time.
1698 local AUTOTEST
="aptautotest_$(basename "$CMD" | tr -d '-')_$(echo "$FIRSTOPT" | tr -d '-')"
1699 if command -v $AUTOTEST >/dev
/null
; then
1701 # save and restore the *.output files from other tests
1702 # as we might otherwise override them in these automatic tests
1703 rm -rf ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before
1704 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before
1705 mkdir ${TMPWORKINGDIRECTORY}/rootdir
/tmp
1706 $AUTOTEST "$TESTCALL" "$@"
1707 rm -rf ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-aptautotest
1708 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
${TMPWORKINGDIRECTORY}/rootdir
/tmp
-aptautotest
1709 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before ${TMPWORKINGDIRECTORY}/rootdir
/tmp
1713 aptautotest_aptget_update
() {
1715 while [ -n "$2" ]; do
1716 if [ "$2" = '--print-uris' ]; then return; fi # simulation mode
1719 if ! test -d "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"; then return; fi
1720 testfilestats
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:755"
1721 testfilestats
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:755"
1722 # all copied files are properly chmodded
1723 for file in $(find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" -type f ! -name 'lock'); do
1724 testfilestats
"$file" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
1726 if [ "$TESTCALL" = 'testsuccess' ]; then
1727 # failure cases can retain partial files and such
1728 testempty
find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" -mindepth 1 ! \
( -name 'lock' -o -name '*.FAILED' \
)
1731 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; }
1732 aptautotest_aptcdrom_add
() { aptautotest_aptget_update
"$@"; }
1734 testaptautotestnodpkgwarning
() {
1736 while [ -n "$2" ]; do
1737 if expr match
"$2" '^-[a-z]*s' >/dev
/null
2>&1; then return; fi # simulation mode
1738 if expr match
"$2" '^-dy\?' >/dev
/null
2>&1; then return; fi # download-only mode
1741 testfailure
grep '^dpkg: warning:.*ignor.*' "${TMPWORKINGDIRECTORY}/rootdir/tmp-before/${TESTCALL}.output"
1744 aptautotest_aptget_install
() { testaptautotestnodpkgwarning
"$@"; }
1745 aptautotest_aptget_remove
() { testaptautotestnodpkgwarning
"$@"; }
1746 aptautotest_aptget_purge
() { testaptautotestnodpkgwarning
"$@"; }
1747 aptautotest_apt_install
() { testaptautotestnodpkgwarning
"$@"; }
1748 aptautotest_apt_remove
() { testaptautotestnodpkgwarning
"$@"; }
1749 aptautotest_apt_purge
() { testaptautotestnodpkgwarning
"$@"; }