From 0d51cf142884801c903df0cddaec5545f0174553 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 1 Mar 2021 21:43:03 +0100 Subject: regression fix: do require force-loopbreak for Conflicts Conflicts do require removing the package temporarily, so they really should not be used. We need to improve that eventually such that we can deconfigure packages when we have to remove their dependencies due to conflicts. --- apt-pkg/packagemanager.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index ad7612bc3..1a2850a2a 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -654,6 +654,9 @@ bool pkgPackageManager::EarlyRemove(PkgIterator Pkg, DepIterator const * const D bool IsEssential = false; if ((Pkg->Flags & pkgCache::Flag::Essential) != 0) IsEssential = true; + bool IsProtected = false; + if ((Pkg->Flags & pkgCache::Flag::Important) != 0) + IsProtected = true; /* Check for packages that are the dependents of essential packages and promote them too */ @@ -661,13 +664,17 @@ bool pkgPackageManager::EarlyRemove(PkgIterator Pkg, DepIterator const * const D { for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false && IsEssential == false; ++D) - if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) + if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) { if ((D.ParentPkg()->Flags & pkgCache::Flag::Essential) != 0) IsEssential = true; + if ((D.ParentPkg()->Flags & pkgCache::Flag::Important) != 0) + IsProtected = true; + } } if (IsEssential == true) { + // FIXME: Unify messaging with Protected below. if (_config->FindB("APT::Force-LoopBreak",false) == false) return _error->Error(_("This installation run will require temporarily " "removing the essential package %s due to a " @@ -678,6 +685,16 @@ bool pkgPackageManager::EarlyRemove(PkgIterator Pkg, DepIterator const * const D // dpkg will auto-deconfigure it, no need for the big remove hammer else if (Dep != NULL && (*Dep)->Type == pkgCache::Dep::DpkgBreaks) return true; + else if (IsProtected == true) + { + // FIXME: Message should talk about Protected, not Essential, and unified. + if (_config->FindB("APT::Force-LoopBreak",false) == false) + return _error->Error(_("This installation run will require temporarily " + "removing the essential package %s due to a " + "Conflicts/Pre-Depends loop. This is often bad, " + "but if you really want to do it, activate the " + "APT::Force-LoopBreak option."),Pkg.FullName().c_str()); + } bool Res = SmartRemove(Pkg); if (Cache[Pkg].Delete() == false) -- cgit v1.2.3-70-g09d2