From 91d590c01521449cce67c7eb8876c9e317aeebe8 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Mon, 25 Nov 2019 23:39:44 -0500 Subject: [pacman-dev] [PATCH] makepkg: implement --question, like in make This returns 0 if the package is fully built, or else returns failure. Implements FS#18709 Signed-off-by: Eli Schwartz --- scripts/makepkg.sh.in | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index b1fa96f7..2dcc45c5 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -70,6 +70,7 @@ NOEXTRACT=0 PKGFUNC=0 PKGVERFUNC=0 PREPAREFUNC=0 +QUESTION=0 REPKG=0 REPRODUCIBLE=0 RMDEPS=0 @@ -870,7 +871,9 @@ check_build_status() { pkgarch=$(get_pkg_arch) if [[ -f $PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT} ]] \ && ! (( FORCE || SOURCEONLY || NOBUILD || NOARCHIVE)); then - if (( INSTALL )); then + if (( QUESTION )); then + exit 0 + elif (( INSTALL )); then warning "$(gettext "A package has already been built, installing existing package...")" install_package exit $? @@ -893,7 +896,9 @@ check_build_status() { done if ! (( FORCE || SOURCEONLY || NOBUILD || NOARCHIVE)); then if (( allpkgbuilt )); then - if (( INSTALL )); then + if (( QUESTION )); then + exit 0 + elif (( INSTALL )); then warning "$(gettext "The package group has already been built, installing existing packages...")" install_package exit $? @@ -902,13 +907,17 @@ check_build_status() { exit $E_ALREADY_BUILT fi fi - if (( somepkgbuilt && ! PKGVERFUNC )); then + if (( somepkgbuilt && ! QUESTION && ! PKGVERFUNC )); then error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f" exit $E_ALREADY_BUILT fi fi unset allpkgbuilt somepkgbuilt fi + if (( QUESTION )); then + # not all packages were built, or we would exit above + exit 1 + fi } backup_package_variables() { @@ -964,6 +973,7 @@ usage() { printf -- "$(gettext " -m, --nocolor Disable colorized output messages")\n" printf -- "$(gettext " -o, --nobuild Download and extract files only")\n" printf -- "$(gettext " -p Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT" + printf -- "$(gettext " -q, --question Do nothing; exit status says if package has already been built")" printf -- "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")\n" printf -- "$(gettext " -R, --repackage Repackage contents of the package without rebuilding")\n" printf -- "$(gettext " -s, --syncdeps Install missing dependencies with %s")\n" "pacman" @@ -1022,11 +1032,11 @@ fi ARGLIST=("$@") # Parse Command Line Options. -OPT_SHORT="AcCdefFghiLmop:rRsSV" +OPT_SHORT="AcCdefFghiLmop:qrRsSV" 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' + 'printsrcinfo' 'question' 'repackage' 'rmdeps' 'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source' 'syncdeps' 'verifysource' 'version') # Pacman Options @@ -1072,6 +1082,7 @@ while true; do -p) shift; BUILDFILE=$1 ;; --packagelist) BUILDPKG=0 PACKAGELIST=1 ;; --printsrcinfo) BUILDPKG=0 PRINTSRCINFO=1 IGNOREARCH=1;; + -q|--question) QUESTION=1 ;; -r|--rmdeps) RMDEPS=1 ;; -R|--repackage) REPKG=1 ;; --sign) SIGNPKG='y' ;; @@ -1304,7 +1315,7 @@ if (( PRINTSRCINFO )); then exit $E_OK fi -if (( ! PKGVERFUNC )); then +if (( QUESTION || ! PKGVERFUNC )); then check_build_status fi -- 2.24.0