From c1e0a100d11e6e6d529d9f52375f979a9dbd4d04 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Nov 2012 10:43:12 +0100 Subject: * apt-pkg/depcache.cc: - don't call MarkInstall with the FromUser flag set for packages which are dependencies of APT::Never-MarkAuto-Sections matchers --- apt-pkg/depcache.cc | 19 ++++++------------- debian/changelog | 3 +++ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index deb8ec21f..6ceb18492 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1178,22 +1178,15 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, std::clog << OutputInDepth(Depth) << "Installing " << InstPkg.Name() << " as " << Start.DepType() << " of " << Pkg.Name() << std::endl; - // now check if we should consider it a automatic dependency or not - if(Pkg.Section() && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", Pkg.Section())) - { + MarkInstall(InstPkg, true, Depth + 1, false, ForceImportantDeps); + // now check if we should consider it a automatic dependency or not + if(InstPkg->CurrentVer == 0 && Pkg->Section != 0 && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", Pkg.Section())) + { if(DebugAutoInstall == true) std::clog << OutputInDepth(Depth) << "Setting NOT as auto-installed (direct " << Start.DepType() << " of pkg in APT::Never-MarkAuto-Sections)" << std::endl; - MarkInstall(InstPkg,true,Depth + 1, true); - } - else - { - // mark automatic dependency - MarkInstall(InstPkg,true,Depth + 1, false, ForceImportantDeps); - // Set the autoflag, after MarkInstall because MarkInstall unsets it - if (InstPkg->CurrentVer == 0) - PkgState[InstPkg->ID].Flags |= Flag::Auto; - } + MarkAuto(InstPkg, false); + } } continue; } diff --git a/debian/changelog b/debian/changelog index 98ae49f74..10a3b7252 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,9 @@ apt (0.9.7.7) UNRELEASED; urgency=low - do not do lock-step configuration for a M-A:same package if it isn't unpacked yet in SmartConfigure and do not unpack a M-A:same package again in SmartUnPack if we have already configured it (LP: #1062503) + * apt-pkg/depcache.cc: + - don't call MarkInstall with the FromUser flag set for packages + which are dependencies of APT::Never-MarkAuto-Sections matchers -- Jordi Mallach Thu, 18 Oct 2012 23:30:46 +0200 -- cgit v1.2.3 From 35f6b9ea8a28022607e3921475c165c06d5ead8a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Nov 2012 10:47:30 +0100 Subject: no mode changes should obviously be ok for pkgDepCache::IsModeChangeOk --- apt-pkg/depcache.cc | 8 ++++++-- debian/changelog | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 6ceb18492..2ec346f0b 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -913,11 +913,15 @@ bool pkgDepCache::IsModeChangeOk(ModeList const mode, PkgIterator const &Pkg, return true; StateCache &P = PkgState[Pkg->ID]; + // not changing the mode is obviously also fine as we might want to call + // e.g. MarkInstall multiple times with different arguments for the same package + if (P.Mode == mode) + return true; // if previous state was set by user only user can reset it if ((P.iFlags & Protected) == Protected) { - if (unlikely(DebugMarker == true) && P.Mode != mode) + if (unlikely(DebugMarker == true)) std::clog << OutputInDepth(Depth) << "Ignore Mark" << PrintMode(mode) << " of " << Pkg << " as its mode (" << PrintMode(P.Mode) << ") is protected" << std::endl; @@ -927,7 +931,7 @@ bool pkgDepCache::IsModeChangeOk(ModeList const mode, PkgIterator const &Pkg, else if (mode != ModeKeep && Pkg->SelectedState == pkgCache::State::Hold && _config->FindB("APT::Ignore-Hold",false) == false) { - if (unlikely(DebugMarker == true) && P.Mode != mode) + if (unlikely(DebugMarker == true)) std::clog << OutputInDepth(Depth) << "Hold prevents Mark" << PrintMode(mode) << " of " << Pkg << std::endl; return false; diff --git a/debian/changelog b/debian/changelog index 10a3b7252..7644320c3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,7 @@ apt (0.9.7.7) UNRELEASED; urgency=low * apt-pkg/depcache.cc: - don't call MarkInstall with the FromUser flag set for packages which are dependencies of APT::Never-MarkAuto-Sections matchers + - no mode changes should obviously be ok for pkgDepCache::IsModeChangeOk -- Jordi Mallach Thu, 18 Oct 2012 23:30:46 +0200 -- cgit v1.2.3 From b29c448254fbc2000ea986a828cc6ec7dbbe41aa Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Nov 2012 10:49:21 +0100 Subject: * cmdline/apt-get.cc: - do not call Mark{Install,Delete} from the autoremove code with the FromUser bit set to avoid modifying the auto-installed bit --- cmdline/apt-get.cc | 6 +++--- debian/changelog | 3 +++ test/integration/test-bug-604222-new-and-autoremove | 2 +- test/integration/test-bug-618848-always-respect-user-requests | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6890b7120..1bb981b20 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1736,7 +1736,7 @@ bool DoAutomaticRemove(CacheFile &Cache) { if(Pkg.CurrentVer() != 0 && Pkg->CurrentState != pkgCache::State::ConfigFiles) - Cache->MarkDelete(Pkg, purgePkgs); + Cache->MarkDelete(Pkg, purgePkgs, 0, false); else Cache->MarkKeep(Pkg, false, false); } @@ -1750,7 +1750,7 @@ bool DoAutomaticRemove(CacheFile &Cache) { if (Pkg.CandVersion() != 0) tooMuch.insert(Pkg); - Cache->MarkDelete(Pkg, false); + Cache->MarkDelete(Pkg, false, 0, false); } // only show stuff in the list that is not yet marked for removal else if(hideAutoRemove == false && Cache[Pkg].Delete() == false) @@ -1787,7 +1787,7 @@ bool DoAutomaticRemove(CacheFile &Cache) continue; if (Debug == true) std::clog << "Save " << Pkg << " as another installed garbage package depends on it" << std::endl; - Cache->MarkInstall(Pkg, false); + Cache->MarkInstall(Pkg, false, 0, false); if (hideAutoRemove == false) ++autoRemoveCount; tooMuch.erase(Pkg); diff --git a/debian/changelog b/debian/changelog index 7644320c3..b12e076d5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,9 @@ apt (0.9.7.7) UNRELEASED; urgency=low - don't call MarkInstall with the FromUser flag set for packages which are dependencies of APT::Never-MarkAuto-Sections matchers - no mode changes should obviously be ok for pkgDepCache::IsModeChangeOk + * cmdline/apt-get.cc: + - do not call Mark{Install,Delete} from the autoremove code with + the FromUser bit set to avoid modifying the auto-installed bit -- Jordi Mallach Thu, 18 Oct 2012 23:30:46 +0200 diff --git a/test/integration/test-bug-604222-new-and-autoremove b/test/integration/test-bug-604222-new-and-autoremove index 5820fb0dc..ea73c5775 100755 --- a/test/integration/test-bug-604222-new-and-autoremove +++ b/test/integration/test-bug-604222-new-and-autoremove @@ -51,7 +51,7 @@ Building dependency tree... MarkInstall libvtk5.4 [ i386 ] < none -> 5.4.2-8 > ( libs ) FU=0 MarkKeep libvtk5-dev [ i386 ] < none -> 5.4.2-8 > ( libdevel ) FU=0 MarkKeep libvtk5-dev [ i386 ] < none -> 5.4.2-8 > ( libdevel ) FU=0 - MarkDelete libvtk5.4 [ i386 ] < none -> 5.4.2-8 > ( libs ) FU=1 + MarkDelete libvtk5.4 [ i386 ] < none -> 5.4.2-8 > ( libs ) FU=0 The following extra packages will be installed: libavcodec52 libopenal-dev The following NEW packages will be installed: diff --git a/test/integration/test-bug-618848-always-respect-user-requests b/test/integration/test-bug-618848-always-respect-user-requests index 5148be640..1ebadf280 100755 --- a/test/integration/test-bug-618848-always-respect-user-requests +++ b/test/integration/test-bug-618848-always-respect-user-requests @@ -16,11 +16,11 @@ 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 + MarkDelete exim4-daemon-light [ i386 ] < 1.0 > ( other ) FU=0 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 + MarkDelete exim4 [ i386 ] < 1.0 > ( other ) FU=0 The following packages will be REMOVED: exim4 exim4-daemon-light libdb4.8 MarkDelete exim4 [ i386 ] < 1.0 > ( other ) FU=1 -- cgit v1.2.3 From b83cad32f1d67fef2dbb12476ed9d3ad8f353db6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Nov 2012 11:00:02 +0100 Subject: * apt-pkg/algorithms.cc: - ensure pkgProblemResolver calls MarkDelete without FromUser set so that it can't overrule holds and the protection flag --- apt-pkg/algorithms.cc | 16 ++++++++-------- debian/changelog | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 1b0161ffd..b611df172 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -287,13 +287,13 @@ bool pkgApplyStatus(pkgDepCache &Cache) Cache[I].CandidateVerIter(Cache).Downloadable() == true) Cache.MarkInstall(I, true, 0, false); else - Cache.MarkDelete(I); + Cache.MarkDelete(I, false, 0, false); } break; // This means removal failed case pkgCache::State::HalfInstalled: - Cache.MarkDelete(I); + Cache.MarkDelete(I, false, 0, false); break; default: @@ -774,7 +774,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg) if (WasKept == true) Cache.MarkKeep(Pkg, false, false); else - Cache.MarkDelete(Pkg); + Cache.MarkDelete(Pkg, false, 0, false); return false; } @@ -903,7 +903,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) OldBreaks < Cache.BrokenCount()) { if (OldVer == 0) - Cache.MarkDelete(I); + Cache.MarkDelete(I, false, 0, false); else Cache.MarkKeep(I, false, false); } @@ -942,7 +942,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) { if (Debug == true) clog << " Or group remove for " << I.FullName(false) << endl; - Cache.MarkDelete(I); + Cache.MarkDelete(I, false, 0, false); Change = true; } } @@ -1077,7 +1077,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) { if (Debug == true) clog << " Removing " << I.FullName(false) << " rather than change " << Start.TargetPkg().FullName(false) << endl; - Cache.MarkDelete(I); + Cache.MarkDelete(I, false, 0, false); if (Counter > 1 && Scores[Pkg->ID] > Scores[I->ID]) Scores[I->ID] = Scores[Pkg->ID]; } @@ -1166,7 +1166,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) if (Debug == true) clog << " Removing " << I.FullName(false) << " because I can't find " << Start.TargetPkg().FullName(false) << endl; if (InOr == false) - Cache.MarkDelete(I); + Cache.MarkDelete(I, false, 0, false); } Change = true; @@ -1193,7 +1193,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) { if (Debug == true) clog << " Fixing " << I.FullName(false) << " via remove of " << J->Pkg.FullName(false) << endl; - Cache.MarkDelete(J->Pkg); + Cache.MarkDelete(J->Pkg, false, 0, false); } } else diff --git a/debian/changelog b/debian/changelog index b12e076d5..ddbc8de89 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,6 +17,9 @@ apt (0.9.7.7) UNRELEASED; urgency=low * cmdline/apt-get.cc: - do not call Mark{Install,Delete} from the autoremove code with the FromUser bit set to avoid modifying the auto-installed bit + * apt-pkg/algorithms.cc: + - ensure pkgProblemResolver calls MarkDelete without FromUser set + so that it can't overrule holds and the protection flag -- Jordi Mallach Thu, 18 Oct 2012 23:30:46 +0200 -- cgit v1.2.3 From 0291f6459b0a8de04268225cc0c88d340ba48653 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Sat, 10 Nov 2012 14:25:45 +0100 Subject: * apt-pkg/algorithms.cc: - fix package-pointer array memory leak in ResolveByKeepInternal() --- apt-pkg/algorithms.cc | 12 +++++++++--- debian/changelog | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index b611df172..8cd9d4c6e 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1419,12 +1419,18 @@ bool pkgProblemResolver::ResolveByKeepInternal() continue; // Restart again. - if (K == LastStop) - return _error->Error("Internal Error, pkgProblemResolver::ResolveByKeep is looping on package %s.",I.FullName(false).c_str()); + if (K == LastStop) { + // I is an iterator based off our temporary package list, + // so copy the name we need before deleting the temporary list + std::string const LoopingPackage = I.FullName(false); + delete[] PList; + return _error->Error("Internal Error, pkgProblemResolver::ResolveByKeep is looping on package %s.", LoopingPackage.c_str()); + } LastStop = K; K = PList - 1; - } + } + delete[] PList; return true; } /*}}}*/ diff --git a/debian/changelog b/debian/changelog index ddbc8de89..e2b0d753e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,10 @@ apt (0.9.7.7) UNRELEASED; urgency=low - ensure pkgProblemResolver calls MarkDelete without FromUser set so that it can't overrule holds and the protection flag + [ Jonathan Thomas ] + * apt-pkg/algorithms.cc: + - fix package-pointer array memory leak in ResolveByKeepInternal() + -- Jordi Mallach Thu, 18 Oct 2012 23:30:46 +0200 apt (0.9.7.6) unstable; urgency=low -- cgit v1.2.3