# HG changeset patch # User Franz Glasner # Date 1730382867 -3600 # Node ID 7f64b44207034eeb83955a97db18c696d5f974cf # Parent e48d173534ec86a1295ada68f0cf78e546e8d066 fports: Refactor: split up command_detail(): make a function that is called for each package diff -r e48d173534ec -r 7f64b4420703 sbin/fports --- a/sbin/fports Thu Oct 31 14:42:51 2024 +0100 +++ b/sbin/fports Thu Oct 31 14:54:27 2024 +0100 @@ -355,30 +355,7 @@ 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 + _package_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}" done falist_release "${packagemapping}" @@ -387,6 +364,55 @@ #: +#: Implementation of printing the most details possible for a package. +#: +#: Implements all the repeating stuff for a package for e.g. `command_detail`. +#: +#: Args: +#: $1 (str): The name of the package +#: $2 (alist): The +#: $3 (array): The array with all the configured/active repositories +#: $4 (str, null): The local index file if it exists +#: +_package_detail() { + local package packagemapping repositories indexfile + + local instver instrepo repo title_printed _dummy \ + pkglabel pkgdescr pkgversion mapped_package + + package="${1}" + packagemapping="${2}" + repositories="${3}" + indexfile="${4}" + + # 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 _mapped_package_repository_detail "${mapped_package}" "{instver}" 19 + fi +} + + +#: #: Array callback to print package details with regard to a repository. #: #: Args: @@ -396,7 +422,7 @@ #: $4 (str): The (master) package name #: $5 (int): The extra indent value to forward to called functions #: -_command_package_repository_detail() { +_package_repository_detail() { local repositories idx reponame package extraindent local _dummy \ @@ -429,7 +455,7 @@ #: $5 (str): The parent package version #: $6 (int): The extra indent value to forward to called functions #: -_command_mapped_package_repository_detail() { +_mapped_package_repository_detail() { local repositories idx reponame package parent_pkgversion extraindent local _dummy \