diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2011-03-26 12:41:51 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2011-03-26 12:41:51 +0100 |
commit | cc26da01ef43686d67959ef080e5492410d20e4e (patch) | |
tree | a8b3fe789e8e9b96aa2b747faef1642835ebc143 | |
parent | 8aec002f1d3eb70423c760a68a9825a92bba7b2a (diff) |
do not change protected packages in autoinstall (Closes: #618848)
-rw-r--r-- | apt-pkg/algorithms.h | 2 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 19 | ||||
-rw-r--r-- | apt-pkg/depcache.h | 3 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rwxr-xr-x | test/integration/test-bug-549968-install-depends-of-not-installed | 2 | ||||
-rwxr-xr-x | test/integration/test-bug-618848-always-respect-user-requests | 32 |
6 files changed, 55 insertions, 6 deletions
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index cf4a98c4f..ebe31cc10 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -108,7 +108,7 @@ class pkgProblemResolver /*{{{*/ public: - inline void Protect(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= Protected;}; + inline void Protect(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= Protected; Cache.MarkProtected(Pkg);}; inline void Remove(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] |= ToRemove;}; inline void Clear(pkgCache::PkgIterator Pkg) {Flags[Pkg->ID] &= ~(Protected | ToRemove);}; diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 1c89bd32f..07803d7bf 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -964,11 +964,26 @@ bool pkgDepCache::IsModeChangeOk(ModeList const mode, PkgIterator const &Pkg, if (unlikely(Pkg.end() == true || Pkg->VersionList == 0)) return false; + // the user is always right + if (FromUser == true) + return true; + + StateCache &P = PkgState[Pkg->ID]; + + // if previous state was set by user only user can reset it + if ((P.iFlags & Protected) == Protected) + { + if (unlikely(DebugMarker == true) && P.Mode != mode) + std::clog << OutputInDepth(Depth) << "Ignore Mark" << PrintMode(mode) + << " of " << Pkg << " as its mode (" << PrintMode(P.Mode) + << ") is protected" << std::endl; + return false; + } // enforce dpkg holds - if (FromUser == false && mode != ModeKeep && Pkg->SelectedState == pkgCache::State::Hold && + else if (mode != ModeKeep && Pkg->SelectedState == pkgCache::State::Hold && _config->FindB("APT::Ignore-Hold",false) == false) { - if (unlikely(DebugMarker == true) && PkgState[Pkg->ID].Mode != mode) + if (unlikely(DebugMarker == true) && P.Mode != mode) std::clog << OutputInDepth(Depth) << "Hold prevents Mark" << PrintMode(mode) << " of " << Pkg << std::endl; return false; diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 8cf7db80a..750da3d6f 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -119,7 +119,7 @@ class pkgDepCache : protected pkgCache::Namespace DepCandPolicy = (1 << 4), DepCandMin = (1 << 5)}; // These flags are used in StateCache::iFlags - enum InternalFlags {AutoKept = (1 << 0), Purge = (1 << 1), ReInstall = (1 << 2)}; + enum InternalFlags {AutoKept = (1 << 0), Purge = (1 << 1), ReInstall = (1 << 2), Protected = (1 << 3)}; enum VersionTypes {NowVersion, InstallVersion, CandidateVersion}; enum ModeList {ModeDelete = 0, ModeKeep = 1, ModeInstall = 2}; @@ -393,6 +393,7 @@ class pkgDepCache : protected pkgCache::Namespace void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, unsigned long Depth = 0, bool FromUser = true, bool ForceImportantDeps = false); + void MarkProtected(PkgIterator const &Pkg) { PkgState[Pkg->ID].iFlags |= Protected; }; void SetReInstall(PkgIterator const &Pkg,bool To); // FIXME: Remove the unused boolean parameter on abi break diff --git a/debian/changelog b/debian/changelog index 1c2cd9da7..2af2517e1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ apt (0.8.13.1) UNRELEASED; urgency=low as suggested by Charles Plessy (Closes: #619083) * apt-pkg/depcache.cc: - remove pseudo handling leftover from SetReInstall + - do not change protected packages in autoinstall (Closes: #618848) * apt-pkg/pkgcachegen.cc: - make "all"->"native" an implementation detail of NewPackage rather than rewrite it in higher methods @@ -25,7 +26,7 @@ apt (0.8.13.1) UNRELEASED; urgency=low - use dpkg --print-foreign-architectures to get multiarch configuration if non is specified with APT::Architectures (Closes: #612958) - -- David Kalnischkies <kalnischkies@gmail.com> Sat, 26 Mar 2011 01:28:38 +0100 + -- David Kalnischkies <kalnischkies@gmail.com> Sat, 26 Mar 2011 12:26:32 +0100 apt (0.8.13) unstable; urgency=low diff --git a/test/integration/test-bug-549968-install-depends-of-not-installed b/test/integration/test-bug-549968-install-depends-of-not-installed index 7b4b4b71c..78c0801f2 100755 --- a/test/integration/test-bug-549968-install-depends-of-not-installed +++ b/test/integration/test-bug-549968-install-depends-of-not-installed @@ -17,7 +17,7 @@ setupaptarchive testequal 'Reading package lists... Building dependency tree... MarkInstall coolstuff [ i386 ] < none -> 1.0 > ( other ) FU=1 - Hold prevents MarkInstall of extracoolstuff [ i386 ] < none -> 1.0 > ( other ) + Ignore MarkInstall of extracoolstuff [ i386 ] < none -> 1.0 > ( other ) as its mode (Keep) is protected Package extracoolstuff is not installed, so not removed The following NEW packages will be installed: coolstuff diff --git a/test/integration/test-bug-618848-always-respect-user-requests b/test/integration/test-bug-618848-always-respect-user-requests new file mode 100755 index 000000000..5148be640 --- /dev/null +++ b/test/integration/test-bug-618848-always-respect-user-requests @@ -0,0 +1,32 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +insertinstalledpackage 'libdb4.8' 'all' '1.0' +insertinstalledpackage 'exim4' 'all' '1.0' 'Depends: exim4-daemon-light | exim4-daemon-heavy' +insertinstalledpackage 'exim4-daemon-light' 'all' '1.0' 'Depends: libdb4.8' +insertpackage 'unstable' 'exim4-daemon-heavy' 'all' '1.0' 'Depends: libdb4.8' + +setupaptarchive + +testequal 'Reading package lists... +Building dependency tree... + MarkDelete libdb4.8 [ i386 ] < 1.0 > ( other ) FU=1 + MarkDelete exim4-daemon-light [ i386 ] < 1.0 > ( other ) FU=1 + MarkInstall exim4-daemon-heavy [ i386 ] < none -> 1.0 > ( other ) FU=0 + Ignore MarkInstall of libdb4.8 [ i386 ] < 1.0 > ( other ) as its mode (Delete) is protected + MarkDelete exim4-daemon-heavy [ i386 ] < none -> 1.0 > ( other ) FU=0 + MarkDelete exim4 [ i386 ] < 1.0 > ( other ) FU=1 +The following packages will be REMOVED: + exim4 exim4-daemon-light libdb4.8 + MarkDelete exim4 [ i386 ] < 1.0 > ( other ) FU=1 +0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded. +Remv exim4 [1.0] + MarkDelete exim4-daemon-light [ i386 ] < 1.0 > ( other ) FU=1 +Remv exim4-daemon-light [1.0] + MarkDelete libdb4.8 [ i386 ] < 1.0 > ( other ) FU=1 +Remv libdb4.8 [1.0]' aptget remove libdb4.8 -s -o Debug::pkgDepCache::Marker=1 |