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 if [ -n "$MSGTEST_MSGMSG" ]; then
70 echo "$MSGTEST_MSGMSG"
72 if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
73 echo "Part of the test group: $MSGTEST_GRP"
75 echo -n "$MSGTEST_MSG"
78 if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2;
79 else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi
82 if [ -n "$MSGTEST_MSG" ]; then
83 if [ -n "$MSGTEST_MSGMSG" ]; then
84 echo "$MSGTEST_MSGMSG"
86 if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
87 echo "Part of the test group: $MSGTEST_GRP"
89 echo -n "$MSGTEST_MSG"
92 if [ $# -gt 0 ] && [ -n "$1" ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
93 else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
94 if [ -n "$APT_DEBUG_TESTS" ]; then
97 EXIT_CODE
=$((EXIT_CODE+1));
102 if [ $MSGGROUP_LEVEL = 0 ]; then
105 MSGGROUP_LEVEL
=$((MSGGROUP_LEVEL+1));
107 MSGGROUP_LEVEL
=$((MSGGROUP_LEVEL-1));
108 if [ $MSGGROUP_LEVEL = 0 ]; then
114 # enable / disable Debugging
115 if [ $MSGLEVEL -le 0 ]; then
118 if [ $MSGLEVEL -le 1 ]; then
122 if [ $MSGLEVEL -le 2 ]; then
124 MSGTEST_MSGMSG
="$(msgprintf "${CMSG}%s" '%s' "${CNORMAL}" "$@")"
128 MSGTEST_MSG
="$(msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@")"
129 if [ "$MSGTEST_GRP" = 'NEXT' ]; then
130 MSGTEST_GRP
="$MSGTEST_MSG"
133 msgpass
() { printf " ${CPASS}P${CNORMAL}"; }
135 if [ $MSGLEVEL -le 3 ]; then
139 if [ $MSGLEVEL -le 4 ]; then
141 msgndebug
() { true
; }
144 if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
145 [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
146 [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
147 [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
148 [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
151 printf "${CDONE}DONE${CNORMAL}\n";
155 if [ -f .
/aptconfig.conf
]; then
156 echo "$(readlink -f ./aptconfig.conf)"
157 elif [ -f ..
/aptconfig.conf
]; then
158 echo "$(readlink -f ../aptconfig.conf)"
159 elif [ -f ..
/..
/aptconfig.conf
]; then
160 echo "$(readlink -f ../../aptconfig.conf)"
161 elif [ -f "${TMPWORKINGDIRECTORY}/aptconfig.conf" ]; then
162 echo "$(readlink -f "${TMPWORKINGDIRECTORY}/aptconfig.conf")"
166 msgdebug
"Executing: ${CCMD}$*${CDEBUG} "
170 sh
|aptitude
|*/*|command) ;;
171 *) CMD
="${BUILDDIRECTORY}/$CMD";;
173 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 APT_CONFIG
="$(getaptconfig)" LD_LIBRARY_PATH
=${LIBRARYPATH} $CMD "$@"
175 aptconfig
() { runapt apt
-config "$@"; }
176 aptcache
() { runapt apt
-cache "$@"; }
177 aptcdrom
() { runapt apt
-cdrom "$@"; }
178 aptget
() { runapt apt
-get "$@"; }
179 aptftparchive
() { runapt apt
-ftparchive "$@"; }
180 aptkey
() { runapt apt
-key "$@"; }
181 aptmark
() { runapt apt
-mark "$@"; }
182 aptsortpkgs
() { runapt apt
-sortpkgs "$@"; }
183 apt
() { runapt apt
"$@"; }
184 apthelper
() { runapt
"${APTHELPERBINDIR}/apt-helper" "$@"; }
185 aptwebserver
() { runapt
"${APTWEBSERVERBINDIR}/aptwebserver" "$@"; }
186 aptitude
() { runapt aptitude
"$@"; }
187 aptextracttemplates
() { runapt apt
-extracttemplates "$@"; }
188 aptinternalsolver
() { runapt
"${APTINTERNALSOLVER}" "$@"; }
189 aptdumpsolver
() { runapt
"${APTDUMPSOLVER}" "$@"; }
192 "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "$@"
194 dpkgcheckbuilddeps
() {
195 command dpkg
-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir
/var
/lib
/dpkg
"$@"
200 aptget
) CMD
="apt-get";;
201 aptcache
) CMD
="apt-cache";;
202 aptcdrom
) CMD
="apt-cdrom";;
203 aptconfig
) CMD
="apt-config";;
204 aptmark
) CMD
="apt-mark";;
205 apthelper
) CMD
="apt-helper";;
206 aptftparchive
) CMD
="apt-ftparchive";;
210 runapt
command gdb
--quiet -ex run
"${BUILDDIRECTORY}/$CMD" --args "${BUILDDIRECTORY}/$CMD" "$@"
214 # error if we about to overflow, but ...
215 # "255 failures ought to be enough for everybody"
216 if [ $EXIT_CODE -gt 255 ]; then
217 msgdie
"Total failure count $EXIT_CODE too big"
219 exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
222 shellsetedetector
() {
224 if [ "$exit_status" != '0' ]; then
225 printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n"
226 if [ "$EXIT_CODE" = '0' ]; then
227 EXIT_CODE
="$exit_status"
233 if [ "$1" = 'prefix' ]; then
234 CURRENTTRAP
="$2 $CURRENTTRAP"
236 CURRENTTRAP
="$CURRENTTRAP $1"
238 trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
242 # privilege dropping and testing doesn't work if /tmp isn't world-writeable (as e.g. with libpam-tmpdir)
243 if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$(stat --format '%a' "$TMPDIR")" != '1777' ]; then
246 TMPWORKINGDIRECTORY
=$(mktemp -d)
247 addtrap
"cd /; rm -rf $TMPWORKINGDIRECTORY;"
248 msgninfo
"Preparing environment for $(basename $0) in ${TMPWORKINGDIRECTORY}…"
250 mkdir -m 700 "${TMPWORKINGDIRECTORY}/downloaded"
251 if [ "$(id -u)" = '0' ]; then
252 # relax permissions so that running as root with user switching works
254 chmod 711 "$TMPWORKINGDIRECTORY"
255 chown _apt
:root
"${TMPWORKINGDIRECTORY}/downloaded"
258 TESTDIRECTORY
=$(readlink -f $(dirname $0))
259 # allow overriding the default BUILDDIR location
260 SOURCEDIRECTORY
=${APT_INTEGRATION_TESTS_SOURCE_DIR:-"${TESTDIRECTORY}/../../"}
261 BUILDDIRECTORY
=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
262 LIBRARYPATH
=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
263 METHODSDIR
=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
264 APTHELPERBINDIR
=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
265 APTWEBSERVERBINDIR
=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
266 APTINTERNALSOLVER
=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"}
267 APTDUMPSOLVER
=${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${BUILDDIRECTORY}/apt-dump-solver"}
268 test -x "${BUILDDIRECTORY}/apt-get" || msgdie
"You need to build tree first"
271 cd $TMPWORKINGDIRECTORY
272 mkdir rootdir aptarchive keys
274 mkdir -p etc
/apt
/apt.conf.d etc
/apt
/sources.list.d etc
/apt
/trusted.gpg.d etc
/apt
/preferences.d
275 mkdir -p usr
/bin var
/cache var
/lib var
/log tmp
276 mkdir -p var
/lib
/dpkg
/info var
/lib
/dpkg
/updates var
/lib
/dpkg
/triggers
277 touch var
/lib
/dpkg
/available
279 ln -s ${METHODSDIR} usr
/lib
/apt
/methods
280 if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
281 mkdir -p usr
/lib
/apt
/solvers
282 ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr
/lib
/apt
/solvers
/dump
283 ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr
/lib
/apt
/solvers
/apt
284 echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc
/apt
/apt.conf.d
/externalsolver.conf
286 # use the autoremove from the BUILDDIRECTORY if its there, otherwise
288 if [ -e ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove
]; then
289 ln -s ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove etc
/apt
/apt.conf.d
/01autoremove
291 ln -s /etc
/apt
/apt.conf.d
/01autoremove etc
/apt
/apt.conf.d
/01autoremove
294 local PACKAGESFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
295 if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
296 cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
298 local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
299 if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
300 cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive
/Sources
302 cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys
/
303 chmod 644 $(find keys -name '*.pub' -o -name '*.sec')
304 ln -s ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
306 echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
307 echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
308 echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
309 echo "Dir::Bin::Methods \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods\";" >> aptconfig.conf
310 # store apt-key were we can access it, even if we run it as a different user
311 # destroys coverage reporting though, so just do it for root for now
312 if [ "$(id -u)" = '0' ]; then
313 cp "${BUILDDIRECTORY}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/"
314 chmod o
+rx
"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key"
315 echo "Dir::Bin::apt-key \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key\";" >> aptconfig.conf
317 echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
320 cat << EOF > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
323 if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then
324 if [ -n "\$LD_PRELOAD" ]; then
325 export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so \${LD_PRELOAD}"
327 export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so"
330 exec fakeroot dpkg --root="${TMPWORKINGDIRECTORY}/rootdir" \\
331 --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\
332 --force-not-root --force-bad-path "\$@"
334 chmod +x
"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
335 echo "Dir::Bin::dpkg \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg\";" > rootdir
/etc
/apt
/apt.conf.d
/99dpkg
338 if ! command dpkg
--assert-multi-arch >/dev
/null
2>&1; then
339 echo "DPKG::options:: \"--force-architecture\";" # Added to test multiarch before dpkg is ready for it…
341 echo 'quiet::NoUpdate "true";'
342 echo 'quiet::NoStatistic "true";'
343 # too distracting for users, but helpful to detect changes
344 echo 'Acquire::Progress::Ignore::ShowErrorText "true";'
345 echo 'Acquire::Progress::Diffpercent "true";'
346 # in testcases, it can appear as if localhost has a rotation setup,
347 # hide this as we can't really deal with it properly
348 echo 'Acquire::Failure::ShowIP "false";'
351 cp "${TESTDIRECTORY}/apt.pem" "${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
352 if [ "$(id -u)" = '0' ]; then
353 chown _apt
:root
"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
355 echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir
/etc
/apt
/apt.conf.d
/99https
356 echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir
/etc
/apt
/apt.conf.d
/apt
-binary
357 configcompression
'.' 'gz' #'bz2' 'lzma' 'xz'
359 # create some files in /tmp and look at user/group to get what this means
360 TEST_DEFAULT_USER
="$USER"
361 if [ "$(uname)" = 'GNU/kFreeBSD' ]; then
362 TEST_DEFAULT_GROUP
='root'
364 TEST_DEFAULT_GROUP
="$USER"
367 # Acquire::AllowInsecureRepositories=false is not yet the default
368 # but we want it to be the default soon
369 configallowinsecurerepositories
"false";
371 # cleanup the environment a bit
372 # prefer our apt binaries over the system apt binaries
373 export PATH
="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
374 export LC_ALL
=C.UTF
-8
375 unset LANGUAGE APT_CONFIG
376 unset GREP_OPTIONS DEB_BUILD_PROFILES
381 if [ "$1" = "native" -o -z "$1" ]; then
382 eval `aptconfig shell ARCH APT::Architecture`
383 if [ -n "$ARCH" ]; then
386 dpkg
--print-architecture
394 aptconfig dump
--no-empty --format '%v%n' APT
::Architecture APT
::Architectures
| sort -u | tr '\n' ' '
397 getarchitecturesfromcommalist
() {
398 echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
401 configarchitecture
() {
403 echo "APT::Architecture \"$(getarchitecture $1)\";"
404 while [ -n "$1" ]; do
405 echo "APT::Architectures:: \"$(getarchitecture $1)\";"
408 } >rootdir
/etc
/apt
/apt.conf.d
/01multiarch.conf
413 if [ ! -e rootdir
/var
/lib
/dpkg
/status
]; then
414 local STATUSFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
415 if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
416 cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
418 echo -n > rootdir/var/lib/dpkg/status
421 rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
422 if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
423 local ARCHS="$(getarchitectures)"
424 if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
425 DPKGARCH="$(dpkg --print-architecture)"
426 for ARCH in ${ARCHS}; do
427 if [ "${ARCH}" != "${DPKGARCH}" ]; then
428 if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
429 # old-style used e.g. in Ubuntu-P – and as it seems travis
430 echo "DPKG
::options
:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
431 echo "DPKG
::options
:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
435 if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
436 # dpkg doesn't really check the version as long as it is fully installed,
437 # but just to be sure we choose one above the required version
438 insertinstalledpackage 'dpkg' "all
" '1.16.2+fake'
444 configdpkgnoopchroot() {
445 # create a library to noop chroot() and rewrite maintainer script executions
446 # via execvp() as used by dpkg as we don't want our rootdir to be a fullblown
447 # chroot directory dpkg could chroot into to execute the maintainer scripts
448 msgtest 'Building library to preload to make maintainerscript work in' 'dpkg'
449 cat << EOF > noopchroot.c
456 static char * chrootdir = NULL;
458 int chroot(const char *path) {
459 printf("WARNING
: CHROOTing to
%s was ignored
!\n", path);
461 chrootdir = strdup(path);
464 int execvp(const char *file, char *const argv[]) {
465 static int (*func_execvp) (const char *, char * const []) = NULL;
466 if (func_execvp == NULL)
467 func_execvp = (int (*) (const char *, char * const [])) dlsym(RTLD_NEXT, "execvp
");
468 if (chrootdir == NULL || strncmp(file, "/var
/lib
/dpkg
/", strlen("/var
/lib
/dpkg
/")) != 0)
469 return func_execvp(file, argv);
470 printf("REWRITE execvp call
%s into
%s
\n", file, chrootdir);
471 char newfile[strlen(chrootdir) + strlen(file)];
472 strcpy(newfile, chrootdir);
473 strcat(newfile, file);
474 char const * const baseadmindir = "/var
/lib
/dpkg
";
475 char admindir[strlen(chrootdir) + strlen(baseadmindir)];
476 strcpy(admindir, chrootdir);
477 strcat(admindir, baseadmindir);
478 setenv("DPKG_ADMINDIR
", admindir, 1);
479 return func_execvp(newfile, argv);
482 testsuccess --nomsg gcc -fPIC -shared -o noopchroot.so noopchroot.c -ldl
485 configallowinsecurerepositories() {
486 echo "Acquire
::AllowInsecureRepositories
\"$1\";" > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf
490 configcompression() {
491 while [ -n "$1" ]; do
493 '.') printf ".
\t.
\tcat
\n";;
494 'gz') printf "gzip\tgz
\tgzip
\n";;
495 'bz2') printf "bzip2\tbz
2\tbzip
2\n";;
496 'lzma') printf "lzma
\tlzma
\txz
--format=lzma
\n";;
497 'xz') printf "xz
\txz
\txz
\n";;
498 *) printf "$1\t$1\t$1\n";;
501 done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
508 gzip) COMPRESS='gz';;
509 bzip2) COMPRESS='bz2';;
510 lzma) COMPRESS='lzma';;
512 *) msgdie "Compressor
$COMPRESSOR is unknown to framework
, so can
't be forced by forcecompressor!";;
514 local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
515 echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
516 Dir::Bin::uncompressed \"/does/not/exist\";
517 Dir::Bin::gzip \"/does/not/exist\";
518 Dir::Bin::bzip2 \"/does/not/exist\";
519 Dir::Bin::lzma \"/does/not/exist\";
520 Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
521 if [ -e "/bin/${COMPRESSOR}" ]; then
522 echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
523 elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
524 echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
525 elif [ "${COMPRESSOR}" = 'lzma
' ]; then
526 echo 'Dir
::Bin
::xz
"/usr/bin/xz";' >> "$CONFFILE"
527 COMPRESSOR_CMD='xz
--format=lzma
'
529 msgtest 'Test
for availability of compressor
' "${COMPRESSOR}"
530 msgfail "${COMPRESSOR} not available"
534 setupsimplenativepackage() {
538 local RELEASE="${4:-unstable}"
539 local DEPENDENCIES="$5"
540 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
541 If you find such a package installed on your system,
542 something went horribly wrong! They are autogenerated
543 und used only by testcases and surf no other propose…"}"
545 local SECTION="${7:-others}"
547 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
550 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
552 local BUILDDIR=incoming/${NAME}-${VERSION}
553 mkdir -p ${BUILDDIR}/debian/source
555 echo "* most suckless software product ever" > FEATURES
556 test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
557 test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
561 -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog
562 test -e debian/control || echo "Source: $NAME
565 Maintainer: Joe Sixpack <joe@example.org>
566 Build-Depends: debhelper (>= 7)
567 Standards-Version: 3.9.1
569 Package: $NAME" > debian/control
570 if [ "$ARCH" = 'all
' ]; then
571 echo "Architecture: all" >> debian/control
573 echo "Architecture: any" >> debian/control
575 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
576 echo "Description: $DESCRIPTION" >> debian/control
578 test -e debian/compat || echo "7" > debian/compat
579 test -e debian/source/format || echo "3.0 (native)" > debian/source/format
580 test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
584 buildsimplenativepackage() {
587 if [ "$(echo "$NAME" | cut -c 1-3)" = 'lib
' ]; then
588 NM="$(echo "$NAME" | cut -c 1-4)"
590 NM="$(echo "$NAME" | cut -c 1)"
594 local RELEASE="${4:-unstable}"
595 local DEPENDENCIES="$5"
596 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
597 If you find such a package installed on your system,
598 something went horribly wrong! They are autogenerated
599 und used only by testcases and surf no other propose…"}"
601 local SECTION="${7:-others}"
602 local PRIORITY="${8:-optional}"
604 local COMPRESS_TYPE="${10:-gzip}"
606 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
609 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
611 local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
613 msgtest "Build source package in version ${VERSION} for ${RELEASE} in ${DISTSECTION}" "$NAME"
614 mkdir -p $BUILDDIR/debian/source
615 echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
617 echo '$NAME says
\"Hello
!\"'" > ${BUILDDIR}/${NAME}
619 echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright
620 echo "$NAME ($VERSION) $RELEASE; urgency=low
624 -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog
627 Maintainer: Joe Sixpack <joe@example.org>
628 Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control
629 if [ "$SECTION" != '<none
>' ]; then
630 echo "Section: $SECTION" >> ${BUILDDIR}/debian/control
632 local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
633 test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
635 Package: $NAME" >> ${BUILDDIR}/debian/control
637 if [ "$ARCH" = 'all
' ]; then
638 echo "Architecture: all" >> ${BUILDDIR}/debian/control
640 echo "Architecture: any" >> ${BUILDDIR}/debian/control
642 local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
643 test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
644 echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control
646 echo '3.0 (native
)' > ${BUILDDIR}/debian/source/format
648 testsuccess --nomsg dpkg-source -b ${NAME}-${VERSION}
650 sed -n 's
#^dpkg-source: info: building [^ ]\+ in ##p' ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output \
652 echo "pool/${SRC}" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.srclist
653 # if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
654 # aptkey --keyring ./keys/joesixpack.pub --secret-keyring ./keys/joesixpack.sec --quiet --readonly \
655 # adv --yes --default-key 'Joe Sixpack' \
656 # --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
657 # mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
661 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
662 msgtest
"Build binary package for ${RELEASE} in ${SECTION}" "$NAME"
663 rm -rf ${BUILDDIR}/debian
/tmp
664 mkdir -p ${BUILDDIR}/debian
/tmp
/DEBIAN
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
665 cp ${BUILDDIR}/debian
/copyright
${BUILDDIR}/debian
/changelog
${BUILDDIR}/FEATURES
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME}
666 cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
/${NAME}-${arch}
667 if [ -n "$FILE_TREE" ]; then
668 cp -ar "$FILE_TREE" ${BUILDDIR}/debian
/tmp
671 (cd ${BUILDDIR}; dpkg
-gencontrol -DArchitecture=$arch)
672 (cd ${BUILDDIR}/debian
/tmp
; md5sum $(find usr/ -type f) > DEBIAN
/md5sums
)
673 local LOG
="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log"
674 # ensure the right permissions as dpkg-deb insists
675 chmod 755 ${BUILDDIR}/debian
/tmp
/DEBIAN
676 testsuccess
--nomsg dpkg
-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian
/tmp
${BUILDDIR}/..
677 echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.pkglist
680 local CHANGEPATH
="${BUILDDIR}/../${DISTSECTION}/${NM}/${NAME}/${NAME}_${VERSION}"
682 cp ${BUILDDIR}/debian
/changelog
$CHANGEPATH
691 local ARCH
=$(getarchitecture $4)
692 local PKGNAME
="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
693 local BUILDLOG
="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
694 msgtest
"Build package for ${RELEASE} in ${SECTION}" "$PKGNAME"
696 if [ "$ARCH" = "all" ]; then
697 ARCH
="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
699 testsuccess
--nomsg dpkg
-buildpackage -uc -us -a$ARCH
700 cp ${TMPWORKINGDIRECTORY}/rootdir
/tmp
/testsuccess.output
$BUILDLOG
701 local PKGS
="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
702 local SRCS
="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
705 echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.pkglist
708 echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.srclist
713 if [ -d incoming
]; then
714 buildaptarchivefromincoming
"$@"
716 buildaptarchivefromfiles
"$@"
720 createaptftparchiveconfig
() {
721 local COMPRESSORS
="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
722 local COMPRESSORS
="${COMPRESSORS%* }"
723 local ARCHS
="$(getarchitectures)"
725 ArchiveDir "' >> ftparchive.conf
726 echo -n $(readlink -f .) >> ftparchive.conf
728 CacheDir "' >> ftparchive.conf
729 echo -n $(readlink -f ..) >> ftparchive.conf
731 FileListDir "' >> ftparchive.conf
732 echo -n $(readlink -f pool/) >> ftparchive.conf
736 Packages::Compress "'"$COMPRESSORS"'";
737 Sources::Compress "'"$COMPRESSORS"'";
738 Contents::Compress "'"$COMPRESSORS"'";
739 Translation::Compress "'"$COMPRESSORS"'";
740 LongDescription "false";
744 SrcDirectory "pool/";
750 Label "apttestcases";
752 Description "repository with dummy packages";
753 Architectures "' >> ftparchive.conf
754 echo -n "$ARCHS" >> ftparchive.conf
758 };' >> ftparchive.conf
759 for DIST
in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
760 echo -n 'tree "dists/' >> ftparchive.conf
761 echo -n "$DIST" >> ftparchive.conf
763 Architectures "' >> ftparchive.conf
764 echo -n "$ARCHS" >> ftparchive.conf
766 FileList "' >> ftparchive.conf
767 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
769 SourceFileList "' >> ftparchive.conf
770 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
772 Sections "' >> ftparchive.conf
773 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
775 };' >> ftparchive.conf
779 buildaptftparchivedirectorystructure
() {
780 local DISTS
="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
781 for DIST
in $DISTS; do
782 local SECTIONS
="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
783 for SECTION
in $SECTIONS; do
784 local ARCHS
="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
785 for ARCH
in $ARCHS; do
786 mkdir -p dists
/${DIST}/${SECTION}/binary
-${ARCH}
788 mkdir -p dists
/${DIST}/${SECTION}/source
789 mkdir -p dists
/${DIST}/${SECTION}/i18n
799 local DEPENDENCIES
="$5"
800 local PRIORITY
="${6:-optional}"
801 local DESCRIPTION
="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASES}
802 If you find such a package installed on your system,
803 something went horribly wrong! They are autogenerated
804 und used only by testcases and surf no other propose…"}"
806 for RELEASE in $(printf '%s' "$RELEASES" | tr ',' '\n'); do
807 if [ "$RELEASE" = 'installed' ]; then
808 insertinstalledpackage "$2" "$3" "$4" "$5" "$6" "$7"
811 for arch in $(getarchitecturesfromcommalist "$ARCH"); do
812 if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
813 ARCHS="$(getarchitectures)"
817 for BUILDARCH in $ARCHS; do
818 local PPATH="aptarchive
/dists
/${RELEASE}/main
/binary
-${BUILDARCH}"
820 local FILE="${PPATH}/Packages
"
825 Maintainer
: Joe Sixpack
<joe@example.org
>" >> $FILE
826 test "$arch" = 'none' || echo "Architecture
: $arch" >> $FILE
827 echo "Version
: $VERSION
828 Filename
: pool
/main
/${NAME}/${NAME}_
${VERSION}_
${arch}.deb
" >> $FILE
829 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
830 echo "Description
: $(printf '%s' "$DESCRIPTION" | head -n 1)" >> $FILE
831 echo "Description
-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)" >> $FILE
835 mkdir -p aptarchive/dists/${RELEASE}/main/source aptarchive/dists/${RELEASE}/main/i18n
836 touch aptarchive/dists/${RELEASE}/main/source/Sources
838 Description
-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)
839 Description
-en: $DESCRIPTION
840 " >> aptarchive/dists/${RELEASE}/main/i18n/Translation-en
849 local DEPENDENCIES="$5"
850 local BINARY="${6:-$NAME}"
852 local SPATH="aptarchive
/dists
/${RELEASE}/main
/source"
854 local FILE="${SPATH}/Sources
"
855 local DSCFILE="${NAME}_
${VERSION}.dsc
"
856 local TARFILE="${NAME}_
${VERSION}.
tar.gz
"
860 Maintainer
: Joe Sixpack
<joe@example.org
>
861 Architecture
: $ARCH" >> $FILE
862 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
864 $(echo -n "$DSCFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) $DSCFILE
865 $(echo -n "$TARFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) $TARFILE
867 $(echo -n "$DSCFILE" | sha256sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) $DSCFILE
868 $(echo -n "$TARFILE" | sha256sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) $TARFILE
872 insertinstalledpackage() {
876 local DEPENDENCIES="$4"
877 local PRIORITY="${5:-optional}"
878 local STATUS="${6:-install ok installed}"
879 local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
880 If you
find such a package installed on your system
,
881 something went horribly wrong
! They are autogenerated
882 und used only by testcases and surf no other propose…
"}"
884 local FILE
='rootdir/var/lib/dpkg/status'
885 local INFO
='rootdir/var/lib/dpkg/info'
886 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
892 Maintainer: Joe Sixpack <joe@example.org>
893 Version: $VERSION" >> $FILE
894 test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
895 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
896 echo "Description: $DESCRIPTION" >> $FILE
898 if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
899 echo -n > ${INFO}/${NAME}:${arch}.list
901 echo -n > ${INFO}/${NAME}.list
907 buildaptarchivefromincoming
() {
908 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
910 [ -e pool
] || ln -s ..
/incoming pool
911 [ -e ftparchive.conf
] || createaptftparchiveconfig
912 [ -e dists
] || buildaptftparchivedirectorystructure
913 msgninfo
"\tGenerate Packages, Sources and Contents files… "
914 testsuccess aptftparchive generate ftparchive.conf
917 generatereleasefiles
"$@"
920 buildaptarchivefromfiles
() {
921 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
922 local DIR
='aptarchive'
923 if [ -d "${DIR}/dists" ]; then DIR
="${DIR}/dists"; fi
924 find "$DIR" -name 'Packages' -o -name 'Sources' -o -name 'Translation-*' | while read line
; do
925 msgninfo
"\t${line} file… "
926 compressfile
"$line" "$1"
929 generatereleasefiles
"$@"
933 cat ${TMPWORKINGDIRECTORY}/rootdir
/etc
/testcase
-compressor.conf
| while read compressor extension
command; do
934 if [ "$compressor" = '.' ]; then
940 cat "$1" | $command > "${1}.${extension}"
942 touch -d "$2" "${1}.${extension}"
947 # can be overridden by testcases for their pleasure
948 getcodenamefromsuite
() {
950 unstable
) echo 'sid';;
954 getreleaseversionfromsuite
() { true
; }
955 getlabelfromsuite
() { true
; }
956 getoriginfromsuite
() { true
; }
958 generatereleasefiles
() {
959 # $1 is the Date header and $2 is the ValidUntil header to be set
960 # both should be given in notation date/touch can understand
961 msgninfo
"\tGenerate Release files… "
962 if [ -e aptarchive
/dists
]; then
963 for dir
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
964 local SUITE
="$(echo "$dir" | cut -d'/' -f 4)"
965 local CODENAME
="$(getcodenamefromsuite $SUITE)"
966 local VERSION
="$(getreleaseversionfromsuite $SUITE)"
967 local LABEL
="$(getlabelfromsuite $SUITE)"
968 local ORIGIN
="$(getoriginfromsuite $SUITE)"
969 if [ -n "$VERSION" ]; then
970 VERSION
="-o APT::FTPArchive::Release::Version=${VERSION}"
972 if [ -n "$LABEL" ]; then
973 LABEL
="-o APT::FTPArchive::Release::Label=${LABEL}"
975 if [ -n "$ORIGIN" ]; then
976 ORIGIN
="-o APT::FTPArchive::Release::Origin=${ORIGIN}"
978 aptftparchive
-qq release
$dir \
979 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
980 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
984 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
985 if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
987 NotAutomatic: yes' $dir/Release
989 if [ -n "$1" -a "$1" != "now" ]; then
990 sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
994 Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
998 aptftparchive
-qq release .
/aptarchive
| sed -e '/0 Release$/ d' > aptarchive
/Release
# remove the self reference
1000 if [ -n "$1" -a "$1" != "now" ]; then
1001 for release
in $(find ./aptarchive -name 'Release'); do
1002 touch -d "$1" $release
1008 setupdistsaptarchive
() {
1009 local APTARCHIVE
=$(readlink -f ./aptarchive)
1010 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb.list
1011 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb-src.list
1012 for DISTS
in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
1013 SECTIONS
=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
1014 msgninfo
"\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
1015 echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb.list
1016 echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb-src.list
1021 setupflataptarchive
() {
1022 local APTARCHIVE
=$(readlink -f ./aptarchive)
1023 if [ -f ${APTARCHIVE}/Packages
]; then
1024 msgninfo
"\tadd deb sources.list line… "
1025 echo "deb file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
1028 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
1030 if [ -f ${APTARCHIVE}/Sources
]; then
1031 msgninfo
"\tadd deb-src sources.list line… "
1032 echo "deb-src file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
1035 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
1041 if [ "$1" = '--no-update' ]; then
1045 buildaptarchive
"$@"
1046 if [ -e aptarchive
/dists
]; then
1047 setupdistsaptarchive
1051 signreleasefiles
'Joe Sixpack'
1052 if [ "1" != "$NOUPDATE" ]; then
1053 testsuccess aptget update
-o Debug
::pkgAcquire
::Worker
=true
-o Debug
::Acquire
::gpgv
=true
1057 signreleasefiles
() {
1058 local SIGNER
="${1:-Joe Sixpack}"
1059 local REPODIR
="${2:-aptarchive}"
1060 local KEY
="keys/$(echo "$SIGNER" | tr 'A-Z' 'a-z' | sed 's# ##g')"
1061 local GPG
="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes"
1062 msgninfo
"\tSign archive with $SIGNER key $KEY… "
1063 local REXKEY
='keys/rexexpired'
1064 local SECEXPIREBAK
="${REXKEY}.sec.bak"
1065 local PUBEXPIREBAK
="${REXKEY}.pub.bak"
1066 if [ "${SIGNER}" = 'Rex Expired' ]; then
1067 # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
1068 # option doesn't exist anymore (and using faketime would add a new obscure dependency)
1069 # therefore we 'temporary' make the key not expired and restore a backup after signing
1070 cp ${REXKEY}.sec
$SECEXPIREBAK
1071 cp ${REXKEY}.pub
$PUBEXPIREBAK
1072 local SECUNEXPIRED
="${REXKEY}.sec.unexpired"
1073 local PUBUNEXPIRED
="${REXKEY}.pub.unexpired"
1074 if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
1075 cp $SECUNEXPIRED ${REXKEY}.sec
1076 cp $PUBUNEXPIRED ${REXKEY}.pub
1078 if ! printf "expire\n1w\nsave\n" | $GPG --default-key "$SIGNER" --command-fd 0 --edit-key "${SIGNER}" >setexpire.gpg
2>&1; then
1082 cp ${REXKEY}.sec
$SECUNEXPIRED
1083 cp ${REXKEY}.pub
$PUBUNEXPIRED
1086 for RELEASE
in $(find ${REPODIR}/ -name Release); do
1087 $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg
${RELEASE}
1088 local INRELEASE
="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
1089 $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
1090 # we might have set a specific date for the Release file, so copy it
1091 touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg
${INRELEASE}
1093 if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
1094 mv -f $SECEXPIREBAK ${REXKEY}.sec
1095 mv -f $PUBEXPIREBAK ${REXKEY}.pub
1100 redatereleasefiles
() {
1101 local DATE
="$(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')"
1102 for release
in $(find aptarchive/ -name 'Release'); do
1103 sed -i "s/^Date: .*$/Date: ${DATE}/" $release
1104 touch -d "$DATE" $release
1106 signreleasefiles
"${2:-Joe Sixpack}"
1110 local WEBSERVER
="${3:-http://localhost:8080}"
1112 if [ "$1" = '--no-check' ]; then
1116 local DOWNLOG
='rootdir/tmp/download-testfile.log'
1117 local STATUS
='downloaded/webserverconfig.status'
1118 rm -f "$STATUS" "$DOWNLOG"
1120 if [ -n "$2" ]; then
1121 msgtest
"Set webserver config option '${1}' to" "$2"
1122 URI
="${WEBSERVER}/_config/set/${1}/${2}"
1124 msgtest
'Clear webserver config option' "${1}"
1125 URI
="${WEBSERVER}/_config/clear/${1}"
1127 if downloadfile
"$URI" "$STATUS" > "$DOWNLOG"; then
1130 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/webserverconfig.output"
1131 cat "$DOWNLOG" "$STATUS" >"$OUTPUT" 2>&1 || true
1132 msgfailoutput
'' "$OUTPUT"
1134 $NOCHECK || testwebserverlaststatuscode
'200'
1137 rewritesourceslist
() {
1138 local APTARCHIVE
="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
1139 for LIST
in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
1140 sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#https://localhost:4433/#${1}#"
1144 # wait for up to 10s for a pid file to appear to avoid possible race
1145 # when a helper is started and dosn't write the PID quick enough
1148 for i
in $(seq 10); do
1149 if test -s "$PIDFILE"; then
1154 msgdie
"waiting for $PIDFILE failed"
1158 changetowebserver
() {
1159 if [ "$1" != '--no-rewrite' ]; then
1160 rewritesourceslist
'http://localhost:8080/'
1164 if test -x ${APTWEBSERVERBINDIR}/aptwebserver
; then
1166 local LOG
="webserver.log"
1167 if ! aptwebserver
-o aptwebserver
::fork
=1 "$@" >$LOG 2>&1 ; then
1171 waitforpidfile aptwebserver.pid
1172 local PID
="$(cat aptwebserver.pid)"
1173 if [ -z "$PID" ]; then
1174 msgdie
'Could not fork aptwebserver successfully'
1176 addtrap
"kill $PID;"
1179 msgdie
'You have to build aptwerbserver or install a webserver'
1183 changetohttpswebserver
() {
1184 if ! which stunnel4
>/dev
/null
; then
1185 msgdie
'You need to install stunnel4 for https testcases'
1187 if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
1188 changetowebserver
--no-rewrite "$@"
1190 echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
1191 cert = ${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem
1197 " > ${TMPWORKINGDIRECTORY}/stunnel.conf
1198 stunnel4
"${TMPWORKINGDIRECTORY}/stunnel.conf"
1199 waitforpidfile
"${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
1200 local PID
="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
1201 if [ -z "$PID" ]; then
1202 msgdie
'Could not fork stunnel4 successfully'
1204 addtrap
'prefix' "kill ${PID};"
1205 rewritesourceslist
'https://localhost:4433/'
1209 mkdir -p rootdir
/media
/cdrom
/.disk
1210 local CD
="$(readlink -f rootdir/media/cdrom)"
1211 echo "acquire::cdrom::mount \"${CD}\";
1212 acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
1213 acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
1214 acquire::cdrom::autodetect 0;" > rootdir
/etc
/apt
/apt.conf.d
/00cdrom
1215 echo -n "$1" > ${CD}/.disk
/info
1216 if [ ! -d aptarchive
/dists
]; then
1217 msgdie
'Flat file archive cdroms can not be created currently'
1220 mv aptarchive
/dists
"$CD"
1221 ln -s "$(readlink -f ./incoming)" $CD/pool
1222 find rootdir
/etc
/apt
/sources.list.d
/ -name 'apt-test-*.list' -delete
1223 # start with an unmounted disk
1224 mv "${CD}" "${CD}-unmounted"
1225 # we don't want the disk to be modifiable
1226 addtrap
'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
1227 chmod -R 555 rootdir
/media
/cdrom
-unmounted/dists
1231 local PROTO
="${1%%:*}"
1232 if ! apthelper
-o Debug
::Acquire
::${PROTO}=1 -o Debug
::pkgAcquire
::Worker
=1 \
1233 download
-file "$1" "$2" "$3" 2>&1 ; then
1236 # only if the file exists the download was successful
1237 if [ -r "$2" ]; then
1245 local DIFFTEXT
="$(command diff -u "$@" 2>&1 | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
1246 if [ -n "$DIFFTEXT" ]; then
1248 echo >&2 "$DIFFTEXT"
1256 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testoutputequal.output"
1257 local COMPAREFILE
="$1"
1259 if "$@" 2>&1 | checkdiff
$COMPAREFILE - >"$OUTPUT" 2>&1; then
1262 echo "=== content of file we compared with (${COMPAREFILE}) ===" >>"${OUTPUT}"
1263 cat "$COMPAREFILE" >>"${OUTPUT}"
1264 msgfailoutput
'' "$OUTPUT" "$@"
1270 local MSG
='Test for correctness of file'
1271 if [ "$1" = '--nomsg' ]; then
1277 if [ -n "$MSG" ]; then
1278 msgtest
"$MSG" "$FILE"
1280 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfileequal.output"
1281 if [ -z "$*" ]; then
1282 testoutputequal
"$FILE" echo -n ''
1284 testoutputequal
"$FILE" echo "$*"
1291 msgtest
"Test for no output of" "$*"
1292 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
1293 if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
1296 msgfailoutput
'' "$COMPAREFILE" "$@"
1298 aptautotest
'testempty' "$@"
1304 local MSG
='Test of equality of'
1305 if [ "$1" = '--nomsg' ]; then
1310 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile"
1311 echo "$1" > $COMPAREFILE
1314 if [ -n "$MSG" ]; then
1317 testoutputequal
"$COMPAREFILE" "$@"
1318 aptautotest
'testequal' "$@"
1324 local COMPAREFILE1
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
1325 local COMPAREFILE2
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
1326 local COMPAREAGAINST
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
1327 echo "$1" > $COMPAREFILE1
1328 echo "$2" > $COMPAREFILE2
1330 msgtest
"Test for equality OR of" "$*"
1331 "$@" >$COMPAREAGAINST 2>&1 || true
1332 if checkdiff
$COMPAREFILE1 $COMPAREAGAINST >/dev
/null
2>&1 || \
1333 checkdiff
$COMPAREFILE2 $COMPAREAGAINST >/dev
/null
2>&1
1337 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.output"
1338 echo -n "\n${CINFO}Diff against OR 1${CNORMAL}" >"$OUTPUT" 2>&1
1339 checkdiff
"$COMPAREFILE1" "$COMPAREAGAINST" >"$OUTPUT" 2>&1 || true
1340 echo -n "${CINFO}Diff against OR 2${CNORMAL}" >"$OUTPUT" 2>&1
1341 checkdiff
"$COMPAREFILE2" "$COMPAREAGAINST" >"$OUTPUT" 2>&1 || true
1342 msgfailoutput
'' "$OUTPUT"
1344 aptautotest
'testequalor2' "$@"
1350 local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual"
1353 while [ -n "$1" ]; do
1355 N: Can't select versions from package '$1' as it is purely virtual"
1356 PACKAGE
="${PACKAGE} $1"
1359 msgtest
"Test for virtual packages" "apt-cache show $PACKAGE"
1361 N: No packages found"
1362 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile"
1363 local ARCH
="$(getarchitecture 'native')"
1364 echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' >"$COMPAREFILE"
1365 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.output"
1366 testoutputequal
"$COMPAREFILE" aptcache show
-q=0 "$PACKAGE"
1372 msgtest
"Test for non-existent packages" "apt-cache show $*"
1373 local SHOWPKG
="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
1374 if [ -n "$SHOWPKG" ]; then
1375 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testnopackage.output"
1376 echo "$SHOWPKG" >"$OUTPUT"
1377 msgfailoutput
'' "$OUTPUT"
1389 msgtest
"Test that $NR package(s) are in state $STATE with" "dpkg -l $*"
1390 local PKGS
="$(dpkg -l "$@" 2>/dev/null | grep "^${STATE}" | wc -l)"
1391 if [ "$PKGS" != $NR ]; then
1392 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testnopackage.output"
1393 echo "$PKGS" >"$OUTPUT"
1394 dpkg
-l "$@" | grep '^[a-z]' >"$OUTPUT" >&2 || true
1395 msgfailoutput
'' "$OUTPUT"
1402 testdpkginstalled
() {
1404 testdpkgstatus
'ii' "$#" "$@"
1408 testdpkgnotinstalled
() {
1410 testdpkgstatus
'ii' '0' "$@"
1416 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
1417 if [ -n "$1" ]; then
1418 msgtest
'Test for correctly marked as auto-installed' "$*"
1419 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1421 msgtest
'Test for correctly marked as auto-installed' 'no package'
1422 echo -n > $COMPAREFILE
1424 testoutputequal
"$COMPAREFILE" aptmark showauto
1427 testmarkedmanual
() {
1429 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.comparefile"
1430 if [ -n "$1" ]; then
1431 msgtest
'Test for correctly marked as manually installed' "$*"
1432 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1434 msgtest
'Test for correctly marked as manually installed' 'no package'
1435 echo -n > $COMPAREFILE
1437 testoutputequal
"$COMPAREFILE" aptmark showmanual
1442 if [ -n "$MSGTEST_MSG" ]; then
1444 if [ -n "$MSGTEST_MSGMSG" ]; then
1445 echo "$MSGTEST_MSGMSG"
1447 if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
1448 echo "${CFAIL}Part of the test group: $MSGTEST_GRP"
1450 echo -n "$MSGTEST_MSG"
1456 if [ "$1" = 'grep' ]; then
1458 while [ -n "$2" ]; do shift; done
1459 echo "#### Complete file: $1 ####"
1460 cat >&2 "$1" || true
1461 echo '#### grep output ####'
1462 elif [ "$1" = 'test' ]; then
1464 # doesn't support ! or non-file flags
1465 msgfailoutputstatfile
() {
1466 local FILEFLAGS
='^-[bcdefgGhkLOprsStuwx]$'
1467 if expr match
"$1" "$FILEFLAGS" >/dev
/null
; then
1468 echo "#### stat(2) of file: $2 ####"
1472 msgfailoutputstatfile
"$2" "$3"
1473 while [ -n "$5" ] && [ "$4" = '-o' -o "$4" = '-a' ]; do
1475 msgfailoutputstatfile
"$2" "$3"
1477 echo '#### test output ####'
1485 if [ "$1" = '--nomsg' ]; then
1488 msgtest
'Test for successful execution of' "$*"
1490 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
1491 if "$@" >${OUTPUT} 2>&1; then
1492 if expr match
"$1" '^apt.*' >/dev
/null
; then
1493 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1494 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1495 elif grep -E '^[WE]: ' "$OUTPUT" > "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" 2>&1; then
1496 if [ "$IGNORE_PTY_NOT_MOUNTED" = '1' ]; then
1497 if echo 'E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory)' \
1498 | cmp - "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" >/dev
/null
2>&1; then
1501 msgfailoutput
'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
1504 msgfailoutput
'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
1514 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1516 aptautotest
'testsuccess' "$@"
1521 if [ "$1" = '--nomsg' ]; then
1524 msgtest
'Test for successful execution with warnings of' "$*"
1526 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output"
1527 if "$@" >${OUTPUT} 2>&1; then
1528 if expr match
"$1" '^apt.*' >/dev
/null
; then
1529 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1530 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1531 elif grep -q -E '^E: ' "$OUTPUT"; then
1532 msgfailoutput
'successful run, but output contains errors' "$OUTPUT" "$@"
1533 elif ! grep -q -E '^W: ' "$OUTPUT"; then
1534 msgfailoutput
'successful run, but output contains no warnings' "$OUTPUT" "$@"
1543 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1545 aptautotest
'testwarning' "$@"
1550 if [ "$1" = '--nomsg' ]; then
1553 msgtest
'Test for failure in execution of' "$*"
1555 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
1556 if "$@" >${OUTPUT} 2>&1; then
1558 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1561 if expr match
"$1" '^apt.*' >/dev
/null
; then
1562 if [ "$1" = 'aptkey' ]; then
1563 if grep -q -E " Can't check signature: " "$OUTPUT" || \
1564 grep -q -E " BAD signature from " "$OUTPUT"; then
1567 msgfailoutput
"run failed with exitcode ${EXITCODE}, but no signature error" "$OUTPUT" "$@"
1570 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1571 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1572 elif grep -q -E '==ERROR' "$OUTPUT"; then
1573 msgfailoutput
'compiler sanitizers reported errors' "$OUTPUT" "$@"
1574 elif ! grep -q -E '^E: ' "$OUTPUT"; then
1575 msgfailoutput
"run failed with exitcode ${EXITCODE}, but with no errors" "$OUTPUT" "$@"
1584 aptautotest
'testfailure' "$@"
1588 testsuccessequal
() {
1593 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" "$CMP"
1596 testwarningequal
() {
1601 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" "$CMP"
1604 testfailureequal
() {
1609 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" "$CMP"
1618 msgtest
'Check that the output of the previous failed command has expected' 'failures and warnings'
1619 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailuremsg.comparefile"
1620 grep '^\(W\|E\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "$COMPAREFILE" 2>&1 || true
1621 testoutputequal
"$COMPAREFILE" echo "$CMP"
1627 msgtest
"Test that file $1 has $2 $3" "$4"
1628 if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
1631 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfilestats.output"
1634 echo -n "stat(1) reports for $2: "
1635 stat
--format "$2" "$1" || true
1637 msgfailoutput
'' "$OUTPUT"
1641 testaccessrights
() {
1643 testfilestats
"$1" '%a' '=' "$2"
1647 testwebserverlaststatuscode
() {
1649 local DOWNLOG
='rootdir/tmp/webserverstatus-testfile.log'
1650 local STATUS
='downloaded/webserverstatus-statusfile.log'
1651 rm -f "$DOWNLOG" "$STATUS"
1652 msgtest
'Test last status code from the webserver was' "$1"
1653 if downloadfile
"http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" && [ "$(cat "$STATUS")" = "$1" ]; then
1656 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwebserverlaststatuscode.output"
1658 if [ -n "$2" ]; then
1660 echo >&2 '#### Additionally provided output files contain:'
1663 echo >&2 '#### Download log of the status code:'
1666 msgfailoutput
"Status was $(cat "$STATUS")" "$OUTPUT"
1672 echo "STOPPED execution. Press enter to continue"
1677 listcurrentlistsdirectory
() {
1679 find rootdir
/var
/lib
/apt
/lists
-maxdepth 1 -type d
| while read line
; do
1680 stat
--format '%U:%G:%a:%n' "$line"
1682 find rootdir
/var
/lib
/apt
/lists
-maxdepth 1 \
! -type d
| while read line
; do
1683 stat
--format '%U:%G:%a:%s:%y:%n' "$line"
1688 ### convenience hacks ###
1690 # creating some directories by hand is a tedious task, so make it look simple
1691 if [ "$*" = '-p rootdir/var/lib/apt/lists' ] || [ "$*" = "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" ] ||
1692 [ "$*" = '-p rootdir/var/lib/apt/lists/partial' ] || [ "$*" = "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" ]; then
1693 # only the last directory created by mkdir is effected by the -m !
1694 command mkdir -m 755 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt"
1695 command mkdir -m 755 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"
1696 command mkdir -m 700 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial"
1697 touch "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/lock"
1698 if [ "$(id -u)" = '0' ]; then
1699 chown _apt
:root
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial"
1706 ### The following tests are run by most test methods automatically to check
1707 ### general things about commands executed without writing the test every time.
1713 local AUTOTEST
="aptautotest_$(basename "$CMD" | tr -d '-')_$(echo "$FIRSTOPT" | tr -d '-')"
1714 if command -v $AUTOTEST >/dev
/null
; then
1716 # save and restore the *.output files from other tests
1717 # as we might otherwise override them in these automatic tests
1718 rm -rf ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before
1719 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before
1720 mkdir ${TMPWORKINGDIRECTORY}/rootdir
/tmp
1721 $AUTOTEST "$TESTCALL" "$@"
1722 rm -rf ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-aptautotest
1723 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
${TMPWORKINGDIRECTORY}/rootdir
/tmp
-aptautotest
1724 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before ${TMPWORKINGDIRECTORY}/rootdir
/tmp
1728 aptautotest_aptget_update
() {
1730 while [ -n "$2" ]; do
1731 if [ "$2" = '--print-uris' ]; then return; fi # simulation mode
1734 if ! test -d "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"; then return; fi
1735 testfilestats
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:755"
1736 testfilestats
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:755"
1737 # all copied files are properly chmodded
1738 for file in $(find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" -type f ! -name 'lock'); do
1739 testfilestats
"$file" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
1741 if [ "$TESTCALL" = 'testsuccess' ]; then
1742 # failure cases can retain partial files and such
1743 testempty
find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" -mindepth 1 ! \
( -name 'lock' -o -name '*.FAILED' \
)
1746 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; }
1747 aptautotest_aptcdrom_add
() { aptautotest_aptget_update
"$@"; }
1749 testaptautotestnodpkgwarning
() {
1751 while [ -n "$2" ]; do
1752 if expr match
"$2" '^-[a-z]*s' >/dev
/null
2>&1; then return; fi # simulation mode
1753 if expr match
"$2" '^-dy\?' >/dev
/null
2>&1; then return; fi # download-only mode
1756 testfailure
grep '^dpkg: warning:.*ignor.*' "${TMPWORKINGDIRECTORY}/rootdir/tmp-before/${TESTCALL}.output"
1759 aptautotest_aptget_install
() { testaptautotestnodpkgwarning
"$@"; }
1760 aptautotest_aptget_remove
() { testaptautotestnodpkgwarning
"$@"; }
1761 aptautotest_aptget_purge
() { testaptautotestnodpkgwarning
"$@"; }
1762 aptautotest_apt_install
() { testaptautotestnodpkgwarning
"$@"; }
1763 aptautotest_apt_remove
() { testaptautotestnodpkgwarning
"$@"; }
1764 aptautotest_apt_purge
() { testaptautotestnodpkgwarning
"$@"; }