Browse Source

do dpkg --configure before --remove/--purge --pending

Commit 7ec343309b got us most of the way,
but the last mile was botched by having the pending calls in the wrong
order as this way we potentially 'force' dpkg to remove/purge a package
it doesn't want to as another package still depends on it and the
replacement isn't fully installed yet.

So what we do now is a configure before remove and purge (all with
--no-triggers) and finishing off with another configure pending call to
take care of the triggers.

Note that in the bugreport example our current planner is forcing dpkg
to remove the package earlier via --force-depends which we could do for
the pending calls as well and could be used as a workaround, but we want
to do less forcing eventually.

Closes: 835094
tags/debian/1.3_rc3
David Kalnischkies 4 years ago
parent
commit
fb51ce3295
3 changed files with 52 additions and 3 deletions
  1. +7
    -3
      apt-pkg/deb/dpkgpm.cc
  2. +44
    -0
      test/integration/test-bug-835094-configure-before-purge
  3. +1
    -0
      test/integration/test-no-fds-leaked-to-maintainer-scripts

+ 7
- 3
apt-pkg/deb/dpkgpm.cc View File

@@ -1535,9 +1535,13 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
if (I.Op == Item::Remove || I.Op == Item::Purge)
toBeRemoved[I.Pkg->ID] = false;

if (std::find(toBeRemoved.begin(), toBeRemoved.end(), true) != toBeRemoved.end())
bool const RemovePending = std::find(toBeRemoved.begin(), toBeRemoved.end(), true) != toBeRemoved.end();
bool const PurgePending = approvedStates.Purge().empty() == false;
if (RemovePending != false || PurgePending != false)
List.emplace_back(Item::ConfigurePending, pkgCache::PkgIterator());
if (RemovePending)
List.emplace_back(Item::RemovePending, pkgCache::PkgIterator());
if (approvedStates.Purge().empty() == false)
if (PurgePending)
List.emplace_back(Item::PurgePending, pkgCache::PkgIterator());

// support subpressing of triggers processing for special
@@ -1606,7 +1610,7 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
unsigned long const Op = I->Op;

if (NoTriggers == true && I->Op != Item::TriggersPending &&
I->Op != Item::ConfigurePending)
(I->Op != Item::ConfigurePending || std::next(I) != List.end()))
{
ADDARGC("--no-triggers");
}


+ 44
- 0
test/integration/test-bug-835094-configure-before-purge View File

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

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

buildsimplenativepackage 'kernel' 'amd64' '1' 'unstable' 'Depends: initramfs-tools | linux-initramfs-tool'

#buildsimplenativepackage 'initramfs-tools' 'amd64' '1.0.16' 'unstable' 'Provides: linux-initramfs-tool'
setupsimplenativepackage 'initramfs-tools' 'amd64' '1' 'unstable' 'Provides: linux-initramfs-tool'
BUILDDIR='incoming/initramfs-tools-1'
mkdir -p "${BUILDDIR}/debian/initramfs-tools/etc"
echo 'foo2=bar2;' > "${BUILDDIR}/init.conf"
echo 'init.conf /etc/init.conf' >> "${BUILDDIR}/debian/install"
buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
rm -rf "$BUILDDIR"

buildsimplenativepackage 'dracut' 'amd64' '1' 'unstable' 'Provides: linux-initramfs-tool
Conflicts: initramfs-tools'

setupaptarchive

testdpkgnotinstalled 'kernel' 'initramfs-tools' 'dracut'
testsuccess apt install kernel -y
testdpkginstalled 'kernel' 'initramfs-tools'
testsuccess test -s rootdir/etc/init.conf
testsuccessequal 'Reading package lists...
Building dependency tree...
Reading state information...
The following packages will be REMOVED:
initramfs-tools*
The following NEW packages will be installed:
dracut
0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
Purg initramfs-tools [1] [kernel:amd64 ]
Inst dracut (1 unstable [amd64])
Conf dracut (1 unstable [amd64])' apt install --purge dracut -s
testsuccess apt install --purge dracut -y -o Debug::pkgDpkgPm=1 -o Dpkg::Use-Pty=0
testsuccess apt install --purge dracut -y
testdpkginstalled 'kernel' 'dracut'
testdpkgnotinstalled 'initramfs-tools'
testsuccess test ! -s rootdir/etc/init.conf

+ 1
- 0
test/integration/test-no-fds-leaked-to-maintainer-scripts View File

@@ -79,6 +79,7 @@ status half-configured $PKGNAME 1.0
status half-installed $PKGNAME 1.0
status config-files $PKGNAME 1.0
status config-files $PKGNAME 1.0
startup packages configure
startup packages purge
remove $PKGNAME 1.0 <none>
purge $PKGNAME 1.0 <none>


Loading…
Cancel
Save