summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/depcache.cc21
-rwxr-xr-xtest/integration/test-bug-549968-install-depends-of-not-installed1
-rwxr-xr-xtest/integration/test-bug-618848-always-respect-user-requests1
-rwxr-xr-xtest/integration/test-resolver-delays-remove-decisions33
4 files changed, 51 insertions, 5 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 7a068da1b..817d9de3c 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1278,10 +1278,23 @@ static APT::VersionVector getAllPossibleSolutions(pkgDepCache &Cache, pkgCache::
toNewInstall.emplace_back(std::move(Ver));
}
} while (Start++ != End);
- std::move(toNewInstall.begin(), toNewInstall.end(), std::back_inserter(toUpgrade));
+ if (toUpgrade.empty())
+ toUpgrade = std::move(toNewInstall);
+ else
+ std::move(toNewInstall.begin(), toNewInstall.end(), std::back_inserter(toUpgrade));
+
if (not sorted)
std::sort(toUpgrade.begin(), toUpgrade.end(), [](pkgCache::VerIterator const &A, pkgCache::VerIterator const &B) { return A->ID < B->ID; });
toUpgrade.erase(std::unique(toUpgrade.begin(), toUpgrade.end()), toUpgrade.end());
+
+ if (not End.IsNegative())
+ toUpgrade.erase(std::remove_if(toUpgrade.begin(), toUpgrade.end(), [&Cache](pkgCache::VerIterator const &V) {
+ auto const P = V.ParentPkg();
+ auto const &State = Cache[P];
+ return State.Protect() && (State.Delete() || (State.Keep() && P->CurrentVer == 0));
+ }),
+ toUpgrade.end());
+
return toUpgrade;
}
/*}}}*/
@@ -1521,10 +1534,12 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst,
unsigned long Depth, bool FromUser,
bool ForceImportantDeps)
{
- if (not IsModeChangeOk(*this, ModeInstall, Pkg, Depth, FromUser, DebugMarker))
+ StateCache &P = PkgState[Pkg->ID];
+ if (P.Protect() && P.Keep() && P.CandidateVer != nullptr && P.CandidateVer == Pkg.CurrentVer())
+ ; // we are here to mark our dependencies as protected, no state is changed
+ else if (not IsModeChangeOk(*this, ModeInstall, Pkg, Depth, FromUser, DebugMarker))
return false;
- StateCache &P = PkgState[Pkg->ID];
// See if there is even any possible installation candidate
if (P.CandidateVer == 0)
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 75e7474ff..90ce58a33 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,6 @@ setupaptarchive
testsuccessequal "Reading package lists...
Building dependency tree...
MarkInstall coolstuff:i386 < none -> 1.0 @un puN IPb > FU=1
- Ignore MarkInstall of extracoolstuff:i386 < none | 1.0 @hn puH > as its mode (Keep) is protected
coolstuff:i386 Recommends on extracoolstuff:i386 < none | 1.0 @hn puH > can't be satisfied! (dep)
Package 'extracoolstuff' is not installed, so not removed
Recommended packages:
diff --git a/test/integration/test-bug-618848-always-respect-user-requests b/test/integration/test-bug-618848-always-respect-user-requests
index c9a7b714e..1e144f1ee 100755
--- a/test/integration/test-bug-618848-always-respect-user-requests
+++ b/test/integration/test-bug-618848-always-respect-user-requests
@@ -18,7 +18,6 @@ Building dependency tree...
MarkDelete libdb4.8:i386 < 1.0 @ii pmK > FU=1
MarkDelete exim4-daemon-light:i386 < 1.0 @ii mK Ib > FU=0
MarkInstall exim4-daemon-heavy:i386 < none -> 1.0 @un uN Ib > FU=0
- Ignore MarkInstall of libdb4.8:i386 < 1.0 @ii pmR > as its mode (Delete) is protected
exim4-daemon-heavy:i386 Depends on libdb4.8:i386 < 1.0 @ii pmR > can't be satisfied! (dep)
MarkDelete exim4:i386 < 1.0 @ii mK Ib > FU=0
The following packages will be REMOVED:
diff --git a/test/integration/test-resolver-delays-remove-decisions b/test/integration/test-resolver-delays-remove-decisions
index 3321ed3a7..d8dfd7c9a 100755
--- a/test/integration/test-resolver-delays-remove-decisions
+++ b/test/integration/test-resolver-delays-remove-decisions
@@ -72,3 +72,36 @@ Inst foobar (1 unstable [all])
Conf foo-dep (1 unstable [all])
Conf foo (1 unstable [all])
Conf foobar (1 unstable [all])" apt install foobar -s -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::Marker=1 -o Debug::pkgDepCache::AutoInstall=1
+
+# Same solution but the installs are considered protected now as there is no other solution
+testsuccessequal "Reading package lists...
+Building dependency tree...
+ MarkInstall foobar:amd64 < none -> 1 @un puN Ib > FU=1
+ Installing foo:amd64 as Depends of foobar:amd64
+ Removing: stuff:amd64 as upgrade is not an option for foo:amd64 (1)
+ MarkDelete stuff:amd64 < 1 @ii mK > FU=0
+ MarkInstall foo:amd64 < none -> 1 @un puN Ib > FU=0
+ Installing foo-dep:amd64 as Depends of foo:amd64
+ MarkInstall foo-dep:amd64 < none -> 1 @un puN > FU=0
+ MarkInstall uninstallable:amd64 < 1 @ii pmK > FU=0
+Starting pkgProblemResolver with broken count: 0
+Starting 2 pkgProblemResolver with broken count: 0
+Done
+ Ignore MarkGarbage of foo:amd64 < none -> 1 @un puN > as its mode (Install) is protected
+ Ignore MarkGarbage of foo:amd64 < none -> 1 @un puN > as its mode (Install) is protected
+Package 'bar' is not installed, so not removed
+The following additional packages will be installed:
+ foo foo-dep
+The following packages will be REMOVED:
+ stuff
+The following NEW packages will be installed:
+ foo foo-dep foobar
+ MarkDelete stuff:amd64 < 1 | none @ii H > FU=1
+0 upgraded, 3 newly installed, 1 to remove and 0 not upgraded.
+Remv stuff [1]
+Inst foo-dep (1 unstable [all])
+Inst foo (1 unstable [all])
+Inst foobar (1 unstable [all])
+Conf foo-dep (1 unstable [all])
+Conf foo (1 unstable [all])
+Conf foobar (1 unstable [all])" apt install foobar bar- -q=0 -s -o Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::Marker=1 -o Debug::pkgDepCache::AutoInstall=1