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 <georges.dubus@compiletoi.net> Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
477a66cd0e
commit
4b83bcfcee
1 changed files with 9 additions and 0 deletions
|
@ -228,6 +228,15 @@ run_pacman() {
|
||||||
else
|
else
|
||||||
cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
|
cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
|
||||||
fi
|
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
|
fi
|
||||||
"${cmd[@]}"
|
"${cmd[@]}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue