1 #!/bin/sh -- # no runable script, just for vi
5 # we all like colorful messages
6 if [ "$MSGCOLOR" != 'NO' ]; then
7 if ! expr match
"$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev
/null
; then
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
() { echo "${CERROR}E: $1${CNORMAL}" >&2; exit 1; }
27 msgwarn
() { echo "${CWARNING}W: $1${CNORMAL}" >&2; }
28 msgmsg
() { echo "${CMSG}$1${CNORMAL}"; }
29 msginfo
() { echo "${CINFO}I: $1${CNORMAL}"; }
30 msgdebug
() { echo "${CDEBUG}D: $1${CNORMAL}"; }
31 msgdone
() { echo "${CDONE}DONE${CNORMAL}"; }
32 msgnwarn
() { echo -n "${CWARNING}W: $1${CNORMAL}" >&2; }
33 msgnmsg
() { echo -n "${CMSG}$1${CNORMAL}"; }
34 msgninfo
() { echo -n "${CINFO}I: $1${CNORMAL}"; }
35 msgndebug
() { echo -n "${CDEBUG}D: $1${CNORMAL}"; }
38 echo -n "${CINFO}$1${CCMD} "
39 echo -n "$(echo "$2" | sed -e 's#^apt\([cgfs]\)#apt-\1#')${CINFO} "
41 if [ -n "$1" ]; then shift; else break; fi
43 echo -n "…${CNORMAL} "
45 msgpass
() { echo "${CPASS}PASS${CNORMAL}"; }
46 msgskip
() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
48 if [ $# -gt 0 ]; then echo "${CFAIL}FAIL: $*${CNORMAL}" >&2;
49 else echo "${CFAIL}FAIL${CNORMAL}" >&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
() { echo -n " ${CPASS}P${CNORMAL}"; }
67 msgskip
() { echo -n " ${CWARNING}S${CNORMAL}" >&2; }
68 if [ -n "$CFAIL" ]; then
69 msgfail
() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE
=$((EXIT_CODE+1)); }
71 msgfail
() { echo -n " ###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 echo "${CDONE}DONE${CNORMAL}";
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} "
106 *) CMD
="${BUILDDIRECTORY}/$CMD";;
108 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 APT_CONFIG
="$(getaptconfig)" LD_LIBRARY_PATH
=${BUILDDIRECTORY} $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
"${APTINTERNALSOLVERBINDIR}/apt-internal-solver" "$@"; }
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
"$@"
136 APT_CONFIG
=aptconfig.conf LD_LIBRARY_PATH
=${LIBRARYPATH} command gdb
${BUILDDIRECTORY}/$CMD --args ${BUILDDIRECTORY}/$CMD "$@"
139 # see apt-key for the whole trickery. Setup is done in setupenvironment
140 command gpg
--ignore-time-conflict --no-options --no-default-keyring \
141 --homedir "${TMPWORKINGDIRECTORY}/gnupghome" \
142 --no-auto-check-trustdb --trust-model always \
147 # error if we about to overflow, but ...
148 # "255 failures ought to be enough for everybody"
149 if [ $EXIT_CODE -gt 255 ]; then
150 msgdie
"Total failure count $EXIT_CODE too big"
152 exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
155 shellsetedetector
() {
157 if [ "$exit_status" != '0' ]; then
158 echo >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}"
159 if [ "$EXIT_CODE" = '0' ]; then
160 EXIT_CODE
="$exit_status"
166 if [ "$1" = 'prefix' ]; then
167 CURRENTTRAP
="$2 $CURRENTTRAP"
169 CURRENTTRAP
="$CURRENTTRAP $1"
171 trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
175 TMPWORKINGDIRECTORY
=$(mktemp -d)
176 TESTDIRECTORY
=$(readlink -f $(dirname $0))
177 msgninfo
"Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
179 # allow overriding the default BUILDDIR location
180 BUILDDIRECTORY
=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
181 LIBRARYPATH
=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
182 METHODSDIR
=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
183 APTHELPERBINDIR
=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
184 APTWEBSERVERBINDIR
=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
185 APTINTERNALSOLVERBINDIR
=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER_DIR:-"${BUILDDIRECTORY}"}
186 test -x "${BUILDDIRECTORY}/apt-get" || msgdie
"You need to build tree first"
189 addtrap
"cd /; rm -rf $TMPWORKINGDIRECTORY;"
190 cd $TMPWORKINGDIRECTORY
191 mkdir rootdir aptarchive keys
193 mkdir -p etc
/apt
/apt.conf.d etc
/apt
/sources.list.d etc
/apt
/trusted.gpg.d etc
/apt
/preferences.d
194 mkdir -p var
/cache var
/lib
/apt var
/log tmp
195 mkdir -p var
/lib
/dpkg
/info var
/lib
/dpkg
/updates var
/lib
/dpkg
/triggers
196 touch var
/lib
/dpkg
/available
198 ln -s ${METHODSDIR} usr
/lib
/apt
/methods
199 if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
200 mkdir -p usr
/lib
/apt
/solvers
201 ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr
/lib
/apt
/solvers
/dump
202 ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr
/lib
/apt
/solvers
/apt
203 echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc
/apt
/apt.conf.d
/externalsolver.conf
205 # use the autoremove from the BUILDDIRECTORY if its there, otherwise
207 if [ -e ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove
]; then
208 ln -s ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove etc
/apt
/apt.conf.d
/01autoremove
210 ln -s /etc
/apt
/apt.conf.d
/01autoremove etc
/apt
/apt.conf.d
/01autoremove
213 local PACKAGESFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
214 if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
215 cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
217 local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
218 if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
219 cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive
/Sources
221 cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys
/
222 ln -s ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
223 echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
224 echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
225 echo "Debug::NoLocking \"true\";" >> aptconfig.conf
226 echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
227 echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf
228 echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
229 echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
230 echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
231 echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
232 echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
233 if ! command dpkg
--assert-multi-arch >/dev
/null
2>&1; then
234 echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf
# Added to test multiarch before dpkg is ready for it…
236 echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
237 echo 'quiet::NoUpdate "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 export PATH
="${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
257 export LC_ALL
=C.UTF
-8
258 unset LANGUAGE APT_CONFIG
259 unset GREP_OPTIONS DEB_BUILD_PROFILES
265 if [ "$1" = "native" -o -z "$1" ]; then
266 eval `aptconfig shell ARCH APT::Architecture`
267 if [ -n "$ARCH" ]; then
270 dpkg
--print-architecture
278 echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
281 getarchitecturesfromcommalist
() {
282 echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
285 configarchitecture
() {
287 echo "APT::Architecture \"$(getarchitecture $1)\";"
288 while [ -n "$1" ]; do
289 echo "APT::Architectures:: \"$(getarchitecture $1)\";"
292 } >rootdir
/etc
/apt
/apt.conf.d
/01multiarch.conf
297 if [ ! -e rootdir
/var
/lib
/dpkg
/status
]; then
298 local STATUSFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
299 if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
300 cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
302 echo -n > rootdir/var/lib/dpkg/status
305 rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
306 if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
307 local ARCHS="$(getarchitectures)"
308 if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
309 DPKGARCH="$(dpkg --print-architecture)"
310 for ARCH in ${ARCHS}; do
311 if [ "${ARCH}" != "${DPKGARCH}" ]; then
312 if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
313 # old-style used e.g. in Ubuntu-P – and as it seems travis
314 echo "DPKG
::options
:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
315 echo "DPKG
::options
:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
319 if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
320 # dpkg doesn't really check the version as long as it is fully installed,
321 # but just to be sure we choose one above the required version
322 insertinstalledpackage 'dpkg' "all
" '1.16.2+fake'
328 configcompression() {
329 while [ -n "$1" ]; do
331 '.') echo ".
\t.
\tcat
";;
332 'gz') echo "gzip\tgz
\tgzip
";;
333 'bz2') echo "bzip2\tbz
2\tbzip
2";;
334 'lzma') echo "lzma
\tlzma
\txz
--format=lzma
";;
335 'xz') echo "xz
\txz
\txz
";;
336 *) echo "$1\t$1\t$1";;
339 done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
342 setupsimplenativepackage() {
346 local RELEASE="${4:-unstable}"
347 local DEPENDENCIES="$5"
348 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
349 If you
find such a package installed on your system
,
350 something went horribly wrong
! They are autogenerated
351 und used only by testcases and surf no other propose…
"}"
353 local SECTION
="${7:-others}"
355 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
358 DISTSECTION
="$(echo "$SECTION" | cut -d'/' -f 1)"
360 local BUILDDIR
=incoming
/${NAME}-${VERSION}
361 mkdir -p ${BUILDDIR}/debian
/source
363 echo "* most suckless software product ever" > FEATURES
364 test -e debian
/copyright
|| echo "Copyleft by Joe Sixpack $(date +%Y)" > debian
/copyright
365 test -e debian
/changelog
|| echo "$NAME ($VERSION) $RELEASE; urgency=low
369 -- Joe Sixpack <joe@example.org> $(date -R)" > debian
/changelog
370 test -e debian
/control
|| echo "Source: $NAME
373 Maintainer: Joe Sixpack <joe@example.org>
374 Build-Depends: debhelper (>= 7)
375 Standards-Version: 3.9.1
377 Package: $NAME" > debian
/control
378 if [ "$ARCH" = 'all' ]; then
379 echo "Architecture: all" >> debian
/control
381 echo "Architecture: any" >> debian
/control
383 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian
/control
384 echo "Description: $DESCRIPTION" >> debian
/control
386 test -e debian
/compat
|| echo "7" > debian
/compat
387 test -e debian
/source
/format
|| echo "3.0 (native)" > debian
/source
/format
388 test -e debian
/rules
|| cp /usr
/share
/doc
/debhelper
/examples
/rules.tiny debian
/rules
392 buildsimplenativepackage
() {
396 local RELEASE
="${4:-unstable}"
397 local DEPENDENCIES
="$5"
398 local DESCRIPTION
="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
399 If you find such a package installed on your system,
400 something went horribly wrong! They are autogenerated
401 und used only by testcases and surf no other propose…"}"
403 local SECTION="${7:-others}"
404 local PRIORITY="${8:-optional}"
406 local COMPRESS_TYPE="${10:-gzip}"
408 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
411 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
413 local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
415 msgninfo "Build package
${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}…
"
416 mkdir -p $BUILDDIR/debian/source
417 echo "* most suckless software product ever
" > ${BUILDDIR}/FEATURES
419 echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
421 echo "Copyleft by Joe Sixpack
$(date +%Y)" > ${BUILDDIR}/debian/copyright
422 echo "$NAME ($VERSION) $RELEASE; urgency
=low
426 -- Joe Sixpack
<joe@example.org
> $(date -R)" > ${BUILDDIR}/debian/changelog
430 Maintainer
: Joe Sixpack
<joe@example.org
>
431 Standards
-Version: 3.9.3" > ${BUILDDIR}/debian/control
432 local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
433 test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
435 Package
: $NAME" >> ${BUILDDIR}/debian/control
437 if [ "$ARCH" = 'all' ]; then
438 echo "Architecture
: all
" >> ${BUILDDIR}/debian/control
440 echo "Architecture
: any
" >> ${BUILDDIR}/debian/control
442 local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
443 test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
444 echo "Description
: $DESCRIPTION" >> ${BUILDDIR}/debian/control
446 echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
447 (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | sed -n 's#^dpkg-source: info: building [^ ]\+ in ##p' \
449 echo "pool
/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
450 # if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
451 # gpg --yes --secret-keyring ./keys/joesixpack.sec \
452 # --keyring ./keys/joesixpack.pub --default-key 'Joe Sixpack' \
453 # --clearsign -o "${BUILDDIR}/..
/${SRC}.sign
" "${BUILDDIR}/..
/$SRC"
454 # mv "${BUILDDIR}/..
/${SRC}.sign
" "${BUILDDIR}/..
/$SRC"
458 for arch in $(getarchitecturesfromcommalist "$ARCH"); do
459 rm -rf ${BUILDDIR}/debian/tmp
460 mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
461 cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
462 cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
463 if [ -n "$FILE_TREE" ]; then
464 cp -ar "$FILE_TREE" ${BUILDDIR}/debian/tmp
467 (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
468 (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
469 local LOG="${BUILDDIR}/..
/${NAME}_
${VERSION}_
${arch}.dpkg
-deb.log
"
470 # ensure the right permissions as dpkg-deb ensists
471 chmod 755 ${BUILDDIR}/debian/tmp/DEBIAN
472 if ! dpkg-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. >$LOG 2>&1; then
477 echo "pool
/${NAME}_
${VERSION}_
${arch}.deb
" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
480 mkdir -p ${BUILDDIR}/../${NAME}_${VERSION}
481 cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/
482 cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog
491 local ARCH=$(getarchitecture $4)
492 local PKGNAME="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
493 local BUILDLOG="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
494 msgninfo "Build package
${PKGNAME} for ${RELEASE} in ${SECTION}…
"
496 if [ "$ARCH" = "all
" ]; then
497 ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
499 if ! dpkg-buildpackage -uc -us -a$ARCH >$BUILDLOG 2>&1 ; then
503 local PKGS="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
504 local SRCS="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
507 echo "pool
/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
510 echo "pool
/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
516 if [ -d incoming ]; then
517 buildaptarchivefromincoming "$@
"
519 buildaptarchivefromfiles "$@
"
523 createaptftparchiveconfig() {
524 local COMPRESSORS="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
525 COMPRESSORS="${COMPRESSORS%* }"
526 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' ' ')"
527 if [ -z "$ARCHS" ]; then
528 # the pool is empty, so we will operate on faked packages - let us use the configured archs
529 ARCHS
="$(getarchitectures)"
532 ArchiveDir "' >> ftparchive.conf
533 echo -n $(readlink -f .) >> ftparchive.conf
535 CacheDir "' >> ftparchive.conf
536 echo -n $(readlink -f ..) >> ftparchive.conf
538 FileListDir "' >> ftparchive.conf
539 echo -n $(readlink -f pool/) >> ftparchive.conf
543 Packages::Compress "'"$COMPRESSORS"'";
544 Sources::Compress "'"$COMPRESSORS"'";
545 Contents::Compress "'"$COMPRESSORS"'";
546 Translation::Compress "'"$COMPRESSORS"'";
547 LongDescription "false";
551 SrcDirectory "pool/";
557 Label "apttestcases";
559 Description "repository with dummy packages";
560 Architectures "' >> ftparchive.conf
561 echo -n "$ARCHS" >> ftparchive.conf
565 };' >> ftparchive.conf
566 for DIST
in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
567 echo -n 'tree "dists/' >> ftparchive.conf
568 echo -n "$DIST" >> ftparchive.conf
570 Architectures "' >> ftparchive.conf
571 echo -n "$ARCHS" >> ftparchive.conf
573 FileList "' >> ftparchive.conf
574 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
576 SourceFileList "' >> ftparchive.conf
577 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
579 Sections "' >> ftparchive.conf
580 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
582 };' >> ftparchive.conf
586 buildaptftparchivedirectorystructure
() {
587 local DISTS
="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
588 for DIST
in $DISTS; do
589 local SECTIONS
="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
590 for SECTION
in $SECTIONS; do
591 local ARCHS
="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
592 for ARCH
in $ARCHS; do
593 mkdir -p dists
/${DIST}/${SECTION}/binary
-${ARCH}
595 mkdir -p dists
/${DIST}/${SECTION}/source
596 mkdir -p dists
/${DIST}/${SECTION}/i18n
606 local DEPENDENCIES
="$5"
607 local PRIORITY
="${6:-optional}"
608 local DESCRIPTION
="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
609 If you find such a package installed on your system,
610 something went horribly wrong! They are autogenerated
611 und used only by testcases and surf no other propose…"}"
613 for arch in $(getarchitecturesfromcommalist "$ARCH"); do
614 if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
615 ARCHS="$(getarchitectures)"
619 for BUILDARCH in $ARCHS; do
620 local PPATH="aptarchive
/dists
/${RELEASE}/main
/binary
-${BUILDARCH}"
621 mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
622 touch aptarchive/dists/${RELEASE}/main/source/Sources
623 local FILE="${PPATH}/Packages
"
628 Maintainer
: Joe Sixpack
<joe@example.org
>" >> $FILE
629 test "$arch" = 'none' || echo "Architecture
: $arch" >> $FILE
630 echo "Version
: $VERSION
631 Filename
: pool
/main
/${NAME}/${NAME}_
${VERSION}_
${arch}.deb
" >> $FILE
632 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
633 echo "Description
: $DESCRIPTION" >> $FILE
644 local DEPENDENCIES="$5"
646 local SPATH="aptarchive
/dists
/${RELEASE}/main
/source"
648 local FILE="${SPATH}/Sources
"
652 Maintainer
: Joe Sixpack
<joe@example.org
>
653 Architecture
: $ARCH" >> $FILE
654 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
656 d41d8cd98f00b204e9800998ecf8427e
0 ${NAME}_
${VERSION}.dsc
657 d41d8cd98f00b204e9800998ecf8427e
0 ${NAME}_
${VERSION}.
tar.gz
661 insertinstalledpackage() {
665 local DEPENDENCIES="$4"
666 local PRIORITY="${5:-optional}"
667 local STATUS="${6:-install ok installed}"
668 local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
669 If you
find such a package installed on your system
,
670 something went horribly wrong
! They are autogenerated
671 und used only by testcases and surf no other propose…
"}"
673 local FILE
='rootdir/var/lib/dpkg/status'
674 local INFO
='rootdir/var/lib/dpkg/info'
675 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
681 Maintainer: Joe Sixpack <joe@example.org>
682 Version: $VERSION" >> $FILE
683 test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
684 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
685 echo "Description: $DESCRIPTION" >> $FILE
687 if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
688 echo -n > ${INFO}/${NAME}:${arch}.list
690 echo -n > ${INFO}/${NAME}.list
696 buildaptarchivefromincoming
() {
697 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
699 [ -e pool
] || ln -s ..
/incoming pool
700 [ -e ftparchive.conf
] || createaptftparchiveconfig
701 [ -e dists
] || buildaptftparchivedirectorystructure
702 msgninfo
"\tGenerate Packages, Sources and Contents files… "
703 aptftparchive
-qq generate ftparchive.conf
709 buildaptarchivefromfiles
() {
710 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
711 find aptarchive
-name 'Packages' -o -name 'Sources' | while read line
; do
712 msgninfo
"\t${line} file… "
713 compressfile
"$line" "$1"
716 generatereleasefiles
"$@"
720 cat ${TMPWORKINGDIRECTORY}/rootdir
/etc
/testcase
-compressor.conf
| while read compressor extension
command; do
721 if [ "$compressor" = '.' ]; then
727 cat "$1" | $command > "${1}.${extension}"
729 touch -d "$2" "${1}.${extension}"
734 # can be overridden by testcases for their pleasure
735 getcodenamefromsuite
() {
737 unstable
) echo 'sid';;
741 getreleaseversionfromsuite
() { true
; }
742 getlabelfromsuite
() { true
; }
744 generatereleasefiles
() {
745 # $1 is the Date header and $2 is the ValidUntil header to be set
746 # both should be given in notation date/touch can understand
747 msgninfo
"\tGenerate Release files… "
748 if [ -e aptarchive
/dists
]; then
749 for dir
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
750 local SUITE
="$(echo "$dir" | cut -d'/' -f 4)"
751 local CODENAME
="$(getcodenamefromsuite $SUITE)"
752 local VERSION
="$(getreleaseversionfromsuite $SUITE)"
753 local LABEL
="$(getlabelfromsuite $SUITE)"
754 if [ -n "$VERSION" ]; then
755 VERSION
="-o APT::FTPArchive::Release::Version=${VERSION}"
757 if [ -n "$LABEL" ]; then
758 LABEL
="-o APT::FTPArchive::Release::Label=${LABEL}"
760 aptftparchive
-qq release
$dir \
761 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
762 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
765 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
766 if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
768 NotAutomatic: yes' $dir/Release
770 if [ -n "$1" -a "$1" != "now" ]; then
771 sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
775 Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
779 aptftparchive
-qq release .
/aptarchive
| sed -e '/0 Release$/ d' > aptarchive
/Release
# remove the self reference
781 if [ -n "$1" -a "$1" != "now" ]; then
782 for release
in $(find ./aptarchive -name 'Release'); do
783 touch -d "$1" $release
789 setupdistsaptarchive
() {
790 local APTARCHIVE
=$(readlink -f ./aptarchive)
791 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb.list
792 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb-src.list
793 for DISTS
in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
794 SECTIONS
=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
795 msgninfo
"\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
796 echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb.list
797 echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb-src.list
802 setupflataptarchive
() {
803 local APTARCHIVE
=$(readlink -f ./aptarchive)
804 if [ -f ${APTARCHIVE}/Packages
]; then
805 msgninfo
"\tadd deb sources.list line… "
806 echo "deb file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
809 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
811 if [ -f ${APTARCHIVE}/Sources
]; then
812 msgninfo
"\tadd deb-src sources.list line… "
813 echo "deb-src file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
816 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
822 if [ -e aptarchive
/dists
]; then
828 if [ "$1" != '--no-update' ]; then
829 msgninfo
"\tSync APT's cache with the archive… "
836 local SIGNER
="${1:-Joe Sixpack}"
837 local GPG
="gpg --batch --yes"
838 msgninfo
"\tSign archive with $SIGNER key… "
839 local REXKEY
='keys/rexexpired'
840 local SECEXPIREBAK
="${REXKEY}.sec.bak"
841 local PUBEXPIREBAK
="${REXKEY}.pub.bak"
842 if [ "${SIGNER}" = 'Rex Expired' ]; then
843 # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
844 # option doesn't exist anymore (and using faketime would add a new obscure dependency)
845 # therefore we 'temporary' make the key not expired and restore a backup after signing
846 cp ${REXKEY}.sec
$SECEXPIREBAK
847 cp ${REXKEY}.pub
$PUBEXPIREBAK
848 local SECUNEXPIRED
="${REXKEY}.sec.unexpired"
849 local PUBUNEXPIRED
="${REXKEY}.pub.unexpired"
850 if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
851 cp $SECUNEXPIRED ${REXKEY}.sec
852 cp $PUBUNEXPIRED ${REXKEY}.pub
854 printf "expire\n1w\nsave\n" | $GPG --keyring ${REXKEY}.pub
--secret-keyring ${REXKEY}.sec
--command-fd 0 --edit-key "${SIGNER}" >/dev
/null
2>&1 || true
855 cp ${REXKEY}.sec
$SECUNEXPIRED
856 cp ${REXKEY}.pub
$PUBUNEXPIRED
859 for KEY
in $(find keys/ -name '*.sec'); do
860 GPG
="$GPG --secret-keyring $KEY"
862 for KEY
in $(find keys/ -name '*.pub'); do
863 GPG
="$GPG --keyring $KEY"
865 for RELEASE
in $(find aptarchive/ -name Release); do
866 $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg
${RELEASE}
867 local INRELEASE
="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
868 $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
869 # we might have set a specific date for the Release file, so copy it
870 touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg
${INRELEASE}
872 if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
873 mv -f $SECEXPIREBAK ${REXKEY}.sec
874 mv -f $PUBEXPIREBAK ${REXKEY}.pub
880 msgtest
"Set webserver config option '${1}' to" "$2"
881 local DOWNLOG
='rootdir/tmp/download-testfile.log'
882 local STATUS
='rootdir/tmp/webserverconfig.status'
883 rm -f "$STATUS" "$DOWNLOG"
884 if downloadfile
"http://localhost:8080/_config/set/${1}/${2}" "$STATUS" > "$DOWNLOG"; then
887 cat "$DOWNLOG" "$STATUS"
890 testwebserverlaststatuscode
'200'
893 rewritesourceslist
() {
894 local APTARCHIVE
="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
895 for LIST
in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
896 sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#http://localhost:4433/#${1}#"
900 # wait for up to 10s for a pid file to appear to avoid possible race
901 # when a helper is started and dosn't write the PID quick enough
904 for i
in $(seq 10); do
905 if test -s "$PIDFILE"; then
910 msgdie
"waiting for $PIDFILE failed"
914 changetowebserver
() {
915 if [ "$1" != '--no-rewrite' ]; then
916 rewritesourceslist
'http://localhost:8080/'
920 if test -x ${APTWEBSERVERBINDIR}/aptwebserver
; then
922 local LOG
="webserver.log"
923 if ! aptwebserver
-o aptwebserver
::fork
=1 "$@" >$LOG 2>&1 ; then
927 waitforpidfile aptwebserver.pid
928 local PID
="$(cat aptwebserver.pid)"
929 if [ -z "$PID" ]; then
930 msgdie
'Could not fork aptwebserver successfully'
935 msgdie
'You have to build aptwerbserver or install a webserver'
939 changetohttpswebserver
() {
940 if ! which stunnel4
>/dev
/null
; then
941 msgdie
'You need to install stunnel4 for https testcases'
943 if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
944 changetowebserver
--no-rewrite "$@"
946 echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
947 cert = ${TESTDIRECTORY}/apt.pem
953 " > ${TMPWORKINGDIRECTORY}/stunnel.conf
954 stunnel4
"${TMPWORKINGDIRECTORY}/stunnel.conf"
955 waitforpidfile
"${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
956 local PID
="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
957 if [ -z "$PID" ]; then
958 msgdie
'Could not fork stunnel4 successfully'
960 addtrap
'prefix' "kill ${PID};"
961 rewritesourceslist
'https://localhost:4433/'
965 mkdir -p rootdir
/media
/cdrom
/.disk
966 local CD
="$(readlink -f rootdir/media/cdrom)"
967 echo "acquire::cdrom::mount \"${CD}\";
968 acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
969 acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
970 acquire::cdrom::autodetect 0;" > rootdir
/etc
/apt
/apt.conf.d
/00cdrom
971 echo -n "$1" > ${CD}/.disk
/info
972 if [ ! -d aptarchive
/dists
]; then
973 msgdie
'Flat file archive cdroms can not be created currently'
976 mv aptarchive
/dists
"$CD"
977 ln -s "$(readlink -f ./incoming)" $CD/pool
978 find rootdir
/etc
/apt
/sources.list.d
/ -name 'apt-test-*.list' -delete
979 # start with an unmounted disk
980 mv "${CD}" "${CD}-unmounted"
981 # we don't want the disk to be modifiable
982 addtrap
'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
983 chmod -R -w rootdir
/media
/cdrom
-unmounted/dists
987 local PROTO
="$(echo "$1" | cut -d':' -f 1 )"
988 apthelper
-o Debug
::Acquire
::${PROTO}=1 \
989 download
-file "$1" "$2" 2>&1 || true
990 # only if the file exists the download was successful
999 local DIFFTEXT
="$(command diff -u "$@" | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
1000 if [ -n "$DIFFTEXT" ]; then
1002 echo >&2 "$DIFFTEXT"
1012 msgtest
"Test for correctness of file" "$FILE"
1013 if [ -z "$*" ]; then
1014 echo -n "" | checkdiff
$FILE - && msgpass
|| msgfail
1016 echo "$*" | checkdiff
$FILE - && msgpass
|| msgfail
1021 msgtest
"Test for no output of" "$*"
1022 test -z "$($* 2>&1)" && msgpass
|| msgfail
1026 local MSG
='Test of equality of'
1027 if [ "$1" = '--nomsg' ]; then
1032 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile"
1033 echo "$1" > $COMPAREFILE
1036 if [ -n "$MSG" ]; then
1039 $
* 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1043 local COMPAREFILE1
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
1044 local COMPAREFILE2
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
1045 local COMPAREAGAINST
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
1046 echo "$1" > $COMPAREFILE1
1047 echo "$2" > $COMPAREFILE2
1049 msgtest
"Test for equality OR of" "$*"
1050 $
* >$COMPAREAGAINST 2>&1 || true
1051 if checkdiff
$COMPAREFILE1 $COMPAREAGAINST >/dev
/null
2>&1 || \
1052 checkdiff
$COMPAREFILE2 $COMPAREAGAINST >/dev
/null
2>&1
1056 echo -n "\n${CINFO}Diff against OR 1${CNORMAL}"
1057 checkdiff
$COMPAREFILE1 $COMPAREAGAINST || true
1058 echo -n "${CINFO}Diff against OR 2${CNORMAL}"
1059 checkdiff
$COMPAREFILE2 $COMPAREAGAINST || true
1065 local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual"
1068 while [ -n "$1" ]; do
1070 N: Can't select versions from package '$1' as it is purely virtual"
1071 PACKAGE
="${PACKAGE} $1"
1074 msgtest
"Test for virtual packages" "apt-cache show $PACKAGE"
1076 N: No packages found"
1077 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile"
1078 local ARCH
="$(getarchitecture 'native')"
1079 echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
1080 aptcache show
-q=0 $PACKAGE 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1084 msgtest
"Test for non-existent packages" "apt-cache show $*"
1085 local SHOWPKG
="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
1086 if [ -n "$SHOWPKG" ]; then
1095 testdpkginstalled
() {
1096 msgtest
"Test for correctly installed package(s) with" "dpkg -l $*"
1097 local PKGS
="$(dpkg -l "$@" 2>/dev/null | grep '^i' | wc -l)"
1098 if [ "$PKGS" != $# ]; then
1100 dpkg
-l "$@" | grep '^[a-z]' >&2
1107 testdpkgnotinstalled
() {
1108 msgtest
"Test for correctly not-installed package(s) with" "dpkg -l $*"
1109 local PKGS
="$(dpkg -l "$@" 2> /dev/null | grep '^i' | wc -l)"
1110 if [ "$PKGS" != 0 ]; then
1112 dpkg
-l "$@" | grep '^[a-z]' >&2
1120 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
1121 if [ -n "$1" ]; then
1122 msgtest
'Test for correctly marked as auto-installed' "$*"
1123 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1125 msgtest
'Test for correctly marked as auto-installed' 'no package'
1126 echo -n > $COMPAREFILE
1128 aptmark showauto
2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1132 if [ "$1" = '--nomsg' ]; then
1135 msgtest
'Test for successful execution of' "$*"
1137 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
1138 if $@
>${OUTPUT} 2>&1; then
1148 if [ "$1" = '--nomsg' ]; then
1151 msgtest
'Test for failure in execution of' "$*"
1153 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
1154 if $@
>${OUTPUT} 2>&1; then
1163 testwebserverlaststatuscode
() {
1164 local DOWNLOG
='rootdir/tmp/webserverstatus-testfile.log'
1165 local STATUS
='rootdir/tmp/webserverstatus-statusfile.log'
1166 rm -f "$DOWNLOG" "$STATUS"
1167 msgtest
'Test last status code from the webserver was' "$1"
1168 downloadfile
"http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG"
1169 if [ "$(cat "$STATUS")" = "$1" ]; then
1173 if [ -n "$2" ]; then
1175 echo >&2 '#### Additionally provided output files contain:'
1178 echo >&2 '#### Download log of the status code:'
1180 msgfail
"Status was $(cat "$STATUS")"
1185 echo "STOPPED execution. Press enter to continue"