summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-03-26 12:41:51 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-03-26 12:41:51 +0100
commitcc26da01ef43686d67959ef080e5492410d20e4e (patch)
treea8b3fe789e8e9b96aa2b747faef1642835ebc143 /apt-pkg
parent8aec002f1d3eb70423c760a68a9825a92bba7b2a (diff)
do not change protected packages in autoinstall (Closes: #618848)
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/algorithms.h2
-rw-r--r--apt-pkg/depcache.cc19
-rw-r--r--apt-pkg/depcache.h3
3 files changed, 20 insertions, 4 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