From 4b83bcfcee46b6adcb80fc7a9fb85d3af58fb741 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Wed, 20 Feb 2019 21:35:19 -0500 Subject: makepkg: implement locking for pacman commands When pacman is run as root to do -S, -U, or -R, it would immediately abort if pacman is not ready for use. Instead, poll the lockfile and wait until it becomes available. Implements FS#28840 Original-patch-by: Georges Dubus Signed-off-by: Eli Schwartz Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 5606f65b..4e7b2e6c 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -228,6 +228,15 @@ run_pacman() { else cmd=(su root -c "$(printf '%q ' "${cmd[@]}")") fi + local lockfile="$(pacman-conf DBPath)/db.lck" + while [[ -f $lockfile ]]; do + local timer=0 + msg "$(gettext "Pacman is currently in use, please wait...")" + while [[ -f $lockfile ]] && (( timer < 10 )); do + (( ++timer )) + sleep 3 + done + done fi "${cmd[@]}" } -- cgit v1.2.3-55-g3dc8