diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2010-08-20 19:09:16 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2010-08-20 19:09:16 +0200 |
commit | 75954ae2420ae7755d8482f2f1eecc03595a5153 (patch) | |
tree | 582ec4e5bb4f3975e8374e409d5b261b55daa665 /test | |
parent | cd725954f6df5b809fe8d90ee135e222d1cef30e (diff) |
* apt-pkg/deb/dpkgpm.cc:
- use the InstVer instead of the CurrentVer for the autobit transfer
Add also a small testcase to check the handling automatical
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/framework | 54 | ||||
-rwxr-xr-x | test/integration/test-disappearing-packages | 54 |
2 files changed, 101 insertions, 7 deletions
diff --git a/test/integration/framework b/test/integration/framework index 01b795ba9..82fca2046 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -74,13 +74,13 @@ aptget() { runapt apt-get $*; } aptftparchive() { runapt apt-ftparchive $*; } setupenvironment() { - local TMPWORKINGDIRECTORY=$(mktemp -d) + TMPWORKINGDIRECTORY=$(mktemp -d) local TESTDIR=$(readlink -f $(dirname $0)) msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… " BUILDDIRECTORY="${TESTDIR}/../../build/bin" test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" local OLDWORKINGDIRECTORY=$(pwd) - trap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM +# trap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM cd $TMPWORKINGDIRECTORY mkdir rootdir aptarchive keys cd rootdir @@ -128,7 +128,7 @@ configarchitecture() { done } -buildsimplenativepackage() { +setupsimplenativepackage() { local NAME="$1" local ARCH="$2" local VERSION="$3" @@ -142,7 +142,6 @@ buildsimplenativepackage() { else DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)" fi - msgninfo "Build package ${CCMD}${NAME}=${VERSION}/${RELEASE}${CINFO}… " local BUILDDIR=incoming/${NAME}-${VERSION} mkdir -p ${BUILDDIR}/debian/source cd ${BUILDDIR} @@ -174,17 +173,47 @@ Architecture: $ARCH" > debian/control test -e debian/compat || echo "7" > debian/compat test -e debian/source/format || echo "3.0 (native)" > debian/source/format test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules + cd - > /dev/null +} + +buildsimplenativepackage() { + local NAME="$1" + local ARCH="$2" + local VERSION="$3" + local RELEASE="${4:-unstable}" + local DEPENDENCIES="$5" + local DESCRIPTION="$6" + local SECTION="${7:-others}" + local DISTSECTION + if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then + DISTSECTION="main" + else + DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)" + fi + setupsimplenativepackage "$NAME" "$ARCH" "$VERSION" "$RELEASE" "$DEPENDENCIES" "$DESCRIPTION" "$SECTION" + buildpackage "incoming/${NAME}-${VERSION}" "$RELEASE" "$DISTSECTION" + rm -rf "incoming/${NAME}-${VERSION}" +} + +buildpackage() { + local BUILDDIR=$1 + local RELEASE=$2 + local SECTION=$3 + msgninfo "Build package $(echo "$BUILDDIR" | grep -o '[^/]*$') for ${RELEASE} in ${SECTION}… " + cd $BUILDDIR + if [ "$ARCH" = "all" ]; then + ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)" + fi local BUILT="$(dpkg-buildpackage -uc -us -a$ARCH 2> /dev/null)" local PKGS="$( echo "$BUILT" | grep '^dpkg-deb: building package' | cut -d'/' -f 2 | sed -e "s#'\.##")" local SRCS="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._-]*$')" cd - > /dev/null for PKG in $PKGS; do - echo "pool/${PKG}" >> ./incoming/${RELEASE}.${DISTSECTION}.pkglist + echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist done for SRC in $SRCS; do - echo "pool/${SRC}" >> ./incoming/${RELEASE}.${DISTSECTION}.srclist + echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist done - rm -rf $BUILDDIR msgdone "info" } @@ -365,6 +394,17 @@ diff() { fi } +testfileequal() { + local FILE="$1" + shift + msgtest "Test for correctness of file" "$FILE" + if [ -z "$*" ]; then + echo -n "" | diff $FILE - && msgpass || msgfail + else + echo "$*" | diff $FILE - && msgpass || msgfail + fi +} + testequal() { local COMPAREFILE=$(mktemp) echo "$1" > $COMPAREFILE diff --git a/test/integration/test-disappearing-packages b/test/integration/test-disappearing-packages new file mode 100755 index 000000000..ebf2bb14f --- /dev/null +++ b/test/integration/test-disappearing-packages @@ -0,0 +1,54 @@ +#!/bin/sh +set -e + +local TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture "i386" + +buildsimplenativepackage "old-pkg" "i386" "1.0" "stable" +buildsimplenativepackage "unrelated" "all" "0.5" "unstable" + +setupsimplenativepackage "new-pkg" "i386" "2.0" "unstable" "Provides: old-pkg +Replaces: old-pkg +Conflicts: old-pkg (<< 2.0)" +local BUILDDIR="incoming/new-pkg-2.0" +echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/new-pkg.links +buildpackage "$BUILDDIR" "unstable" "main" +rm -rf "$BUILDDIR" + +setupsimplenativepackage "old-pkg" "all" "2.0" "unstable" "Depends: new-pkg" +local BUILDDIR="incoming/old-pkg-2.0" +echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/old-pkg.links +echo " +override_dh_link: + rm -rf debian/old-pkg/usr/share/doc/old-pkg/ + dh_link" >> ${BUILDDIR}/debian/rules +buildpackage "$BUILDDIR" "unstable" "main" +rm -rf "$BUILDDIR" + +setupaptarchive + +aptget install old-pkg=1.0 --trivial-only -qq 2>&1 > /dev/null + +testfileequal "rootdir/var/lib/apt/extended_states" "" # old-pkg is manual installed + +local CMD="aptget dist-upgrade -y -q=0" +msgtest "Test for equality of" "$CMD" +local COMPAREFILE=$(mktemp) +echo "The following package disappeared from your system as +all files have been overwritten by other packages: + old-pkg +Note: This is done automatic and on purpose by dpkg." > $COMPAREFILE +$CMD 2>&1 | tail -n 4 | diff $COMPAREFILE - && msgpass || msgfail +rm $COMPAREFILE + +sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d' +testfileequal "rootdir/var/log/apt/history.log" " +Install: old-pkg:i386 (1.0) + +Install: new-pkg:i386 (2.0, automatic) +Upgrade: old-pkg:i386 (1.0, 2.0) +Disappeared: old-pkg (1.0)" + +testfileequal "rootdir/var/lib/apt/extended_states" "" # new-pkg should have get the manual flag from old-pkg |