summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorBalint Reczey <balint@balintreczey.hu>2024-12-28 23:58:36 +0100
committerBalint Reczey <balint@balintreczey.hu>2024-12-30 13:15:44 +0100
commit8e6a86aa3bc6d5a9013bb42fccea9bbce3fd97e2 (patch)
treee1dd86ffac39c0c88134b2c5e9c2b0f38f793196 /apt-pkg/deb
parent073c266ced5ea4057d0da8c86e6f1b72fcaf4f1f (diff)
apt-pkg/deb/debsystem.cc: Fall back to "dpkg" when Dir::Bin::dpkg is not found
The custom dpkg binary may be removed by apt and that breaks the end of the operation. This can be observed when using eatmydata as dpkg and removing the symlink to eatmydata when removing the apt-eatmydata package.
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debsystem.cc11
-rw-r--r--apt-pkg/deb/dpkgpm.cc3
2 files changed, 11 insertions, 3 deletions
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 8533b1157..749969759 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -392,7 +392,16 @@ std::string debSystem::StripDpkgChrootDirectory(std::string const &File)/*{{{*/
/*}}}*/
std::string debSystem::GetDpkgExecutable() /*{{{*/
{
- return StripDpkgChrootDirectory(_config->Find("Dir::Bin::dpkg","dpkg"));
+ std::string dpkg_executable = _config->Find("Dir::Bin::dpkg","dpkg");
+ if (APT::String::Startswith(dpkg_executable, "/")) {
+ struct stat buf;
+ if (stat(dpkg_executable.c_str(), &buf) != 0) {
+ _error->Warning(_("The dpkg executable set in Dir::Bin::dpkg is "
+ "missing, falling back to using default dpkg."));
+ dpkg_executable = "dpkg";
+ }
+ }
+ return StripDpkgChrootDirectory(dpkg_executable);
}
/*}}}*/
std::vector<std::string> debSystem::GetDpkgBaseCommand() /*{{{*/
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 8cadd2712..49c6f24f7 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1773,7 +1773,6 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
// this loop is runs once per dpkg operation
vector<Item>::const_iterator I = List.cbegin();
- BuildDpkgCall Args;
while (I != List.end())
{
// Do all actions with the same Op in one run
@@ -1795,7 +1794,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
else
J = std::find_if(J, List.cend(), [&J](Item const &I) { return I.Op != J->Op; });
- Args.clearCallArguments();
+ BuildDpkgCall Args;
Args.reserve((J - I) + 10);
int fd[2];