Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff sbin/check-ports @ 150:937c96ffe358
Implemented the "-n" option to check only given packages but in the most detail possible
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 03 Nov 2019 18:06:31 +0100 |
| parents | c4e9099a3d3e |
| children | 27b7454140be |
line wrap: on
line diff
--- 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 <<EOF_INSTALLED +$(pkg query '%v %R' "${_package}") +EOF_INSTALLED + if [ -n "${_version}" ]; then + title_printed="" + print_title "${_package}" "${_version}" "${_repo}" + if [ -n "${_local_index_exists}" ]; then + read -r _dummy _label _descr <<EOF_INDEX +$(pkg version -U -I -n "${_package}" -v) +EOF_INDEX + _version="$(get_immediate_index_version "${_package}")" + print_detail_item "INDEX" "${_version}" "${_label}" "${_descr}" + fi + for _repo in "${FREEBSD_REPO}" "${LOCALBSDPORTS_REPO}" "${SHARED_LOCAL_REPO}" "${LOCAL_REPO}"; do + read -r _dummy _label _descr <<EOF_REPO +$(pkg version -U -R -r "${_repo}" -n "${_package}" -v) +EOF_REPO + _version="$(pkg rquery -U -r "${_repo}" '%v' "${_package}")" + print_detail_item "${_repo}" "${_version}" "${_label}" "${_descr}" + done + _mapped_package_name="$(get_mapping "${_ipackage}")" + if [ -n "${_mapped_package_name}" ] ; then + printf '%18s %s %s (%s)\n' "--------------->" "${_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
