summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2021-11-17 17:22:00 +0000
committerJulian Andres Klode <jak@debian.org>2021-11-17 17:22:00 +0000
commit16706bbae1a1168bd327ce1587b63d9353bab144 (patch)
tree11b77ce7cf551b65e3fe3fcedadc71e1e7f49781
parent68a6dffed6ad5e5dc4ac01319b31843951d0eb21 (diff)
parent891efe3b201a104445ea723a3a5b9b434a78c364 (diff)
Merge branch 'pu/essential-removal' into 'main'
Do not remove Essential/Protected due to dependencies See merge request apt-team/apt!198
-rw-r--r--apt-pkg/depcache.cc18
-rw-r--r--doc/examples/configure-index1
-rwxr-xr-xtest/integration/test-bug-601961-install-info14
-rwxr-xr-xtest/integration/test-bug-675449-essential-are-protected14
-rwxr-xr-xtest/integration/test-bug-960705-propagate-protected-to-satisfied-conflict2
5 files changed, 46 insertions, 3 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 460fb296e..7c19fd7ca 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -930,6 +930,24 @@ static bool IsModeChangeOk(pkgDepCache &Cache, pkgDepCache::ModeList const mode,
<< " of " << APT::PrettyPkg(&Cache, Pkg) << std::endl;
return false;
}
+ // Do not allow removals of essential packages not explicitly triggered by the user
+ else if (mode == pkgDepCache::ModeDelete && (Pkg->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential &&
+ not _config->FindB("APT::Get::Allow-Solver-Remove-Essential", false))
+ {
+ if (unlikely(DebugMarker == true))
+ std::clog << OutputInDepth(Depth) << "Essential prevents Mark" << PrintMode(mode)
+ << " of " << APT::PrettyPkg(&Cache, Pkg) << std::endl;
+ return false;
+ }
+ // Do not allow removals of essential packages not explicitly triggered by the user
+ else if (mode == pkgDepCache::ModeDelete && (Pkg->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important &&
+ not _config->FindB("APT::Get::Allow-Solver-Remove-Essential", false))
+ {
+ if (unlikely(DebugMarker == true))
+ std::clog << OutputInDepth(Depth) << "Protected prevents Mark" << PrintMode(mode)
+ << " of " << APT::PrettyPkg(&Cache, Pkg) << std::endl;
+ return false;
+ }
return true;
}
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index f05981045..ce51153c3 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -74,6 +74,7 @@ APT
Allow-Downgrades "<BOOL>";
Allow-Change-Held-Packages "<BOOL>";
Allow-Remove-Essential "<BOOL>";
+ Allow-Solver-Remove-Essential "<BOOL>";
Assume-Yes "<BOOL>"; // not as dangerous, but use with care still
Assume-No "<BOOL>";
Trivial-Only "<BOOL>";
diff --git a/test/integration/test-bug-601961-install-info b/test/integration/test-bug-601961-install-info
index 10944384a..3e135606d 100755
--- a/test/integration/test-bug-601961-install-info
+++ b/test/integration/test-bug-601961-install-info
@@ -35,4 +35,16 @@ This should NOT be done unless you know exactly what you are doing!
findutils essentialpkg (due to findutils)
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 2007 kB disk space will be freed.
-E: Trivial Only specified but this is not a trivial operation.' aptget remove essentialpkg --trivial-only
+E: Trivial Only specified but this is not a trivial operation.' aptget remove essentialpkg findutils --trivial-only
+
+testfailureequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ findutils : Depends: essentialpkg but it is not going to be installed
+E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.' aptget remove essentialpkg --trivial-only
diff --git a/test/integration/test-bug-675449-essential-are-protected b/test/integration/test-bug-675449-essential-are-protected
index 69f6c2a3b..e7460aeb7 100755
--- a/test/integration/test-bug-675449-essential-are-protected
+++ b/test/integration/test-bug-675449-essential-are-protected
@@ -100,4 +100,16 @@ This should NOT be done unless you know exactly what you are doing!
foo libfoo (due to foo)
0 upgraded, 0 newly installed, 2 to remove and 4 not upgraded.
Purg foo [1]
-Purg libfoo [1]' aptget purge libfoo -s
+Purg libfoo [1]' aptget purge foo libfoo -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo : Depends: libfoo but it is not going to be installed
+E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.' aptget purge libfoo -s
diff --git a/test/integration/test-bug-960705-propagate-protected-to-satisfied-conflict b/test/integration/test-bug-960705-propagate-protected-to-satisfied-conflict
index 824851278..c16a27569 100755
--- a/test/integration/test-bug-960705-propagate-protected-to-satisfied-conflict
+++ b/test/integration/test-bug-960705-propagate-protected-to-satisfied-conflict
@@ -50,4 +50,4 @@ Remv init [1]
MarkDelete systemd-sysv:amd64 < 1 | none @ii H > FU=1
Remv systemd-sysv [1]
Inst runit-init (1 unstable [all])
-Conf runit-init (1 unstable [all])" apt install runit-init -so Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::Marker=1 -o Debug::pkgDepCache::AutoInstall=1
+Conf runit-init (1 unstable [all])" apt install runit-init -so Debug::pkgProblemResolver=1 -o Debug::pkgDepCache::Marker=1 -o Debug::pkgDepCache::AutoInstall=1 -o APT::Get::Allow-Solver-Remove-Essential=1