Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/fports @ 797:7f64b4420703
fports: Refactor: split up command_detail(): make a function that is called for each package
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 31 Oct 2024 14:54:27 +0100 |
| parents | e48d173534ec |
| children | e48b38cf7bb1 |
comparison
equal
deleted
inserted
replaced
| 796:e48d173534ec | 797:7f64b4420703 |
|---|---|
| 353 packagemapping='' | 353 packagemapping='' |
| 354 init_package_mapping packagemapping | 354 init_package_mapping packagemapping |
| 355 indexfile="$(get_local_index_file)" | 355 indexfile="$(get_local_index_file)" |
| 356 | 356 |
| 357 for package in "$@"; do | 357 for package in "$@"; do |
| 358 # shellcheck disable=SC2034 # appears unused | 358 _package_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}" |
| 359 title_printed=no | 359 done |
| 360 IFS='|' read -r instver instrepo <<EOF_e9bd7819-b4c5-4a86-b984-f5226db58cb1 | 360 |
| 361 falist_release "${packagemapping}" | |
| 362 farray_release "${repositories}" | |
| 363 } | |
| 364 | |
| 365 | |
| 366 #: | |
| 367 #: Implementation of printing the most details possible for a package. | |
| 368 #: | |
| 369 #: Implements all the repeating stuff for a package for e.g. `command_detail`. | |
| 370 #: | |
| 371 #: Args: | |
| 372 #: $1 (str): The name of the package | |
| 373 #: $2 (alist): The | |
| 374 #: $3 (array): The array with all the configured/active repositories | |
| 375 #: $4 (str, null): The local index file if it exists | |
| 376 #: | |
| 377 _package_detail() { | |
| 378 local package packagemapping repositories indexfile | |
| 379 | |
| 380 local instver instrepo repo title_printed _dummy \ | |
| 381 pkglabel pkgdescr pkgversion mapped_package | |
| 382 | |
| 383 package="${1}" | |
| 384 packagemapping="${2}" | |
| 385 repositories="${3}" | |
| 386 indexfile="${4}" | |
| 387 | |
| 388 # shellcheck disable=SC2034 # appears unused | |
| 389 title_printed=no | |
| 390 IFS='|' read -r instver instrepo <<EOF_e9bd7819-b4c5-4a86-b984-f5226db58cb1 | |
| 361 $(LC_ALL=C.UTF-8 "${PKG}" query '%v|%R' "${package}") | 391 $(LC_ALL=C.UTF-8 "${PKG}" query '%v|%R' "${package}") |
| 362 EOF_e9bd7819-b4c5-4a86-b984-f5226db58cb1 | 392 EOF_e9bd7819-b4c5-4a86-b984-f5226db58cb1 |
| 363 print_title title_printed "${package}" "${instver}" "${instrepo}" | 393 print_title title_printed "${package}" "${instver}" "${instrepo}" |
| 364 if [ -n "${indexfile}" ]; then | 394 if [ -n "${indexfile}" ]; then |
| 365 read -r _dummy pkglabel pkgdescr <<EOF_b1f225bd-d234-4a23-8a2a-40c2e5b7ff3c | 395 read -r _dummy pkglabel pkgdescr <<EOF_b1f225bd-d234-4a23-8a2a-40c2e5b7ff3c |
| 366 $(LC_ALL=C.UTF-8 "${PKG}" version -U -I -n "${package}" -v "${indexfile}") | 396 $(LC_ALL=C.UTF-8 "${PKG}" version -U -I -n "${package}" -v "${indexfile}") |
| 367 EOF_b1f225bd-d234-4a23-8a2a-40c2e5b7ff3c | 397 EOF_b1f225bd-d234-4a23-8a2a-40c2e5b7ff3c |
| 368 pkgversion="$(parse_index_file_for_package_version "${indexfile}" "${package}")" | 398 pkgversion="$(parse_index_file_for_package_version "${indexfile}" "${package}")" |
| 369 print_detail_item "INDEX" "${pkgversion}" "${pkglabel}" "${pkgdescr}" | 399 print_detail_item "INDEX" "${pkgversion}" "${pkglabel}" "${pkgdescr}" |
| 370 fi | 400 fi |
| 371 farray_for_each repositories _command_package_repository_detail "${package}" 0 | 401 farray_for_each repositories _package_repository_detail "${package}" 0 |
| 372 mapped_package="$(get_package_mapping "${packagemapping}" "${package}")" | 402 mapped_package="$(get_package_mapping "${packagemapping}" "${package}")" |
| 373 if [ -z "${mapped_package}" ]; then | 403 if [ -z "${mapped_package}" ]; then |
| 374 printf '%18s %s\n' "--------------->" "${mapped_package}" | 404 printf '%18s %s\n' "--------------->" "${mapped_package}" |
| 375 if [ -n "${indexfile}" ]; then | 405 if [ -n "${indexfile}" ]; then |
| 376 pkgversion="$(parse_index_file_for_package_version "${indexfile}" "${mapped_package}")" | 406 pkgversion="$(parse_index_file_for_package_version "${indexfile}" "${mapped_package}")" |
| 377 pkglabel="$(LC_ALL=C.UTF-8 "${PKG}" version --test-version "${instver}" "${pkgversion}")" | 407 pkglabel="$(LC_ALL=C.UTF-8 "${PKG}" version --test-version "${instver}" "${pkgversion}")" |
| 378 print_detail_item "INDEX" "${pkgversion}" "${pkglabel}" '' 19 | 408 print_detail_item "INDEX" "${pkgversion}" "${pkglabel}" '' 19 |
| 379 fi | 409 fi |
| 380 farray_for_each repositories _command_mapped_package_repository_detail "${mapped_package}" "{instver}" 19 | 410 farray_for_each repositories _mapped_package_repository_detail "${mapped_package}" "{instver}" 19 |
| 381 fi | 411 fi |
| 382 done | |
| 383 | |
| 384 falist_release "${packagemapping}" | |
| 385 farray_release "${repositories}" | |
| 386 } | 412 } |
| 387 | 413 |
| 388 | 414 |
| 389 #: | 415 #: |
| 390 #: Array callback to print package details with regard to a repository. | 416 #: Array callback to print package details with regard to a repository. |
| 394 #: $2 (int): The current index | 420 #: $2 (int): The current index |
| 395 #: $3: The element value (i.e. repository name) | 421 #: $3: The element value (i.e. repository name) |
| 396 #: $4 (str): The (master) package name | 422 #: $4 (str): The (master) package name |
| 397 #: $5 (int): The extra indent value to forward to called functions | 423 #: $5 (int): The extra indent value to forward to called functions |
| 398 #: | 424 #: |
| 399 _command_package_repository_detail() { | 425 _package_repository_detail() { |
| 400 local repositories idx reponame package extraindent | 426 local repositories idx reponame package extraindent |
| 401 | 427 |
| 402 local _dummy \ | 428 local _dummy \ |
| 403 pkglabel pkgdescr pkgversion | 429 pkglabel pkgdescr pkgversion |
| 404 | 430 |
| 427 #: $3: The element value (i.e. repository name) | 453 #: $3: The element value (i.e. repository name) |
| 428 #: $4 (str): The mapped package name | 454 #: $4 (str): The mapped package name |
| 429 #: $5 (str): The parent package version | 455 #: $5 (str): The parent package version |
| 430 #: $6 (int): The extra indent value to forward to called functions | 456 #: $6 (int): The extra indent value to forward to called functions |
| 431 #: | 457 #: |
| 432 _command_mapped_package_repository_detail() { | 458 _mapped_package_repository_detail() { |
| 433 local repositories idx reponame package parent_pkgversion extraindent | 459 local repositories idx reponame package parent_pkgversion extraindent |
| 434 | 460 |
| 435 local _dummy \ | 461 local _dummy \ |
| 436 pkglabel pkgversion | 462 pkglabel pkgversion |
| 437 | 463 |
