summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc11
-rw-r--r--apt-pkg/deb/debsystem.cc9
-rw-r--r--apt-pkg/deb/debsystem.h1
-rw-r--r--apt-pkg/deb/dpkgpm.cc14
4 files changed, 28 insertions, 7 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index ab957a01a..240946529 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -318,6 +318,8 @@ bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
return false;
if (Section.FindFlag(pkgTagSection::Key::Important,Pkg->Flags,pkgCache::Flag::Important) == false)
return false;
+ if (Section.FindFlag(pkgTagSection::Key::Protected, Pkg->Flags, pkgCache::Flag::Important) == false)
+ return false;
if (std::find(forceEssential.begin(), forceEssential.end(), Pkg.Name()) != forceEssential.end())
{
@@ -1018,12 +1020,11 @@ debDebFileParser::debDebFileParser(FileFd *File, std::string const &DebFile)
bool debDebFileParser::UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver)
{
- bool res = debListParser::UsePackage(Pkg, Ver);
- // we use the full file path as a provides so that the file is found
- // by its name
- if(NewProvides(Ver, DebFile, Pkg.Cache()->NativeArch(), Ver.VerStr(), 0) == false)
+ if (not debListParser::UsePackage(Pkg, Ver))
return false;
- return res;
+ // we use the full file path as a provides so that the file is found by its name
+ // using the MultiArchImplicit flag for this is a bit of a stretch
+ return NewProvides(Ver, DebFile, Pkg.Cache()->NativeArch(), Ver.VerStr(), pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific);
}
debListParser::~debListParser() {}
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 6904879b6..eac43c3b7 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -270,7 +270,7 @@ static std::string getDpkgStatusLocation(Configuration const &Cnf) {
Configuration PathCnf;
PathCnf.Set("Dir", Cnf.Find("Dir", "/"));
PathCnf.Set("Dir::State::status", "status");
- auto const cnfstatedir = Cnf.Find("Dir::State", STATE_DIR + 1);
+ auto const cnfstatedir = Cnf.Find("Dir::State", &STATE_DIR[1]);
// if the state dir ends in apt, replace it with dpkg -
// for the default this gives us the same as the fallback below.
// This can't be a ../dpkg as that would play bad with symlinks
@@ -466,8 +466,13 @@ pid_t debSystem::ExecDpkg(std::vector<std::string> const &sArgs, int * const inp
/*}}}*/
bool debSystem::MultiArchSupported() const /*{{{*/
{
+ return AssertFeature("multi-arch");
+}
+ /*}}}*/
+bool debSystem::AssertFeature(std::string const &feature) /*{{{*/
+{
std::vector<std::string> Args = GetDpkgBaseCommand();
- Args.push_back("--assert-multi-arch");
+ Args.push_back("--assert-" + feature);
pid_t const dpkgAssertMultiArch = ExecDpkg(Args, nullptr, nullptr, true);
if (dpkgAssertMultiArch > 0)
{
diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h
index 2e5a8550c..b3d241512 100644
--- a/apt-pkg/deb/debsystem.h
+++ b/apt-pkg/deb/debsystem.h
@@ -45,6 +45,7 @@ class debSystem : public pkgSystem
APT_HIDDEN static void DpkgChrootDirectory();
APT_HIDDEN static pid_t ExecDpkg(std::vector<std::string> const &sArgs, int * const inputFd, int * const outputFd, bool const DiscardOutput);
bool MultiArchSupported() const override;
+ static bool AssertFeature(std::string const &Feature);
std::vector<std::string> ArchitecturesSupported() const override;
bool LockInner(OpProgress *const Progress, int timeoutSec) override;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index ef73881c8..c496538cc 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1416,6 +1416,15 @@ static bool ItemIsEssential(pkgDPkgPM::Item const &I)
return true;
return (I.Pkg->Flags & pkgCache::Flag::Essential) != 0;
}
+static bool ItemIsProtected(pkgDPkgPM::Item const &I)
+{
+ static auto const cachegen = _config->Find("pkgCacheGen::Protected");
+ if (cachegen == "none" || cachegen == "native")
+ return true;
+ if (unlikely(I.Pkg.end()))
+ return true;
+ return (I.Pkg->Flags & pkgCache::Flag::Important) != 0;
+}
bool pkgDPkgPM::ExpandPendingCalls(std::vector<Item> &List, pkgDepCache &Cache)
{
{
@@ -1712,6 +1721,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
OpenLog();
bool dpkgMultiArch = _system->MultiArchSupported();
+ bool dpkgProtectedField = debSystem::AssertFeature("protected-field");
// start pty magic before the loop
StartPtyMagic();
@@ -1780,6 +1790,10 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
{
ADDARGC("--force-remove-essential");
}
+ if (dpkgProtectedField && std::any_of(I, J, ItemIsProtected))
+ {
+ ADDARGC("--force-remove-protected");
+ }
ADDARGC("--remove");
break;