From 8e6a86aa3bc6d5a9013bb42fccea9bbce3fd97e2 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Sat, 28 Dec 2024 23:58:36 +0100 Subject: 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. --- apt-pkg/deb/debsystem.cc | 11 ++++++++++- apt-pkg/deb/dpkgpm.cc | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'apt-pkg/deb') 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 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::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]; -- cgit v1.2.3-70-g09d2