From patchwork Wed Oct 23 06:13:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Schwartz X-Patchwork-Id: 1292 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 80BFF149A1503 for ; Wed, 23 Oct 2019 06:14:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1, MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Wed, 23 Oct 2019 06:14:26 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 67AD91609AECEC; Wed, 23 Oct 2019 06:14:25 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Wed, 23 Oct 2019 06:14:25 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 5850F2CF59; Wed, 23 Oct 2019 06:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1571811265; bh=jsgXPXw1s/UPFYTLz5l0hYBVlLU98d2zwdTcZhrHCeE=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=nvgHKt/YnOiOyIaOAUofDjQG+SnCLiaspjwnZhl0TsXni0yXsVD/myj7nrl5dfNet 8YMfKySt4D2g/1ke8T8/2zNFAbPaC/qx4AMy2srnUt0dmhPtrQCj4M0TeF52VOT6RK pXnJCziR/FqcRywchcnGcT9/l3Vn79kh7STwxcf62JFnU66rzNSCbCAC8WtjVW02Ki JNpxqDy9M8qoonDYAkki9JdkALJBi+QkEt74IyFb7RvVM6ponZMtMC/W0sBs8hmdIM dNbn8jGcQNSvKHBhM7kbpxBMxKJ3zfmgams32WyOTvgD/lhcgcfGdxmg3gS/xkkBJv 6H/w8XJOV9JBlXf9zIIdtwR2qKXGNS02yqvZlq5iguE8vwOn5GhSYbDbxpiqFwkw+j dWgf3Ngp9SBS7rWb3fHTXa82CinMGZ0KQaB/lyDP7LsGo/1TG4xbDf6aBGLKpG3/0u jL4teNP7K8Ann4fHG2UZvSrN/TlziieGTthCFOMbFiPIscS82ejwiNJDMErVQS7MBh icsUlM2WDEZ2S+qu7bJEwNn4aLfEgC7dg5yZpMR0F+6Qo1RfbvfNTS8hCWgwU9C0AX uZlTQkr08izVY0kCDA3+QahBzomZLQB1xCLYNaySQW8Zsle01eurdrIuvArRYqyF3P qZL5cr00XCO7sX2KSsVGn568= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 1B2982CF59 for ; Wed, 23 Oct 2019 06:14:21 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Wed, 23 Oct 2019 06:14:21 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id D05091609AECD7; Wed, 23 Oct 2019 06:14:16 +0000 (UTC) Received: from didactylos.attlocal.net (unknown [IPv6:2600:1700:57f0:ca20:763a:c795:fcf6:91ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: eschwartz) by orion.archlinux.org (Postfix) with ESMTPSA id 0413A1609AECD6; Wed, 23 Oct 2019 06:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1571811256; bh=jsgXPXw1s/UPFYTLz5l0hYBVlLU98d2zwdTcZhrHCeE=; h=From:To:Subject:Date; b=VOv17u8/culmjASaXZTXdtcfceicDkvd64hDrCqZknizKRdqfquLCJQOPN/GbUlV9 C0wT5+IrRK6L2xF9GFF3QlPcj3V6b7oxgxuuee+SBVddByMPDaG84HDk66QhoLdL9a 3qnS6E9MdDmbGU1zyk5WY8rORUEauRaaM+hKmN/FFwti2L10SC0M+ODhMQvcHgBBOs KCOat/Kx94vwqqb5Ef533Ny9Wbq/LyEa1f1OjH1UQXqszvc0bDIKDKLwDoV+1bmQRR 8zbcSo+S2AdlkPtZNc8bPP7O07Uww5vTbFWLjQVuH1/SAknsWTm9xOXflBqvLGOlig JpVwjaWDpI9JYkOa8n64vqMuewGxeTDuO/gRNeGPzeVyAnyGp0QGoZaZYgB3hnml+Q XrqkI4MnRv9A3NeR43LAwe8fuS3OqIoP7QMMdfjMAa2uSCY+RtNZANm+ktSniUUjfZ zb666Z1UR86dwubxA1Qxs6yFBA2LP/Rk+t2lVhMNNpOt9i6rtDc39jbillN+n+740T 44hdCyW7oAdyN1dDF9kJ3331uCLeTR+ZIbXOjzJL2gjNTsmo6XcM6dcmxPX3kzweOB lM3yeO5oYcGQoQ8OMGJqIN5dawMm+Xn5SBmI/oJisTcNyovkUuNHyFBFj76Xt3XHh3 Bzw+Zs6oiSjQwNnya6MdrKpI= From: Eli Schwartz To: pacman-contrib@lists.archlinux.org Subject: [pacman-contrib] [PATCH 1/4] Port to libmakepkg Date: Wed, 23 Oct 2019 02:13:56 -0400 Message-Id: <20191023061359.820902-1-eschwartz@archlinux.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" Replace m4 macros with use of libmakepkg extensions. Signed-off-by: Eli Schwartz --- configure.ac | 5 ++ lib/Makefile.am | 5 +- lib/output_format.sh | 32 ---------- lib/parseopts.sh | 137 ----------------------------------------- lib/term_colors.sh | 21 ------- src/Makefile.am | 9 +-- src/checkupdates.sh.in | 20 ++++-- src/paccache.sh.in | 14 ++++- src/pacdiff.sh.in | 12 +++- 9 files changed, 48 insertions(+), 207 deletions(-) delete mode 100644 lib/output_format.sh delete mode 100644 lib/parseopts.sh delete mode 100644 lib/term_colors.sh diff --git a/configure.ac b/configure.ac index ecb34db..82c16b3 100644 --- a/configure.ac +++ b/configure.ac @@ -65,6 +65,10 @@ PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 2.8.0], , PKG_CHECK_MODULES(LIBALPM, [libalpm], , AC_MSG_ERROR([*** libalpm is needed to build pacman-contrib!])) +PKG_CHECK_VAR(LIBMAKEPKGDIR, [libmakepkg], [libmakepkgdir], , + AC_MSG_ERROR([*** libmakepkg is needed to build pacman-contrib!])) +AC_SUBST(LIBMAKEPKGDIR) + # Enable or disable use of git version in version string AC_MSG_CHECKING(whether to use git version if available) if test "x$wantgitver" = "xyes" ; then @@ -173,6 +177,7 @@ ${PACKAGE_NAME}: localstatedir : $(eval echo ${localstatedir}) database dir : $(eval echo ${localstatedir})/lib/pacman/ cache dir : $(eval echo ${localstatedir})/cache/pacman/pkg/ + libmakepkg dir : $(eval echo ${LIBMAKEPKGDIR}) compiler : ${CC} compiler flags : ${WARNING_CFLAGS} ${CFLAGS} diff --git a/lib/Makefile.am b/lib/Makefile.am index 8b18cb5..c7a1385 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -3,9 +3,6 @@ SUBDIRS= DIST_SUBDIRS = $(SUBDIRS) EXTRA_DIST = \ - output_format.sh \ - parseopts.sh \ - size_to_human.sh \ - term_colors.sh + size_to_human.sh # vim:set noet: diff --git a/lib/output_format.sh b/lib/output_format.sh deleted file mode 100644 index 9f02c00..0000000 --- a/lib/output_format.sh +++ /dev/null @@ -1,32 +0,0 @@ -plain() { - (( QUIET )) && return - local mesg=$1; shift - printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 -} - -msg() { - (( QUIET )) && return - local mesg=$1; shift - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 -} - -msg2() { - (( QUIET )) && return - local mesg=$1; shift - printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 -} - -ask() { - local mesg=$1; shift - printf "${BLUE}::${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@" >&1 -} - -warning() { - local mesg=$1; shift - printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -error() { - local mesg=$1; shift - printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} diff --git a/lib/parseopts.sh b/lib/parseopts.sh deleted file mode 100644 index cf6aa6c..0000000 --- a/lib/parseopts.sh +++ /dev/null @@ -1,137 +0,0 @@ -# getopt-like parser -parseopts() { - local opt= optarg= i= shortopts=$1 - local -a longopts=() unused_argv=() - - shift - while [[ $1 && $1 != '--' ]]; do - longopts+=("$1") - shift - done - shift - - longoptmatch() { - local o longmatch=() - for o in "${longopts[@]}"; do - if [[ ${o%:} = "$1" ]]; then - longmatch=("$o") - break - fi - [[ ${o%:} = "$1"* ]] && longmatch+=("$o") - done - - case ${#longmatch[*]} in - 1) - # success, override with opt and return arg req (0 == none, 1 == required) - opt=${longmatch%:} - if [[ $longmatch = *: ]]; then - return 1 - else - return 0 - fi ;; - 0) - # fail, no match found - return 255 ;; - *) - # fail, ambiguous match - printf "@SCRIPTNAME@: $(gettext "option '%s' is ambiguous; possibilities:")" "--$1" - printf " '%s'" "${longmatch[@]%:}" - printf '\n' - return 254 ;; - esac >&2 - } - - while (( $# )); do - case $1 in - --) # explicit end of options - shift - break - ;; - -[!-]*) # short option - for (( i = 1; i < ${#1}; i++ )); do - opt=${1:i:1} - - # option doesn't exist - if [[ $shortopts != *$opt* ]]; then - printf "@SCRIPTNAME@: $(gettext "invalid option") -- '%s'\n" "$opt" >&2 - OPTRET=(--) - return 1 - fi - - OPTRET+=("-$opt") - # option requires optarg - if [[ $shortopts = *$opt:* ]]; then - # if we're not at the end of the option chunk, the rest is the optarg - if (( i < ${#1} - 1 )); then - OPTRET+=("${1:i+1}") - break - # if we're at the end, grab the the next positional, if it exists - elif (( i == ${#1} - 1 )) && [[ $2 ]]; then - OPTRET+=("$2") - shift - break - # parse failure - else - printf "@SCRIPTNAME@: $(gettext "option requires an argument") -- '%s'\n" "$opt" >&2 - OPTRET=(--) - return 1 - fi - fi - done - ;; - --?*=*|--?*) # long option - IFS='=' read -r opt optarg <<< "${1#--}" - longoptmatch "$opt" - case $? in - 0) - # parse failure - if [[ $optarg ]]; then - printf "@SCRIPTNAME@: $(gettext "option '%s' does not allow an argument")\n" "--$opt" >&2 - OPTRET=(--) - return 1 - # --longopt - else - OPTRET+=("--$opt") - fi - ;; - 1) - # --longopt=optarg - if [[ $optarg ]]; then - OPTRET+=("--$opt" "$optarg") - # --longopt optarg - elif [[ $2 ]]; then - OPTRET+=("--$opt" "$2" ) - shift - # parse failure - else - printf "@SCRIPTNAME@: $(gettext "option '%s' requires an argument")\n" "--$opt" >&2 - OPTRET=(--) - return 1 - fi - ;; - 254) - # ambiguous option -- error was reported for us by longoptmatch() - OPTRET=(--) - return 1 - ;; - 255) - # parse failure - printf "@SCRIPTNAME@: $(gettext "invalid option") '--%s'\n" "$opt" >&2 - OPTRET=(--) - return 1 - ;; - esac - ;; - *) # non-option arg encountered, add it as a parameter - unused_argv+=("$1") - ;; - esac - shift - done - - # add end-of-opt terminator and any leftover positional parameters - OPTRET+=('--' "${unused_argv[@]}" "$@") - unset longoptmatch - - return 0 -} diff --git a/lib/term_colors.sh b/lib/term_colors.sh deleted file mode 100644 index 87e95ee..0000000 --- a/lib/term_colors.sh +++ /dev/null @@ -1,21 +0,0 @@ -# check if messages are to be printed using color -unset ALL_OFF BOLD BLUE GREEN RED YELLOW -if [[ -t 2 && ! $USE_COLOR = "n" && ! $TERM = "dumb" ]]; then - # prefer terminal safe colored and bold text when tput is supported - if tput setaf 0 &>/dev/null; then - ALL_OFF="$(tput sgr0)" - BOLD="$(tput bold)" - BLUE="${BOLD}$(tput setaf 4)" - GREEN="${BOLD}$(tput setaf 2)" - RED="${BOLD}$(tput setaf 1)" - YELLOW="${BOLD}$(tput setaf 3)" - else - ALL_OFF="\e[1;0m" - BOLD="\e[1;1m" - BLUE="${BOLD}\e[1;34m" - GREEN="${BOLD}\e[1;32m" - RED="${BOLD}\e[1;31m" - YELLOW="${BOLD}\e[1;33m" - fi -fi -readonly ALL_OFF BOLD BLUE GREEN RED YELLOW diff --git a/src/Makefile.am b/src/Makefile.am index 08dde4b..2efd416 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -92,10 +92,11 @@ AM_CFLAGS = \ $(LIBALPM_CFLAGS) edit = sed \ - -e 's|@bindir[@]|${bindir}|g' \ + -e 's|@bindir[@]|$(bindir)|g' \ -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ -e 's|@localstatedir[@]|$(localstatedir)|g' \ -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \ + -e 's|@libmakepkgdir[@]|$(LIBMAKEPKGDIR)|g' \ -e 's|@SIZECMD[@]|$(SIZECMD)|g' \ -e 's|@SCRIPTNAME[@]|$@|g' \ -e '1s|!/bin/bash|!$(BASH_SHELL)|g' \ @@ -121,9 +122,9 @@ $(OURFILES): Makefile all-am: $(OURSCRIPTS) $(OURFILES) -checkupdates: $(srcdir)/checkupdates.sh.in $(top_srcdir)/lib/output_format.sh $(top_srcdir)/lib/term_colors.sh -paccache: $(srcdir)/paccache.sh.in $(top_srcdir)/lib/output_format.sh $(top_srcdir)/lib/parseopts.sh $(top_srcdir)/lib/size_to_human.sh $(top_srcdir)/lib/term_colors.sh -pacdiff: $(srcdir)/pacdiff.sh.in $(top_srcdir)/lib/output_format.sh $(top_srcdir)/lib/term_colors.sh +checkupdates: $(srcdir)/checkupdates.sh.in +paccache: $(srcdir)/paccache.sh.in +pacdiff: $(srcdir)/pacdiff.sh.in paclist: $(srcdir)/paclist.sh.in paclog-pkglist: $(srcdir)/paclog-pkglist.sh.in pacscripts: $(srcdir)/pacscripts.sh.in diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index 0885983..eecb4a7 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -21,11 +21,14 @@ declare -r myname='checkupdates' declare -r myver='@PACKAGE_VERSION@' +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + DOWNLOAD_CACHE=0 +USE_COLOR=0 -m4_include(../lib/output_format.sh) -m4_include(../lib/term_colors.sh) -m4_include(../lib/parseopts.sh) +# Import libmakepkg +source "$LIBRARY"/util/message.sh +source "$LIBRARY"/util/parseopts.sh usage() { cat << __EOF__ @@ -45,7 +48,7 @@ __EOF__ } OPT_SHORT='dh' -OPT_LONG=('download' 'help') +OPT_LONG=('download' 'help' 'nocolor') if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then exit 1 @@ -60,6 +63,8 @@ while :; do -h|--help) usage exit 0 ;; + --nocolor) + USE_COLOR='n';; --) shift break ;; @@ -67,6 +72,13 @@ while :; do shift done +# check if messages are to be printed using color +if [[ -t 2 && $USE_COLOR != "n" ]]; then + colorize +else + unset ALL_OFF BOLD BLUE GREEN RED YELLOW +fi + if ! type -P fakeroot >/dev/null; then error 'Cannot find the fakeroot binary.' exit 1 diff --git a/src/paccache.sh.in b/src/paccache.sh.in index c7265ba..af901f4 100644 --- a/src/paccache.sh.in +++ b/src/paccache.sh.in @@ -25,6 +25,8 @@ shopt -s extglob declare -r myname='paccache' declare -r myver='@PACKAGE_VERSION@' +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + declare -a cachedirs=() candidates=() cmdopts=() whitelist=() blacklist=() declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0 declare -i min_atime=0 min_mtime=0 @@ -33,8 +35,9 @@ declare delim=$'\n' keep=3 movedir= scanarch= QUIET=0 USE_COLOR='y' -m4_include(../lib/output_format.sh) -m4_include(../lib/parseopts.sh) +# Import libmakepkg +source "$LIBRARY"/util/message.sh +source "$LIBRARY"/util/parseopts.sh die() { error "$@" @@ -310,7 +313,12 @@ while :; do shift done -m4_include(../lib/term_colors.sh) +# check if messages are to be printed using color +if [[ -t 2 && $USE_COLOR != "n" ]]; then + colorize +else + unset ALL_OFF BOLD BLUE GREEN RED YELLOW +fi # setting default cachedirs if [[ -z $cachedirs ]]; then diff --git a/src/pacdiff.sh.in b/src/pacdiff.sh.in index 8a70d4e..e3b8f8c 100644 --- a/src/pacdiff.sh.in +++ b/src/pacdiff.sh.in @@ -23,13 +23,16 @@ shopt -s extglob declare -r myname='pacdiff' declare -r myver='@PACKAGE_VERSION@' +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + diffprog=${DIFFPROG:-'vim -d'} diffsearchpath=${DIFFSEARCHPATH:-/etc} USE_COLOR='y' declare -a oldsaves declare -i USE_FIND=0 USE_LOCATE=0 USE_PACDB=0 OUTPUTONLY=0 -m4_include(../lib/output_format.sh) +# Import libmakepkg +source "$LIBRARY"/util/message.sh usage() { cat </dev/null && (( ! OUTPUTONLY )); then error "Cannot find the $diffprog binary required for viewing differences." From patchwork Wed Oct 23 06:13:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Schwartz X-Patchwork-Id: 1293 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 7E4B4149A1502 for ; Wed, 23 Oct 2019 06:14:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1, MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Wed, 23 Oct 2019 06:14:25 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 9B18C1609AECE9; Wed, 23 Oct 2019 06:14:24 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Wed, 23 Oct 2019 06:14:24 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 4070A2CF5F; Wed, 23 Oct 2019 06:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1571811264; bh=ejWY1xbppoKESZRC37JQDJ/OTXeP7k/VfjrHhm2WIyE=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=UCT+1M7Ts6AIayfMhHj2ElZhvTffXSxackrArZs5CG8oD3C0x8IbL4Jp+o4eJ3Q0Z jgfBhpg8KCD9RfkdBs8qcVU5gHYptuUOu/lqtgSvNK+NXK3yq6li8CXYtAidtsBJ+D hSrTdMLyxbQEOLmVX+IpBkFC47JNVD56ruoBw9HKWqL7+07yp4l5LRMtPthCqhrOww mOIjlQYVzWkbdrroHEcE/s4Vyh3rfdWn6BlTRIN41LU4ly8s3Cnf5cmXw/V4HYa5rh 82xR+uThBHb9aOABFzX4CeAQYK54na8dHlSRqvLd4PvFpHmOK11GyYx2jwnE2+ywbu Wz+zwPoPtfGNP4xwG4wJbILeL/05qY9VpKgYKSd0L+npa2zFSOZR45ezwRyK4q5jTd NCiitIrs/QLt5gGRBtShMPh1jbSX3Xl0662TThxz2P8xkOwven63kMUu53+Hzyr6YB 7pcdDIEaHXBXUdpqxAYeNgbdnMuGlJWpyzHxhQ92c/DD8kO0VLCjHep1eBNDIpRpWS Ngs+7YSIfA48VXoSlJv1NnBY3arGnbZLgDMJMaTdb3IkUiudXApzB3F582721G3nwe lCkaVTjlFmPxUwERXl2GkKItpfJvGRL9kHSUxtcLSlAkNH7cu2L6zhuEOU52SXYOMm 4aJiG8UqMzCpXXs0xpfD/bGM= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id B14E92CF56 for ; Wed, 23 Oct 2019 06:14:20 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Wed, 23 Oct 2019 06:14:20 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id A2AAD1609AECD9; Wed, 23 Oct 2019 06:14:17 +0000 (UTC) Received: from didactylos.attlocal.net (unknown [IPv6:2600:1700:57f0:ca20:763a:c795:fcf6:91ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: eschwartz) by orion.archlinux.org (Postfix) with ESMTPSA id 0B0FD1609AECD8; Wed, 23 Oct 2019 06:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1571811257; bh=ejWY1xbppoKESZRC37JQDJ/OTXeP7k/VfjrHhm2WIyE=; h=From:To:Subject:Date:In-Reply-To:References; b=Dx29bW1yRk6JaoAtnTvtjuuIjE7tQ8zuGGyIxi+5oXe9xLnStFdfW8ccGTE7XYMMo CzjB58Q8rQCDbxBjq3fIlbgSTL2P37kXRaeqj+jw2j5+9KWp0ZdVR3SGSau8PcdPLt NEDXr0/87K5EfQyHJhbMiKyq6KUTyo9degoiyzYidDTnl5IS43IoVF0wRhZ39eWyRP BilCIGVsxDs1tMRpQODjhnSOimNKlb/oeU84TCBRnR7GHHssytkwpY1bluHaLIH9f0 /JuGm5qQMNhn+TZ7m2N9eMuQsEuJvPMket+5p0xmUGn2LibjyHl5yALEdQRLqI/VG4 G3f/7hWeYAUsW69tkXAdu3j+AwHPKmS7an6MQg/55AX6OuyyGBXx+rhzuau6yZiFkQ dUurwpEGJ1LVuFu3PKLPYa6Qwlu3vxyRjmAoYZQ14TB2+MMfPpxPAOSc+gUOuv5xvX 3dSVbA5FWPGyiwRW+9FSLwOAkR9B7sQHBhdWWxIMShKFGY74Hzc3nuD+1cOKmBfJlV 7N3m5jwVC94AnYyUekePv2rKVTtZke8SX3YxYqnjl6IJBgsUFbPp8mUloTHRR/3IuW st3ltW44xZgqTZlThJdILXr7vok7jLtjKUI0/WPE3l8m/L8o8iYXSLOC0U5cjuc9W8 QfBylOWe5eX3/hSPmW82Zc7I= From: Eli Schwartz To: pacman-contrib@lists.archlinux.org Subject: [pacman-contrib] [PATCH 2/4] updpkgsums: rely on makepkg's exported schema declaration for algo types Date: Wed, 23 Oct 2019 02:13:57 -0400 Message-Id: <20191023061359.820902-2-eschwartz@archlinux.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023061359.820902-1-eschwartz@archlinux.org> References: <20191023061359.820902-1-eschwartz@archlinux.org> MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" Rather than heuristically match (md|sha)[[:digit:]]+sums or even .*sums, read makepkg's internal description of known hash algorithms, and use it to generate a search pattern. This ensures that we will always be in sync with the makepkg installed on the user's system. Fixes support for the newly added b2sums algorithm. Signed-off-by: Eli Schwartz --- src/updpkgsums.sh.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/updpkgsums.sh.in b/src/updpkgsums.sh.in index 9c545ea..41965f5 100644 --- a/src/updpkgsums.sh.in +++ b/src/updpkgsums.sh.in @@ -22,6 +22,11 @@ shopt -s extglob declare -r myname='updpkgsums' declare -r myver='@PACKAGE_VERSION@' +LIBRARY=${LIBRARY:-'@libmakepkgdir@'} + +# Import libmakepkg +source "$LIBRARY"/util/schema.sh + usage() { printf "%s v%s\n" "${myname}" "${myver}" echo @@ -92,9 +97,10 @@ export BUILDDIR=$(mktemp -d "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") newbuildfile=$(mktemp "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT +sumtypes=$(IFS='|'; echo "${known_hash_algos[*]}") newsums=$(makepkg -g -p "$buildfile" "${MAKEPKG_OPTS[@]}") || die 'Failed to generate new checksums' -awk -v newsums="$newsums" ' - /^[[:blank:]]*(md|sha)[[:digit:]]+sums(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ { +awk -v sumtypes="$sumtypes" -v newsums="$newsums" ' + $0 ~"^[[:blank:]]*(" sumtypes ")sums(_[^=]+)?=", $0 ~ "\\)[[:blank:]]*(#.*)?$" { if (!w) { print newsums w++ From patchwork Wed Oct 23 06:13:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Schwartz X-Patchwork-Id: 1291 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id BD77C149A1505 for ; Wed, 23 Oct 2019 06:14:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1, MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Wed, 23 Oct 2019 06:14:27 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 757FD1609AECF0; Wed, 23 Oct 2019 06:14:26 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Wed, 23 Oct 2019 06:14:26 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 6B4D32CF64; Wed, 23 Oct 2019 06:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1571811266; bh=xf0VETBF2cpNh5p6UhEBm1d/FMVH4q9n863kkLIxN2A=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=FdyrNQgPHxkz6zgVNsGlYDG5Tg8Ca6dmx+Lsxu52zCqtcUR968BspI+0GAIhkozku 6BhtSaDcbgDDyt5LPVedI8TjWMQPOPY4rYaURCMH8D9CVLq4PYeny+35Z/gFnOfWag BQAeYtd3YVwlGkKs0LADzyQ+3fSclHVkmighbXtsoTo2rKg6QBjIfuseEMR2gejQH/ 8XcgmG6CAtmRsdQKcN2t6OQ9IvEYKB0OB437qEEnRc0QLoDSHjCOlV/ulC4GL9y4NQ 1bBp43UpKZyBey9JAuHBxnQoyEz+2ZTcgcfz3ylNtqf5rSZxj/72RsHJTNjYRetMnK 1HW+FCTVxEX7cjEUrdlwmTcqPnj5hbTFhYxR+lYUsxK8reTxDXy8dFf2VHcRst2Odm QkVn+Op2T61K7584XZR3Ut8VR4zMocLpFqlzegnN0bfjxSoOflKJWi+C+ohoidE8Zh bCE81ZTOb5zwy3Ha9YSDjMe4RK2t635FtLeW9V5ZtsPFPEC4Xgs+aoJMLRzC/OCgwO sDMG9raJ5dq88GwJh2LVOTN3rhJT68wv58+abzb2T+UjMS74FiYAelW+0mAEWE4iij QpNrFf4MwVLoKUsBjWqNVDTtI3d/TH5m2z24u2kG4GdKchF9EOljX6qL+EgQVlNfAa x+lmOkfzEyQsrdaagcdQ5aZQ= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 61A992CF5C for ; Wed, 23 Oct 2019 06:14:21 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Wed, 23 Oct 2019 06:14:21 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 7E92C1609AECDB; Wed, 23 Oct 2019 06:14:18 +0000 (UTC) Received: from didactylos.attlocal.net (unknown [IPv6:2600:1700:57f0:ca20:763a:c795:fcf6:91ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: eschwartz) by orion.archlinux.org (Postfix) with ESMTPSA id D0B891609AECDA; Wed, 23 Oct 2019 06:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1571811258; bh=xf0VETBF2cpNh5p6UhEBm1d/FMVH4q9n863kkLIxN2A=; h=From:To:Subject:Date:In-Reply-To:References; b=FnW6HoP4sl3+hNhkHpktT+rncBib/iMOtZy1ydVLW5jNyt90dDfQaiz2LSJuaOkUB EfbPTmGC3PSngEonF5ZuJri8WO8ZERFFejl/grtUlIHySsAPcqFB+AYBsQQ1pHidfO o7S0Bbb1umKWLDT32867c7RIhw9jv/20OStXVtmb/Ox1N/E5z/Ip0NE/yzoZDDHBx2 UUACrEO00TQcpeDXNKZsP5MaPW++vopDlRZnJrWr5+UzUNRY8GlaH1bFGA1BuvLwU8 8ecfu8ILuZ+YThrY6RsWwsSjqC9nIn8wsMkXjkTs8Pnjg5zRzOXduh7ypFGU42jG+N wjm87imEGfqiIV9qi1S4f8IqVTBpy4Td56buOGwWNVdCe7CJYqVmGAwSNd3RJFg9p1 j7++rFJx1Y+2Zi0tHoijoKmXYS/Vac4XzbsLsP87il3sGeoVx8dZJn53LhppRleTJU swTSTtJeKW5KtUySR0LH/kj1GffdiOK3TwfpyRCab87XvOGTYEyv5DX4xx1CmYOKtn AlCIcXqR80sVoukWV1udpLS25Bs1QjKjmmYaqBrDLHE9gSNvrZ3R8F405zvJzqEMeO +n3sd+qTKuUARgAXwE0fVwJkfsaPCQevA5IjgqKSleAHB1uagyqqxwAWLA4eYNoj2E iqAZxnOoxMO5UdoJZWTu59OY= From: Eli Schwartz To: pacman-contrib@lists.archlinux.org Subject: [pacman-contrib] [PATCH 3/4] Makefile: be more templated when calculating dependency patterns Date: Wed, 23 Oct 2019 02:13:58 -0400 Message-Id: <20191023061359.820902-3-eschwartz@archlinux.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023061359.820902-1-eschwartz@archlinux.org> References: <20191023061359.820902-1-eschwartz@archlinux.org> MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" Signed-off-by: Eli Schwartz --- src/Makefile.am | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 2efd416..093ae71 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -122,16 +122,8 @@ $(OURFILES): Makefile all-am: $(OURSCRIPTS) $(OURFILES) -checkupdates: $(srcdir)/checkupdates.sh.in -paccache: $(srcdir)/paccache.sh.in -pacdiff: $(srcdir)/pacdiff.sh.in -paclist: $(srcdir)/paclist.sh.in -paclog-pkglist: $(srcdir)/paclog-pkglist.sh.in -pacscripts: $(srcdir)/pacscripts.sh.in -rankmirrors: $(srcdir)/rankmirrors.sh.in -updpkgsums: $(srcdir)/updpkgsums.sh.in - -pacsearch: $(srcdir)/pacsearch.pl.in +$(BASHSCRIPTS): %: $(srcdir)/%.sh.in +$(PERLSCRIPTS): %: $(srcdir)/%.pl.in pacsort_SOURCES = pacsort.c pacsort_LDADD = $(LIBARCHIVE_LIBS) $(LIBALPM_LIBS) From patchwork Wed Oct 23 06:13:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Schwartz X-Patchwork-Id: 1290 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 1D905149A1507 for ; Wed, 23 Oct 2019 06:14:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1, MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Wed, 23 Oct 2019 06:14:28 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 3CDAE1609AECE7; Wed, 23 Oct 2019 06:14:24 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Wed, 23 Oct 2019 06:14:24 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 2A4202CF56; Wed, 23 Oct 2019 06:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1571811264; bh=qWAhkTjWFImRBr5ByB03XuNWQWn/Qt4a4aeY1mK4ljE=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe; b=HjPlU838ClWn0j/xdK2tRBeM7QRL3JVo/qf/Fukzw6JZVtd656cagMRKtxXo/aeIy Zp+dhb0KyBFCtcRbS+d/NUHTemQ73vCUbrols6DzcyuYLa6l1j754Q6Tg1ER6LXDN/ imMtCprUBBzJubtEwjnrXcdSpGKWJEoWCvYya7UCI86CV++5UAecHbeUn7bDWmcF2l oTqAUwpHOzOXt5OTF4wM7WGx+8OaJ4ZiL7195zfuW/BvBcQ1NhkwwRLY1aGJgAas8i WOwwrFm0ukmNX5AQJRlDbp1wVwMSmquy+D+Q6u/2MgQBN7k5izudNlSkhvBV4nXBtq Nij4Khay3bCs9CC5I9spr5mksFKTi5sI0f11XnYBwQ9bW1L2aertp/XHGzkLGb+JQA sbKZHQ4RhmoZHgDbSZ5xJ9yEtozY6sROLu9HLKwUj1uxGsvL7pb6oUY2UB32Yoqheu xHDgqhCssbBSqmaZaVfbrHIip2PUyQxikAzoBC99s6JyoO/zvQCna4F0bMua+pwk/M mpHG7i27rGf11OrTiHq/HhppKYsmSLYEqY02h8H66amHJBA2tEwGMVCOfLCtrk1EGl Fv/4xqrsfFvcYLrPVmGJzSa40pfsvbYJIOvYh5S/S3Tn5hPPwj488ax3/+ybwQQo1H b7uphvZs2x3wgNTeK1HVqRd0= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id A88A32CF50 for ; Wed, 23 Oct 2019 06:14:20 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Wed, 23 Oct 2019 06:14:20 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 782C21609AECDD; Wed, 23 Oct 2019 06:14:19 +0000 (UTC) Received: from didactylos.attlocal.net (unknown [IPv6:2600:1700:57f0:ca20:763a:c795:fcf6:91ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: eschwartz) by orion.archlinux.org (Postfix) with ESMTPSA id ABCF41609AECDC; Wed, 23 Oct 2019 06:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1571811259; bh=qWAhkTjWFImRBr5ByB03XuNWQWn/Qt4a4aeY1mK4ljE=; h=From:To:Subject:Date:In-Reply-To:References; b=pwfBTEHwAk/Q2Kti3XfbXr7i8IaI59Zmv2MFwjGdqTA4m2XfkuKZX1z5Kuq87FtpF vDlB6v0wKfCc5dKnDX7/NL5MQGXe9BoDIa783kjzu19pVWvxqQFgXKyOjyL7YuGpUT er6rORAvbEDwXWEVkkipq+2XqfSa9jyZmShd86701xmUILveWqfmr+0Pt9xPPHkj2f Vp2LsbTRu/yt3ZN5BjOw0QnRX10wUMuKFKOPuOZnNlS/M2/9I9o/BmiTTQIu95Tk4s +kV9mw+KXT3xyFcQ0MrwlknLMnnKLxrbJePjV43SjoDJvwTxNiwrnBnWOXr3x1Xa2b yxZyobCufvokAYGtnllpDFPJHsMImKGuDm9CrmvtW3QPAOay3/cTpD1LHvkVFMfncg 7qPwf0ACTZLcHDELymS68kd8eMDtyTdntu6fxp4uJrFs1noBN3X6ksyn2k7Dbq7U/q uWh7PvSeZnHU75CZkYKnuW3hBpERrjz+f3E3k1/qDtx29S7nilQvnGS+53gzxzcFOZ XIGyCrriHt1Ar7JXB7p4v1empOjc0cHdEUl51Q7aSZR7EoKsN+bwlYA6GniaQk167x wUukz1+7ncJxg/Nj1OBzpXrgFVVfXZ4tVDXALjpyQRCTCPvNUa9Wp7k072YN+NhN8z ps0+X5osP1RrvDoiTUoiictY= From: Eli Schwartz To: pacman-contrib@lists.archlinux.org Subject: [pacman-contrib] [PATCH 4/4] checkupdates: exit 2 if no updates are available Date: Wed, 23 Oct 2019 02:13:59 -0400 Message-Id: <20191023061359.820902-4-eschwartz@archlinux.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023061359.820902-1-eschwartz@archlinux.org> References: <20191023061359.820902-1-eschwartz@archlinux.org> MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" It's useful to distinguish the failure to find updates. This carries over the ability for pacman -Qu to return errors when no upgrades are available. At the same time, this should (unlike pacman -Qu) use its own unique return code, since checkupdates may error for a couple of reasons including download issues. Fixes FS#64219 Signed-off-by: Eli Schwartz --- doc/checkupdates.8.txt | 14 ++++++++++++++ src/checkupdates.sh.in | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/checkupdates.8.txt b/doc/checkupdates.8.txt index ff10930..b1a94d8 100644 --- a/doc/checkupdates.8.txt +++ b/doc/checkupdates.8.txt @@ -39,6 +39,20 @@ Environment Overrides the default '/tmp' temporary directory. +Errors +------ +On exit, checkpkg will return one of the following error codes. + +0:: + Normal exit condition. + +1:: + Unknown cause of failure. + +2:: + No updates are available. + + See Also -------- linkman:pacman[8], linkman:pacman.conf[5] diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index eecb4a7..52f8899 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -109,7 +109,7 @@ if (( ${#updates[@]} )); then sudo pacman -Sw --noconfirm "${updates[@]%% *}" --dbpath "$CHECKUPDATES_DB" --logfile /dev/null fi else - exit 1 + exit 2 fi # vim: set noet: