I would like to do something like this:
- Ask user which packages to remove interactively
- Remove the requested packages
And I want to keep the package system intact while getting the user input.
It is different thing to wait while some other program is changing something in the package management system than to prevent some other program from starting to mess with the package management system while my program is deciding what to do with the package management system and while doing the decided actions.
See a related bug report and comments there.
Currently there are at least two lock files used for locking the dpkg system: '/var/lib/dpkg/lock' and '/var/lib/dpkg/lock-frontend'. I try to lock using the former file by starting the following script as superuser:
#!/bin/bash
exec {var}>/var/lib/dpkg/lock
flock -n $var || { echo was locked already; exit 1; }
read -p 'Now the lock should be active. Press enter to release.'
exit
But I can still use e.g. sudo apt install
, so apt
does not think the file is locked.
/usr/bin/synaptic-pkexec
or by GUI menu. – jarno Dec 19 '19 at 21:19