[pacman-dev] [PATCH] Adds a --nowait option
Daniel Radetsky
dradetsky at gmail.com
Fri Feb 12 17:21:14 UTC 2021
Apologies if gmail ruins this. I'm used to github prs & don't have time to
setup mutt at the moment.
If pacman is in use, makepkg -si will wait until it is available. This
can be undesirable if you aren't running makepkg -si in the normal
interactive way. For example, if you're running it from ansible (so
shell output is supressed), and you also have a pacman -Syuw running in
another terminal which you forgot to confirm, it will hang forever and
you won't know why.
More generally, if you're running it in any kind of non-interactive
environment, you may want it to fail fast instead of waiting for some
other condition to resolve.
This is kind of a work-in-progress. I'm not totally sure what to do with
the .po files (do I manually fix all the line number comments? God, I
hope not). And maybe --nowait is a bad name; I'd have gone with a longer
name normally like --no-wait-for-pacman, since I don't expect this to be
something a user is typing a lot in a terminal, but writing and
copypasta-ing in a script. But I also didn't want to buck the
conventions. Whatever, I can change it.
Signed-off-by: Daniel Radetsky <dradetsky at gmail.com>
---
scripts/makepkg.sh.in | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index b39433f3..a1a450dd 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -67,6 +67,7 @@ NOARCHIVE=0
NOBUILD=0
NODEPS=0
NOEXTRACT=0
+NOWAIT=0
PKGFUNC=0
PKGVERFUNC=0
PREPAREFUNC=0
@@ -236,6 +237,10 @@ run_pacman() {
cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
fi
local lockfile="$(pacman-conf DBPath)/db.lck"
+ if (( NOWAIT )) && [[ -f $lockfile ]]; then
+ msg "$(gettext "Pacman is currently in use, exiting")"
+ exit $E_FAIL
+ fi
while [[ -f $lockfile ]]; do
local timer=0
msg "$(gettext "Pacman is currently in use, please wait...")"
@@ -984,6 +989,7 @@ usage() {
printf -- "$(gettext " --nocheck Do not run the %s function in
the %s")\n" "check()" "$BUILDSCRIPT"
printf -- "$(gettext " --noprepare Do not run the %s function in
the %s")\n" "prepare()" "$BUILDSCRIPT"
printf -- "$(gettext " --nosign Do not create a signature for
the package")\n"
+ printf -- "$(gettext " --nowait Exit immediately if pacman is in
use")\n"
printf -- "$(gettext " --packagelist Only list package filepaths that
would be produced")\n"
printf -- "$(gettext " --printsrcinfo Print the generated SRCINFO and
exit")\n"
printf -- "$(gettext " --sign Sign the resulting package with
%s")\n" "gpg"
@@ -1030,10 +1036,11 @@ ARGLIST=("$@")
# Parse Command Line Options.
OPT_SHORT="AcCdefFghiLmop:rRsSV"
OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'force'
'geninteg'
- 'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive'
'nobuild'
- 'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign'
'packagelist'
- 'printsrcinfo' 'repackage' 'rmdeps' 'sign' 'skipchecksums'
'skipinteg'
- 'skippgpcheck' 'source' 'syncdeps' 'verifysource' 'version')
+ 'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive'
+ 'nobuild' 'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare'
+ 'nosign' 'nowait' 'packagelist' 'printsrcinfo' 'repackage'
'rmdeps'
+ 'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source'
'syncdeps'
+ 'verifysource' 'version')
# Pacman Options
OPT_LONG+=('asdeps' 'noconfirm' 'needed' 'noprogressbar')
@@ -1074,6 +1081,7 @@ while true; do
--nocheck) RUN_CHECK='n' ;;
--noprepare) RUN_PREPARE='n' ;;
--nosign) SIGNPKG='n' ;;
+ --nowait) NOWAIT=1 ;;
-o|--nobuild) BUILDPKG=0 NOBUILD=1 ;;
-p) shift; BUILDFILE=$1 ;;
--packagelist) BUILDPKG=0 PACKAGELIST=1 IGNOREARCH=1;;
--
2.30.0
More information about the pacman-dev
mailing list