1 #!/bin/sh -- # no runable script, just for vi
5 # we all like colorful messages
6 if [ "$MSGCOLOR" != 'NO' ]; then
7 if [ ! -t 1 ]; then # but check that we output to a terminal
13 if [ "$MSGCOLOR" != 'NO' ]; then
14 CERROR
="\033[1;31m" # red
15 CWARNING
="\033[1;33m" # yellow
16 CMSG
="\033[1;32m" # green
17 CINFO
="\033[1;96m" # light blue
18 CDEBUG
="\033[1;94m" # blue
19 CNORMAL
="\033[0;39m" # default system console color
20 CDONE
="\033[1;32m" # green
21 CPASS
="\033[1;32m" # green
22 CFAIL
="\033[1;31m" # red
23 CCMD
="\033[1;35m" # pink
26 msgdie
() { printf "${CERROR}E: $1${CNORMAL}\n" >&2; exit 1; }
27 msgwarn
() { printf "${CWARNING}W: $1${CNORMAL}\n" >&2; }
28 msgmsg
() { printf "${CMSG}$1${CNORMAL}\n"; }
29 msginfo
() { printf "${CINFO}I: $1${CNORMAL}\n"; }
30 msgdebug
() { printf "${CDEBUG}D: $1${CNORMAL}\n"; }
31 msgdone
() { printf "${CDONE}DONE${CNORMAL}\n"; }
32 msgnwarn
() { printf "${CWARNING}W: $1${CNORMAL}" >&2; }
33 msgnmsg
() { printf "${CMSG}$1${CNORMAL}"; }
34 msgninfo
() { printf "${CINFO}I: $1${CNORMAL}"; }
35 msgndebug
() { printf "${CDEBUG}D: $1${CNORMAL}"; }
38 printf "${CINFO}$1${CCMD} "
39 printf -- "$(echo "$2" | sed -e 's#^apt\([cgfs]\)#apt-\1#')${CINFO} "
41 if [ -n "$1" ]; then shift; else break; fi
45 msgpass
() { printf "${CPASS}PASS${CNORMAL}\n"; }
46 msgskip
() { printf "${CWARNING}SKIP${CNORMAL}\n" >&2; }
48 if [ $# -gt 0 ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
49 else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
50 EXIT_CODE
=$((EXIT_CODE+1));
53 # enable / disable Debugging
54 MSGLEVEL
=${MSGLEVEL:-3}
55 if [ $MSGLEVEL -le 0 ]; then
58 if [ $MSGLEVEL -le 1 ]; then
62 if [ $MSGLEVEL -le 2 ]; then
66 msgpass
() { printf " ${CPASS}P${CNORMAL}"; }
67 msgskip
() { printf " ${CWARNING}S${CNORMAL}" >&2; }
68 if [ -n "$CFAIL" ]; then
69 msgfail
() { printf " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE
=$((EXIT_CODE+1)); }
71 msgfail
() { printf " ###FAILED###" >&2; EXIT_CODE
=$((EXIT_CODE+1)); }
74 if [ $MSGLEVEL -le 3 ]; then
78 if [ $MSGLEVEL -le 4 ]; then
83 if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
84 [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
85 [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
86 [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
87 [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
90 printf "${CDONE}DONE${CNORMAL}\n";
94 if [ -f .
/aptconfig.conf
]; then
95 echo "./aptconfig.conf"
96 elif [ -f ..
/aptconfig.conf
]; then
97 echo "../aptconfig.conf"
101 msgdebug
"Executing: ${CCMD}$*${CDEBUG} "
105 sh
|aptitude
|*/*|command) ;;
106 *) CMD
="${BUILDDIRECTORY}/$CMD";;
108 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 APT_CONFIG
="$(getaptconfig)" LD_LIBRARY_PATH
=${LIBRARYPATH} $CMD "$@"
110 aptconfig
() { runapt apt
-config "$@"; }
111 aptcache
() { runapt apt
-cache "$@"; }
112 aptcdrom
() { runapt apt
-cdrom "$@"; }
113 aptget
() { runapt apt
-get "$@"; }
114 aptftparchive
() { runapt apt
-ftparchive "$@"; }
115 aptkey
() { runapt apt
-key "$@"; }
116 aptmark
() { runapt apt
-mark "$@"; }
117 aptsortpkgs
() { runapt apt
-sortpkgs "$@"; }
118 apt
() { runapt apt
"$@"; }
119 apthelper
() { runapt
"${APTHELPERBINDIR}/apt-helper" "$@"; }
120 aptwebserver
() { runapt
"${APTWEBSERVERBINDIR}/aptwebserver" "$@"; }
121 aptitude
() { runapt aptitude
"$@"; }
122 aptextracttemplates
() { runapt apt
-extracttemplates "$@"; }
123 aptinternalsolver
() { runapt
"${APTINTERNALSOLVER}" "$@"; }
126 command dpkg
--root=${TMPWORKINGDIRECTORY}/rootdir
--force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir
/var
/log
/dpkg.log
"$@"
128 dpkgcheckbuilddeps
() {
129 command dpkg
-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir
/var
/lib
/dpkg
"$@"
134 runapt
command gdb
--quiet -ex run
"${BUILDDIRECTORY}/$CMD" --args "${BUILDDIRECTORY}/$CMD" "$@"
137 # see apt-key for the whole trickery. Setup is done in setupenvironment
138 command gpg
--ignore-time-conflict --no-options --no-default-keyring \
139 --homedir "${TMPWORKINGDIRECTORY}/gnupghome" \
140 --no-auto-check-trustdb --trust-model always \
145 # error if we about to overflow, but ...
146 # "255 failures ought to be enough for everybody"
147 if [ $EXIT_CODE -gt 255 ]; then
148 msgdie
"Total failure count $EXIT_CODE too big"
150 exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
153 shellsetedetector
() {
155 if [ "$exit_status" != '0' ]; then
156 printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n"
157 if [ "$EXIT_CODE" = '0' ]; then
158 EXIT_CODE
="$exit_status"
164 if [ "$1" = 'prefix' ]; then
165 CURRENTTRAP
="$2 $CURRENTTRAP"
167 CURRENTTRAP
="$CURRENTTRAP $1"
169 trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
173 TMPWORKINGDIRECTORY
=$(mktemp -d)
174 TESTDIRECTORY
=$(readlink -f $(dirname $0))
175 msgninfo
"Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
177 # allow overriding the default BUILDDIR location
178 BUILDDIRECTORY
=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
179 LIBRARYPATH
=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
180 METHODSDIR
=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
181 APTHELPERBINDIR
=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
182 APTWEBSERVERBINDIR
=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
183 APTINTERNALSOLVER
=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"}
184 test -x "${BUILDDIRECTORY}/apt-get" || msgdie
"You need to build tree first"
187 addtrap
"cd /; rm -rf $TMPWORKINGDIRECTORY;"
188 cd $TMPWORKINGDIRECTORY
189 mkdir rootdir aptarchive keys
191 mkdir -p etc
/apt
/apt.conf.d etc
/apt
/sources.list.d etc
/apt
/trusted.gpg.d etc
/apt
/preferences.d
192 mkdir -p var
/cache var
/lib
/apt var
/log tmp
193 mkdir -p var
/lib
/dpkg
/info var
/lib
/dpkg
/updates var
/lib
/dpkg
/triggers
194 touch var
/lib
/dpkg
/available
196 ln -s ${METHODSDIR} usr
/lib
/apt
/methods
197 if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
198 mkdir -p usr
/lib
/apt
/solvers
199 ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr
/lib
/apt
/solvers
/dump
200 ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr
/lib
/apt
/solvers
/apt
201 echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc
/apt
/apt.conf.d
/externalsolver.conf
203 # use the autoremove from the BUILDDIRECTORY if its there, otherwise
205 if [ -e ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove
]; then
206 ln -s ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove etc
/apt
/apt.conf.d
/01autoremove
208 ln -s /etc
/apt
/apt.conf.d
/01autoremove etc
/apt
/apt.conf.d
/01autoremove
211 local PACKAGESFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
212 if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
213 cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
215 local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
216 if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
217 cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive
/Sources
219 cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys
/
220 ln -s ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
221 echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
222 echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
223 echo "Debug::NoLocking \"true\";" >> aptconfig.conf
224 echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
225 echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf
226 echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
227 echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
228 echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
229 echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
230 echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
231 echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
232 if ! command dpkg
--assert-multi-arch >/dev
/null
2>&1; then
233 echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf
# Added to test multiarch before dpkg is ready for it…
235 echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
236 echo 'quiet::NoUpdate "true";' >> aptconfig.conf
237 echo 'quiet::NoStatistic "true";' >> aptconfig.conf
238 echo "Acquire::https::CaInfo \"${TESTDIR}/apt.pem\";" > rootdir
/etc
/apt
/apt.conf.d
/99https
239 echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir
/etc
/apt
/apt.conf.d
/apt
-binary
240 configcompression
'.' 'gz' #'bz2' 'lzma' 'xz'
242 # gpg needs a trustdb to function, but it can't be invalid (not even empty)
243 # see also apt-key where this trickery comes from:
244 local TRUSTDBDIR
="${TMPWORKINGDIRECTORY}/gnupghome"
246 chmod 700 "$TRUSTDBDIR"
247 # We also don't use a secret keyring, of course, but gpg panics and
248 # implodes if there isn't one available - and writeable for imports
249 local SECRETKEYRING
="${TRUSTDBDIR}/secring.gpg"
251 # now create the trustdb with an (empty) dummy keyring
252 # newer gpg versions are fine without it, but play it safe for now
253 gpg
--quiet --check-trustdb --secret-keyring $SECRETKEYRING --keyring $SECRETKEYRING >/dev
/null
2>&1
255 # cleanup the environment a bit
256 # prefer our apt binaries over the system apt binaries
257 export PATH
="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
258 export LC_ALL
=C.UTF
-8
259 unset LANGUAGE APT_CONFIG
260 unset GREP_OPTIONS DEB_BUILD_PROFILES
266 if [ "$1" = "native" -o -z "$1" ]; then
267 eval `aptconfig shell ARCH APT::Architecture`
268 if [ -n "$ARCH" ]; then
271 dpkg
--print-architecture
279 echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
282 getarchitecturesfromcommalist
() {
283 echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
286 configarchitecture
() {
288 echo "APT::Architecture \"$(getarchitecture $1)\";"
289 while [ -n "$1" ]; do
290 echo "APT::Architectures:: \"$(getarchitecture $1)\";"
293 } >rootdir
/etc
/apt
/apt.conf.d
/01multiarch.conf
298 if [ ! -e rootdir
/var
/lib
/dpkg
/status
]; then
299 local STATUSFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
300 if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
301 cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
303 echo -n > rootdir/var/lib/dpkg/status
306 rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
307 if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
308 local ARCHS="$(getarchitectures)"
309 if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
310 DPKGARCH="$(dpkg --print-architecture)"
311 for ARCH in ${ARCHS}; do
312 if [ "${ARCH}" != "${DPKGARCH}" ]; then
313 if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
314 # old-style used e.g. in Ubuntu-P – and as it seems travis
315 echo "DPKG
::options
:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
316 echo "DPKG
::options
:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
320 if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
321 # dpkg doesn't really check the version as long as it is fully installed,
322 # but just to be sure we choose one above the required version
323 insertinstalledpackage 'dpkg' "all
" '1.16.2+fake'
329 configcompression() {
330 while [ -n "$1" ]; do
332 '.') printf ".
\t.
\tcat
\n";;
333 'gz') printf "gzip\tgz
\tgzip
\n";;
334 'bz2') printf "bzip2\tbz
2\tbzip
2\n";;
335 'lzma') printf "lzma
\tlzma
\txz
--format=lzma
\n";;
336 'xz') printf "xz
\txz
\txz
\n";;
337 *) printf "$1\t$1\t$1\n";;
340 done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
343 setupsimplenativepackage() {
347 local RELEASE="${4:-unstable}"
348 local DEPENDENCIES="$5"
349 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
350 If you
find such a package installed on your system
,
351 something went horribly wrong
! They are autogenerated
352 und used only by testcases and surf no other propose…
"}"
354 local SECTION
="${7:-others}"
356 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
359 DISTSECTION
="$(echo "$SECTION" | cut -d'/' -f 1)"
361 local BUILDDIR
=incoming
/${NAME}-${VERSION}
362 mkdir -p ${BUILDDIR}/debian
/source
364 echo "* most suckless software product ever" > FEATURES
365 test -e debian
/copyright
|| echo "Copyleft by Joe Sixpack $(date +%Y)" > debian
/copyright
366 test -e debian
/changelog
|| echo "$NAME ($VERSION) $RELEASE; urgency=low
370 -- Joe Sixpack <joe@example.org> $(date -R)" > debian
/changelog
371 test -e debian
/control
|| echo "Source: $NAME
374 Maintainer: Joe Sixpack <joe@example.org>
375 Build-Depends: debhelper (>= 7)
376 Standards-Version: 3.9.1
378 Package: $NAME" > debian
/control
379 if [ "$ARCH" = 'all' ]; then
380 echo "Architecture: all" >> debian
/control
382 echo "Architecture: any" >> debian
/control
384 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian
/control
385 echo "Description: $DESCRIPTION" >> debian
/control
387 test -e debian
/compat
|| echo "7" > debian
/compat
388 test -e debian
/source
/format
|| echo "3.0 (native)" > debian
/source
/format
389 test -e debian
/rules
|| cp /usr
/share
/doc
/debhelper
/examples
/rules.tiny debian
/rules
393 buildsimplenativepackage
() {
397 local RELEASE
="${4:-unstable}"
398 local DEPENDENCIES
="$5"
399 local DESCRIPTION
="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
400 If you find such a package installed on your system,
401 something went horribly wrong! They are autogenerated
402 und used only by testcases and surf no other propose…"}"
404 local SECTION="${7:-others}"
405 local PRIORITY="${8:-optional}"
407 local COMPRESS_TYPE="${10:-gzip}"
409 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
412 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
414 local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
416 msgninfo "Build package
${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}…
"
417 mkdir -p $BUILDDIR/debian/source
418 echo "* most suckless software product ever
" > ${BUILDDIR}/FEATURES
420 echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
422 echo "Copyleft by Joe Sixpack
$(date +%Y)" > ${BUILDDIR}/debian/copyright
423 echo "$NAME ($VERSION) $RELEASE; urgency
=low
427 -- Joe Sixpack
<joe@example.org
> $(date -R)" > ${BUILDDIR}/debian/changelog
431 Maintainer
: Joe Sixpack
<joe@example.org
>
432 Standards
-Version: 3.9.3" > ${BUILDDIR}/debian/control
433 local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
434 test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
436 Package
: $NAME" >> ${BUILDDIR}/debian/control
438 if [ "$ARCH" = 'all' ]; then
439 echo "Architecture
: all
" >> ${BUILDDIR}/debian/control
441 echo "Architecture
: any
" >> ${BUILDDIR}/debian/control
443 local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
444 test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
445 echo "Description
: $DESCRIPTION" >> ${BUILDDIR}/debian/control
447 echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
448 (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | sed -n 's#^dpkg-source: info: building [^ ]\+ in ##p' \
450 echo "pool
/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
451 # if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
452 # gpg --yes --secret-keyring ./keys/joesixpack.sec \
453 # --keyring ./keys/joesixpack.pub --default-key 'Joe Sixpack' \
454 # --clearsign -o "${BUILDDIR}/..
/${SRC}.sign
" "${BUILDDIR}/..
/$SRC"
455 # mv "${BUILDDIR}/..
/${SRC}.sign
" "${BUILDDIR}/..
/$SRC"
459 for arch in $(getarchitecturesfromcommalist "$ARCH"); do
460 rm -rf ${BUILDDIR}/debian/tmp
461 mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
462 cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
463 cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
464 if [ -n "$FILE_TREE" ]; then
465 cp -ar "$FILE_TREE" ${BUILDDIR}/debian/tmp
468 (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
469 (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
470 local LOG="${BUILDDIR}/..
/${NAME}_
${VERSION}_
${arch}.dpkg
-deb.log
"
471 # ensure the right permissions as dpkg-deb ensists
472 chmod 755 ${BUILDDIR}/debian/tmp/DEBIAN
473 if ! dpkg-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. >$LOG 2>&1; then
478 echo "pool
/${NAME}_
${VERSION}_
${arch}.deb
" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
481 mkdir -p ${BUILDDIR}/../${NAME}_${VERSION}
482 cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/
483 cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog
492 local ARCH=$(getarchitecture $4)
493 local PKGNAME="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
494 local BUILDLOG="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
495 msgninfo "Build package
${PKGNAME} for ${RELEASE} in ${SECTION}…
"
497 if [ "$ARCH" = "all
" ]; then
498 ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
500 if ! dpkg-buildpackage -uc -us -a$ARCH >$BUILDLOG 2>&1 ; then
504 local PKGS="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
505 local SRCS="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
508 echo "pool
/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
511 echo "pool
/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
517 if [ -d incoming ]; then
518 buildaptarchivefromincoming "$@
"
520 buildaptarchivefromfiles "$@
"
524 createaptftparchiveconfig() {
525 local COMPRESSORS="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
526 COMPRESSORS="${COMPRESSORS%* }"
527 local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb
$#\
1#' | tr '\n' ' ')"
528 if [ -z "$ARCHS" ]; then
529 # the pool is empty, so we will operate on faked packages - let us use the configured archs
530 ARCHS
="$(getarchitectures)"
533 ArchiveDir "' >> ftparchive.conf
534 echo -n $(readlink -f .) >> ftparchive.conf
536 CacheDir "' >> ftparchive.conf
537 echo -n $(readlink -f ..) >> ftparchive.conf
539 FileListDir "' >> ftparchive.conf
540 echo -n $(readlink -f pool/) >> ftparchive.conf
544 Packages::Compress "'"$COMPRESSORS"'";
545 Sources::Compress "'"$COMPRESSORS"'";
546 Contents::Compress "'"$COMPRESSORS"'";
547 Translation::Compress "'"$COMPRESSORS"'";
548 LongDescription "false";
552 SrcDirectory "pool/";
558 Label "apttestcases";
560 Description "repository with dummy packages";
561 Architectures "' >> ftparchive.conf
562 echo -n "$ARCHS" >> ftparchive.conf
566 };' >> ftparchive.conf
567 for DIST
in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
568 echo -n 'tree "dists/' >> ftparchive.conf
569 echo -n "$DIST" >> ftparchive.conf
571 Architectures "' >> ftparchive.conf
572 echo -n "$ARCHS" >> ftparchive.conf
574 FileList "' >> ftparchive.conf
575 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
577 SourceFileList "' >> ftparchive.conf
578 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
580 Sections "' >> ftparchive.conf
581 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
583 };' >> ftparchive.conf
587 buildaptftparchivedirectorystructure
() {
588 local DISTS
="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
589 for DIST
in $DISTS; do
590 local SECTIONS
="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
591 for SECTION
in $SECTIONS; do
592 local ARCHS
="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
593 for ARCH
in $ARCHS; do
594 mkdir -p dists
/${DIST}/${SECTION}/binary
-${ARCH}
596 mkdir -p dists
/${DIST}/${SECTION}/source
597 mkdir -p dists
/${DIST}/${SECTION}/i18n
607 local DEPENDENCIES
="$5"
608 local PRIORITY
="${6:-optional}"
609 local DESCRIPTION
="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
610 If you find such a package installed on your system,
611 something went horribly wrong! They are autogenerated
612 und used only by testcases and surf no other propose…"}"
614 for arch in $(getarchitecturesfromcommalist "$ARCH"); do
615 if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
616 ARCHS="$(getarchitectures)"
620 for BUILDARCH in $ARCHS; do
621 local PPATH="aptarchive
/dists
/${RELEASE}/main
/binary
-${BUILDARCH}"
622 mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
623 touch aptarchive/dists/${RELEASE}/main/source/Sources
624 local FILE="${PPATH}/Packages
"
629 Maintainer
: Joe Sixpack
<joe@example.org
>" >> $FILE
630 test "$arch" = 'none' || echo "Architecture
: $arch" >> $FILE
631 echo "Version
: $VERSION
632 Filename
: pool
/main
/${NAME}/${NAME}_
${VERSION}_
${arch}.deb
" >> $FILE
633 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
634 echo "Description
: $DESCRIPTION" >> $FILE
645 local DEPENDENCIES="$5"
647 local SPATH="aptarchive
/dists
/${RELEASE}/main
/source"
649 local FILE="${SPATH}/Sources
"
653 Maintainer
: Joe Sixpack
<joe@example.org
>
654 Architecture
: $ARCH" >> $FILE
655 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
657 d41d8cd98f00b204e9800998ecf8427e
0 ${NAME}_
${VERSION}.dsc
658 d41d8cd98f00b204e9800998ecf8427e
0 ${NAME}_
${VERSION}.
tar.gz
662 insertinstalledpackage() {
666 local DEPENDENCIES="$4"
667 local PRIORITY="${5:-optional}"
668 local STATUS="${6:-install ok installed}"
669 local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
670 If you
find such a package installed on your system
,
671 something went horribly wrong
! They are autogenerated
672 und used only by testcases and surf no other propose…
"}"
674 local FILE
='rootdir/var/lib/dpkg/status'
675 local INFO
='rootdir/var/lib/dpkg/info'
676 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
682 Maintainer: Joe Sixpack <joe@example.org>
683 Version: $VERSION" >> $FILE
684 test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
685 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
686 echo "Description: $DESCRIPTION" >> $FILE
688 if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
689 echo -n > ${INFO}/${NAME}:${arch}.list
691 echo -n > ${INFO}/${NAME}.list
697 buildaptarchivefromincoming
() {
698 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
700 [ -e pool
] || ln -s ..
/incoming pool
701 [ -e ftparchive.conf
] || createaptftparchiveconfig
702 [ -e dists
] || buildaptftparchivedirectorystructure
703 msgninfo
"\tGenerate Packages, Sources and Contents files… "
704 aptftparchive
-qq generate ftparchive.conf
710 buildaptarchivefromfiles
() {
711 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
712 find aptarchive
-name 'Packages' -o -name 'Sources' | while read line
; do
713 msgninfo
"\t${line} file… "
714 compressfile
"$line" "$1"
717 generatereleasefiles
"$@"
721 cat ${TMPWORKINGDIRECTORY}/rootdir
/etc
/testcase
-compressor.conf
| while read compressor extension
command; do
722 if [ "$compressor" = '.' ]; then
728 cat "$1" | $command > "${1}.${extension}"
730 touch -d "$2" "${1}.${extension}"
735 # can be overridden by testcases for their pleasure
736 getcodenamefromsuite
() {
738 unstable
) echo 'sid';;
742 getreleaseversionfromsuite
() { true
; }
743 getlabelfromsuite
() { true
; }
745 generatereleasefiles
() {
746 # $1 is the Date header and $2 is the ValidUntil header to be set
747 # both should be given in notation date/touch can understand
748 msgninfo
"\tGenerate Release files… "
749 if [ -e aptarchive
/dists
]; then
750 for dir
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
751 local SUITE
="$(echo "$dir" | cut -d'/' -f 4)"
752 local CODENAME
="$(getcodenamefromsuite $SUITE)"
753 local VERSION
="$(getreleaseversionfromsuite $SUITE)"
754 local LABEL
="$(getlabelfromsuite $SUITE)"
755 if [ -n "$VERSION" ]; then
756 VERSION
="-o APT::FTPArchive::Release::Version=${VERSION}"
758 if [ -n "$LABEL" ]; then
759 LABEL
="-o APT::FTPArchive::Release::Label=${LABEL}"
761 aptftparchive
-qq release
$dir \
762 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
763 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
766 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
767 if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
769 NotAutomatic: yes' $dir/Release
771 if [ -n "$1" -a "$1" != "now" ]; then
772 sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
776 Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
780 aptftparchive
-qq release .
/aptarchive
| sed -e '/0 Release$/ d' > aptarchive
/Release
# remove the self reference
782 if [ -n "$1" -a "$1" != "now" ]; then
783 for release
in $(find ./aptarchive -name 'Release'); do
784 touch -d "$1" $release
790 setupdistsaptarchive
() {
791 local APTARCHIVE
=$(readlink -f ./aptarchive)
792 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb.list
793 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb-src.list
794 for DISTS
in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
795 SECTIONS
=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
796 msgninfo
"\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
797 echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb.list
798 echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb-src.list
803 setupflataptarchive
() {
804 local APTARCHIVE
=$(readlink -f ./aptarchive)
805 if [ -f ${APTARCHIVE}/Packages
]; then
806 msgninfo
"\tadd deb sources.list line… "
807 echo "deb file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
810 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
812 if [ -f ${APTARCHIVE}/Sources
]; then
813 msgninfo
"\tadd deb-src sources.list line… "
814 echo "deb-src file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
817 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
823 if [ -e aptarchive
/dists
]; then
829 if [ "$1" != '--no-update' ]; then
830 msgninfo
"\tSync APT's cache with the archive… "
837 local SIGNER
="${1:-Joe Sixpack}"
838 local GPG
="gpg --batch --yes"
839 msgninfo
"\tSign archive with $SIGNER key… "
840 local REXKEY
='keys/rexexpired'
841 local SECEXPIREBAK
="${REXKEY}.sec.bak"
842 local PUBEXPIREBAK
="${REXKEY}.pub.bak"
843 if [ "${SIGNER}" = 'Rex Expired' ]; then
844 # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
845 # option doesn't exist anymore (and using faketime would add a new obscure dependency)
846 # therefore we 'temporary' make the key not expired and restore a backup after signing
847 cp ${REXKEY}.sec
$SECEXPIREBAK
848 cp ${REXKEY}.pub
$PUBEXPIREBAK
849 local SECUNEXPIRED
="${REXKEY}.sec.unexpired"
850 local PUBUNEXPIRED
="${REXKEY}.pub.unexpired"
851 if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
852 cp $SECUNEXPIRED ${REXKEY}.sec
853 cp $PUBUNEXPIRED ${REXKEY}.pub
855 printf "expire\n1w\nsave\n" | $GPG --keyring ${REXKEY}.pub
--secret-keyring ${REXKEY}.sec
--command-fd 0 --edit-key "${SIGNER}" >/dev
/null
2>&1 || true
856 cp ${REXKEY}.sec
$SECUNEXPIRED
857 cp ${REXKEY}.pub
$PUBUNEXPIRED
860 for KEY
in $(find keys/ -name '*.sec'); do
861 GPG
="$GPG --secret-keyring $KEY"
863 for KEY
in $(find keys/ -name '*.pub'); do
864 GPG
="$GPG --keyring $KEY"
866 for RELEASE
in $(find aptarchive/ -name Release); do
867 $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg
${RELEASE}
868 local INRELEASE
="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
869 $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
870 # we might have set a specific date for the Release file, so copy it
871 touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg
${INRELEASE}
873 if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
874 mv -f $SECEXPIREBAK ${REXKEY}.sec
875 mv -f $PUBEXPIREBAK ${REXKEY}.pub
881 msgtest
"Set webserver config option '${1}' to" "$2"
882 local DOWNLOG
='rootdir/tmp/download-testfile.log'
883 local STATUS
='rootdir/tmp/webserverconfig.status'
884 rm -f "$STATUS" "$DOWNLOG"
885 if downloadfile
"http://localhost:8080/_config/set/${1}/${2}" "$STATUS" > "$DOWNLOG"; then
888 cat "$DOWNLOG" "$STATUS"
891 testwebserverlaststatuscode
'200'
894 rewritesourceslist
() {
895 local APTARCHIVE
="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
896 for LIST
in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
897 sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#http://localhost:4433/#${1}#"
901 # wait for up to 10s for a pid file to appear to avoid possible race
902 # when a helper is started and dosn't write the PID quick enough
905 for i
in $(seq 10); do
906 if test -s "$PIDFILE"; then
911 msgdie
"waiting for $PIDFILE failed"
915 changetowebserver
() {
916 if [ "$1" != '--no-rewrite' ]; then
917 rewritesourceslist
'http://localhost:8080/'
921 if test -x ${APTWEBSERVERBINDIR}/aptwebserver
; then
923 local LOG
="webserver.log"
924 if ! aptwebserver
-o aptwebserver
::fork
=1 "$@" >$LOG 2>&1 ; then
928 waitforpidfile aptwebserver.pid
929 local PID
="$(cat aptwebserver.pid)"
930 if [ -z "$PID" ]; then
931 msgdie
'Could not fork aptwebserver successfully'
936 msgdie
'You have to build aptwerbserver or install a webserver'
940 changetohttpswebserver
() {
941 if ! which stunnel4
>/dev
/null
; then
942 msgdie
'You need to install stunnel4 for https testcases'
944 if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
945 changetowebserver
--no-rewrite "$@"
947 echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
948 cert = ${TESTDIRECTORY}/apt.pem
954 " > ${TMPWORKINGDIRECTORY}/stunnel.conf
955 stunnel4
"${TMPWORKINGDIRECTORY}/stunnel.conf"
956 waitforpidfile
"${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
957 local PID
="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
958 if [ -z "$PID" ]; then
959 msgdie
'Could not fork stunnel4 successfully'
961 addtrap
'prefix' "kill ${PID};"
962 rewritesourceslist
'https://localhost:4433/'
966 mkdir -p rootdir
/media
/cdrom
/.disk
967 local CD
="$(readlink -f rootdir/media/cdrom)"
968 echo "acquire::cdrom::mount \"${CD}\";
969 acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
970 acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
971 acquire::cdrom::autodetect 0;" > rootdir
/etc
/apt
/apt.conf.d
/00cdrom
972 echo -n "$1" > ${CD}/.disk
/info
973 if [ ! -d aptarchive
/dists
]; then
974 msgdie
'Flat file archive cdroms can not be created currently'
977 mv aptarchive
/dists
"$CD"
978 ln -s "$(readlink -f ./incoming)" $CD/pool
979 find rootdir
/etc
/apt
/sources.list.d
/ -name 'apt-test-*.list' -delete
980 # start with an unmounted disk
981 mv "${CD}" "${CD}-unmounted"
982 # we don't want the disk to be modifiable
983 addtrap
'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
984 chmod -R -w rootdir
/media
/cdrom
-unmounted/dists
988 local PROTO
="$(echo "$1" | cut -d':' -f 1 )"
989 apthelper
-o Debug
::Acquire
::${PROTO}=1 \
990 download
-file "$1" "$2" 2>&1 || true
991 # only if the file exists the download was successful
1000 local DIFFTEXT
="$(command diff -u "$@" | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
1001 if [ -n "$DIFFTEXT" ]; then
1003 echo >&2 "$DIFFTEXT"
1013 msgtest
"Test for correctness of file" "$FILE"
1014 if [ -z "$*" ]; then
1015 echo -n "" | checkdiff
$FILE - && msgpass
|| msgfail
1017 echo "$*" | checkdiff
$FILE - && msgpass
|| msgfail
1022 msgtest
"Test for no output of" "$*"
1023 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
1024 if $
* >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
1033 local MSG
='Test of equality of'
1034 if [ "$1" = '--nomsg' ]; then
1039 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile"
1040 echo "$1" > $COMPAREFILE
1043 if [ -n "$MSG" ]; then
1046 $
* 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1050 local COMPAREFILE1
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
1051 local COMPAREFILE2
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
1052 local COMPAREAGAINST
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
1053 echo "$1" > $COMPAREFILE1
1054 echo "$2" > $COMPAREFILE2
1056 msgtest
"Test for equality OR of" "$*"
1057 $
* >$COMPAREAGAINST 2>&1 || true
1058 if checkdiff
$COMPAREFILE1 $COMPAREAGAINST >/dev
/null
2>&1 || \
1059 checkdiff
$COMPAREFILE2 $COMPAREAGAINST >/dev
/null
2>&1
1063 echo -n "\n${CINFO}Diff against OR 1${CNORMAL}"
1064 checkdiff
$COMPAREFILE1 $COMPAREAGAINST || true
1065 echo -n "${CINFO}Diff against OR 2${CNORMAL}"
1066 checkdiff
$COMPAREFILE2 $COMPAREAGAINST || true
1072 local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual"
1075 while [ -n "$1" ]; do
1077 N: Can't select versions from package '$1' as it is purely virtual"
1078 PACKAGE
="${PACKAGE} $1"
1081 msgtest
"Test for virtual packages" "apt-cache show $PACKAGE"
1083 N: No packages found"
1084 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile"
1085 local ARCH
="$(getarchitecture 'native')"
1086 echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
1087 aptcache show
-q=0 $PACKAGE 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1091 msgtest
"Test for non-existent packages" "apt-cache show $*"
1092 local SHOWPKG
="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
1093 if [ -n "$SHOWPKG" ]; then
1102 testdpkginstalled
() {
1103 msgtest
"Test for correctly installed package(s) with" "dpkg -l $*"
1104 local PKGS
="$(dpkg -l "$@" 2>/dev/null | grep '^i' | wc -l)"
1105 if [ "$PKGS" != $# ]; then
1107 dpkg
-l "$@" | grep '^[a-z]' >&2
1114 testdpkgnotinstalled
() {
1115 msgtest
"Test for correctly not-installed package(s) with" "dpkg -l $*"
1116 local PKGS
="$(dpkg -l "$@" 2> /dev/null | grep '^i' | wc -l)"
1117 if [ "$PKGS" != 0 ]; then
1119 dpkg
-l "$@" | grep '^[a-z]' >&2
1127 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
1128 if [ -n "$1" ]; then
1129 msgtest
'Test for correctly marked as auto-installed' "$*"
1130 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1132 msgtest
'Test for correctly marked as auto-installed' 'no package'
1133 echo -n > $COMPAREFILE
1135 aptmark showauto
2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1139 if [ "$1" = '--nomsg' ]; then
1142 msgtest
'Test for successful execution of' "$*"
1144 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
1145 if $@
>${OUTPUT} 2>&1; then
1155 if [ "$1" = '--nomsg' ]; then
1158 msgtest
'Test for failure in execution of' "$*"
1160 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
1161 if $@
>${OUTPUT} 2>&1; then
1170 testwebserverlaststatuscode
() {
1171 local DOWNLOG
='rootdir/tmp/webserverstatus-testfile.log'
1172 local STATUS
='rootdir/tmp/webserverstatus-statusfile.log'
1173 rm -f "$DOWNLOG" "$STATUS"
1174 msgtest
'Test last status code from the webserver was' "$1"
1175 downloadfile
"http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG"
1176 if [ "$(cat "$STATUS")" = "$1" ]; then
1180 if [ -n "$2" ]; then
1182 echo >&2 '#### Additionally provided output files contain:'
1185 echo >&2 '#### Download log of the status code:'
1187 msgfail
"Status was $(cat "$STATUS")"
1192 echo "STOPPED execution. Press enter to continue"