]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
be able to set priorities for created test packages
[apt.git] / test / integration / framework
index 5b83e7519e33ab719dfea627f34f9fd7263b8037..b0ea7a5c02b58eb9e081aa4b1ff761dd244decc4 100644 (file)
@@ -79,6 +79,7 @@ aptcache() { runapt apt-cache $*; }
 aptget() { runapt apt-get $*; }
 aptftparchive() { runapt apt-ftparchive $*; }
 aptkey() { runapt apt-key $*; }
+aptmark() { runapt apt-mark $*; }
 dpkg() {
        $(which dpkg) --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log $*
 }
@@ -188,8 +189,12 @@ Maintainer: Joe Sixpack <joe@example.org>
 Build-Depends: debhelper (>= 7)
 Standards-Version: 3.9.1
 
-Package: $NAME
-Architecture: $ARCH" > debian/control
+Package: $NAME" > debian/control
+       if [ "$ARCH" = 'all' ]; then
+               echo "Architecture: all" >> debian/control
+       else
+               echo "Architecture: any" >> debian/control
+       fi
        test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
        if [ -z "$DESCRIPTION" ]; then
                echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
@@ -213,15 +218,16 @@ buildsimplenativepackage() {
        local DEPENDENCIES="$5"
        local DESCRIPTION="$6"
        local SECTION="${7:-others}"
+       local PRIORITY="${8:-optional}"
        local DISTSECTION
        if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
                DISTSECTION="main"
        else
                DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
        fi
-       local BUILDDIR=incoming/${NAME}-${VERSION}
+       local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
 
-       msgninfo "Build package ${NAME} in ${VERSIOM} for ${RELEASE} in ${DISTSECTION}… "
+       msgninfo "Build package ${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}… "
        mkdir -p $BUILDDIR/debian/source
        echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
        echo "#!/bin/sh
@@ -235,12 +241,16 @@ echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
  -- Joe Sixpack <joe@example.org>  $(date -R)" > ${BUILDDIR}/debian/changelog
        echo "Source: $NAME
 Section: $SECTION
-Priority: optional
+Priority: $PRIORITY
 Maintainer: Joe Sixpack <joe@example.org>
 Standards-Version: 3.9.1
 
-Package: $NAME
-Architecture: $ARCH" > ${BUILDDIR}/debian/control
+Package: $NAME" > ${BUILDDIR}/debian/control
+       if [ "$ARCH" = 'all' ]; then
+               echo "Architecture: all" >> ${BUILDDIR}/debian/control
+       else
+               echo "Architecture: any" >> ${BUILDDIR}/debian/control
+       fi
        test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> ${BUILDDIR}/debian/control
        if [ -z "$DESCRIPTION" ]; then
                echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
@@ -252,19 +262,26 @@ Architecture: $ARCH" > ${BUILDDIR}/debian/control
        fi
        echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
        local SRCS="$( (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')"
+       for SRC in $SRCS; do
+               echo "pool/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
+       done
 
-       mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
-       cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
-       cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
-       (cd ${BUILDDIR}; dpkg-gencontrol)
-       (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
+       for arch in $(echo "$ARCH" | sed -e 's#,#\n#g'); do
+               rm -rf ${BUILDDIR}/debian/tmp
+               mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
+               cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
+               cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
+               (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
+               (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
 
-       dpkg-deb --build ${BUILDDIR}/debian/tmp incoming > /dev/null
-       echo "pool/${NAME}_${VERSION}_${ARCH}.deb" >> incoming/${RELEASE}.${DISTSECTION}.pkglist
-       for SRC in $SRCS; do
-               echo "pool/${SRC}" >> incoming/${RELEASE}.${DISTSECTION}.srclist
+               dpkg-deb --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. 2> /dev/null > /dev/null
+               echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
        done
-       rm -rf "incoming/${NAME}-${VERSION}"
+
+       mkdir -p ${BUILDDIR}/../${NAME}_${VERSION}
+       cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/
+       cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog
+       rm -rf "${BUILDDIR}"
        msgdone "info"
 }
 
@@ -316,9 +333,11 @@ createaptftparchiveconfig() {
        echo -n '";
 };
 Default {
-       Packages::Compress ". gzip bzip2 lzma";
-       Sources::Compress ". gzip bzip2 lzma";
-       Contents::Compress ". gzip bzip2 lzma";
+       Packages::Compress ". gzip bzip2 lzma xz";
+       Sources::Compress ". gzip bzip2 lzma xz";
+       Contents::Compress ". gzip bzip2 lzma xz";
+       Translation::Compress ". gzip bzip2 lzma xz";
+       LongDescription "false";
 };
 TreeDefault {
        Directory "pool/";
@@ -378,25 +397,55 @@ insertpackage() {
        local ARCH="$3"
        local VERSION="$4"
        local DEPENDENCIES="$5"
-       local ARCHS="$ARCH"
-       if [ "$ARCHS" = "all" ]; then
-               ARCHS="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
-       fi
-       for BUILDARCH in $ARCHS; do
-               local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
-               mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
-               touch aptarchive/dists/${RELEASE}/main/source/Sources
-               local FILE="${PPATH}/Packages"
-               echo "Package: $NAME
-Priority: optional
+       local PRIORITY="${6:-optional}"
+       local ARCHS=""
+       for arch in $(echo "$ARCH" | sed -e 's#,#\n#g'); do
+               if [ "$arch" = "all" ]; then
+                       ARCHS="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
+               else
+                       ARCHS="$arch"
+               fi
+               for BUILDARCH in $ARCHS; do
+                       local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
+                       mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
+                       touch aptarchive/dists/${RELEASE}/main/source/Sources
+                       local FILE="${PPATH}/Packages"
+                       echo "Package: $NAME
+Priority: $PRIORITY
 Section: other
 Installed-Size: 42
 Maintainer: Joe Sixpack <joe@example.org>
-Architecture: $ARCH
+Architecture: $arch
 Version: $VERSION
-Filename: pool/main/${NAME}/${NAME}_${VERSION}_${ARCH}.deb" >> $FILE
+Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
+                       test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
+                       echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ If you find such a package installed on your system,
+ YOU did something horribly wrong! They are autogenerated
+ und used only by testcases for APT and surf no other propose…
+" >> $FILE
+               done
+       done
+}
+
+insertinstalledpackage() {
+       local NAME="$1"
+       local ARCH="$2"
+       local VERSION="$3"
+       local DEPENDENCIES="$4"
+       local PRIORITY="${5:-optional}"
+       local FILE="rootdir/var/lib/dpkg/status"
+       for arch in $(echo "$ARCH" | sed -e 's#,#\n#g'); do
+               echo "Package: $NAME
+Status: install ok installed
+Priority: $PRIORITY
+Section: other
+Installed-Size: 42
+Maintainer: Joe Sixpack <joe@example.org>
+Architecture: $arch
+Version: $VERSION" >> $FILE
                test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
-               echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+               echo "Description: an autogenerated dummy ${NAME}=${VERSION}/installed
  If you find such a package installed on your system,
  YOU did something horribly wrong! They are autogenerated
  und used only by testcases for APT and surf no other propose…
@@ -404,6 +453,7 @@ Filename: pool/main/${NAME}/${NAME}_${VERSION}_${ARCH}.deb" >> $FILE
        done
 }
 
+
 buildaptarchivefromincoming() {
        msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
        cd aptarchive
@@ -424,6 +474,7 @@ buildaptarchivefromfiles() {
                cat ${line} | gzip > ${line}.gz
                cat ${line} | bzip2 > ${line}.bz2
                cat ${line} | lzma > ${line}.lzma
+               cat ${line} | xz > ${line}.xz
                msgdone "info"
        done
        generatereleasefiles
@@ -433,6 +484,9 @@ generatereleasefiles() {
        msgninfo "\tGenerate Release files… "
        local DATE="${1:-now}"
        if [ -e aptarchive/dists ]; then
+               for dir in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do
+                       aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index
+               done
                for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
                        local CODENAME="$(echo "$dir" | cut -d'/' -f 4)"
                        aptftparchive -qq release $dir -o APT::FTPArchive::Release::Suite="${CODENAME}" -o APT::FTPArchive::Release::Codename="${CODENAME}" | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
@@ -576,12 +630,12 @@ testequalor2() {
 }
 
 testshowvirtual() {
-       local VIRTUAL="N: Can't select versions from package '$1' as it purely virtual"
+       local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual"
        local PACKAGE="$1"
        shift
        while [ -n "$1" ]; do
                VIRTUAL="${VIRTUAL}
-N: Can't select versions from package '$1' as it purely virtual"
+N: Can't select versions from package '$1' as it is purely virtual"
                PACKAGE="${PACKAGE} $1"
                shift
        done
@@ -610,8 +664,8 @@ testnopackage() {
 
 testdpkginstalled() {
        msgtest "Test for correctly installed package(s) with" "dpkg -l $*"
-       local PKGS="$(dpkg -l $* | grep '^[a-z]' | grep '^[^i]' | wc -l)"
-       if [ "$PKGS" != 0 ]; then
+       local PKGS="$(dpkg -l $* | grep '^i' | wc -l)"
+       if [ "$PKGS" != $# ]; then
                echo $PKGS
                dpkg -l $* | grep '^[a-z]'
                msgfail
@@ -620,9 +674,9 @@ testdpkginstalled() {
        msgpass
 }
 
-testdpkgnoninstalled() {
-       msgtest "Test for correctly non-installed package(s) with" "dpkg -l $*"
-       local PKGS="$(dpkg -l $* | grep '^[a-z]' | grep '^[^u]' | wc -l)"
+testdpkgnotinstalled() {
+       msgtest "Test for correctly not-installed package(s) with" "dpkg -l $*"
+       local PKGS="$(dpkg -l $* 2> /dev/null | grep '^i' | wc -l)"
        if [ "$PKGS" != 0 ]; then
                echo
                dpkg -l $* | grep '^[a-z]'
@@ -631,3 +685,16 @@ testdpkgnoninstalled() {
        fi
        msgpass
 }
+
+testmarkedauto() {
+       local COMPAREFILE=$(mktemp)
+       addtrap "rm $COMPAREFILE;"
+       if [ -n "$1" ]; then
+               msgtest 'Test for correctly marked as auto-installed' "$*"
+               while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
+       else
+               msgtest 'Test for correctly marked as auto-installed' 'no package'
+               echo > $COMPAREFILE
+       fi
+       aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
+}