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"; }
47 if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2;
48 else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi
51 if [ $# -gt 0 ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
52 else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
53 if [ -n "$APT_DEBUG_TESTS" ]; then
56 EXIT_CODE
=$((EXIT_CODE+1));
59 # enable / disable Debugging
60 MSGLEVEL
=${MSGLEVEL:-3}
61 if [ $MSGLEVEL -le 0 ]; then
64 if [ $MSGLEVEL -le 1 ]; then
68 if [ $MSGLEVEL -le 2 ]; then
72 msgpass
() { printf " ${CPASS}P${CNORMAL}"; }
73 msgskip
() { printf " ${CWARNING}S${CNORMAL}" >&2; }
74 if [ -n "$CFAIL" ]; then
75 msgfail
() { printf " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE
=$((EXIT_CODE+1)); }
77 msgfail
() { printf " ###FAILED###" >&2; EXIT_CODE
=$((EXIT_CODE+1)); }
80 if [ $MSGLEVEL -le 3 ]; then
84 if [ $MSGLEVEL -le 4 ]; then
89 if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
90 [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
91 [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
92 [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
93 [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
96 printf "${CDONE}DONE${CNORMAL}\n";
100 if [ -f .
/aptconfig.conf
]; then
101 echo "./aptconfig.conf"
102 elif [ -f ..
/aptconfig.conf
]; then
103 echo "../aptconfig.conf"
107 msgdebug
"Executing: ${CCMD}$*${CDEBUG} "
111 sh
|aptitude
|*/*|command) ;;
112 *) CMD
="${BUILDDIRECTORY}/$CMD";;
114 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 APT_CONFIG
="$(getaptconfig)" LD_LIBRARY_PATH
=${LIBRARYPATH} $CMD "$@"
116 aptconfig
() { runapt apt
-config "$@"; }
117 aptcache
() { runapt apt
-cache "$@"; }
118 aptcdrom
() { runapt apt
-cdrom "$@"; }
119 aptget
() { runapt apt
-get "$@"; }
120 aptftparchive
() { runapt apt
-ftparchive "$@"; }
121 aptkey
() { runapt apt
-key "$@"; }
122 aptmark
() { runapt apt
-mark "$@"; }
123 aptsortpkgs
() { runapt apt
-sortpkgs "$@"; }
124 apt
() { runapt apt
"$@"; }
125 apthelper
() { runapt
"${APTHELPERBINDIR}/apt-helper" "$@"; }
126 aptwebserver
() { runapt
"${APTWEBSERVERBINDIR}/aptwebserver" "$@"; }
127 aptitude
() { runapt aptitude
"$@"; }
128 aptextracttemplates
() { runapt apt
-extracttemplates "$@"; }
129 aptinternalsolver
() { runapt
"${APTINTERNALSOLVER}" "$@"; }
132 command dpkg
--root=${TMPWORKINGDIRECTORY}/rootdir
--force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir
/var
/log
/dpkg.log
"$@"
134 dpkgcheckbuilddeps
() {
135 command dpkg
-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir
/var
/lib
/dpkg
"$@"
140 runapt
command gdb
--quiet -ex run
"${BUILDDIRECTORY}/$CMD" --args "${BUILDDIRECTORY}/$CMD" "$@"
144 # error if we about to overflow, but ...
145 # "255 failures ought to be enough for everybody"
146 if [ $EXIT_CODE -gt 255 ]; then
147 msgdie
"Total failure count $EXIT_CODE too big"
149 exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
152 shellsetedetector
() {
154 if [ "$exit_status" != '0' ]; then
155 printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n"
156 if [ "$EXIT_CODE" = '0' ]; then
157 EXIT_CODE
="$exit_status"
163 if [ "$1" = 'prefix' ]; then
164 CURRENTTRAP
="$2 $CURRENTTRAP"
166 CURRENTTRAP
="$CURRENTTRAP $1"
168 trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
172 TMPWORKINGDIRECTORY
=$(mktemp -d)
173 addtrap
"cd /; rm -rf $TMPWORKINGDIRECTORY;"
174 msgninfo
"Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
176 if [ "$(id -u)" = '0' ]; then
177 # relax permissions so that running as root with user switching works
179 chmod o
+rx
"$TMPWORKINGDIRECTORY"
182 TESTDIRECTORY
=$(readlink -f $(dirname $0))
183 # allow overriding the default BUILDDIR location
184 BUILDDIRECTORY
=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
185 LIBRARYPATH
=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
186 METHODSDIR
=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
187 APTHELPERBINDIR
=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
188 APTWEBSERVERBINDIR
=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
189 APTINTERNALSOLVER
=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"}
190 test -x "${BUILDDIRECTORY}/apt-get" || msgdie
"You need to build tree first"
193 cd $TMPWORKINGDIRECTORY
194 mkdir rootdir aptarchive keys
196 mkdir -p etc
/apt
/apt.conf.d etc
/apt
/sources.list.d etc
/apt
/trusted.gpg.d etc
/apt
/preferences.d
197 mkdir -p usr
/bin var
/cache var
/lib
/apt var
/log tmp
198 mkdir -p var
/lib
/dpkg
/info var
/lib
/dpkg
/updates var
/lib
/dpkg
/triggers
199 touch var
/lib
/dpkg
/available
201 ln -s ${METHODSDIR} usr
/lib
/apt
/methods
202 if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
203 mkdir -p usr
/lib
/apt
/solvers
204 ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr
/lib
/apt
/solvers
/dump
205 ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr
/lib
/apt
/solvers
/apt
206 echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc
/apt
/apt.conf.d
/externalsolver.conf
208 # use the autoremove from the BUILDDIRECTORY if its there, otherwise
210 if [ -e ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove
]; then
211 ln -s ${BUILDDIRECTORY}/..
/..
/debian
/apt.conf.autoremove etc
/apt
/apt.conf.d
/01autoremove
213 ln -s /etc
/apt
/apt.conf.d
/01autoremove etc
/apt
/apt.conf.d
/01autoremove
216 local PACKAGESFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
217 if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
218 cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
220 local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
221 if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
222 cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive
/Sources
224 cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys
/
225 chmod 644 $(find keys -name '*.pub' -o -name '*.sec')
226 ln -s ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
228 echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
229 echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
230 echo "Debug::NoLocking \"true\";" >> aptconfig.conf
231 echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
232 echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf
233 # store apt-key were we can access it, even if we run it as a different user
234 # destroys coverage reporting though, so just do it for root for now
235 if [ "$(id -u)" = '0' ]; then
236 cp "${BUILDDIRECTORY}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/"
237 chmod o
+rx
"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key"
238 echo "Dir::Bin::apt-key \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key\";" >> aptconfig.conf
240 echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
242 echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
243 echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
244 echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
245 echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
246 echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
247 if ! command dpkg
--assert-multi-arch >/dev
/null
2>&1; then
248 echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf
# Added to test multiarch before dpkg is ready for it…
250 echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
251 echo 'quiet::NoUpdate "true";' >> aptconfig.conf
252 echo 'quiet::NoStatistic "true";' >> aptconfig.conf
253 # too distracting for users, but helpful to detect changes
254 echo 'Acquire::Progress::Ignore::ShowErrorText "true";' >> aptconfig.conf
255 # in testcases, it can appear as if localhost has a rotation setup,
256 # hide this as we can't really deal with it properly
257 echo 'Acquire::Failure::ShowIP "false";' >> aptconfig.conf
259 cp "${TESTDIRECTORY}/apt.pem" "${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
260 if [ "$(id -u)" = '0' ]; then
261 chown _apt
:root
"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
263 echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir
/etc
/apt
/apt.conf.d
/99https
264 echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir
/etc
/apt
/apt.conf.d
/apt
-binary
265 configcompression
'.' 'gz' #'bz2' 'lzma' 'xz'
267 # Acquire::AllowInsecureRepositories=false is not yet the default
268 # but we want it to be the default soon
269 configallowinsecurerepositories
"false";
271 # cleanup the environment a bit
272 # prefer our apt binaries over the system apt binaries
273 export PATH
="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
274 export LC_ALL
=C.UTF
-8
275 unset LANGUAGE APT_CONFIG
276 unset GREP_OPTIONS DEB_BUILD_PROFILES
282 if [ "$1" = "native" -o -z "$1" ]; then
283 eval `aptconfig shell ARCH APT::Architecture`
284 if [ -n "$ARCH" ]; then
287 dpkg
--print-architecture
295 echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
298 getarchitecturesfromcommalist
() {
299 echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
302 configarchitecture
() {
304 echo "APT::Architecture \"$(getarchitecture $1)\";"
305 while [ -n "$1" ]; do
306 echo "APT::Architectures:: \"$(getarchitecture $1)\";"
309 } >rootdir
/etc
/apt
/apt.conf.d
/01multiarch.conf
314 if [ ! -e rootdir
/var
/lib
/dpkg
/status
]; then
315 local STATUSFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
316 if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
317 cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
319 echo -n > rootdir/var/lib/dpkg/status
322 rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
323 if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
324 local ARCHS="$(getarchitectures)"
325 if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
326 DPKGARCH="$(dpkg --print-architecture)"
327 for ARCH in ${ARCHS}; do
328 if [ "${ARCH}" != "${DPKGARCH}" ]; then
329 if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
330 # old-style used e.g. in Ubuntu-P – and as it seems travis
331 echo "DPKG
::options
:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
332 echo "DPKG
::options
:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
336 if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
337 # dpkg doesn't really check the version as long as it is fully installed,
338 # but just to be sure we choose one above the required version
339 insertinstalledpackage 'dpkg' "all
" '1.16.2+fake'
345 configallowinsecurerepositories() {
346 echo "Acquire
::AllowInsecureRepositories
\"$1\";" > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf
350 configcompression() {
351 while [ -n "$1" ]; do
353 '.') printf ".
\t.
\tcat
\n";;
354 'gz') printf "gzip\tgz
\tgzip
\n";;
355 'bz2') printf "bzip2\tbz
2\tbzip
2\n";;
356 'lzma') printf "lzma
\tlzma
\txz
--format=lzma
\n";;
357 'xz') printf "xz
\txz
\txz
\n";;
358 *) printf "$1\t$1\t$1\n";;
361 done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
368 gzip) COMPRESS='gz';;
369 bzip2) COMPRESS='bz2';;
370 lzma) COMPRESS='lzma';;
372 *) msgdie "Compressor
$COMPRESSOR is unknown to framework
, so can
't be forced by forcecompressor!";;
374 local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
375 echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
376 Dir::Bin::uncompressed \"/does/not/exist\";
377 Dir::Bin::gzip \"/does/not/exist\";
378 Dir::Bin::bzip2 \"/does/not/exist\";
379 Dir::Bin::lzma \"/does/not/exist\";
380 Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
381 if [ -e "/bin/${COMPRESSOR}" ]; then
382 echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
383 elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
384 echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
385 elif [ "${COMPRESSOR}" = 'lzma
' ]; then
386 echo 'Dir
::Bin
::xz
"/usr/bin/xz";' >> "$CONFFILE"
387 COMPRESSOR_CMD='xz
--format=lzma
'
389 msgtest 'Test
for availability of compressor
' "${COMPRESSOR}"
394 setupsimplenativepackage() {
398 local RELEASE="${4:-unstable}"
399 local DEPENDENCIES="$5"
400 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
401 If you find such a package installed on your system,
402 something went horribly wrong! They are autogenerated
403 und used only by testcases and surf no other propose…"}"
405 local SECTION="${7:-others}"
407 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
410 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
412 local BUILDDIR=incoming/${NAME}-${VERSION}
413 mkdir -p ${BUILDDIR}/debian/source
415 echo "* most suckless software product ever" > FEATURES
416 test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
417 test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
421 -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog
422 test -e debian/control || echo "Source: $NAME
425 Maintainer: Joe Sixpack <joe@example.org>
426 Build-Depends: debhelper (>= 7)
427 Standards-Version: 3.9.1
429 Package: $NAME" > debian/control
430 if [ "$ARCH" = 'all
' ]; then
431 echo "Architecture: all" >> debian/control
433 echo "Architecture: any" >> debian/control
435 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
436 echo "Description: $DESCRIPTION" >> debian/control
438 test -e debian/compat || echo "7" > debian/compat
439 test -e debian/source/format || echo "3.0 (native)" > debian/source/format
440 test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
444 buildsimplenativepackage() {
448 local RELEASE="${4:-unstable}"
449 local DEPENDENCIES="$5"
450 local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
451 If you find such a package installed on your system,
452 something went horribly wrong! They are autogenerated
453 und used only by testcases and surf no other propose…"}"
455 local SECTION="${7:-others}"
456 local PRIORITY="${8:-optional}"
458 local COMPRESS_TYPE="${10:-gzip}"
460 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
463 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
465 local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
467 msgninfo "Build package ${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}… "
468 mkdir -p $BUILDDIR/debian/source
469 echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
471 echo '$NAME says
\"Hello
!\"'" > ${BUILDDIR}/${NAME}
473 echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright
474 echo "$NAME ($VERSION) $RELEASE; urgency=low
478 -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog
482 Maintainer: Joe Sixpack <joe@example.org>
483 Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control
484 local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
485 test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
487 Package: $NAME" >> ${BUILDDIR}/debian/control
489 if [ "$ARCH" = 'all
' ]; then
490 echo "Architecture: all" >> ${BUILDDIR}/debian/control
492 echo "Architecture: any" >> ${BUILDDIR}/debian/control
494 local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
495 test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
496 echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control
498 echo '3.0 (native
)' > ${BUILDDIR}/debian/source/format
499 (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | sed -n 's
#^dpkg-source: info: building [^ ]\+ in ##p' \
501 echo "pool/${SRC}" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.srclist
502 # if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
503 # aptkey --keyring ./keys/joesixpack.pub --secret-keyring ./keys/joesixpack.sec --quiet --readonly \
504 # adv --yes --default-key 'Joe Sixpack' \
505 # --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
506 # mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
510 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
511 rm -rf ${BUILDDIR}/debian
/tmp
512 mkdir -p ${BUILDDIR}/debian
/tmp
/DEBIAN
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
513 cp ${BUILDDIR}/debian
/copyright
${BUILDDIR}/debian
/changelog
${BUILDDIR}/FEATURES
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME}
514 cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
/${NAME}-${arch}
515 if [ -n "$FILE_TREE" ]; then
516 cp -ar "$FILE_TREE" ${BUILDDIR}/debian
/tmp
519 (cd ${BUILDDIR}; dpkg
-gencontrol -DArchitecture=$arch)
520 (cd ${BUILDDIR}/debian
/tmp
; md5sum $(find usr/ -type f) > DEBIAN
/md5sums
)
521 local LOG
="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log"
522 # ensure the right permissions as dpkg-deb ensists
523 chmod 755 ${BUILDDIR}/debian
/tmp
/DEBIAN
524 if ! dpkg
-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian
/tmp
${BUILDDIR}/..
>$LOG 2>&1; then
529 echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.pkglist
532 mkdir -p ${BUILDDIR}/..
/${NAME}_
${VERSION}
533 cp ${BUILDDIR}/debian
/changelog
${BUILDDIR}/..
/${NAME}_
${VERSION}/
534 cp ${BUILDDIR}/debian
/changelog
${BUILDDIR}/..
/${NAME}_
${VERSION}.changelog
543 local ARCH
=$(getarchitecture $4)
544 local PKGNAME
="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
545 local BUILDLOG
="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
546 msgninfo
"Build package ${PKGNAME} for ${RELEASE} in ${SECTION}… "
548 if [ "$ARCH" = "all" ]; then
549 ARCH
="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
551 if ! dpkg
-buildpackage -uc -us -a$ARCH >$BUILDLOG 2>&1 ; then
555 local PKGS
="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
556 local SRCS
="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
559 echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.pkglist
562 echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.srclist
568 if [ -d incoming
]; then
569 buildaptarchivefromincoming
"$@"
571 buildaptarchivefromfiles
"$@"
575 createaptftparchiveconfig
() {
576 local COMPRESSORS
="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
577 COMPRESSORS
="${COMPRESSORS%* }"
578 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' ' ')"
579 if [ -z "$ARCHS" ]; then
580 # the pool is empty, so we will operate on faked packages - let us use the configured archs
581 ARCHS
="$(getarchitectures)"
584 ArchiveDir "' >> ftparchive.conf
585 echo -n $(readlink -f .) >> ftparchive.conf
587 CacheDir "' >> ftparchive.conf
588 echo -n $(readlink -f ..) >> ftparchive.conf
590 FileListDir "' >> ftparchive.conf
591 echo -n $(readlink -f pool/) >> ftparchive.conf
595 Packages::Compress "'"$COMPRESSORS"'";
596 Sources::Compress "'"$COMPRESSORS"'";
597 Contents::Compress "'"$COMPRESSORS"'";
598 Translation::Compress "'"$COMPRESSORS"'";
599 LongDescription "false";
603 SrcDirectory "pool/";
609 Label "apttestcases";
611 Description "repository with dummy packages";
612 Architectures "' >> ftparchive.conf
613 echo -n "$ARCHS" >> ftparchive.conf
617 };' >> ftparchive.conf
618 for DIST
in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
619 echo -n 'tree "dists/' >> ftparchive.conf
620 echo -n "$DIST" >> ftparchive.conf
622 Architectures "' >> ftparchive.conf
623 echo -n "$ARCHS" >> ftparchive.conf
625 FileList "' >> ftparchive.conf
626 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
628 SourceFileList "' >> ftparchive.conf
629 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
631 Sections "' >> ftparchive.conf
632 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
634 };' >> ftparchive.conf
638 buildaptftparchivedirectorystructure
() {
639 local DISTS
="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
640 for DIST
in $DISTS; do
641 local SECTIONS
="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
642 for SECTION
in $SECTIONS; do
643 local ARCHS
="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
644 for ARCH
in $ARCHS; do
645 mkdir -p dists
/${DIST}/${SECTION}/binary
-${ARCH}
647 mkdir -p dists
/${DIST}/${SECTION}/source
648 mkdir -p dists
/${DIST}/${SECTION}/i18n
658 local DEPENDENCIES
="$5"
659 local PRIORITY
="${6:-optional}"
660 local DESCRIPTION
="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
661 If you find such a package installed on your system,
662 something went horribly wrong! They are autogenerated
663 und used only by testcases and surf no other propose…"}"
665 for arch in $(getarchitecturesfromcommalist "$ARCH"); do
666 if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
667 ARCHS="$(getarchitectures)"
671 for BUILDARCH in $ARCHS; do
672 local PPATH="aptarchive
/dists
/${RELEASE}/main
/binary
-${BUILDARCH}"
673 mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
674 touch aptarchive/dists/${RELEASE}/main/source/Sources
675 local FILE="${PPATH}/Packages
"
680 Maintainer
: Joe Sixpack
<joe@example.org
>" >> $FILE
681 test "$arch" = 'none' || echo "Architecture
: $arch" >> $FILE
682 echo "Version
: $VERSION
683 Filename
: pool
/main
/${NAME}/${NAME}_
${VERSION}_
${arch}.deb
" >> $FILE
684 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
685 echo "Description
: $DESCRIPTION" >> $FILE
696 local DEPENDENCIES="$5"
698 local SPATH="aptarchive
/dists
/${RELEASE}/main
/source"
700 local FILE="${SPATH}/Sources
"
704 Maintainer
: Joe Sixpack
<joe@example.org
>
705 Architecture
: $ARCH" >> $FILE
706 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
708 d41d8cd98f00b204e9800998ecf8427e
0 ${NAME}_
${VERSION}.dsc
709 d41d8cd98f00b204e9800998ecf8427e
0 ${NAME}_
${VERSION}.
tar.gz
713 insertinstalledpackage() {
717 local DEPENDENCIES="$4"
718 local PRIORITY="${5:-optional}"
719 local STATUS="${6:-install ok installed}"
720 local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
721 If you
find such a package installed on your system
,
722 something went horribly wrong
! They are autogenerated
723 und used only by testcases and surf no other propose…
"}"
725 local FILE
='rootdir/var/lib/dpkg/status'
726 local INFO
='rootdir/var/lib/dpkg/info'
727 for arch
in $(getarchitecturesfromcommalist "$ARCH"); do
733 Maintainer: Joe Sixpack <joe@example.org>
734 Version: $VERSION" >> $FILE
735 test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
736 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
737 echo "Description: $DESCRIPTION" >> $FILE
739 if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
740 echo -n > ${INFO}/${NAME}:${arch}.list
742 echo -n > ${INFO}/${NAME}.list
748 buildaptarchivefromincoming
() {
749 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
751 [ -e pool
] || ln -s ..
/incoming pool
752 [ -e ftparchive.conf
] || createaptftparchiveconfig
753 [ -e dists
] || buildaptftparchivedirectorystructure
754 msgninfo
"\tGenerate Packages, Sources and Contents files… "
755 aptftparchive
-qq generate ftparchive.conf
758 generatereleasefiles
"$@"
761 buildaptarchivefromfiles
() {
762 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
763 find aptarchive
-name 'Packages' -o -name 'Sources' | while read line
; do
764 msgninfo
"\t${line} file… "
765 compressfile
"$line" "$1"
768 generatereleasefiles
"$@"
772 cat ${TMPWORKINGDIRECTORY}/rootdir
/etc
/testcase
-compressor.conf
| while read compressor extension
command; do
773 if [ "$compressor" = '.' ]; then
779 cat "$1" | $command > "${1}.${extension}"
781 touch -d "$2" "${1}.${extension}"
786 # can be overridden by testcases for their pleasure
787 getcodenamefromsuite
() {
789 unstable
) echo 'sid';;
793 getreleaseversionfromsuite
() { true
; }
794 getlabelfromsuite
() { true
; }
796 generatereleasefiles
() {
797 # $1 is the Date header and $2 is the ValidUntil header to be set
798 # both should be given in notation date/touch can understand
799 msgninfo
"\tGenerate Release files… "
800 if [ -e aptarchive
/dists
]; then
801 for dir
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
802 local SUITE
="$(echo "$dir" | cut -d'/' -f 4)"
803 local CODENAME
="$(getcodenamefromsuite $SUITE)"
804 local VERSION
="$(getreleaseversionfromsuite $SUITE)"
805 local LABEL
="$(getlabelfromsuite $SUITE)"
806 if [ -n "$VERSION" ]; then
807 VERSION
="-o APT::FTPArchive::Release::Version=${VERSION}"
809 if [ -n "$LABEL" ]; then
810 LABEL
="-o APT::FTPArchive::Release::Label=${LABEL}"
812 aptftparchive
-qq release
$dir \
813 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
814 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
817 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
818 if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
820 NotAutomatic: yes' $dir/Release
822 if [ -n "$1" -a "$1" != "now" ]; then
823 sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
827 Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
831 aptftparchive
-qq release .
/aptarchive
| sed -e '/0 Release$/ d' > aptarchive
/Release
# remove the self reference
833 if [ -n "$1" -a "$1" != "now" ]; then
834 for release
in $(find ./aptarchive -name 'Release'); do
835 touch -d "$1" $release
841 setupdistsaptarchive
() {
842 local APTARCHIVE
=$(readlink -f ./aptarchive)
843 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb.list
844 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb-src.list
845 for DISTS
in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
846 SECTIONS
=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
847 msgninfo
"\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
848 echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb.list
849 echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb-src.list
854 setupflataptarchive
() {
855 local APTARCHIVE
=$(readlink -f ./aptarchive)
856 if [ -f ${APTARCHIVE}/Packages
]; then
857 msgninfo
"\tadd deb sources.list line… "
858 echo "deb file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
861 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
863 if [ -f ${APTARCHIVE}/Sources
]; then
864 msgninfo
"\tadd deb-src sources.list line… "
865 echo "deb-src file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
868 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
874 if [ "$1" = '--no-update' ]; then
879 if [ -e aptarchive
/dists
]; then
884 signreleasefiles
'Joe Sixpack'
885 if [ "1" != "$NOUPDATE" ]; then
886 testsuccess aptget update
-o Debug
::pkgAcquire
::Worker
=true
-o Debug
::Acquire
::gpgv
=true
891 local SIGNER
="${1:-Joe Sixpack}"
892 local REPODIR
="${2:-aptarchive}"
893 local KEY
="keys/$(echo "$SIGNER" | tr 'A-Z' 'a-z' | sed 's# ##g')"
894 local GPG
="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes"
895 msgninfo
"\tSign archive with $SIGNER key $KEY… "
896 local REXKEY
='keys/rexexpired'
897 local SECEXPIREBAK
="${REXKEY}.sec.bak"
898 local PUBEXPIREBAK
="${REXKEY}.pub.bak"
899 if [ "${SIGNER}" = 'Rex Expired' ]; then
900 # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
901 # option doesn't exist anymore (and using faketime would add a new obscure dependency)
902 # therefore we 'temporary' make the key not expired and restore a backup after signing
903 cp ${REXKEY}.sec
$SECEXPIREBAK
904 cp ${REXKEY}.pub
$PUBEXPIREBAK
905 local SECUNEXPIRED
="${REXKEY}.sec.unexpired"
906 local PUBUNEXPIRED
="${REXKEY}.pub.unexpired"
907 if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
908 cp $SECUNEXPIRED ${REXKEY}.sec
909 cp $PUBUNEXPIRED ${REXKEY}.pub
911 if ! printf "expire\n1w\nsave\n" | $GPG --default-key "$SIGNER" --command-fd 0 --edit-key "${SIGNER}" >setexpire.gpg
2>&1; then
915 cp ${REXKEY}.sec
$SECUNEXPIRED
916 cp ${REXKEY}.pub
$PUBUNEXPIRED
919 for RELEASE
in $(find ${REPODIR}/ -name Release); do
920 $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg
${RELEASE}
921 local INRELEASE
="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
922 $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
923 # we might have set a specific date for the Release file, so copy it
924 touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg
${INRELEASE}
926 if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
927 mv -f $SECEXPIREBAK ${REXKEY}.sec
928 mv -f $PUBEXPIREBAK ${REXKEY}.pub
934 msgtest
"Set webserver config option '${1}' to" "$2"
935 local DOWNLOG
='rootdir/tmp/download-testfile.log'
936 local STATUS
='rootdir/tmp/webserverconfig.status'
937 rm -f "$STATUS" "$DOWNLOG"
938 if downloadfile
"http://localhost:8080/_config/set/${1}/${2}" "$STATUS" > "$DOWNLOG"; then
941 cat "$DOWNLOG" "$STATUS"
944 testwebserverlaststatuscode
'200'
947 rewritesourceslist
() {
948 local APTARCHIVE
="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
949 for LIST
in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
950 sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#http://localhost:4433/#${1}#"
954 # wait for up to 10s for a pid file to appear to avoid possible race
955 # when a helper is started and dosn't write the PID quick enough
958 for i
in $(seq 10); do
959 if test -s "$PIDFILE"; then
964 msgdie
"waiting for $PIDFILE failed"
968 changetowebserver
() {
969 if [ "$1" != '--no-rewrite' ]; then
970 rewritesourceslist
'http://localhost:8080/'
974 if test -x ${APTWEBSERVERBINDIR}/aptwebserver
; then
976 local LOG
="webserver.log"
977 if ! aptwebserver
-o aptwebserver
::fork
=1 "$@" >$LOG 2>&1 ; then
981 waitforpidfile aptwebserver.pid
982 local PID
="$(cat aptwebserver.pid)"
983 if [ -z "$PID" ]; then
984 msgdie
'Could not fork aptwebserver successfully'
989 msgdie
'You have to build aptwerbserver or install a webserver'
993 changetohttpswebserver
() {
994 if ! which stunnel4
>/dev
/null
; then
995 msgdie
'You need to install stunnel4 for https testcases'
997 if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
998 changetowebserver
--no-rewrite "$@"
1000 echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
1001 cert = ${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem
1007 " > ${TMPWORKINGDIRECTORY}/stunnel.conf
1008 stunnel4
"${TMPWORKINGDIRECTORY}/stunnel.conf"
1009 waitforpidfile
"${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
1010 local PID
="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
1011 if [ -z "$PID" ]; then
1012 msgdie
'Could not fork stunnel4 successfully'
1014 addtrap
'prefix' "kill ${PID};"
1015 rewritesourceslist
'https://localhost:4433/'
1019 mkdir -p rootdir
/media
/cdrom
/.disk
1020 local CD
="$(readlink -f rootdir/media/cdrom)"
1021 echo "acquire::cdrom::mount \"${CD}\";
1022 acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
1023 acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
1024 acquire::cdrom::autodetect 0;" > rootdir
/etc
/apt
/apt.conf.d
/00cdrom
1025 echo -n "$1" > ${CD}/.disk
/info
1026 if [ ! -d aptarchive
/dists
]; then
1027 msgdie
'Flat file archive cdroms can not be created currently'
1030 mv aptarchive
/dists
"$CD"
1031 ln -s "$(readlink -f ./incoming)" $CD/pool
1032 find rootdir
/etc
/apt
/sources.list.d
/ -name 'apt-test-*.list' -delete
1033 # start with an unmounted disk
1034 mv "${CD}" "${CD}-unmounted"
1035 # we don't want the disk to be modifiable
1036 addtrap
'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
1037 chmod -R -w rootdir
/media
/cdrom
-unmounted/dists
1041 local PROTO
="$(echo "$1" | cut -d':' -f 1 )"
1042 apthelper
-o Debug
::Acquire
::${PROTO}=1 \
1043 download
-file "$1" "$2" 2>&1 || true
1044 # only if the file exists the download was successful
1045 if [ -e "$2" ]; then
1053 local DIFFTEXT
="$(command diff -u "$@" | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
1054 if [ -n "$DIFFTEXT" ]; then
1056 echo >&2 "$DIFFTEXT"
1066 msgtest
"Test for correctness of file" "$FILE"
1067 if [ -z "$*" ]; then
1068 echo -n "" | checkdiff
$FILE - && msgpass
|| msgfail
1070 echo "$*" | checkdiff
$FILE - && msgpass
|| msgfail
1075 msgtest
"Test for no output of" "$*"
1076 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
1077 if $
* >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
1086 local MSG
='Test of equality of'
1087 if [ "$1" = '--nomsg' ]; then
1092 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile"
1093 echo "$1" > $COMPAREFILE
1096 if [ -n "$MSG" ]; then
1099 $
* 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1103 local COMPAREFILE1
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
1104 local COMPAREFILE2
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
1105 local COMPAREAGAINST
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
1106 echo "$1" > $COMPAREFILE1
1107 echo "$2" > $COMPAREFILE2
1109 msgtest
"Test for equality OR of" "$*"
1110 $
* >$COMPAREAGAINST 2>&1 || true
1111 if checkdiff
$COMPAREFILE1 $COMPAREAGAINST >/dev
/null
2>&1 || \
1112 checkdiff
$COMPAREFILE2 $COMPAREAGAINST >/dev
/null
2>&1
1116 echo -n "\n${CINFO}Diff against OR 1${CNORMAL}"
1117 checkdiff
$COMPAREFILE1 $COMPAREAGAINST || true
1118 echo -n "${CINFO}Diff against OR 2${CNORMAL}"
1119 checkdiff
$COMPAREFILE2 $COMPAREAGAINST || true
1125 local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual"
1128 while [ -n "$1" ]; do
1130 N: Can't select versions from package '$1' as it is purely virtual"
1131 PACKAGE
="${PACKAGE} $1"
1134 msgtest
"Test for virtual packages" "apt-cache show $PACKAGE"
1136 N: No packages found"
1137 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile"
1138 local ARCH
="$(getarchitecture 'native')"
1139 echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
1140 aptcache show
-q=0 $PACKAGE 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1144 msgtest
"Test for non-existent packages" "apt-cache show $*"
1145 local SHOWPKG
="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
1146 if [ -n "$SHOWPKG" ]; then
1155 testdpkginstalled
() {
1156 msgtest
"Test for correctly installed package(s) with" "dpkg -l $*"
1157 local PKGS
="$(dpkg -l "$@" 2>/dev/null | grep '^i' | wc -l)"
1158 if [ "$PKGS" != $# ]; then
1160 dpkg
-l "$@" | grep '^[a-z]' >&2
1167 testdpkgnotinstalled
() {
1168 msgtest
"Test for correctly not-installed package(s) with" "dpkg -l $*"
1169 local PKGS
="$(dpkg -l "$@" 2> /dev/null | grep '^i' | wc -l)"
1170 if [ "$PKGS" != 0 ]; then
1172 dpkg
-l "$@" | grep '^[a-z]' >&2
1180 local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
1181 if [ -n "$1" ]; then
1182 msgtest
'Test for correctly marked as auto-installed' "$*"
1183 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
1185 msgtest
'Test for correctly marked as auto-installed' 'no package'
1186 echo -n > $COMPAREFILE
1188 aptmark showauto
2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
1192 if [ "$1" = '--nomsg' ]; then
1195 msgtest
'Test for successful execution of' "$*"
1197 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
1198 if $@
>${OUTPUT} 2>&1; then
1204 msgfail
"exitcode $EXITCODE"
1209 if [ "$1" = '--nomsg' ]; then
1212 msgtest
'Test for failure in execution of' "$*"
1214 local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
1215 if $@
>${OUTPUT} 2>&1; then
1219 msgfail
"exitcode $EXITCODE"
1225 testaccessrights
() {
1226 msgtest
"Test that file $1 has access rights set to" "$2"
1227 if [ "$2" = "$(stat --format '%a' "$1")" ]; then
1232 echo -n >&2 "stat(1) reports access rights: "
1233 stat
--format '%a' "$1"
1238 testwebserverlaststatuscode
() {
1239 local DOWNLOG
='rootdir/tmp/webserverstatus-testfile.log'
1240 local STATUS
='rootdir/tmp/webserverstatus-statusfile.log'
1241 rm -f "$DOWNLOG" "$STATUS"
1242 msgtest
'Test last status code from the webserver was' "$1"
1243 downloadfile
"http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG"
1244 if [ "$(cat "$STATUS")" = "$1" ]; then
1248 if [ -n "$2" ]; then
1250 echo >&2 '#### Additionally provided output files contain:'
1253 echo >&2 '#### Download log of the status code:'
1255 msgfail
"Status was $(cat "$STATUS")"
1260 echo "STOPPED execution. Press enter to continue"