]> git.saurik.com Git - apt.git/commitdiff
* apt-pkg/deb/dpkgpm.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 20 Aug 2010 17:09:16 +0000 (19:09 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 20 Aug 2010 17:09:16 +0000 (19:09 +0200)
  - use the InstVer instead of the CurrentVer for the autobit transfer

Add also a small testcase to check the handling automatical

apt-pkg/deb/dpkgpm.cc
debian/changelog
test/integration/framework
test/integration/test-disappearing-packages [new file with mode: 0755]

index aa0b04bd5a9ab0eac5c7a814d0783039e61e8f6b..5530ef12975862f9b24e0aa5d06e7b588689c671 100644 (file)
@@ -554,7 +554,7 @@ void pkgDPkgPM::handleDisappearAction(string const &pkgname)
    // the disappeared package was auto-installed - nothing to do
    if ((Cache[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto)
       return;
-   pkgCache::VerIterator PkgVer = Pkg.CurrentVer();
+   pkgCache::VerIterator PkgVer = Cache[Pkg].InstVerIter(Cache);
    if (unlikely(PkgVer.end() == true))
       return;
    /* search in the list of dependencies for (Pre)Depends,
@@ -571,7 +571,9 @@ void pkgDPkgPM::handleDisappearAction(string const &pkgname)
       // the package is already marked as manual
       if ((Cache[Tar].Flags & pkgCache::Flag::Auto) != pkgCache::Flag::Auto)
         continue;
-      pkgCache::VerIterator TarVer = Tar.CurrentVer();
+      pkgCache::VerIterator TarVer =  Cache[Tar].InstVerIter(Cache);
+      if (TarVer.end() == true)
+        continue;
       for (pkgCache::DepIterator Rep = TarVer.DependsList(); Rep.end() != true; ++Rep)
       {
         if (Rep->Type != pkgCache::Dep::Replaces)
index 88b22c01bdb962599dea0acaeeb5f077559cce09..a08dce97f7afbf66d08fc0405fa95e76490b9ebe 100644 (file)
@@ -13,8 +13,10 @@ apt (0.8.0~pre2) UNRELEASED; urgency=low
     - init valid-until correctly to prevent garbage entering Release file
   * apt-pkg/deb/debsystem.cc:
     - set dir::state::status based at least on dir
+  * apt-pkg/deb/dpkgpm.cc:
+    - use the InstVer instead of the CurrentVer for the autobit transfer
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 19 Aug 2010 00:28:21 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 20 Aug 2010 19:06:29 +0200
 
 apt (0.8.0~pre1) experimental; urgency=low
 
index 01b795ba9ccccaefc50347979ffb1eeae3da0b2e..82fca2046adc0ba55b79618294e296122fef10cd 100644 (file)
@@ -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 (executable)
index 0000000..ebf2bb1
--- /dev/null
@@ -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