packagelib: Avoid running into locking issues with apt

In our CI packagekit holds a lock on /var/lib/apt/lists/lock while we
try to run apt-get clean. Make sure PackageKit is stopped before we
invoke any apt commands.

Only on Debian/Ubuntu is the package manager cache shared with
PackageKit on all other OSes PackageKit uses a separate cache directory.
This commit is contained in:
Jelle van der Waa 2026-10-13 11:05:46 +02:00 committed by Jelle van der Waa
parent a177b46792
commit 55e444a819

View file

@ -53,6 +53,9 @@ class PackageCase(MachineCase):
self.machine.execute("nmcli con add type dummy con-name fake ifname fake0 ip4 1.2.3.4/24 gw4 1.2.3.1")
self.addCleanup(self.machine.execute, "nmcli con delete fake")
# Stop Packagekit to not run into locking issues with apt
self.machine.execute("systemctl stop packagekit; systemctl reset-failed packagekit || true")
self.addCleanup(self.machine.execute, "systemctl stop packagekit; systemctl reset-failed packagekit || true")
# disable all existing repositories to avoid hitting the network