# HG changeset patch # User Franz Glasner # Date 1730382171 -3600 # Node ID e48d173534ec86a1295ada68f0cf78e546e8d066 # Parent 77da0074648568ec1e8d00b0a2f9679e86caed53 fports: Implement "fports detail" to print the status of all given packages in the most detail possible diff -r 77da00746485 -r e48d173534ec docs/man/man8/fports.rst --- a/docs/man/man8/fports.rst Wed Oct 30 15:29:54 2024 +0100 +++ b/docs/man/man8/fports.rst Thu Oct 31 14:42:51 2024 +0100 @@ -15,6 +15,8 @@ **fports deptree** [**-l** `maxlevel`] [**-r**] [**t**] `package` ... +**fports detail** `package` ... + Description ----------- @@ -69,6 +71,17 @@ that depend on a given `package`. +**fports detail** `package` ... + + Print the status of all given packages in the most detail possible. + + The status of the package is printed with regard to its installation status, + local index (if it exists) and all configured and active repositories. + + A package mapping is considered also if applicable. + See :manpage:`package-mapping.conf(5)`. + + Environment ----------- diff -r 77da00746485 -r e48d173534ec sbin/fports --- a/sbin/fports Wed Oct 30 15:29:54 2024 +0100 +++ b/sbin/fports Thu Oct 31 14:42:51 2024 +0100 @@ -24,6 +24,7 @@ USAGE: fports -h fports -V fports deptree [-l maxlevel] [-r] [-t] package... + fports detail package... GLOBAL OPTIONS: @@ -305,7 +306,6 @@ falist_contains pkgdeps "${rootpkg}" || fatal "${EX_SOFTWARE}" "given package \`${rootpkg}' not in the given package dependency map" - # shellcheck disable=SC2034 # appears unused queue='' farray_create queue # array with package names to be flattened @@ -331,12 +331,196 @@ fi done - farray_release queue + farray_release "${queue}" setvar "${1}" "${alldeps}" } +#: +#: Implementation of the "detail" command. +#: +command_detail() { + # $@ + + local package \ + repositories packagemapping instver instrepo \ + repo title_printed indexfile _dummy \ + pkglabel pkgdescr pkgversion mapped_package + + repositories='' + get_active_repositories repositories + packagemapping='' + init_package_mapping packagemapping + indexfile="$(get_local_index_file)" + + for package in "$@"; do + # shellcheck disable=SC2034 # appears unused + title_printed=no + IFS='|' read -r instver instrepo <" "${mapped_package}" + if [ -n "${indexfile}" ]; then + pkgversion="$(parse_index_file_for_package_version "${indexfile}" "${mapped_package}")" + pkglabel="$(LC_ALL=C.UTF-8 "${PKG}" version --test-version "${instver}" "${pkgversion}")" + print_detail_item "INDEX" "${pkgversion}" "${pkglabel}" '' 19 + fi + farray_for_each repositories _command_mapped_package_repository_detail "${mapped_package}" "{instver}" 19 + fi + done + + falist_release "${packagemapping}" + farray_release "${repositories}" +} + + +#: +#: Array callback to print package details with regard to a repository. +#: +#: Args: +#: $1 (str): The repositories array +#: $2 (int): The current index +#: $3: The element value (i.e. repository name) +#: $4 (str): The (master) package name +#: $5 (int): The extra indent value to forward to called functions +#: +_command_package_repository_detail() { + local repositories idx reponame package extraindent + + local _dummy \ + pkglabel pkgdescr pkgversion + + repositories="${1}" + # shellcheck disable=SC2034 # appears unused (yes, accept it) + idx="${2}" + reponame="${3}" + package="${4}" + extraindent="${5:-0}" + + read -r _dummy pkglabel pkgdescr <