Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison sbin/fports @ 806:b59054f11029
fports: Implement "fports detail -b" to print details about all packages that are not installed from the blessed FreeBSD repo.
While there change option handling to allow a combination of selection flags:
merge all selected packages and sort if needed.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 05 Nov 2024 10:57:06 +0100 |
| parents | f406b3b76b62 |
| children | ed94334bc6f1 |
comparison
equal
deleted
inserted
replaced
| 805:e18cc5fe828c | 806:b59054f11029 |
|---|---|
| 22 # shellcheck disable=SC2016 # no expansion | 22 # shellcheck disable=SC2016 # no expansion |
| 23 USAGE=' | 23 USAGE=' |
| 24 USAGE: fports -h|--help | 24 USAGE: fports -h|--help |
| 25 fports -V|--version | 25 fports -V|--version |
| 26 fports deptree [-l maxlevel|--maxlevel=maxlevel] [-r|--reverse] [-t|--list|--transitive] package... | 26 fports deptree [-l maxlevel|--maxlevel=maxlevel] [-r|--reverse] [-t|--list|--transitive] package... |
| 27 fports detail -b|--nofreebsd|--no-freebsd | |
| 27 fports detail -n|--noauto|--no-auto | 28 fports detail -n|--noauto|--no-auto |
| 28 fports detail -m|--mapped | 29 fports detail -m|--mapped |
| 29 fports detail package... | 30 fports detail package... |
| 30 | 31 |
| 31 GLOBAL OPTIONS: | 32 GLOBAL OPTIONS: |
| 348 command_detail() { | 349 command_detail() { |
| 349 local opt_noauto opt_mapped | 350 local opt_noauto opt_mapped |
| 350 # $@ | 351 # $@ |
| 351 | 352 |
| 352 local package \ | 353 local package \ |
| 354 packages do_sort idx prev_package \ | |
| 353 repositories packagemapping instver instrepo \ | 355 repositories packagemapping instver instrepo \ |
| 354 repo title_printed indexfile _dummy opt acookie \ | 356 repo title_printed indexfile _dummy opt acookie \ |
| 355 pkglabel pkgdescr pkgversion mapped_package | 357 pkglabel pkgdescr pkgversion mapped_package |
| 356 | 358 |
| 359 do_sort=no | |
| 360 opt_nofreebsd=no | |
| 357 opt_noauto=no | 361 opt_noauto=no |
| 358 opt_mapped=no | 362 opt_mapped=no |
| 359 while getopts "nm-:" opt; do | 363 while getopts "bnm-:" opt; do |
| 360 postprocess_getopts_for_long "nm-:" opt "noauto" "no-auto" "mapped" "" | 364 postprocess_getopts_for_long "nm-:" opt "nofreebsd" "no-freebsd" "noauto" "no-auto" "mapped" "" |
| 361 case "${opt}" in | 365 case "${opt}" in |
| 366 b|nofreebsd|no-freebsd) | |
| 367 # shellcheck disable=SC2034 # appears unused | |
| 368 opt_nofreebsd=yes | |
| 369 do_sort=yes | |
| 370 ;; | |
| 362 n|noauto|no-auto) | 371 n|noauto|no-auto) |
| 363 # shellcheck disable=SC2034 # appears unused | 372 # shellcheck disable=SC2034 # appears unused |
| 364 opt_noauto=yes;; | 373 opt_noauto=yes |
| 374 do_sort=yes | |
| 375 ;; | |
| 365 m|mapped) | 376 m|mapped) |
| 366 # shellcheck disable=SC2034 # appears unused | 377 # shellcheck disable=SC2034 # appears unused |
| 367 opt_mapped=yes;; | 378 opt_mapped=yes |
| 379 do_sort=yes | |
| 380 ;; | |
| 368 \?) | 381 \?) |
| 369 exit 2;; | 382 exit 2;; |
| 370 *) | 383 *) |
| 371 fatal 2 "option handling failed";; | 384 fatal 2 "option handling failed";; |
| 372 esac | 385 esac |
| 373 done | 386 done |
| 374 shift $((OPTIND-1)) | 387 shift $((OPTIND-1)) |
| 375 OPTIND=1 | 388 OPTIND=1 |
| 376 | 389 |
| 377 if checkyesno opt_noauto || checkyesno opt_mapped; then | 390 packages='' |
| 378 [ $# -gt 0 ] && fatal "${EX_USAGE}" "packages are not allowed for options -n or -m" | 391 farray_create packages |
| 379 if checkyesno opt_noauto && checkyesno opt_mapped; then | |
| 380 fatal "${EX_USAGE}" "cannot use -n and -m together" | |
| 381 fi | |
| 382 fi | |
| 383 | |
| 384 repositories='' | 392 repositories='' |
| 385 get_active_repositories repositories | 393 get_active_repositories repositories |
| 386 packagemapping='' | 394 packagemapping='' |
| 387 init_package_mapping packagemapping | 395 init_package_mapping packagemapping |
| 388 indexfile="$(get_local_index_file)" | 396 indexfile="$(get_local_index_file)" |
| 389 | 397 |
| 398 if checkyesno opt_nofreebsd; then | |
| 399 while IFS='|' read -r package repo; do | |
| 400 [ "${repo}" != 'FreeBSD' ] && farray_append packages "${package}" | |
| 401 done <<EOF_1fa6f326-49e6-4b01-a7ea-52372d00df1e | |
| 402 $(LC_ALL=C.UTF-8 "${PKG}" query '%n|%R') | |
| 403 EOF_1fa6f326-49e6-4b01-a7ea-52372d00df1e | |
| 404 fi | |
| 390 if checkyesno opt_noauto; then | 405 if checkyesno opt_noauto; then |
| 391 for package in $(LC_ALL=C.UTF-8 "${PKG}" query -e '%a = 0' '%n'); do | 406 for package in $(LC_ALL=C.UTF-8 "${PKG}" query -e '%a = 0' '%n'); do |
| 392 _package_max_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}" | 407 farray_append packages "${package}" |
| 393 done | 408 done |
| 394 elif checkyesno opt_mapped; then | 409 fi |
| 410 if checkyesno opt_mapped; then | |
| 395 acookie="$(falist_cookie_first packagemapping)" | 411 acookie="$(falist_cookie_first packagemapping)" |
| 396 while falist_tryget_key_at package "${acookie}"; do | 412 while falist_tryget_key_at package "${acookie}"; do |
| 397 _package_max_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}" | 413 farray_append packages "${package}" |
| 398 acookie="$(falist_cookie_next "${acookie}")" | 414 acookie="$(falist_cookie_next "${acookie}")" |
| 399 done | 415 done |
| 400 else | 416 fi |
| 401 for package in "$@"; do | 417 for package in "$@"; do |
| 418 farray_append packages "${package}" | |
| 419 done | |
| 420 checkyesnovalue "${do_sort}" && farray_sort packages | |
| 421 | |
| 422 idx=1 | |
| 423 prev_package='' # to skip duplicate packages | |
| 424 while farray_tryget package packages "${idx}"; do | |
| 425 if [ "${prev_package}" != "${package}" ]; then | |
| 402 _package_max_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}" | 426 _package_max_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}" |
| 403 done | 427 prev_package="${package}" |
| 404 fi | 428 fi |
| 405 | 429 idx=$((idx + 1)) |
| 430 done | |
| 431 | |
| 406 falist_release "${packagemapping}" | 432 falist_release "${packagemapping}" |
| 407 farray_release "${repositories}" | 433 farray_release "${repositories}" |
| 434 farray_release "${packages}" | |
| 408 } | 435 } |
| 409 | 436 |
| 410 | 437 |
| 411 #: | 438 #: |
| 412 #: Implementation of printing the most details possible for a package. | 439 #: Implementation of printing the most details possible for a package. |
