Browse Source

Pass --abort-after=1 to dpkg when using --force-depends

Using --force-depends causes dpkg to continue removing packages
a package depends upon even if that package fails to be removed,
because dpkg turns off all sanity checks. So we gotta tell dpkg
to stop immediately if there's an error removing stuff.

Closes: #935910
LP: #1844634
(cherry picked from commit 8a54113d45)
tags/debian/1.8.4
Julian Andres Klode 1 year ago
parent
commit
cfc6870e9b
2 changed files with 30 additions and 0 deletions
  1. +1
    -0
      apt-pkg/deb/dpkgpm.cc
  2. +29
    -0
      test/integration/test-apt-get-remove-depends

+ 1
- 0
apt-pkg/deb/dpkgpm.cc View File

@@ -1790,6 +1790,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
case Item::Remove:
case Item::Purge:
ADDARGC("--force-depends");
ADDARGC("--abort-after=1");
if (std::any_of(I, J, ItemIsEssential))
{
ADDARGC("--force-remove-essential");


+ 29
- 0
test/integration/test-apt-get-remove-depends View File

@@ -0,0 +1,29 @@
#!/bin/sh
set -e

TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"
setupenvironment
configarchitecture 'i386'

buildsimplenativepackage 'alpha' 'all' '1' 'unstable' 'Depends: beta'
buildsimplenativepackage 'beta' 'all' '1' 'unstable'
setupaptarchive

testsuccess aptget install alpha -y

cat > rootdir/var/lib/dpkg/info/alpha.prerm << EOF
#!/bin/sh
exit 42
EOF
chmod 755 rootdir/var/lib/dpkg/info/alpha.prerm


testdpkginstalled 'alpha' 'beta'


testfailure aptget remove -y beta

# Beta should not be removed because alpha failed to be removed and depends on it

testdpkginstalled 'alpha' 'beta'

Loading…
Cancel
Save