diff options
-rw-r--r-- | apt-pkg/contrib/error.cc | 4 | ||||
-rw-r--r-- | apt-pkg/contrib/error.h | 23 | ||||
-rw-r--r-- | apt-pkg/orderlist.cc | 79 | ||||
-rw-r--r-- | debian/changelog | 9 | ||||
-rw-r--r-- | test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order | 67 | ||||
-rw-r--r-- | test/integration/framework | 35 | ||||
-rw-r--r-- | test/integration/status-bug-590438-broken-provides-thanks-to-remove-order | 97 | ||||
-rwxr-xr-x | test/integration/test-bug-590438-broken-provides-thanks-to-remove-order | 98 |
8 files changed, 402 insertions, 10 deletions
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index fbb6e4636..d63b06d13 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -180,7 +180,7 @@ bool GlobalError::PopMessage(std::string &Text) { } /*}}}*/ // GlobalError::DumpErrors - Dump all of the errors/warns to cerr /*{{{*/ -void GlobalError::DumpErrors(std::ostream &out, MsgType const &trashhold, +void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold, bool const &mergeStack) { if (mergeStack == true) for (std::list<MsgStack>::const_reverse_iterator s = Stacks.rbegin(); @@ -189,7 +189,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &trashhold, for (std::list<Item>::const_iterator m = Messages.begin(); m != Messages.end(); m++) - if (m->Type >= trashhold) + if (m->Type >= threshold) out << (*m) << std::endl; Discard(); } diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h index e5517c2da..4af0302c0 100644 --- a/apt-pkg/contrib/error.h +++ b/apt-pkg/contrib/error.h @@ -204,9 +204,10 @@ public: /*{{{*/ * displayed or not. * * \param[out] out output stream to write the messages in - * \param WithoutNotice output notices or not + * \param threshold minimim level considered + * \param mergeStack */ - void DumpErrors(std::ostream &out, MsgType const &trashhold = WARNING, + void DumpErrors(std::ostream &out, MsgType const &threshold = WARNING, bool const &mergeStack = true); /** \brief dumps the list of messages to std::cerr @@ -214,10 +215,22 @@ public: /*{{{*/ * Note that all messages are discarded, also the notices * displayed or not. * - * \param WithoutNotice print notices or not + * \param threshold minimum level printed */ - void inline DumpErrors(MsgType const &trashhold = WARNING) { - DumpErrors(std::cerr, trashhold); + void inline DumpErrors(MsgType const &threshold) { + DumpErrors(std::cerr, threshold); + } + + // mvo: we do this instead of using a default parameter in the + // previous declaration to avoid a (subtle) API break for + // e.g. sigc++ and mem_fun0 + /** \brief dumps the messages of type WARNING or higher to std::cerr + * + * Note that all messages are discarded, displayed or not. + * + */ + void inline DumpErrors() { + DumpErrors(WARNING); } /** \brief put the current Messages into the stack diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 55f9cb9cc..602b63d3b 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -886,13 +886,16 @@ bool pkgOrderList::DepRemove(DepIterator D) continue; /* We wish to see if the dep on the parent package is okay - in the removed (install) state of the target pkg. */ + in the removed (install) state of the target pkg. */ + bool tryFixDeps = false; if (CheckDep(D) == true) { // We want to catch loops with the code below. if (IsFlag(D.ParentPkg(),AddPending) == false) continue; } + else + tryFixDeps = true; // This is the loop detection if (IsFlag(D.ParentPkg(),Added) == true || @@ -903,6 +906,80 @@ bool pkgOrderList::DepRemove(DepIterator D) continue; } + if (tryFixDeps == true) + { + for (pkgCache::DepIterator F = D.ParentPkg().CurrentVer().DependsList(); + F.end() == false; ++F) + { + if (F->Type != pkgCache::Dep::Depends && F->Type != pkgCache::Dep::PreDepends) + continue; + // Check the Providers + if (F.TargetPkg()->ProvidesList != 0) + { + pkgCache::PrvIterator Prov = F.TargetPkg().ProvidesList(); + for (; Prov.end() == false; ++Prov) + { + pkgCache::PkgIterator const P = Prov.OwnerPkg(); + if (IsFlag(P, InList) == true && + IsFlag(P, AddPending) == true && + IsFlag(P, Added) == false && + Cache[P].InstallVer == 0) + break; + } + if (Prov.end() == false) + for (pkgCache::PrvIterator Prv = F.TargetPkg().ProvidesList(); + Prv.end() == false; ++Prv) + { + pkgCache::PkgIterator const P = Prv.OwnerPkg(); + if (IsFlag(P, InList) == true && + IsFlag(P, AddPending) == false && + Cache[P].InstallVer != 0 && + VisitNode(P) == true) + { + Flag(P, Immediate); + tryFixDeps = false; + break; + } + } + if (tryFixDeps == false) + break; + } + + // Check for Or groups + if ((F->CompareOp & pkgCache::Dep::Or) != pkgCache::Dep::Or) + continue; + // Lets see if the package is part of the Or group + pkgCache::DepIterator S = F; + for (; S.end() == false; ++S) + { + if (S.TargetPkg() == D.TargetPkg()) + break; + if ((S->CompareOp & pkgCache::Dep::Or) != pkgCache::Dep::Or || + CheckDep(S)) // Or group is satisfied by another package + for (;S.end() == false; ++S); + } + if (S.end() == true) + continue; + // skip to the end of the or group + for (;S.end() == false && (S->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; ++S); + ++S; + // The soon to be removed is part of the Or group + // start again in the or group and find something which will serve as replacement + for (; F.end() == false && F != S; ++F) + { + if (F.TargetPkg() == D.TargetPkg() || + IsFlag(F.TargetPkg(), InList) == false || + VisitNode(F.TargetPkg()) == false) + continue; + Flag(F.TargetPkg(), Immediate); + tryFixDeps = false; + break; + } + if (tryFixDeps == false) + break; + } + } + // Skip over missing files if (IsMissing(D.ParentPkg()) == true) continue; diff --git a/debian/changelog b/debian/changelog index 7da25b30d..79f493cee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -37,6 +37,15 @@ apt (0.7.26~exp11) experimental; urgency=low - prefer non-virtual packages in FindPreferredPkg (Closes: #590041) * test/integration/*: - add with bug#590041 testcase a small test "framework" + * apt-pkg/orderlist.cc: + - try to install another or-group member in DepRemove before + breaking the or group (Closes: #590438) + - configure also the replacement before remove by adding Immediate flag + + [ Michael Vogt ] + * apt-pkg/contrib/error.{cc,h} + - docstring cleanup + - add inline DumpError() to avoid subtle API break -- David Kalnischkies <kalnischkies@gmail.com> Mon, 26 Jul 2010 12:40:44 +0200 diff --git a/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order new file mode 100644 index 000000000..75a769e1a --- /dev/null +++ b/test/integration/Packages-bug-590438-broken-provides-thanks-to-remove-order @@ -0,0 +1,67 @@ +Package: gawk +Priority: optional +Section: interpreters +Installed-Size: 2084 +Maintainer: Arthur Loiret <aloiret@debian.org> +Architecture: i386 +Version: 1:3.1.7.dfsg-5 +Provides: awk +Pre-Depends: libc6 (>= 2.3) +Filename: pool/main/g/gawk/gawk_3.1.7.dfsg-5_i386.deb +Size: 766008 +MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252 +SHA1: ac033488dae4b7e8167d610e490319c047edf7e4 +SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627 +Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache +Homepage: http://www.gnu.org/software/gawk/ +Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text + +Package: aawk +Priority: optional +Section: interpreters +Installed-Size: 2084 +Maintainer: Arthur Loiret <aloiret@debian.org> +Architecture: i386 +Version: 1:3.1.7.dfsg-5 +Provides: awk +Pre-Depends: libc6 (>= 2.3) +Filename: pool/main/a/aawk/aawk_3.1.7.dfsg-5_i386.deb +Size: 766008 +MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252 +SHA1: ac033488dae4b7e8167d610e490319c047edf7e4 +SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627 +Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache +Homepage: http://www.gnu.org/software/gawk/ +Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text + +Package: gawk2 +Priority: optional +Section: interpreters +Installed-Size: 2084 +Maintainer: Arthur Loiret <aloiret@debian.org> +Architecture: i386 +Version: 1:3.1.7.dfsg-5 +Provides: awk +Pre-Depends: libc6 (>= 2.3) +Depends: coolstuff +Filename: pool/main/g/gawk/gawk_3.1.7.dfsg-5_i386.deb +Size: 766008 +MD5sum: 6459a02cfc1b9eafb3c0415e4ff4e252 +SHA1: ac033488dae4b7e8167d610e490319c047edf7e4 +SHA256: a2337dfe1cc82aeae46f2c722e5cc7be9ecefdea4aaf13f540cfe70bd8b1d627 +Description-de: GNU awk, eine Mustererkennungs- und Verarbeitungssprache +Homepage: http://www.gnu.org/software/gawk/ +Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, suite::gnu, use::filtering, use::scanning, works-with::text + +Package: coolstuff +Priority: optional +Section: cool +Installed-Size: 10 +Maintainer: David Kalnischkies <kalnischkies+debian@gmail.com> +Architecture: all +Version: 1-1 +Filename: pool/main/c/coolstuff/coolstuff_1-1_all.deb +Size: 7608 +MD5sum: 6459aa2efc139eafb323ac3f4f5aeb22 +Description: We all need cool stuff + diff --git a/test/integration/framework b/test/integration/framework index 97dce1e19..b4e9302e8 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -45,8 +45,9 @@ aptftparchive() { runapt apt-ftparchive $*; } setupenvironment() { local TMPWORKINGDIRECTORY=$(mktemp -d) + local TESTDIR=$(readlink -f $(dirname $0)) msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… " - BUILDDIRECTORY=$(readlink -f $(dirname $0)/../../build/bin) + 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 @@ -55,10 +56,21 @@ setupenvironment() { cd rootdir mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache var/lib/dpkg mkdir -p var/cache/apt/archives/partial var/lib/apt/lists/partial - touch var/lib/dpkg/status + local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/') + if [ -f "${TESTDIR}/${STATUSFILE}" ]; then + cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status + else + touch var/lib/dpkg/status + fi mkdir -p usr/lib/apt ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods cd .. + local PACKAGESFILE=$(echo "$(basename $0)" | sed 's/^test-/Packages-/') + if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then + cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages + else + touch var/lib/dpkg/status + fi echo "RootDir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf echo "Debug::NoLocking \"true\";" >> aptconfig.conf echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf @@ -135,6 +147,24 @@ testequal() { shift msgtest "Test for equality of" "$*" $* 2>&1 | diff $COMPAREFILE - && msgpass || msgfail + rm $COMPAREFILE +} + +testequalor2() { + local COMPAREFILE1=$(mktemp) + local COMPAREFILE2=$(mktemp) + local COMPAREAGAINST=$(mktemp) + echo "$1" > $COMPAREFILE1 + echo "$2" > $COMPAREFILE2 + shift 2 + msgtest "Test for equality OR of" "$*" + $* 2>&1 1> $COMPAREAGAINST + (diff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null || + diff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass || + ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(diff $COMPAREFILE1 $COMPAREAGAINST)" \ + "\n${CINFO}Diff against OR 2${CNORMAL}" "$(diff $COMPAREFILE2 $COMPAREAGAINST)" && + msgfail ) + rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST } testshowvirtual() { @@ -155,6 +185,7 @@ E: No packages found" eval `apt-config shell ARCH APT::Architecture` echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE aptcache show $PACKAGE 2>&1 | diff $COMPAREFILE - && msgpass || msgfail + rm $COMPAREFILE } testnopackage() { diff --git a/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order new file mode 100644 index 000000000..c2c03c0e4 --- /dev/null +++ b/test/integration/status-bug-590438-broken-provides-thanks-to-remove-order @@ -0,0 +1,97 @@ +Package: libc-bin +Status: install ok installed +Priority: required +Section: libs +Installed-Size: 1516 +Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org> +Architecture: i386 +Source: eglibc +Version: 2.11.2-2 +Replaces: libc0.1, libc0.3, libc6, libc6.1 +Breaks: libc0.1 (<< 2.10), libc0.3 (<< 2.10), libc6 (<< 2.10), libc6.1 (<< 2.10) +Filename: pool/main/e/eglibc/libc-bin_2.11.2-2_i386.deb +Size: 703542 +MD5sum: f554ec34c092bb8e52e3d917bec7b46c +SHA1: 4d5ba53b50937b1d50e3234e45335de5ea97b84b +SHA256: 4f1e6430a730321209bb6b9cf89ba8a72c95f5c93f3e263a982251b3cc8beb14 +Description-de: Die »Embedded GNU C Library«: Binärdateien +Homepage: http://www.eglibc.org +Tag: devel::lang:c, devel::packaging, implemented-in::c, interface::commandline, role::program, scope::utility, special::auto-inst-parts, suite::gnu, works-with::text, works-with::unicode + +Package: libc6 +Status: install ok installed +Priority: required +Section: libs +Installed-Size: 9340 +Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org> +Architecture: i386 +Source: eglibc +Version: 2.11.2-2 +Provides: glibc-2.11-1 +Depends: libc-bin (= 2.11.2-2), libgcc1 +Recommends: libc6-i686 +Suggests: glibc-doc, debconf | debconf-2.0, locales +Conflicts: tzdata (<< 2007k-1), tzdata-etch +Breaks: locales (<< 2.11), locales-all (<< 2.11), nscd (<< 2.11) +Filename: pool/main/e/eglibc/libc6_2.11.2-2_i386.deb +Size: 3877166 +MD5sum: 3d8fe972a359ad362ac1957c2687e5c2 +SHA1: cd901f3265254e40ad198b935877f546eeaa8403 +SHA256: e1bc3da1e11f9b742d05f927362e2079482db4186ff45af9f937d284e112e7e5 +Description-de: Die »Embedded GNU C Library«: Laufzeitbibliotheken +Homepage: http://www.eglibc.org +Tag: devel::lang:c, devel::library, implemented-in::c, protocol::ipv6, role::shared-lib, suite::gnu + +Package: mawk +Status: install ok installed +Priority: required +Section: utils +Installed-Size: 228 +Maintainer: Steve Langasek <vorlon@debian.org> +Architecture: i386 +Version: 1.3.3-15 +Provides: awk +Pre-Depends: libc6 (>= 2.1) +Filename: pool/main/m/mawk/mawk_1.3.3-15_i386.deb +Size: 81430 +MD5sum: e0f9e9903a862a52b5f107d560c4d8e0 +SHA1: cca3b3ea3a57b9c3c136fb538a4fb06a99d1a33e +SHA256: 7449b10ffb6a8636a249ad6866188cad0040a6a446fb4a3a71d81fd136297ee6 +Description-de: Eine Muster- und Textverarbeitungssprache +Tag: devel::interpreter, implemented-in::c, interface::commandline, role::program, scope::utility, use::filtering, use::scanning, works-with::text + +Package: gcc-4.5-base +Status: install ok installed +Priority: required +Section: libs +Installed-Size: 172 +Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org> +Architecture: i386 +Source: gcc-4.5 +Version: 4.5.0-8 +Filename: pool/main/g/gcc-4.5/gcc-4.5-base_4.5.0-8_i386.deb +Size: 117894 +MD5sum: f5850c42681fcfee3429a1b43da68433 +SHA1: 0548343feba69c4c01d5dbf147393d8dc27605ac +SHA256: 04b60f5fe24b7397e3be233051615ff9addb66d4581578f67fde76f5d7f69f7a +Description: The GNU Compiler Collection (base package) +Homepage: http://gcc.gnu.org/ + +Package: libgcc1 +Status: install ok installed +Priority: required +Section: libs +Installed-Size: 148 +Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org> +Architecture: i386 +Source: gcc-4.5 (4.5.0-8) +Version: 1:4.5.0-8 +Depends: gcc-4.5-base (= 4.5.0-8), libc6 (>= 2.2.4) +Filename: pool/main/g/gcc-4.5/libgcc1_4.5.0-8_i386.deb +Size: 52190 +MD5sum: beda956a1dcdeffed11072c2d0f3eb83 +SHA1: 7117ec43eec7982a030fcc9a12d4772de3fcdba0 +SHA256: 1d10bd532adce8683b475fcc60c22300f717ef19bf84dc5bf43b07e504f85dcb +Description: GCC support library +Homepage: http://gcc.gnu.org/ + diff --git a/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order new file mode 100755 index 000000000..17ce50295 --- /dev/null +++ b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order @@ -0,0 +1,98 @@ +#!/bin/sh +set -e + +local TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture "i386" +setupflataptarchive + +pkgbasefile="Package: base-files +Status: install ok installed +Essential: yes +Priority: required +Section: admin +Installed-Size: 472 +Maintainer: Santiago Vila <sanvila@debian.org> +Architecture: i386 +Version: 5.8 +Replaces: base, dpkg (<= 1.15.0), miscutils +Provides: base +Filename: pool/main/b/base-files/base-files_5.8_i386.deb +Size: 73986 +MD5sum: 8489687ce10e656babd467c9ee389349 +Description-de: Verschiedene Dateien für das Basis-System von Debian" + +predependsgawk() { +# rm rootdir/var/cache/apt/*.bin + cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status + echo "$pkgbasefile +Pre-Depends: $1 +" >> rootdir/var/lib/dpkg/status + testequal "Inst gawk (1:3.1.7.dfsg-5 localhost [i386]) +Conf gawk (1:3.1.7.dfsg-5 localhost [i386]) +Remv mawk [1.3.3-15]" aptget install gawk mawk- -sqq -o PreDepends=$(echo "$1" | sed 's/ //g') +} + +predependsgawk "gawk | mawk" +predependsgawk "mawk | gawk" + +predependsgawk "aawk | mawk | gawk" +predependsgawk "aawk | gawk | mawk" + +predependsgawk "gawk | awk" +predependsgawk "aawk | gawk | awk" + +predependsgawk "mawk | awk" + +predependsgawk "awk | gawk" +predependsgawk "awk | gawk | aawk" + +predependsgawk "awk | mawk" + +predependsgawk "aawk | awk" +predependsgawk "awk | aawk" + +predependsgawk "awk" + +predependsgawk2() { +# rm rootdir/var/cache/apt/*.bin + cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status + echo "$pkgbasefile +Pre-Depends: $1 +" >> rootdir/var/lib/dpkg/status + testequalor2 "Inst coolstuff (1-1 localhost [all]) +Conf coolstuff (1-1 localhost [all]) +Inst gawk2 (1:3.1.7.dfsg-5 localhost [i386]) +Conf gawk2 (1:3.1.7.dfsg-5 localhost [i386]) +Remv mawk [1.3.3-15]" "Inst coolstuff (1-1 localhost [all]) +Inst gawk2 (1:3.1.7.dfsg-5 localhost [i386]) +Conf coolstuff (1-1 localhost [all]) +Conf gawk2 (1:3.1.7.dfsg-5 localhost [i386]) +Remv mawk [1.3.3-15]" aptget install gawk2 mawk- -sqq -o PreDepends=$(echo "$1" | sed 's/ //g') +} + +predependsgawk2 "gawk2 | mawk" +predependsgawk2 "mawk | gawk2" + +predependsgawk2 "aawk | mawk | gawk2" +predependsgawk2 "aawk | gawk2 | mawk" + +predependsgawk2 "gawk2 | awk" +predependsgawk2 "aawk | gawk2 | awk" + +predependsgawk2 "mawk | awk" + +predependsgawk2 "awk | gawk2" +predependsgawk2 "awk | gawk2 | aawk" + +predependsgawk2 "awk | mawk" + +predependsgawk2 "aawk | awk" +predependsgawk2 "awk | aawk" + +predependsgawk2 "awk" + + +# aptget install gawk2 mawk- -s #-o Debug::pkgOrderList=1 #-o Debug::pkgPackageManager=1 |