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_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
70 echo "Part of the test group: $MSGTEST_GRP"
72 echo -n "$MSGTEST_MSG"
75 if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2;
76 else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi
79 if [ -n "$MSGTEST_MSG" ]; then
80 if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
81 echo "Part of the test group: $MSGTEST_GRP"
83 echo -n "$MSGTEST_MSG"
86 if [ $# -gt 0 ] && [ -n "$1" ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
87 else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
88 if [ -n "$APT_DEBUG_TESTS" ]; then
91 EXIT_CODE
=$((EXIT_CODE+1));
96 if [ $MSGGROUP_LEVEL = 0 ]; then
99 MSGGROUP_LEVEL
=$((MSGGROUP_LEVEL+1));
101 MSGGROUP_LEVEL
=$((MSGGROUP_LEVEL-1));
102 if [ $MSGGROUP_LEVEL = 0 ]; then
108 # enable / disable Debugging
109 if [ $MSGLEVEL -le 0 ]; then
112 if [ $MSGLEVEL -le 1 ]; then
116 if [ $MSGLEVEL -le 2 ]; then
120 MSGTEST_MSG
="$(msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@")"
121 if [ "$MSGTEST_GRP" = 'NEXT' ]; then
122 MSGTEST_GRP
="$MSGTEST_MSG"
125 msgpass
() { printf " ${CPASS}P${CNORMAL}"; }
127 if [ $MSGLEVEL -le 3 ]; then
131 if [ $MSGLEVEL -le 4 ]; then
133 msgndebug
() { true
; }
136 if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
137 [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
138 [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
139 [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
140 [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
143 printf "${CDONE}DONE${CNORMAL}\n";
147 if [ -f .
/aptconfig.conf
]; then
148 echo "$(readlink -f ./aptconfig.conf)"
149 elif [ -f ..
/aptconfig.conf
]; then
150 echo "$(readlink -f ../aptconfig.conf)"
151 elif [ -f ..
/..
/aptconfig.conf
]; then
152 echo "$(readlink -f ../../aptconfig.conf)"
153 elif [ -f "${TMPWORKINGDIRECTORY}/aptconfig.conf" ]; then
154 echo "$(readlink -f "${TMPWORKINGDIRECTORY}/aptconfig.conf")"
158 msgdebug
"Executing: ${CCMD}$*${CDEBUG} "
162 sh
|aptitude
|*/*|command) ;;
163 *) CMD
="${BUILDDIRECTORY}/$CMD";;
165 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 APT_CONFIG
="$(getaptconfig)" LD_LIBRARY_PATH
=${LIBRARYPATH} $CMD "$@"
167 aptconfig
() { runapt apt
-config "$@"; }
168 aptcache
() { runapt apt
-cache "$@"; }
169 aptcdrom
() { runapt apt
-cdrom "$@"; }
170 aptget
() { runapt apt
-get "$@"; }
171 aptftparchive
() { runapt apt
-ftparchive "$@"; }
172 aptkey
() { runapt apt
-key "$@"; }
173 aptmark
() { runapt apt
-mark "$@"; }
174 aptsortpkgs
() { runapt apt
-sortpkgs "$@"; }
175 apt
() { runapt apt
"$@"; }
176 apthelper
() { runapt
"${APTHELPERBINDIR}/apt-helper" "$@"; }
177 aptwebserver
() { runapt
"${APTWEBSERVERBINDIR}/aptwebserver" "$@"; }
178 aptitude
() { runapt aptitude
"$@"; }
179 aptextracttemplates
() { runapt apt
-extracttemplates "$@"; }
180 aptinternalsolver
() { runapt
"${APTINTERNALSOLVER}" "$@"; }
181 aptdumpsolver
() { runapt
"${APTDUMPSOLVER}" "$@"; }
184 "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "$@"
186 dpkgcheckbuilddeps
() {
187 command dpkg
-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir
/var
/lib
/dpkg
"$@"
192 aptget
) CMD
="apt-get";;
193 aptcache
) CMD
="apt-cache";;
194 aptcdrom
) CMD
="apt-cdrom";;
195 aptconfig
) CMD
="apt-config";;
196 aptmark
) CMD
="apt-mark";;
197 apthelper
) CMD
="apt-helper";;
198 aptftparchive
) CMD
="apt-ftparchive";;
202 runapt
command gdb
--quiet -ex run
"${BUILDDIRECTORY}/$CMD" --args "${BUILDDIRECTORY}/$CMD" "$@"
206 # error if we about to overflow, but ...
207 # "255 failures ought to be enough for everybody"
208 if [ $EXIT_CODE -gt 255 ]; then
209 msgdie
"Total failure count $EXIT_CODE too big"
211 exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
214 shellsetedetector
() {
216 if [ "$exit_status" != '0' ]; then
217 printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n"
218 if [ "$EXIT_CODE" = '0' ]; then
219 EXIT_CODE
="$exit_status"
225 if [ "$1" = 'prefix' ]; then
226 CURRENTTRAP
="$2 $CURRENTTRAP"
228 CURRENTTRAP
="$CURRENTTRAP $1"
230 trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
234 # privilege dropping and testing doesn't work if /tmp isn't world-writeable (as e.g. with libpam-tmpdir)
235 if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$(stat --format '%a' "$TMPDIR")" != '1777' ]; then
238 TMPWORKINGDIRECTORY
=$(mktemp -d)
239 addtrap
"cd /; rm -rf $TMPWORKINGDIRECTORY;"
240 msgninfo
"Preparing environment for $(basename $0) in ${TMPWORKINGDIRECTORY}…"
242 mkdir -m 700 "${TMPWORKINGDIRECTORY}/downloaded"
243 if [ "$(id -u)" = '0' ]; then
244 # relax permissions so that running as root with user switching works
246 chmod 711 "$TMPWORKINGDIRECTORY"
247 chown _apt
:root
"${TMPWORKINGDIRECTORY}/downloaded"
250 TESTDIRECTORY
=$(readlink -f $(dirname $0))
251 # allow overriding the default BUILDDIR location
252 SOURCEDIRECTORY
=${APT_INTEGRATION_TESTS_SOURCE_DIR:-"${TESTDIRECTORY}/../../"}
253 BUILDDIRECTORY
=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
254 LIBRARYPATH
=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
255 METHODSDIR
=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
256 APTHELPERBINDIR
=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
257 APTWEBSERVERBINDIR
=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
258 APTINTERNALSOLVER
=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"}
259 APTDUMPSOLVER
=${APT_INTEGRATION_TESTS_DUMP_SOLVER:-"${BUILDDIRECTORY}/apt-dump-solver"}
260 test -x "${BUILDDIRECTORY}/apt-get" || msgdie
"You need to build tree first"
263 cd $TMPWORKINGDIRECTORY
264 mkdir rootdir aptarchive keys
266 mkdir -p etc
/apt
/apt.conf.d etc
/apt
/sources.list.d etc
/apt
/trusted.gpg.d etc
/apt
/preferences.d
267 mkdir -p usr
/bin var
/cache var
/lib var
/log tmp
268 mkdir -p var
/lib
/dpkg
/info var
/lib
/dpkg
/updates var
/lib
/dpkg
/triggers
269 touch var
/lib
/dpkg
/available
271 ln -s ${METHODSDIR} usr
/lib
/apt
/methods
272 if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
273 mkdir -p usr
/lib
/apt
/solvers
274 ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr
/lib
/apt
/solvers
/dump
275 ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr
/lib
/apt
/solvers
/apt
276 echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc
/apt
/apt.conf.d
/externalsolver.conf
278 # use the autoremove from the BUILDDIRECTORY if its there, otherwise
280 if [ -e ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove
]; then
281 ln -s ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove etc
/apt
/apt.conf.d
/01autoremove
283 ln -s /etc
/apt
/apt.conf.d
/01autoremove etc
/apt
/apt.conf.d
/01autoremove
286 local PACKAGESFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
287 if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
288 cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
290 local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
291 if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
292 cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive
/Sources
294 cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys
/
295 chmod 644 $(find keys -name '*.pub' -o -name '*.sec')
296 ln -s ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
298 echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
299 echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
300 echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
301 echo "Dir::Bin::Methods \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods\";" >> aptconfig.conf
302 # store apt-key were we can access it, even if we run it as a different user
303 # destroys coverage reporting though, so just do it for root for now
304 if [ "$(id -u)" = '0' ]; then
305 cp "${BUILDDIRECTORY}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/"
306 chmod o
+rx
"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key"
307 echo "Dir::Bin::apt-key \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key\";" >> aptconfig.conf
309 echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
312 cat << EOF > "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
315 if [ -r "${TMPWORKINGDIRECTORY}/noopchroot.so" ]; then
316 if [ -n "\$LD_PRELOAD" ]; then
317 export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so \${LD_PRELOAD}"
319 export LD_PRELOAD="${TMPWORKINGDIRECTORY}/noopchroot.so"
322 exec fakeroot dpkg --root="${TMPWORKINGDIRECTORY}/rootdir" \\
323 --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log \\
324 --force-not-root --force-bad-path "\$@"
326 chmod +x
"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg"
327 echo "Dir::Bin::dpkg \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg\";" > rootdir
/etc
/apt
/apt.conf.d
/99dpkg
330 if ! command dpkg
--assert-multi-arch >/dev
/null
2>&1; then
331 echo "DPKG::options:: \"--force-architecture\";" # Added to test multiarch before dpkg is ready for it…
333 echo 'quiet::NoUpdate "true";'
334 echo 'quiet::NoStatistic "true";'
335 # too distracting for users, but helpful to detect changes
336 echo 'Acquire::Progress::Ignore::ShowErrorText "true";'
337 echo 'Acquire::Progress::Diffpercent "true";'
338 # in testcases, it can appear as if localhost has a rotation setup,
339 # hide this as we can't really deal with it properly
340 echo 'Acquire::Failure::ShowIP "false";'
343 cp "${TESTDIRECTORY}/apt.pem" "${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
344 if [ "$(id -u)" = '0' ]; then
345 chown _apt
:root
"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
347 echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir
/etc
/apt
/apt.conf.d
/99https
348 echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir
/etc
/apt
/apt.conf.d
/apt
-binary
349 configcompression
'.' 'gz' #'bz2' 'lzma' 'xz'
351 # create some files in /tmp and look at user/group to get what this means
352 TEST_DEFAULT_USER
="$USER"
353 if [ "$(uname)" = 'GNU/kFreeBSD' ]; then
354 TEST_DEFAULT_GROUP
='root'
356 TEST_DEFAULT_GROUP
="$USER"
359 # Acquire::AllowInsecureRepositories=false is not yet the default
360 # but we want it to be the default soon
361 configallowinsecurerepositories
"false";
363 # cleanup the environment a bit
364 # prefer our apt binaries over the system apt binaries
365 export PATH
="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
366 export LC_ALL
=C.UTF
-8
367 unset LANGUAGE APT_CONFIG
368 unset GREP_OPTIONS DEB_BUILD_PROFILES
373 if [ "$1" = "native" -o -z "$1" ]; then
374 eval `aptconfig shell ARCH APT::Architecture`
375 if [ -n "$ARCH" ]; then
378 dpkg
--print-architecture
386 aptconfig dump
--no-empty --format '%v%n' APT
::Architecture APT
::Architectures
| sort -u | tr '\n' ' '
389 getarchitecturesfromcommalist
() {
390 echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
393 configarchitecture
() {
395 echo "APT::Architecture \"$(getarchitecture $1)\";"
396 while [ -n "$1" ]; do
397 echo "APT::Architectures:: \"$(getarchitecture $1)\";"
400 } >rootdir
/etc
/apt
/apt.conf.d
/01multiarch.conf
405 if [ ! -e rootdir
/var
/lib
/dpkg
/status
]; then
406 local STATUSFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
407 if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
408 cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
410 echo -n > rootdir/var/lib/dpkg/status
413 rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
414 if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
415 local ARCHS="$(getarchitectures)"
416 if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
417 DPKGARCH="$(dpkg --print-architecture)"
418 for ARCH in ${ARCHS}; do
419 if [ "${ARCH}" != "${DPKGARCH}" ]; then
420 if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
421 # old-style used e.g. in Ubuntu-P – and as it seems travis
422 echo "DPKG
::options
:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
423 echo "DPKG
::options
:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
427 if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
428 # dpkg doesn't really check the version as long as it is fully installed,
429 # but just to be sure we choose one above the required version
430 insertinstalledpackage 'dpkg' "all
" '1.16.2+fake'
436 configdpkgnoopchroot() {
437 # create a library to noop chroot() and rewrite maintainer script executions
438 # via execvp() as used by dpkg as we don't want our rootdir to be a fullblown
439 # chroot directory dpkg could chroot into to execute the maintainer scripts
440 msgtest 'Building library to preload to make maintainerscript work in' 'dpkg'
441 cat << EOF > noopchroot.c
448 static char * chrootdir = NULL;
450 int chroot(const char *path) {
451 printf("WARNING
: CHROOTing to
%s was ignored
!\n", path);
453 chrootdir = strdup(path);
456 int execvp(const char *file, char *const argv[]) {
457 static int (*func_execvp) (const char *, char * const []) = NULL;
458 if (func_execvp == NULL)
459 func_execvp = (int (*) (const char *, char * const [])) dlsym(RTLD_NEXT, "execvp
");
460 if (chrootdir == NULL || strncmp(file, "/var
/lib
/dpkg
/", strlen("/var
/lib
/dpkg
/")) != 0)
461 return func_execvp(file, argv);
462 printf("REWRITE execvp call
%s into
%s
\n", file, chrootdir);
463 char newfile[strlen(chrootdir) + strlen(file)];
464 strcpy(newfile, chrootdir);
465 strcat(newfile, file);
466 char const * const baseadmindir = "/var
/lib
/dpkg
";
467 char admindir[strlen(chrootdir) + strlen(baseadmindir)];
468 strcpy(admindir, chrootdir);
469 strcat(admindir, baseadmindir);
470 setenv("DPKG_ADMINDIR
", admindir, 1);
471 return func_execvp(newfile, argv);
474 testsuccess --nomsg gcc -fPIC -shared -o noopchroot.so noopchroot.c -ldl
477 configallowinsecurerepositories() {
478 echo "Acquire
::AllowInsecureRepositories
\"$1\";" > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf
482 configcompression() {
483 while [ -n "$1" ]; do
485 '.') printf ".
\t.
\tcat
\n";;
486 'gz') printf "gzip\tgz
\tgzip
\n";;
487 'bz2') printf "bzip2\tbz
2\tbzip
2\n";;
488 'lzma') printf "lzma
\tlzma
\txz
--format=lzma
\n";;
489 'xz') printf "xz
\txz
\txz
\n";;
490 *) printf "$1\t$1\t$1\n";;
493 done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
500 gzip) COMPRESS='gz';;
501 bzip2) COMPRESS='bz2';;
502 lzma) COMPRESS='lzma';;
504 *) msgdie "Compressor
$COMPRESSOR is unknown to framework
, so can
't be forced by forcecompressor!";;
506 local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
507 echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
508 Dir::Bin::uncompressed \"/does/not/exist\";
509 Dir::Bin::gzip \"/does/not/exist\";
510 Dir::Bin::bzip2 \"/does/not/exist\";
511 Dir::Bin::lzma \"/does/not/exist\";
512 Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
513 if [ -e "/bin/${COMPRESSOR}" ]; then
514 echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
515 elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
516 echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
517 elif [ "${COMPRESSOR}" = 'lzma
' ]; then
518 echo 'Dir
::Bin
::xz
"/usr/bin/xz";' >> "$CONFFILE"
519 COMPRESSOR_CMD='xz
--format=lzma
'
521 msgtest 'Test
for availability of compressor
' "${COMPRESSOR}"
522 msgfail "${COMPRESSOR} not available"
526 setupsimplenativepackage() {
530 local RELEASE="${4:-unstable}"
531 local DEPENDENCIES="$5"
532 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
533 If you find such a package installed on your system,
534 something went horribly wrong! They are autogenerated
535 und used only by testcases and surf no other propose…"}"
537 local SECTION="${7:-others}"
539 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
542 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
544 local BUILDDIR=incoming/${NAME}-${VERSION}
545 mkdir -p ${BUILDDIR}/debian/source
547 echo "* most suckless software product ever" > FEATURES
548 test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
549 test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
553 -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog
554 test -e debian/control || echo "Source: $NAME
557 Maintainer: Joe Sixpack <joe@example.org>
558 Build-Depends: debhelper (>= 7)
559 Standards-Version: 3.9.1
561 Package: $NAME" > debian/control
562 if [ "$ARCH" = 'all
' ]; then
563 echo "Architecture: all" >> debian/control
565 echo "Architecture: any" >> debian/control
567 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
568 echo "Description: $DESCRIPTION" >> debian/control
570 test -e debian/compat || echo "7" > debian/compat
571 test -e debian/source/format || echo "3.0 (native)" > debian/source/format
572 test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
576 buildsimplenativepackage() {
579 if [ "$(echo "$NAME" | cut -c 1-3)" = 'lib
' ]; then
580 NM="$(echo "$NAME" | cut -c 1-4)"
582 NM="$(echo "$NAME" | cut -c 1)"
586 local RELEASE="${4:-unstable}"
587 local DEPENDENCIES="$5"
588 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
589 If you find such a package installed on your system,
590 something went horribly wrong! They are autogenerated
591 und used only by testcases and surf no other propose…"}"
593 local SECTION="${7:-others}"
594 local PRIORITY="${8:-optional}"
596 local COMPRESS_TYPE="${10:-gzip}"
598 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
601 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
603 local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
605 msgtest "Build source package in version ${VERSION} for ${RELEASE} in ${DISTSECTION}" "$NAME"
606 mkdir -p $BUILDDIR/debian/source
607 echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
609 echo '$NAME says
\"Hello
!\"'" > ${BUILDDIR}/${NAME}
611 echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright
612 echo "$NAME ($VERSION) $RELEASE; urgency=low
616 -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog
619 Maintainer: Joe Sixpack <joe@example.org>
620 Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control
621 if [ "$SECTION" != '<none
>' ]; then
622 echo "Section: $SECTION" >> ${BUILDDIR}/debian/control
624 local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
625 test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
627 Package: $NAME" >> ${BUILDDIR}/debian/control
629 if [ "$ARCH" = 'all
' ]; then
630 echo "Architecture: all" >> ${BUILDDIR}/debian/control
632 echo "Architecture: any" >> ${BUILDDIR}/debian/control
634 local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
635 test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
636 echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control
638 echo '3.0 (native
)' > ${BUILDDIR}/debian/source/format
640 testsuccess --nomsg dpkg-source -b ${NAME}-${VERSION}
642 sed -n 's
#^dpkg-source: info: building [^ ]\+ in ##p' ${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output \
644 echo "pool/${SRC}" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.srclist
645 # if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
646 # aptkey --keyring ./keys/joesixpack.pub --secret-keyring ./keys/joesixpack.sec --quiet --readonly \
647 # adv --yes --default-key 'Joe Sixpack' \
648 # --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
649 # mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
653 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
654 msgtest
"Build binary package for ${RELEASE} in ${SECTION}" "$NAME"
655 rm -rf ${BUILDDIR}/debian
/tmp
656 mkdir -p ${BUILDDIR}/debian
/tmp
/DEBIAN
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
657 cp ${BUILDDIR}/debian
/copyright
${BUILDDIR}/debian
/changelog
${BUILDDIR}/FEATURES
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME}
658 cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
/${NAME}-${arch}
659 if [ -n "$FILE_TREE" ]; then
660 cp -ar "$FILE_TREE" ${BUILDDIR}/debian
/tmp
663 (cd ${BUILDDIR}; dpkg
-gencontrol -DArchitecture=$arch)
664 (cd ${BUILDDIR}/debian
/tmp
; md5sum $(find usr/ -type f) > DEBIAN
/md5sums
)
665 local LOG
="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log"
666 # ensure the right permissions as dpkg-deb insists
667 chmod 755 ${BUILDDIR}/debian
/tmp
/DEBIAN
668 testsuccess
--nomsg dpkg
-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian
/tmp
${BUILDDIR}/..
669 echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.pkglist
672 local CHANGEPATH
="${BUILDDIR}/../${DISTSECTION}/${NM}/${NAME}/${NAME}_${VERSION}"
674 cp ${BUILDDIR}/debian
/changelog
$CHANGEPATH
683 local ARCH
=$(getarchitecture $4)
684 local PKGNAME
="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
685 local BUILDLOG
="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
686 msgtest
"Build package for ${RELEASE} in ${SECTION}" "$PKGNAME"
688 if [ "$ARCH" = "all" ]; then
689 ARCH
="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
691 testsuccess
--nomsg dpkg
-buildpackage -uc -us -a$ARCH
692 cp ${TMPWORKINGDIRECTORY}/rootdir
/tmp
/testsuccess.output
$BUILDLOG
693 local PKGS
="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
694 local SRCS
="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
697 echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.pkglist
700 echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.srclist
705 if [ -d incoming
]; then
706 buildaptarchivefromincoming
"$@"
708 buildaptarchivefromfiles
"$@"
712 createaptftparchiveconfig
() {
713 local COMPRESSORS
="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
714 local COMPRESSORS
="${COMPRESSORS%* }"
715 local ARCHS
="$(getarchitectures)"
717 ArchiveDir "' >> ftparchive.conf
718 echo -n $(readlink -f .) >> ftparchive.conf
720 CacheDir "' >> ftparchive.conf
721 echo -n $(readlink -f ..) >> ftparchive.conf
723 FileListDir "' >> ftparchive.conf
724 echo -n $(readlink -f pool/) >> ftparchive.conf
728 Packages::Compress "'"$COMPRESSORS"'";
729 Sources::Compress "'"$COMPRESSORS"'";
730 Contents::Compress "'"$COMPRESSORS"'";
731 Translation::Compress "'"$COMPRESSORS"'";
732 LongDescription "false";
736 SrcDirectory "pool/";
742 Label "apttestcases";
744 Description "repository with dummy packages";
745 Architectures "' >> ftparchive.conf
746 echo -n "$ARCHS" >> ftparchive.conf
750 };' >> ftparchive.conf
751 for DIST
in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
752 echo -n 'tree "dists/' >> ftparchive.conf
753 echo -n "$DIST" >> ftparchive.conf
755 Architectures "' >> ftparchive.conf
756 echo -n "$ARCHS" >> ftparchive.conf
758 FileList "' >> ftparchive.conf
759 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
761 SourceFileList "' >> ftparchive.conf
762 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
764 Sections "' >> ftparchive.conf
765 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
767 };' >> ftparchive.conf
771 buildaptftparchivedirectorystructure
() {
772 local DISTS
="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
773 for DIST
in $DISTS; do
774 local SECTIONS
="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
775 for SECTION
in $SECTIONS; do
776 local ARCHS
="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
777 for ARCH
in $ARCHS; do
778 mkdir -p dists
/${DIST}/${SECTION}/binary
-${ARCH}
780 mkdir -p dists
/${DIST}/${SECTION}/source
781 mkdir -p dists
/${DIST}/${SECTION}/i18n
791 local DEPENDENCIES
="$5"
792 local PRIORITY
="${6:-optional}"
793 local DESCRIPTION
="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASES}
794 If you find such a package installed on your system,
795 something went horribly wrong! They are autogenerated
796 und used only by testcases and surf no other propose…"}"
798 for RELEASE in $(printf '%s' "$RELEASES" | tr ',' '\n'); do
799 if [ "$RELEASE" = 'installed' ]; then
800 insertinstalledpackage "$2" "$3" "$4" "$5" "$6" "$7"
803 for arch in $(getarchitecturesfromcommalist "$ARCH"); do
804 if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
805 ARCHS="$(getarchitectures)"
809 for BUILDARCH in $ARCHS; do
810 local PPATH="aptarchive
/dists
/${RELEASE}/main
/binary
-${BUILDARCH}"
812 local FILE="${PPATH}/Packages
"
817 Maintainer
: Joe Sixpack
<joe@example.org
>" >> $FILE
818 test "$arch" = 'none' || echo "Architecture
: $arch" >> $FILE
819 echo "Version
: $VERSION
820 Filename
: pool
/main
/${NAME}/${NAME}_
${VERSION}_
${arch}.deb
" >> $FILE
821 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
822 echo "Description
: $(printf '%s' "$DESCRIPTION" | head -n 1)" >> $FILE
823 echo "Description
-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)" >> $FILE
827 mkdir -p aptarchive/dists/${RELEASE}/main/source aptarchive/dists/${RELEASE}/main/i18n
828 touch aptarchive/dists/${RELEASE}/main/source/Sources
830 Description
-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)
831 Description
-en: $DESCRIPTION
832 " >> aptarchive/dists/${RELEASE}/main/i18n/Translation-en
841 local DEPENDENCIES="$5"
842 local BINARY="${6:-$NAME}"
844 local SPATH="aptarchive
/dists
/${RELEASE}/main
/source"
846 local FILE="${SPATH}/Sources
"
847 local DSCFILE="${NAME}_
${VERSION}.dsc
"
848 local TARFILE="${NAME}_
${VERSION}.
tar.gz
"
852 Maintainer
: Joe Sixpack
<joe@example.org
>
853 Architecture
: $ARCH" >> $FILE
854 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
856 $(echo -n "$DSCFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) $DSCFILE
857 $(echo -n "$TARFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) $TARFILE
859 $(echo -n "$DSCFILE" | sha256sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) $DSCFILE
860 $(echo -n "$TARFILE" | sha256sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) $TARFILE
864 insertinstalledpackage() {
868 local DEPENDENCIES="$4"
869 local PRIORITY="${5:-optional}"
870 local STATUS="${6:-install ok installed}"
871 local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
872 If you
find such a package installed on your system
,
873 something went horribly wrong
! They are autogenerated
874 und used only by testcases and surf no other propose…
"}"
876 local FILE
='rootdir/var/lib/dpkg/status'
877 local INFO
='rootdir/var/lib/dpkg/info'
878 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
884 Maintainer: Joe Sixpack <joe@example.org>
885 Version: $VERSION" >> $FILE
886 test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
887 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
888 echo "Description: $DESCRIPTION" >> $FILE
890 if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
891 echo -n > ${INFO}/${NAME}:${arch}.list
893 echo -n > ${INFO}/${NAME}.list
899 buildaptarchivefromincoming
() {
900 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
902 [ -e pool
] || ln -s ..
/incoming pool
903 [ -e ftparchive.conf
] || createaptftparchiveconfig
904 [ -e dists
] || buildaptftparchivedirectorystructure
905 msgninfo
"\tGenerate Packages, Sources and Contents files… "
906 testsuccess aptftparchive generate ftparchive.conf
909 generatereleasefiles
"$@"
912 buildaptarchivefromfiles
() {
913 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
914 local DIR
='aptarchive'
915 if [ -d "${DIR}/dists" ]; then DIR
="${DIR}/dists"; fi
916 find "$DIR" -name 'Packages' -o -name 'Sources' -o -name 'Translation-*' | while read line
; do
917 msgninfo
"\t${line} file… "
918 compressfile
"$line" "$1"
921 generatereleasefiles
"$@"
925 cat ${TMPWORKINGDIRECTORY}/rootdir
/etc
/testcase
-compressor.conf
| while read compressor extension
command; do
926 if [ "$compressor" = '.' ]; then
932 cat "$1" | $command > "${1}.${extension}"
934 touch -d "$2" "${1}.${extension}"
939 # can be overridden by testcases for their pleasure
940 getcodenamefromsuite
() {
942 unstable
) echo 'sid';;
946 getreleaseversionfromsuite
() { true
; }
947 getlabelfromsuite
() { true
; }
948 getoriginfromsuite
() { true
; }
950 generatereleasefiles
() {
951 # $1 is the Date header and $2 is the ValidUntil header to be set
952 # both should be given in notation date/touch can understand
953 msgninfo
"\tGenerate Release files… "
954 if [ -e aptarchive
/dists
]; then
955 for dir
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
956 local SUITE
="$(echo "$dir" | cut -d'/' -f 4)"
957 local CODENAME
="$(getcodenamefromsuite $SUITE)"
958 local VERSION
="$(getreleaseversionfromsuite $SUITE)"
959 local LABEL
="$(getlabelfromsuite $SUITE)"
960 local ORIGIN
="$(getoriginfromsuite $SUITE)"
961 if [ -n "$VERSION" ]; then
962 VERSION
="-o APT::FTPArchive::Release::Version=${VERSION}"
964 if [ -n "$LABEL" ]; then
965 LABEL
="-o APT::FTPArchive::Release::Label=${LABEL}"
967 if [ -n "$ORIGIN" ]; then
968 ORIGIN
="-o APT::FTPArchive::Release::Origin=${ORIGIN}"
970 aptftparchive
-qq release
$dir \
971 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
972 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
976 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
977 if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
979 NotAutomatic: yes' $dir/Release
981 if [ -n "$1" -a "$1" != "now" ]; then
982 sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
986 Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
990 aptftparchive
-qq release .
/aptarchive
| sed -e '/0 Release$/ d' > aptarchive
/Release
# remove the self reference
992 if [ -n "$1" -a "$1" != "now" ]; then
993 for release
in $(find ./aptarchive -name 'Release'); do
994 touch -d "$1" $release
1000 setupdistsaptarchive
() {
1001 local APTARCHIVE
=$(readlink -f ./aptarchive)
1002 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb.list
1003 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb-src.list
1004 for DISTS
in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
1005 SECTIONS
=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
1006 msgninfo
"\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
1007 echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb.list
1008 echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb-src.list
1013 setupflataptarchive
() {
1014 local APTARCHIVE
=$(readlink -f ./aptarchive)
1015 if [ -f ${APTARCHIVE}/Packages
]; then
1016 msgninfo
"\tadd deb sources.list line… "
1017 echo "deb file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
1020 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
1022 if [ -f ${APTARCHIVE}/Sources
]; then
1023 msgninfo
"\tadd deb-src sources.list line… "
1024 echo "deb-src file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
1027 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
1033 if [ "$1" = '--no-update' ]; then
1037 buildaptarchive
"$@"
1038 if [ -e aptarchive
/dists
]; then
1039 setupdistsaptarchive
1043 signreleasefiles
'Joe Sixpack'
1044 if [ "1" != "$NOUPDATE" ]; then
1045 testsuccess aptget update
-o Debug
::pkgAcquire
::Worker
=true
-o Debug
::Acquire
::gpgv
=true
1049 signreleasefiles
() {
1050 local SIGNER
="${1:-Joe Sixpack}"
1051 local REPODIR
="${2:-aptarchive}"
1052 local KEY
="keys/$(echo "$SIGNER" | tr 'A-Z' 'a-z' | sed 's# ##g')"
1053 local GPG
="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes"
1054 msgninfo
"\tSign archive with $SIGNER key $KEY… "
1055 local REXKEY
='keys/rexexpired'
1056 local SECEXPIREBAK
="${REXKEY}.sec.bak"
1057 local PUBEXPIREBAK
="${REXKEY}.pub.bak"
1058 if [ "${SIGNER}" = 'Rex Expired' ]; then
1059 # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
1060 # option doesn't exist anymore (and using faketime would add a new obscure dependency)
1061 # therefore we 'temporary' make the key not expired and restore a backup after signing
1062 cp ${REXKEY}.sec
$SECEXPIREBAK
1063 cp ${REXKEY}.pub
$PUBEXPIREBAK
1064 local SECUNEXPIRED
="${REXKEY}.sec.unexpired"
1065 local PUBUNEXPIRED
="${REXKEY}.pub.unexpired"
1066 if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
1067 cp $SECUNEXPIRED ${REXKEY}.sec
1068 cp $PUBUNEXPIRED ${REXKEY}.pub
1070 if ! printf "expire\n1w\nsave\n" | $GPG --default-key "$SIGNER" --command-fd 0 --edit-key "${SIGNER}" >setexpire.gpg
2>&1; then
1074 cp ${REXKEY}.sec
$SECUNEXPIRED
1075 cp ${REXKEY}.pub
$PUBUNEXPIRED
1078 for RELEASE
in $(find ${REPODIR}/ -name Release); do
1079 $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg
${RELEASE}
1080 local INRELEASE
="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
1081 $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
1082 # we might have set a specific date for the Release file, so copy it
1083 touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg
${INRELEASE}
1085 if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
1086 mv -f $SECEXPIREBAK ${REXKEY}.sec
1087 mv -f $PUBEXPIREBAK ${REXKEY}.pub
1092 redatereleasefiles
() {
1093 local DATE
="$(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')"
1094 for release
in $(find aptarchive/ -name 'Release'); do
1095 sed -i "s/^Date: .*$/Date: ${DATE}/" $release
1096 touch -d "$DATE" $release
1098 signreleasefiles
"${2:-Joe Sixpack}"
1102 local WEBSERVER
="${3:-http://localhost:8080}"
1104 if [ "$1" = '--no-check' ]; then
1108 local DOWNLOG
='rootdir/tmp/download-testfile.log'
1109 local STATUS
='downloaded/webserverconfig.status'
1110 rm -f "$STATUS" "$DOWNLOG"
1112 if [ -n "$2" ]; then
1113 msgtest
"Set webserver config option '${1}' to" "$2"
1114 URI
="${WEBSERVER}/_config/set/${1}/${2}"
1116 msgtest
'Clear webserver config option' "${1}"
1117 URI
="${WEBSERVER}/_config/clear/${1}"
1119 if downloadfile
"$URI" "$STATUS" > "$DOWNLOG"; then
1122 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/webserverconfig.output"
1123 cat "$DOWNLOG" "$STATUS" >"$OUTPUT" 2>&1 || true
1124 msgfailoutput
'' "$OUTPUT"
1126 $NOCHECK || testwebserverlaststatuscode
'200'
1129 rewritesourceslist
() {
1130 local APTARCHIVE
="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
1131 for LIST
in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
1132 sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#https://localhost:4433/#${1}#"
1136 # wait for up to 10s for a pid file to appear to avoid possible race
1137 # when a helper is started and dosn't write the PID quick enough
1140 for i
in $(seq 10); do
1141 if test -s "$PIDFILE"; then
1146 msgdie
"waiting for $PIDFILE failed"
1150 changetowebserver
() {
1151 if [ "$1" != '--no-rewrite' ]; then
1152 rewritesourceslist
'http://localhost:8080/'
1156 if test -x ${APTWEBSERVERBINDIR}/aptwebserver
; then
1158 local LOG
="webserver.log"
1159 if ! aptwebserver
-o aptwebserver
::fork
=1 "$@" >$LOG 2>&1 ; then
1163 waitforpidfile aptwebserver.pid
1164 local PID
="$(cat aptwebserver.pid)"
1165 if [ -z "$PID" ]; then
1166 msgdie
'Could not fork aptwebserver successfully'
1168 addtrap
"kill $PID;"
1171 msgdie
'You have to build aptwerbserver or install a webserver'
1175 changetohttpswebserver
() {
1176 if ! which stunnel4
>/dev
/null
; then
1177 msgdie
'You need to install stunnel4 for https testcases'
1179 if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
1180 changetowebserver
--no-rewrite "$@"
1182 echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
1183 cert = ${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem
1189 " > ${TMPWORKINGDIRECTORY}/stunnel.conf
1190 stunnel4
"${TMPWORKINGDIRECTORY}/stunnel.conf"
1191 waitforpidfile
"${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
1192 local PID
="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
1193 if [ -z "$PID" ]; then
1194 msgdie
'Could not fork stunnel4 successfully'
1196 addtrap
'prefix' "kill ${PID};"
1197 rewritesourceslist
'https://localhost:4433/'
1201 mkdir -p rootdir
/media
/cdrom
/.disk
1202 local CD
="$(readlink -f rootdir/media/cdrom)"
1203 echo "acquire::cdrom::mount \"${CD}\";
1204 acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
1205 acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
1206 acquire::cdrom::autodetect 0;" > rootdir
/etc
/apt
/apt.conf.d
/00cdrom
1207 echo -n "$1" > ${CD}/.disk
/info
1208 if [ ! -d aptarchive
/dists
]; then
1209 msgdie
'Flat file archive cdroms can not be created currently'
1212 mv aptarchive
/dists
"$CD"
1213 ln -s "$(readlink -f ./incoming)" $CD/pool
1214 find rootdir
/etc
/apt
/sources.list.d
/ -name 'apt-test-*.list' -delete
1215 # start with an unmounted disk
1216 mv "${CD}" "${CD}-unmounted"
1217 # we don't want the disk to be modifiable
1218 addtrap
'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
1219 chmod -R 555 rootdir
/media
/cdrom
-unmounted/dists
1223 local PROTO
="${1%%:*}"
1224 if ! apthelper
-o Debug
::Acquire
::${PROTO}=1 -o Debug
::pkgAcquire
::Worker
=1 \
1225 download
-file "$1" "$2" "$3" 2>&1 ; then
1228 # only if the file exists the download was successful
1229 if [ -r "$2" ]; then
1237 local DIFFTEXT
="$(command diff -u "$@" 2>&1 | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
1238 if [ -n "$DIFFTEXT" ]; then
1240 echo >&2 "$DIFFTEXT"
1248 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testoutputequal.output"
1249 local COMPAREFILE
="$1"
1251 if "$@" 2>&1 | checkdiff
$COMPAREFILE - >"$OUTPUT" 2>&1; then
1254 echo "=== content of file we compared with (${COMPAREFILE}) ===" >>"${OUTPUT}"
1255 cat "$COMPAREFILE" >>"${OUTPUT}"
1256 msgfailoutput
'' "$OUTPUT" "$@"
1262 local MSG
='Test for correctness of file'
1263 if [ "$1" = '--nomsg' ]; then
1269 if [ -n "$MSG" ]; then
1270 msgtest
"$MSG" "$FILE"
1272 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfileequal.output"
1273 if [ -z "$*" ]; then
1274 testoutputequal
"$FILE" echo -n ''
1276 testoutputequal
"$FILE" echo "$*"
1283 msgtest
"Test for no output of" "$*"
1284 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
1285 if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
1288 msgfailoutput
'' "$COMPAREFILE" "$@"
1290 aptautotest
'testempty' "$@"
1296 local MSG
='Test of equality of'
1297 if [ "$1" = '--nomsg' ]; then
1302 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile"
1303 echo "$1" > $COMPAREFILE
1306 if [ -n "$MSG" ]; then
1309 testoutputequal
"$COMPAREFILE" "$@"
1310 aptautotest
'testequal' "$@"
1316 local COMPAREFILE1
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
1317 local COMPAREFILE2
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
1318 local COMPAREAGAINST
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
1319 echo "$1" > $COMPAREFILE1
1320 echo "$2" > $COMPAREFILE2
1322 msgtest
"Test for equality OR of" "$*"
1323 "$@" >$COMPAREAGAINST 2>&1 || true
1324 if checkdiff
$COMPAREFILE1 $COMPAREAGAINST >/dev
/null
2>&1 || \
1325 checkdiff
$COMPAREFILE2 $COMPAREAGAINST >/dev
/null
2>&1
1329 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.output"
1330 echo -n "\n${CINFO}Diff against OR 1${CNORMAL}" >"$OUTPUT" 2>&1
1331 checkdiff
"$COMPAREFILE1" "$COMPAREAGAINST" >"$OUTPUT" 2>&1 || true
1332 echo -n "${CINFO}Diff against OR 2${CNORMAL}" >"$OUTPUT" 2>&1
1333 checkdiff
"$COMPAREFILE2" "$COMPAREAGAINST" >"$OUTPUT" 2>&1 || true
1334 msgfailoutput
'' "$OUTPUT"
1336 aptautotest
'testequalor2' "$@"
1342 local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual"
1345 while [ -n "$1" ]; do
1347 N: Can't select versions from package '$1' as it is purely virtual"
1348 PACKAGE
="${PACKAGE} $1"
1351 msgtest
"Test for virtual packages" "apt-cache show $PACKAGE"
1353 N: No packages found"
1354 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile"
1355 local ARCH
="$(getarchitecture 'native')"
1356 echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' >"$COMPAREFILE"
1357 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.output"
1358 testoutputequal
"$COMPAREFILE" aptcache show
-q=0 "$PACKAGE"
1364 msgtest
"Test for non-existent packages" "apt-cache show $*"
1365 local SHOWPKG
="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
1366 if [ -n "$SHOWPKG" ]; then
1367 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testnopackage.output"
1368 echo "$SHOWPKG" >"$OUTPUT"
1369 msgfailoutput
'' "$OUTPUT"
1381 msgtest
"Test that $NR package(s) are in state $STATE with" "dpkg -l $*"
1382 local PKGS
="$(dpkg -l "$@" 2>/dev/null | grep "^${STATE}" | wc -l)"
1383 if [ "$PKGS" != $NR ]; then
1384 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testnopackage.output"
1385 echo "$PKGS" >"$OUTPUT"
1386 dpkg
-l "$@" | grep '^[a-z]' >"$OUTPUT" >&2 || true
1387 msgfailoutput
'' "$OUTPUT"
1394 testdpkginstalled
() {
1396 testdpkgstatus
'ii' "$#" "$@"
1400 testdpkgnotinstalled
() {
1402 testdpkgstatus
'ii' '0' "$@"
1408 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
1409 if [ -n "$1" ]; then
1410 msgtest
'Test for correctly marked as auto-installed' "$*"
1411 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1413 msgtest
'Test for correctly marked as auto-installed' 'no package'
1414 echo -n > $COMPAREFILE
1416 testoutputequal
"$COMPAREFILE" aptmark showauto
1419 testmarkedmanual
() {
1421 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.comparefile"
1422 if [ -n "$1" ]; then
1423 msgtest
'Test for correctly marked as manually installed' "$*"
1424 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1426 msgtest
'Test for correctly marked as manually installed' 'no package'
1427 echo -n > $COMPAREFILE
1429 testoutputequal
"$COMPAREFILE" aptmark showmanual
1434 if [ -n "$MSGTEST_MSG" ]; then
1436 if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
1437 echo "${CFAIL}Part of the test group: $MSGTEST_GRP"
1439 echo -n "$MSGTEST_MSG"
1445 if [ "$1" = 'grep' ]; then
1447 while [ -n "$2" ]; do shift; done
1448 echo "#### Complete file: $1 ####"
1449 cat >&2 "$1" || true
1450 echo '#### grep output ####'
1451 elif [ "$1" = 'test' ]; then
1453 # doesn't support ! or non-file flags
1454 msgfailoutputstatfile
() {
1455 local FILEFLAGS
='^-[bcdefgGhkLOprsStuwx]$'
1456 if expr match
"$1" "$FILEFLAGS" >/dev
/null
; then
1457 echo "#### stat(2) of file: $2 ####"
1461 msgfailoutputstatfile
"$2" "$3"
1462 while [ -n "$5" ] && [ "$4" = '-o' -o "$4" = '-a' ]; do
1464 msgfailoutputstatfile
"$2" "$3"
1466 echo '#### test output ####'
1474 if [ "$1" = '--nomsg' ]; then
1477 msgtest
'Test for successful execution of' "$*"
1479 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
1480 if "$@" >${OUTPUT} 2>&1; then
1481 if expr match
"$1" '^apt.*' >/dev
/null
; then
1482 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1483 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1484 elif grep -E '^[WE]: ' "$OUTPUT" > "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" 2>&1; then
1485 if [ "$IGNORE_PTY_NOT_MOUNTED" = '1' ]; then
1486 if echo 'E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory)' \
1487 | cmp - "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" >/dev
/null
2>&1; then
1490 msgfailoutput
'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
1493 msgfailoutput
'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
1503 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1505 aptautotest
'testsuccess' "$@"
1510 if [ "$1" = '--nomsg' ]; then
1513 msgtest
'Test for successful execution with warnings of' "$*"
1515 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output"
1516 if "$@" >${OUTPUT} 2>&1; then
1517 if expr match
"$1" '^apt.*' >/dev
/null
; then
1518 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1519 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1520 elif grep -q -E '^E: ' "$OUTPUT"; then
1521 msgfailoutput
'successful run, but output contains errors' "$OUTPUT" "$@"
1522 elif ! grep -q -E '^W: ' "$OUTPUT"; then
1523 msgfailoutput
'successful run, but output contains no warnings' "$OUTPUT" "$@"
1532 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1534 aptautotest
'testwarning' "$@"
1539 if [ "$1" = '--nomsg' ]; then
1542 msgtest
'Test for failure in execution of' "$*"
1544 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
1545 if "$@" >${OUTPUT} 2>&1; then
1547 msgfailoutput
"exitcode $EXITCODE" "$OUTPUT" "$@"
1550 if expr match
"$1" '^apt.*' >/dev
/null
; then
1551 if [ "$1" = 'aptkey' ]; then
1552 if grep -q -E " Can't check signature: " "$OUTPUT" || \
1553 grep -q -E " BAD signature from " "$OUTPUT"; then
1556 msgfailoutput
"run failed with exitcode ${EXITCODE}, but no signature error" "$OUTPUT" "$@"
1559 if grep -q -E ' runtime error: ' "$OUTPUT"; then
1560 msgfailoutput
'compiler detected undefined behavior' "$OUTPUT" "$@"
1561 elif grep -q -E '==ERROR' "$OUTPUT"; then
1562 msgfailoutput
'compiler sanitizers reported errors' "$OUTPUT" "$@"
1563 elif ! grep -q -E '^E: ' "$OUTPUT"; then
1564 msgfailoutput
"run failed with exitcode ${EXITCODE}, but with no errors" "$OUTPUT" "$@"
1573 aptautotest
'testfailure' "$@"
1577 testsuccessequal
() {
1582 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" "$CMP"
1585 testwarningequal
() {
1590 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testwarning.output" "$CMP"
1593 testfailureequal
() {
1598 testfileequal
"${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" "$CMP"
1607 msgtest
'Check that the output of the previous failed command has expected' 'failures and warnings'
1608 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailuremsg.comparefile"
1609 grep '^\(W\|E\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "$COMPAREFILE" 2>&1 || true
1610 testoutputequal
"$COMPAREFILE" echo "$CMP"
1616 msgtest
"Test that file $1 has $2 $3" "$4"
1617 if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
1620 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfilestats.output"
1623 echo -n "stat(1) reports for $2: "
1624 stat
--format "$2" "$1" || true
1626 msgfailoutput
'' "$OUTPUT"
1630 testaccessrights
() {
1632 testfilestats
"$1" '%a' '=' "$2"
1636 testwebserverlaststatuscode
() {
1638 local DOWNLOG
='rootdir/tmp/webserverstatus-testfile.log'
1639 local STATUS
='downloaded/webserverstatus-statusfile.log'
1640 rm -f "$DOWNLOG" "$STATUS"
1641 msgtest
'Test last status code from the webserver was' "$1"
1642 if downloadfile
"http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" && [ "$(cat "$STATUS")" = "$1" ]; then
1645 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testwebserverlaststatuscode.output"
1647 if [ -n "$2" ]; then
1649 echo >&2 '#### Additionally provided output files contain:'
1652 echo >&2 '#### Download log of the status code:'
1655 msgfailoutput
"Status was $(cat "$STATUS")" "$OUTPUT"
1661 echo "STOPPED execution. Press enter to continue"
1666 listcurrentlistsdirectory
() {
1668 find rootdir
/var
/lib
/apt
/lists
-maxdepth 1 -type d
| while read line
; do
1669 stat
--format '%U:%G:%a:%n' "$line"
1671 find rootdir
/var
/lib
/apt
/lists
-maxdepth 1 \
! -type d
| while read line
; do
1672 stat
--format '%U:%G:%a:%s:%y:%n' "$line"
1677 ### convenience hacks ###
1679 # creating some directories by hand is a tedious task, so make it look simple
1680 if [ "$*" = '-p rootdir/var/lib/apt/lists' ] || [ "$*" = "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" ] ||
1681 [ "$*" = '-p rootdir/var/lib/apt/lists/partial' ] || [ "$*" = "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" ]; then
1682 # only the last directory created by mkdir is effected by the -m !
1683 command mkdir -m 755 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt"
1684 command mkdir -m 755 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"
1685 command mkdir -m 700 -p "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial"
1686 touch "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/lock"
1687 if [ "$(id -u)" = '0' ]; then
1688 chown _apt
:root
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial"
1695 ### The following tests are run by most test methods automatically to check
1696 ### general things about commands executed without writing the test every time.
1702 local AUTOTEST
="aptautotest_$(basename "$CMD" | tr -d '-')_$(echo "$FIRSTOPT" | tr -d '-')"
1703 if command -v $AUTOTEST >/dev
/null
; then
1705 # save and restore the *.output files from other tests
1706 # as we might otherwise override them in these automatic tests
1707 rm -rf ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before
1708 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before
1709 mkdir ${TMPWORKINGDIRECTORY}/rootdir
/tmp
1710 $AUTOTEST "$TESTCALL" "$@"
1711 rm -rf ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-aptautotest
1712 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
${TMPWORKINGDIRECTORY}/rootdir
/tmp
-aptautotest
1713 mv ${TMPWORKINGDIRECTORY}/rootdir
/tmp
-before ${TMPWORKINGDIRECTORY}/rootdir
/tmp
1717 aptautotest_aptget_update
() {
1719 while [ -n "$2" ]; do
1720 if [ "$2" = '--print-uris' ]; then return; fi # simulation mode
1723 if ! test -d "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"; then return; fi
1724 testfilestats
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:755"
1725 testfilestats
"${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:755"
1726 # all copied files are properly chmodded
1727 for file in $(find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" -type f ! -name 'lock'); do
1728 testfilestats
"$file" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:644"
1730 if [ "$TESTCALL" = 'testsuccess' ]; then
1731 # failure cases can retain partial files and such
1732 testempty
find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists/partial" -mindepth 1 ! \
( -name 'lock' -o -name '*.FAILED' \
)
1735 aptautotest_apt_update
() { aptautotest_aptget_update
"$@"; }
1736 aptautotest_aptcdrom_add
() { aptautotest_aptget_update
"$@"; }
1738 testaptautotestnodpkgwarning
() {
1740 while [ -n "$2" ]; do
1741 if expr match
"$2" '^-[a-z]*s' >/dev
/null
2>&1; then return; fi # simulation mode
1742 if expr match
"$2" '^-dy\?' >/dev
/null
2>&1; then return; fi # download-only mode
1745 testfailure
grep '^dpkg: warning:.*ignor.*' "${TMPWORKINGDIRECTORY}/rootdir/tmp-before/${TESTCALL}.output"
1748 aptautotest_aptget_install
() { testaptautotestnodpkgwarning
"$@"; }
1749 aptautotest_aptget_remove
() { testaptautotestnodpkgwarning
"$@"; }
1750 aptautotest_aptget_purge
() { testaptautotestnodpkgwarning
"$@"; }
1751 aptautotest_apt_install
() { testaptautotestnodpkgwarning
"$@"; }
1752 aptautotest_apt_remove
() { testaptautotestnodpkgwarning
"$@"; }
1753 aptautotest_apt_purge
() { testaptautotestnodpkgwarning
"$@"; }