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/^aptc/apt-c/' -e 's/^aptg/apt-g/' -e 's/^aptf/apt-f/')${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}"; 
  95         msgdebug 
"Executing: ${CCMD}$*${CDEBUG} " 
  98         if [ -f .
/aptconfig.conf 
]; then 
  99                 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 APT_CONFIG
=aptconfig.conf LD_LIBRARY_PATH
=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@" 
 100         elif [ -f ..
/aptconfig.conf 
]; then 
 101                 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 APT_CONFIG
=..
/aptconfig.conf LD_LIBRARY_PATH
=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@" 
 103                 MALLOC_PERTURB_
=21 MALLOC_CHECK_
=2 LD_LIBRARY_PATH
=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$CMD "$@" 
 106 aptconfig
() { runapt apt
-config "$@"; } 
 107 aptcache
() { runapt apt
-cache "$@"; } 
 108 aptcdrom
() { runapt apt
-cdrom "$@"; } 
 109 aptget
() { runapt apt
-get "$@"; } 
 110 aptftparchive
() { runapt apt
-ftparchive "$@"; } 
 111 aptkey
() { runapt apt
-key "$@"; } 
 112 aptmark
() { runapt apt
-mark "$@"; } 
 113 apt
() { runapt apt 
"$@"; } 
 115   LD_LIBRARY_PATH
=${APTHELPERBINDIR} ${APTHELPERBINDIR}/apt
-helper "$@"; 
 118   LD_LIBRARY_PATH
=${APTWEBSERVERBINDIR} ${APTWEBSERVERBINDIR}/aptwebserver 
"$@"; 
 121         command dpkg 
--root=${TMPWORKINGDIRECTORY}/rootdir 
--force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir
/var
/log
/dpkg.log 
"$@" 
 124         if [ -f .
/aptconfig.conf 
]; then 
 125                 APT_CONFIG
=aptconfig.conf LD_LIBRARY_PATH
=${BUILDDIRECTORY}  command aptitude 
"$@" 
 126         elif [ -f ..
/aptconfig.conf 
]; then 
 127                 APT_CONFIG
=..
/aptconfig.conf LD_LIBRARY_PATH
=${BUILDDIRECTORY} command aptitude 
"$@" 
 129                 LD_LIBRARY_PATH
=${BUILDDIRECTORY}  command aptitude 
"$@" 
 134         APT_CONFIG
=aptconfig.conf LD_LIBRARY_PATH
=${BUILDDIRECTORY} command gdb 
${BUILDDIRECTORY}/$1 --args "$@" 
 137         LD_LIBRARY_PATH
=${BUILDDIRECTORY} ${BUILDDIRECTORY}/methods
/http
 
 140         # see apt-key for the whole trickery. Setup is done in setupenvironment 
 141         command gpg 
--ignore-time-conflict --no-options --no-default-keyring \
 
 142                 --homedir "${TMPWORKINGDIRECTORY}/gnupghome" \
 
 143                 --no-auto-check-trustdb --trust-model always \
 
 148         # error if we about to overflow, but ... 
 149         #   "255 failures ought to be enough for everybody" 
 150         if [ $EXIT_CODE -gt 255 ]; then 
 151             msgdie 
"Total failure count $EXIT_CODE too big" 
 153         exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255)); 
 156 shellsetedetector
() { 
 158         if [ "$exit_status" != '0' ]; then 
 159                 echo >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}" 
 160                 if [ "$EXIT_CODE" = '0' ]; then 
 161                         EXIT_CODE
="$exit_status" 
 167         if [ "$1" = 'prefix' ]; then 
 168                 CURRENTTRAP
="$2 $CURRENTTRAP" 
 170                 CURRENTTRAP
="$CURRENTTRAP $1" 
 172         trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
 
 176         TMPWORKINGDIRECTORY
=$(mktemp -d) 
 177         TESTDIRECTORY
=$(readlink -f $(dirname $0)) 
 178         msgninfo 
"Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… " 
 180         # allow overriding the default BUILDDIR location 
 181         BUILDDIRECTORY
=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"} 
 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         test -x "${BUILDDIRECTORY}/apt-get" || msgdie 
"You need to build tree first" 
 188         addtrap 
"cd /; rm -rf $TMPWORKINGDIRECTORY;" 
 189         cd $TMPWORKINGDIRECTORY 
 190         mkdir rootdir aptarchive keys
 
 192         mkdir -p etc
/apt
/apt.conf.d etc
/apt
/sources.list.d etc
/apt
/trusted.gpg.d etc
/apt
/preferences.d
 
 193         mkdir -p var
/cache var
/lib var
/log tmp
 
 194         mkdir -p var
/lib
/dpkg
/info var
/lib
/dpkg
/updates var
/lib
/dpkg
/triggers
 
 195         touch var
/lib
/dpkg
/available
 
 197         ln -s ${METHODSDIR} usr
/lib
/apt
/methods
 
 199         local PACKAGESFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/') 
 200         if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then 
 201                 cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages 
 203         local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/') 
 204         if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then 
 205                 cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive
/Sources
 
 207         cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys
/ 
 208         ln -s ${TMPWORKINGDIRECTORY}/keys
/joesixpack.pub rootdir
/etc
/apt
/trusted.gpg.d
/joesixpack.gpg
 
 209         echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
 
 210         echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
 
 211         echo "Debug::NoLocking \"true\";" >> aptconfig.conf
 
 212         echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
 
 213         echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf
 
 214         echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
 
 215         echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
 
 216         echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
 
 217         echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
 
 218         echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
 
 219         if ! command dpkg 
--assert-multi-arch >/dev
/null 
2>&1; then 
 220                 echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf 
# Added to test multiarch before dpkg is ready for it… 
 222         echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
 
 223         echo 'quiet::NoUpdate "true";' >> aptconfig.conf
 
 224         echo "Acquire::https::CaInfo \"${TESTDIR}/apt.pem\";" > rootdir
/etc
/apt
/apt.conf.d
/99https
 
 225         echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir
/etc
/apt
/apt.conf.d
/apt
-binary 
 226         export LC_ALL
=C.UTF
-8 
 227         export PATH
="${PATH}:/usr/local/sbin:/usr/sbin:/sbin" 
 228         configcompression 
'.' 'gz' #'bz2' 'lzma' 'xz' 
 230         # gpg needs a trustdb to function, but it can't be invalid (not even empty) 
 231         # see also apt-key where this trickery comes from: 
 232         local TRUSTDBDIR
="${TMPWORKINGDIRECTORY}/gnupghome" 
 234         chmod 700 "$TRUSTDBDIR" 
 235         # We also don't use a secret keyring, of course, but gpg panics and 
 236         # implodes if there isn't one available - and writeable for imports 
 237         local SECRETKEYRING
="${TRUSTDBDIR}/secring.gpg" 
 239         # now create the trustdb with an (empty) dummy keyring 
 240         # newer gpg versions are fine without it, but play it safe for now 
 241         gpg 
--quiet --check-trustdb --secret-keyring $SECRETKEYRING --keyring $SECRETKEYRING >/dev
/null 
2>&1 
 247         if [ "$1" = "native" -o -z "$1" ]; then 
 248                 eval `aptconfig shell ARCH APT::Architecture` 
 249                 if [ -n "$ARCH" ]; then 
 252                         dpkg 
--print-architecture 
 260         echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')" 
 263 configarchitecture
() { 
 265                 echo "APT::Architecture \"$(getarchitecture $1)\";" 
 266                 while [ -n "$1" ]; do 
 267                         echo "APT::Architectures:: \"$(getarchitecture $1)\";" 
 270         } >rootdir
/etc
/apt
/apt.conf.d
/01multiarch.conf
 
 275         if [ ! -e rootdir
/var
/lib
/dpkg
/status 
]; then 
 276                 local STATUSFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/') 
 277                 if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then 
 278                         cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status 
 280                         echo -n > rootdir/var/lib/dpkg/status 
 283         rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg 
 284         if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then 
 285                 local ARCHS="$(getarchitectures)" 
 286                 if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then 
 287                         DPKGARCH="$(dpkg --print-architecture)" 
 288                         for ARCH in ${ARCHS}; do 
 289                                 if [ "${ARCH}" != "${DPKGARCH}" ]; then 
 290                                         if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then 
 291                                                 # old-style used e.g. in Ubuntu-P – and as it seems travis 
 292                                                 echo "DPKG
::options
:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg 
 293                                                 echo "DPKG
::options
:: \"${ARCH}\";"  >> rootdir/etc/apt/apt.conf.d/00foreigndpkg 
 297                         if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then 
 298                                 # dpkg doesn't really check the version as long as it is fully installed, 
 299                                 # but just to be sure we choose one above the required version 
 300                                 insertinstalledpackage 'dpkg' "all
" '1.16.2+fake' 
 306 configcompression() { 
 307         while [ -n "$1" ]; do 
 309                 '.') echo ".
\t.
\tcat
";; 
 310                 'gz') echo "gzip\tgz
\tgzip
";; 
 311                 'bz2') echo "bzip2\tbz
2\tbzip
2";; 
 312                 'lzma') echo "lzma
\tlzma
\txz 
--format=lzma
";; 
 313                 'xz') echo "xz
\txz
\txz
";; 
 314                 *) echo "$1\t$1\t$1";; 
 317         done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf 
 320 setupsimplenativepackage() { 
 324         local RELEASE="${4:-unstable}" 
 325         local DEPENDENCIES="$5" 
 326         local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} 
 327  If you 
find such a package installed on your system
, 
 328  something went horribly wrong
! They are autogenerated
 
 329  und used only by testcases and surf no other propose…
"}" 
 331         local SECTION
="${7:-others}" 
 333         if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then 
 336                 DISTSECTION
="$(echo "$SECTION" | cut -d'/' -f 1)" 
 338         local BUILDDIR
=incoming
/${NAME}-${VERSION} 
 339         mkdir -p ${BUILDDIR}/debian
/source 
 341         echo "* most suckless software product ever" > FEATURES
 
 342         test -e debian
/copyright 
|| echo "Copyleft by Joe Sixpack $(date +%Y)" > debian
/copyright
 
 343         test -e debian
/changelog 
|| echo "$NAME ($VERSION) $RELEASE; urgency=low 
 347  -- Joe Sixpack <joe@example.org>  $(date -R)" > debian
/changelog
 
 348         test -e debian
/control 
|| echo "Source: $NAME 
 351 Maintainer: Joe Sixpack <joe@example.org> 
 352 Build-Depends: debhelper (>= 7) 
 353 Standards-Version: 3.9.1 
 355 Package: $NAME" > debian
/control
 
 356         if [ "$ARCH" = 'all' ]; then 
 357                 echo "Architecture: all" >> debian
/control
 
 359                 echo "Architecture: any" >> debian
/control
 
 361         test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian
/control
 
 362         echo "Description: $DESCRIPTION" >> debian
/control
 
 364         test -e debian
/compat 
|| echo "7" > debian
/compat
 
 365         test -e debian
/source
/format 
|| echo "3.0 (native)" > debian
/source
/format
 
 366         test -e debian
/rules 
|| cp /usr
/share
/doc
/debhelper
/examples
/rules.tiny debian
/rules
 
 370 buildsimplenativepackage
() { 
 374         local RELEASE
="${4:-unstable}" 
 375         local DEPENDENCIES
="$5" 
 376         local DESCRIPTION
="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} 
 377  If you find such a package installed on your system, 
 378  something went horribly wrong! They are autogenerated 
 379  und used only by testcases and surf no other propose…"}" 
 381         local SECTION="${7:-others}" 
 382         local PRIORITY="${8:-optional}" 
 384         local COMPRESS_TYPE="${10:-gzip}" 
 386         if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then 
 389                 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)" 
 391         local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION} 
 393         msgninfo "Build package 
${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}… 
" 
 394         mkdir -p $BUILDDIR/debian/source 
 395         echo "* most suckless software product ever
" > ${BUILDDIR}/FEATURES 
 397 echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME} 
 399         echo "Copyleft by Joe Sixpack 
$(date +%Y)" > ${BUILDDIR}/debian/copyright 
 400         echo "$NAME ($VERSION) $RELEASE; urgency
=low
 
 404  -- Joe Sixpack 
<joe@example.org
>  $(date -R)" > ${BUILDDIR}/debian/changelog 
 408 Maintainer
: Joe Sixpack 
<joe@example.org
> 
 409 Standards
-Version: 3.9.3" > ${BUILDDIR}/debian/control 
 410         local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')" 
 411         test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control 
 413 Package
: $NAME" >> ${BUILDDIR}/debian/control 
 415         if [ "$ARCH" = 'all' ]; then 
 416                 echo "Architecture
: all
" >> ${BUILDDIR}/debian/control 
 418                 echo "Architecture
: any
" >> ${BUILDDIR}/debian/control 
 420         local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')" 
 421         test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control 
 422         echo "Description
: $DESCRIPTION" >> ${BUILDDIR}/debian/control 
 424         echo '3.0 (native)' > ${BUILDDIR}/debian/source/format 
 425         (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | sed -n 's#^dpkg-source: info: building [^ ]\+ in ##p' \ 
 427                 echo "pool
/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist 
 428 #               if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then 
 429 #                       gpg --yes --secret-keyring ./keys/joesixpack.sec \ 
 430 #                               --keyring ./keys/joesixpack.pub --default-key 'Joe Sixpack' \ 
 431 #                               --clearsign -o "${BUILDDIR}/..
/${SRC}.sign
" "${BUILDDIR}/..
/$SRC" 
 432 #                       mv "${BUILDDIR}/..
/${SRC}.sign
" "${BUILDDIR}/..
/$SRC" 
 436         for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do 
 437                 rm -rf ${BUILDDIR}/debian
/tmp
 
 438                 mkdir -p ${BUILDDIR}/debian
/tmp
/DEBIAN 
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
 
 439                 cp ${BUILDDIR}/debian
/copyright 
${BUILDDIR}/debian
/changelog 
${BUILDDIR}/FEATURES 
${BUILDDIR}/debian
/tmp
/usr
/share
/doc
/${NAME} 
 440                 cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian
/tmp
/usr
/bin
/${NAME}-${arch} 
 441                 if [ -n "$FILE_TREE" ]; then 
 442                     cp -ar "$FILE_TREE" ${BUILDDIR}/debian
/tmp
 
 445                 (cd ${BUILDDIR}; dpkg
-gencontrol -DArchitecture=$arch) 
 446                 (cd ${BUILDDIR}/debian
/tmp
; md5sum $(find usr/ -type f) > DEBIAN
/md5sums
) 
 447                 local LOG
="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log" 
 448                 # ensure the right permissions as dpkg-deb ensists 
 449                 chmod 755 ${BUILDDIR}/debian
/tmp
/DEBIAN
 
 450                 if ! dpkg
-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian
/tmp 
${BUILDDIR}/.. 
>$LOG 2>&1; then 
 455                 echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.pkglist
 
 458         mkdir -p ${BUILDDIR}/..
/${NAME}_
${VERSION} 
 459         cp ${BUILDDIR}/debian
/changelog 
${BUILDDIR}/..
/${NAME}_
${VERSION}/ 
 460         cp ${BUILDDIR}/debian
/changelog 
${BUILDDIR}/..
/${NAME}_
${VERSION}.changelog
 
 469         local ARCH
=$(getarchitecture $4) 
 470         local PKGNAME
="$(echo "$BUILDDIR" | grep -o '[^/]*$')" 
 471         local BUILDLOG
="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")" 
 472         msgninfo 
"Build package ${PKGNAME} for ${RELEASE} in ${SECTION}… " 
 474         if [ "$ARCH" = "all" ]; then 
 475                 ARCH
="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)" 
 477         if ! dpkg
-buildpackage -uc -us -a$ARCH >$BUILDLOG 2>&1 ; then 
 481         local PKGS
="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")" 
 482         local SRCS
="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')" 
 485                 echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.pkglist
 
 488                 echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.srclist
 
 494         if [ -d incoming 
]; then 
 495                 buildaptarchivefromincoming 
"$@" 
 497                 buildaptarchivefromfiles 
"$@" 
 501 createaptftparchiveconfig
() { 
 502         local COMPRESSORS
="$(cut -d'    ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')" 
 503         COMPRESSORS
="${COMPRESSORS%* }" 
 504         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' ' ')" 
 505         if [ -z "$ARCHS" ]; then 
 506                 # the pool is empty, so we will operate on faked packages - let us use the configured archs 
 507                 ARCHS
="$(getarchitectures)" 
 510         ArchiveDir "' >> ftparchive.conf
 
 511         echo -n $(readlink -f .) >> ftparchive.conf
 
 513         CacheDir "' >> ftparchive.conf
 
 514         echo -n $(readlink -f ..) >> ftparchive.conf
 
 516         FileListDir "' >> ftparchive.conf
 
 517         echo -n $(readlink -f pool/) >> ftparchive.conf
 
 521         Packages::Compress "'"$COMPRESSORS"'"; 
 522         Sources::Compress "'"$COMPRESSORS"'"; 
 523         Contents::Compress "'"$COMPRESSORS"'"; 
 524         Translation::Compress "'"$COMPRESSORS"'"; 
 525         LongDescription "false"; 
 529         SrcDirectory "pool/"; 
 535                         Label "apttestcases"; 
 537                         Description "repository with dummy packages"; 
 538                         Architectures "' >> ftparchive.conf
 
 539         echo -n "$ARCHS" >> ftparchive.conf
 
 543 };' >> ftparchive.conf
 
 544         for DIST 
in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do 
 545                 echo -n 'tree "dists/' >> ftparchive.conf
 
 546                 echo -n "$DIST" >> ftparchive.conf
 
 548         Architectures "' >> ftparchive.conf
 
 549                 echo -n "$ARCHS" >> ftparchive.conf
 
 551         FileList "' >> ftparchive.conf
 
 552                 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
 
 554         SourceFileList "' >> ftparchive.conf
 
 555                 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
 
 557         Sections "' >> ftparchive.conf
 
 558                 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
 
 560 };' >> ftparchive.conf
 
 564 buildaptftparchivedirectorystructure
() { 
 565         local DISTS
="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')" 
 566         for DIST 
in $DISTS; do 
 567                 local SECTIONS
="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)" 
 568                 for SECTION 
in $SECTIONS; do 
 569                         local ARCHS
="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')" 
 570                         for ARCH 
in $ARCHS; do 
 571                                 mkdir -p dists
/${DIST}/${SECTION}/binary
-${ARCH} 
 573                         mkdir -p dists
/${DIST}/${SECTION}/source 
 574                         mkdir -p dists
/${DIST}/${SECTION}/i18n
 
 584         local DEPENDENCIES
="$5" 
 585         local PRIORITY
="${6:-optional}" 
 586         local DESCRIPTION
="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} 
 587  If you find such a package installed on your system, 
 588  something went horribly wrong! They are autogenerated 
 589  und used only by testcases and surf no other propose…"}" 
 591         for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do 
 592                 if [ "$arch" = 'all' -o "$arch" = 'none' ]; then 
 593                         ARCHS
="$(getarchitectures)" 
 597                 for BUILDARCH 
in $ARCHS; do 
 598                         local PPATH
="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}" 
 599                         mkdir -p $PPATH aptarchive
/dists
/${RELEASE}/main
/source 
 600                         touch aptarchive
/dists
/${RELEASE}/main
/source
/Sources
 
 601                         local FILE
="${PPATH}/Packages" 
 606 Maintainer: Joe Sixpack <joe@example.org>" >> $FILE 
 607                         test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE 
 608                         echo "Version: $VERSION 
 609 Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE 
 610                         test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE 
 611                         echo "Description: $DESCRIPTION" >> $FILE 
 622         local DEPENDENCIES
="$5" 
 624         local SPATH
="aptarchive/dists/${RELEASE}/main/source" 
 626         local FILE
="${SPATH}/Sources" 
 630 Maintainer: Joe Sixpack <joe@example.org> 
 631 Architecture: $ARCH" >> $FILE 
 632         test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE 
 634  d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc 
 635  d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz 
 639 insertinstalledpackage
() { 
 643         local DEPENDENCIES
="$4" 
 644         local PRIORITY
="${5:-optional}" 
 645         local STATUS
="${6:-install ok installed}" 
 646         local DESCRIPTION
="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed 
 647  If you find such a package installed on your system, 
 648  something went horribly wrong! They are autogenerated 
 649  und used only by testcases and surf no other propose…"}" 
 651         local FILE='rootdir/var/lib/dpkg/status' 
 652         local INFO='rootdir/var/lib/dpkg/info' 
 653         for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do 
 659 Maintainer: Joe Sixpack <joe@example.org> 
 660 Version: $VERSION" >> $FILE 
 661                 test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE 
 662                 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE 
 663                 echo "Description: $DESCRIPTION" >> $FILE 
 665                 if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then 
 666                         echo -n > ${INFO}/${NAME}:${arch}.list
 
 668                         echo -n > ${INFO}/${NAME}.list
 
 674 buildaptarchivefromincoming
() { 
 675         msginfo 
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…" 
 677         [ -e pool 
] || ln -s ..
/incoming pool
 
 678         [ -e ftparchive.conf 
] || createaptftparchiveconfig
 
 679         [ -e dists 
] || buildaptftparchivedirectorystructure
 
 680         msgninfo 
"\tGenerate Packages, Sources and Contents files… " 
 681         aptftparchive 
-qq generate ftparchive.conf
 
 687 buildaptarchivefromfiles
() { 
 688         msginfo 
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…" 
 689         find aptarchive 
-name 'Packages' -o -name 'Sources' | while read line
; do 
 690                 msgninfo 
"\t${line} file… " 
 691                 compressfile 
"$line" "$1" 
 694         generatereleasefiles 
"$@" 
 698         cat ${TMPWORKINGDIRECTORY}/rootdir
/etc
/testcase
-compressor.conf 
| while read compressor extension 
command; do 
 699                 if [ "$compressor" = '.' ]; then 
 705                 cat "$1" | $command > "${1}.${extension}" 
 707                         touch -d "$2" "${1}.${extension}" 
 712 # can be overridden by testcases for their pleasure 
 713 getcodenamefromsuite
() { 
 715         unstable
) echo 'sid';; 
 719 getreleaseversionfromsuite
() { true
; } 
 720 getlabelfromsuite
() { true
; } 
 722 generatereleasefiles
() { 
 723         # $1 is the Date header and $2 is the ValidUntil header to be set 
 724         # both should be given in notation date/touch can understand 
 725         msgninfo 
"\tGenerate Release files… " 
 726         if [ -e aptarchive
/dists 
]; then 
 727                 for dir 
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do 
 728                         local SUITE
="$(echo "$dir" | cut -d'/' -f 4)" 
 729                         local CODENAME
="$(getcodenamefromsuite $SUITE)" 
 730                         local VERSION
="$(getreleaseversionfromsuite $SUITE)" 
 731                         local LABEL
="$(getlabelfromsuite $SUITE)" 
 732                         if [ -n "$VERSION" ]; then 
 733                                 VERSION
="-o APT::FTPArchive::Release::Version=${VERSION}" 
 735                         if [ -n "$LABEL" ]; then 
 736                                 LABEL
="-o APT::FTPArchive::Release::Label=${LABEL}" 
 738                         aptftparchive 
-qq release 
$dir \
 
 739                                 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
 
 740                                 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
 
 743                                         | sed -e '/0 Release$/ d' > $dir/Release 
# remove the self reference 
 744                         if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then 
 746 NotAutomatic: yes' $dir/Release
 
 748                         if [ -n "$1" -a "$1" != "now" ]; then 
 749                                 sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
 
 753 Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
 
 757                 aptftparchive 
-qq release .
/aptarchive 
| sed -e '/0 Release$/ d' > aptarchive
/Release 
# remove the self reference 
 759         if [ -n "$1" -a "$1" != "now" ]; then 
 760                 for release 
in $(find ./aptarchive -name 'Release'); do 
 761                         touch -d "$1" $release 
 767 setupdistsaptarchive
() { 
 768         local APTARCHIVE
=$(readlink -f ./aptarchive) 
 769         rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb.list
 
 770         rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb-src.list
 
 771         for DISTS 
in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do 
 772                 SECTIONS
=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ') 
 773                 msgninfo 
"\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… " 
 774                 echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb.list
 
 775                 echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb-src.list
 
 780 setupflataptarchive
() { 
 781         local APTARCHIVE
=$(readlink -f ./aptarchive) 
 782         if [ -f ${APTARCHIVE}/Packages 
]; then 
 783                 msgninfo 
"\tadd deb sources.list line… " 
 784                 echo "deb file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
 
 787                 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
 
 789         if [ -f ${APTARCHIVE}/Sources 
]; then 
 790                 msgninfo 
"\tadd deb-src sources.list line… " 
 791                 echo "deb-src file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
 
 794                 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
 
 800         if [ -e aptarchive
/dists 
]; then 
 806         if [ "$1" != '--no-update' ]; then 
 807                 msgninfo 
"\tSync APT's cache with the archive… " 
 814         local SIGNER
="${1:-Joe Sixpack}" 
 815         local GPG
="gpg --batch --yes" 
 816         msgninfo 
"\tSign archive with $SIGNER key… " 
 817         local REXKEY
='keys/rexexpired' 
 818         local SECEXPIREBAK
="${REXKEY}.sec.bak" 
 819         local PUBEXPIREBAK
="${REXKEY}.pub.bak" 
 820         if [ "${SIGNER}" = 'Rex Expired' ]; then 
 821                 # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time 
 822                 # option doesn't exist anymore (and using faketime would add a new obscure dependency) 
 823                 # therefore we 'temporary' make the key not expired and restore a backup after signing 
 824                 cp ${REXKEY}.sec 
$SECEXPIREBAK 
 825                 cp ${REXKEY}.pub 
$PUBEXPIREBAK 
 826                 local SECUNEXPIRED
="${REXKEY}.sec.unexpired" 
 827                 local PUBUNEXPIRED
="${REXKEY}.pub.unexpired" 
 828                 if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then 
 829                         cp $SECUNEXPIRED ${REXKEY}.sec
 
 830                         cp $PUBUNEXPIRED ${REXKEY}.pub
 
 832                         printf "expire\n1w\nsave\n" | $GPG --keyring ${REXKEY}.pub 
--secret-keyring ${REXKEY}.sec 
--command-fd 0 --edit-key "${SIGNER}" >/dev
/null 
2>&1 || true
 
 833                         cp ${REXKEY}.sec 
$SECUNEXPIRED 
 834                         cp ${REXKEY}.pub 
$PUBUNEXPIRED 
 837         for KEY 
in $(find keys/ -name '*.sec'); do 
 838                 GPG
="$GPG --secret-keyring $KEY" 
 840         for KEY 
in $(find keys/ -name '*.pub'); do 
 841                 GPG
="$GPG --keyring $KEY" 
 843         for RELEASE 
in $(find aptarchive/ -name Release); do 
 844                 $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg 
${RELEASE} 
 845                 local INRELEASE
="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')" 
 846                 $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE 
 847                 # we might have set a specific date for the Release file, so copy it 
 848                 touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg 
${INRELEASE} 
 850         if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then 
 851                 mv -f $SECEXPIREBAK ${REXKEY}.sec
 
 852                 mv -f $PUBEXPIREBAK ${REXKEY}.pub
 
 858         msgtest 
"Set webserver config option '${1}' to" "$2" 
 859         downloadfile 
"http://localhost:8080/_config/set/${1}/${2}" '/dev/null' >/dev
/null
 
 860         local DOWNLOG
='download-testfile.log' 
 862         local STATUS
="${TMPWORKINGDIRECTORY}/rootdir/tmp/webserverconfig.status" 
 863         downloadfile 
"http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG" 
 864         if [ "$(cat "$STATUS")" = '200' ]; then 
 868                 msgfail 
"Statuscode was $(cat "$STATUS")" 
 873 rewritesourceslist
() { 
 874         local APTARCHIVE
="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")" 
 875         for LIST 
in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do 
 876                 sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#http://localhost:4433/#${1}#" 
 880 changetowebserver
() { 
 881         if [ "$1" != '--no-rewrite' ]; then 
 882                 rewritesourceslist 
'http://localhost:8080/' 
 886         if test -x ${APTWEBSERVERBINDIR}/aptwebserver
; then 
 888                 local LOG
="webserver.log" 
 889                 if ! aptwebserver 
-o aptwebserver
::fork
=1 "$@" >$LOG 2>&1 ; then 
 893                 local PID
="$(cat aptwebserver.pid)" 
 894                 if [ -z "$PID" ]; then 
 895                         msgdie 
'Could not fork aptwebserver successfully' 
 900                 msgdie 
'You have to build aptwerbserver or install a webserver' 
 904 changetohttpswebserver
() { 
 905         if ! which stunnel4 
>/dev
/null
; then 
 906                 msgdie 
'You need to install stunnel4 for https testcases' 
 908         if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then 
 909                 changetowebserver 
--no-rewrite "$@" 
 911         echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid 
 912 cert = ${TESTDIRECTORY}/apt.pem 
 918 " > ${TMPWORKINGDIRECTORY}/stunnel.conf
 
 919         stunnel4 
"${TMPWORKINGDIRECTORY}/stunnel.conf" 
 920         local PID
="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)" 
 921         addtrap 
'prefix' "kill ${PID};" 
 922         rewritesourceslist 
'https://localhost:4433/' 
 926         mkdir -p rootdir
/media
/cdrom
/.disk
 
 927         local CD
="$(readlink -f rootdir/media/cdrom)" 
 928         echo "acquire::cdrom::mount \"${CD}\";" > rootdir
/etc
/apt
/apt.conf.d
/00cdrom
 
 929         echo 'acquire::cdrom::autodetect 0;' >> rootdir
/etc
/apt
/apt.conf.d
/00cdrom
 
 930         echo -n "$1" > ${CD}/.disk
/info
 
 931         if [ ! -d aptarchive
/dists 
]; then 
 932                 msgdie 
'Flat file archive cdroms can not be created currently' 
 935         mv aptarchive
/dists 
$CD 
 936         ln -s "$(readlink -f ./incoming)" $CD/pool
 
 937         find rootdir
/etc
/apt
/sources.list.d
/ -name 'apt-test-*.list' -delete 
 941         PROTO
="$(echo "$1" | cut -d':' -f 1)" 
 942         apthelper 
-o Acquire
::https
::CaInfo
=${TESTDIR}/apt.pem \
 
 943                   -o Debug
::Acquire
::${PROTO}=1 \
 
 944                   download
-file "$1" "$2" 2>&1 
 945         # only if the file exists the download was successful 
 954         local DIFFTEXT
="$(command diff -u "$@" | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')" 
 955         if [ -n "$DIFFTEXT" ]; then 
 967         msgtest 
"Test for correctness of file" "$FILE" 
 969                 echo -n "" | checkdiff 
$FILE - && msgpass 
|| msgfail
 
 971                 echo "$*" | checkdiff 
$FILE - && msgpass 
|| msgfail
 
 976         msgtest 
"Test for no output of" "$*" 
 977         test -z "$($* 2>&1)" && msgpass 
|| msgfail
 
 981         local MSG
='Test of equality of' 
 982         if [ "$1" = '--nomsg' ]; then 
 987         local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile" 
 988         echo "$1" > $COMPAREFILE 
 991         if [ -n "$MSG" ]; then 
 994         $
* 2>&1 | checkdiff 
$COMPAREFILE - && msgpass 
|| msgfail
 
 998         local COMPAREFILE1
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1" 
 999         local COMPAREFILE2
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2" 
1000         local COMPAREAGAINST
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst" 
1001         echo "$1" > $COMPAREFILE1 
1002         echo "$2" > $COMPAREFILE2 
1004         msgtest 
"Test for equality OR of" "$*" 
1005         $
* >$COMPAREAGAINST 2>&1 || true
 
1006         (checkdiff 
$COMPAREFILE1 $COMPAREAGAINST 1> /dev
/null 
|| 
1007                 checkdiff 
$COMPAREFILE2 $COMPAREAGAINST 1> /dev
/null
) && msgpass 
|| 
1008                 ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(checkdiff $COMPAREFILE1 $COMPAREAGAINST)" \
 
1009                        "\n${CINFO}Diff against OR 2${CNORMAL}" "$(checkdiff $COMPAREFILE2 $COMPAREAGAINST)" && 
1014         local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual" 
1017         while [ -n "$1" ]; do 
1019 N: Can't select versions from package '$1' as it is purely virtual" 
1020                 PACKAGE
="${PACKAGE} $1" 
1023         msgtest 
"Test for virtual packages" "apt-cache show $PACKAGE" 
1025 N: No packages found" 
1026         local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile" 
1027         local ARCH
="$(getarchitecture 'native')" 
1028         echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE 
1029         aptcache show 
-q=0 $PACKAGE 2>&1 | checkdiff 
$COMPAREFILE - && msgpass 
|| msgfail
 
1033         msgtest 
"Test for non-existent packages" "apt-cache show $*" 
1034         local SHOWPKG
="$(aptcache show "$@" 2>&1 | grep '^Package: ')" 
1035         if [ -n "$SHOWPKG" ]; then 
1044 testdpkginstalled
() { 
1045         msgtest 
"Test for correctly installed package(s) with" "dpkg -l $*" 
1046         local PKGS
="$(dpkg -l "$@" 2>/dev/null | grep '^i' | wc -l)" 
1047         if [ "$PKGS" != $# ]; then 
1049                 dpkg 
-l "$@" | grep '^[a-z]' 
1056 testdpkgnotinstalled
() { 
1057         msgtest 
"Test for correctly not-installed package(s) with" "dpkg -l $*" 
1058         local PKGS
="$(dpkg -l "$@" 2> /dev/null | grep '^i' | wc -l)" 
1059         if [ "$PKGS" != 0 ]; then 
1061                 dpkg 
-l "$@" | grep '^[a-z]' 
1069         local COMPAREFILE
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile" 
1070         if [ -n "$1" ]; then 
1071                 msgtest 
'Test for correctly marked as auto-installed' "$*" 
1072                 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE 
1074                 msgtest 
'Test for correctly marked as auto-installed' 'no package' 
1075                 echo -n > $COMPAREFILE 
1077         aptmark showauto 
2>&1 | checkdiff 
$COMPAREFILE - && msgpass 
|| msgfail
 
1081         if [ "$1" = '--nomsg' ]; then 
1084                 msgtest 
'Test for successful execution of' "$*" 
1086         local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" 
1087         if $@ 
>${OUTPUT} 2>&1; then 
1097         if [ "$1" = '--nomsg' ]; then 
1100                 msgtest 
'Test for failure in execution of' "$*" 
1102         local OUTPUT
="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" 
1103         if $@ 
>${OUTPUT} 2>&1; then 
1113         echo "STOPPED execution. Press enter to continue"