Files
pmaports-rtwo/extra-repos/systemd/postmarketos-base-systemd/rootfs-usr-libexec-apk-inhibit
T
Clayton Craft 594e361a71 systemd/postmarketos-base-systemd: inhibit sleep when apk is running
This uses some lightweight tools with systemd-inhibit to block sleep and
shutdown when apk is running. This is being installed in a new subpkg
that is pulled in only when apk-tools is installed, so that this is not
installed on duranium.

Signed-off-by: Clayton Craft <craftyguy@postmarketos.org>
Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/8672>
2026-07-19 19:51:53 +00:00

15 lines
512 B
Bash

#!/bin/sh
while true; do
# wait for something to open apk's lock file
inotifywait -q -e open /usr/lib/apk/db/lock
# Take an inhibitor lock and make it conditional on flock, which is trying
# to lock apk's lock file. flock will block until it can take a lock (i.e.
# if apk is doing operations), so the inhibitor lock is held until apk is
# done.
systemd-inhibit --what=sleep --who=apk \
--why="Package transaction in progress" \
flock /usr/lib/apk/db/lock true
done