# HG changeset patch # User Franz Glasner # Date 1572800791 -3600 # Node ID 937c96ffe358172d70e0c05b369d2afaa57706a8 # Parent 04deefed8c61339a61972fa5f12f7b324343ff0a Implemented the "-n" option to check only given packages but in the most detail possible diff -r 04deefed8c61 -r 937c96ffe358 sbin/check-ports --- a/sbin/check-ports Thu Oct 31 09:21:23 2019 +0100 +++ b/sbin/check-ports Sun Nov 03 18:06:31 2019 +0100 @@ -247,7 +247,7 @@ check_ports() { - : 'Implementation of main + : 'Implementation of all command variants besides of `-n` ' local _ipackage _iversion _irepo _mapped_package_name _dummy @@ -386,6 +386,58 @@ } +check_packages() { + : 'Check the status of all given packages in the most detail possible + + Args: + $@: the name of packaged to handle to + + ' + local _package _version _label _repo _descr _dummy + local _local_index_exists _mapped_package_name + + if test_exists_local_index; then + _local_index_exists="1" + fi + + while [ $# -gt 0 ]; do + _package="$1" + shift + read -r _version _repo <" "${_mapped_package_name}" "$(pkg rquery -U '%v' "${_mapped_package_name}")" "$(pkg rquery -U '%R' "${_mapped_package_name}")" + if [ -n "${_local_index_exists}" ]; then + print_detail_item "INDEX" "$(get_immediate_index_version "${_mapped_package_name}")" "" "" + fi + for _repo in "${FREEBSD_REPO}" "${LOCALBSDPORTS_REPO}" "${SHARED_LOCAL_REPO}" "${LOCAL_REPO}"; do + print_detail_item "${_repo}" "$(pkg rquery -U -r "${_repo}" '%v' "${_mapped_package_name}")" "" "" + done + fi + fi + done +} + + option_alldata="" option_alldata_FreeBSD="" option_alldata_LocalBSDPorts="" @@ -393,8 +445,9 @@ option_alldata_LocalRepo="" option_short="" option_verbose="" +option_packages="" -while getopts "VAasv" _opt ; do +while getopts "VAansv" _opt ; do case ${_opt} in V) printf 'check-ports v%s (rv:%s)\n' "${VERSION}" '@@HGREVISION@@' @@ -412,6 +465,13 @@ # Print the data of all repos that have the package option_alldata="1" ;; + n) + # + # Print status of given packages in all details. + # No other options are respected. + # + option_packages="1" + ;; s) # "short" output: if installed from FreeBSD repo: don't # report if only the index is newer @@ -435,9 +495,20 @@ esac done +# +# Reset the Shell's option handling system to prepare for handling +# command-local options. +# +shift $((OPTIND-1)) +OPTIND=1 + if [ -n "${option_short}" -a -n "${option_alldata}" ]; then echo "the -s option cannot be combined with -A or -a" >&2 exit 2 fi -check_ports +if [ -n "${option_packages}" ]; then + check_packages "$@" +else + check_ports +fi