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 <[email protected]>
Signed-off-by: Eli Schwartz <[email protected]>
---
 scripts/makepkg.sh.in | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index cf30c302..25700b09 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -228,6 +228,14 @@ run_pacman() {
                else
                        cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
                fi
+
+               local lockfile="$(pacman-conf DBPath)/db.lck"
+               if [[ -f $lockfile ]]; then
+                       msg "$(gettext "Pacman is currently in use, please 
wait...")"
+                       while [[ -f $lockfile ]]; do
+                               sleep 3
+                       done
+               fi
        fi
        "${cmd[@]}"
 }
-- 
2.20.1

Reply via email to