action_utils: Fix missing parent folder when creating apt hold flag

- When freedombox is installed on a Debian system as a package, the folder
/var/lib/freedombox does not exist. When the service is run and systemd-resolved
is attempted to be installed, we try to hold the freedombox package. We also set
a flag to indicate this in /var/lib/freedombox. Since the folder does not exist,
it fails. Presumably this will also fail when installing any package. Fix this
by creating the parent directory.

Tests:

- On a fresh Debian system, install the freedombox package with these changes.
Wait for setup to run on names app. Install operation fails without this fix and
succeed with the fix (this only happens when names app is setup before backups
app as backups app creates /var/lib/freedombox directory).

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2024-10-04 10:03:03 -07:00 committed by Veiko Aasa
parent db92640f3c
commit afb69c28d1
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -475,6 +475,7 @@ def apt_hold_freedombox():
yield current_hold
else:
# Set the flag.
apt_hold_flag.parent.mkdir(mode=0o755, parents=True, exist_ok=True)
apt_hold_flag.touch(mode=0o660)
yield subprocess.check_call(['apt-mark', 'hold', 'freedombox'])
finally: