upgrades: Check for held freedombox package daily

Guard against removing a hold while the package manager is busy.

Test:
1. Place hold on freedombox package.
2. Wait 3 minutes in development mode.
   - Package is held.
3. Touch /var/lib/freedombox/package-held.
4. Wait 3 minutes in development mode.
   - Package is not held.
   - Flag is removed.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
James Valleroy committed 2021-07-15 20:15:47 -04:00
1 parent 912d9ec9e0
commit 39d411be5b
3 files changed
+26 -12

No files matched your search

+12
View File
@@ -460,3 +460,15 @@ def apt_unhold_freedombox():
subprocess.check_call(['apt-mark', 'unhold', 'freedombox'])
if apt_hold_flag.exists():
apt_hold_flag.unlink()
def is_package_manager_busy():
"""Return whether package manager is busy.
This command uses the `lsof` command to check whether the dpkg lock file
is open which indicates that the package manager is busy"""
LOCK_FILE = '/var/lib/dpkg/lock'
try:
subprocess.check_output(['lsof', LOCK_FILE])
return True
except subprocess.CalledProcessError:
return False