summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/debsystem.cc
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/debsystem.cc
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/debsystem.cc')
-rw-r--r--apt-pkg/deb/debsystem.cc11
1 files changed, 10 insertions, 1 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() /*{{{*/