annotate sbin/fports @ 804:f406b3b76b62

fports: Implemented also long commandline options
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 04 Nov 2024 11:44:47 +0100
parents 31ff8e5efdd6
children b59054f11029
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 #!/bin/sh
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2 # -*- indent-tabs-mode: nil; -*-
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4 #: Check the version status of installed ports and compare them to
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5 #: version in remote repositories and the local ports index.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
7 #: :Author: Franz Glasner
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8 #: :Copyright: (c) 2017-2024 Franz Glasner.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 #: All rights reserved.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 #: :License: BSD 3-Clause "New" or "Revised" License.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 #: See LICENSE for details.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 #: If you cannot find LICENSE see
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13 #: <https://opensource.org/licenses/BSD-3-Clause>
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
14 #: :ID: @(#)@@SIMPLEVERSIONTAG@@
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17 : # separator for shellcheck: no module-level directives below
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
19 # shellcheck disable=SC2034 # VERSION appears unused
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
20 VERSION='@@VERSION@@'
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22 # shellcheck disable=SC2016 # no expansion
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 USAGE='
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
24 USAGE: fports -h|--help
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
25 fports -V|--version
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
26 fports deptree [-l maxlevel|--maxlevel=maxlevel] [-r|--reverse] [-t|--list|--transitive] package...
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
27 fports detail -n|--noauto|--no-auto
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
28 fports detail -m|--mapped
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
29 fports detail package...
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
31 GLOBAL OPTIONS:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
32
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
33 -V, --version Print the program name and version number to stdout and exit.
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
34
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
35 -h, --help Print this help message to stdout and exit.
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
36
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
37 '
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
38
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
39
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40 _p_datadir='@@DATADIR@@'
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
41 [ "${_p_datadir#@@DATADIR}" = '@@' ] && _p_datadir="$(dirname "$0")"/../share/local-bsdtools
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
42 . "${_p_datadir}/common.subr"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
43 . "${_p_datadir}/farray.sh"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
44 . "${_p_datadir}/ports.subr"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
45
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
46
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
47 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
48 #: Configuration directory.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
49 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
50 : "${CONFIGDIR:=@@ETCDIR@@}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
51
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
52 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
53 #: Mapping configuration: installed package name -> original package name.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
54 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
55 #: Note:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
56 #: This is independent of any repo
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
57 #
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
58 : "${PACKAGE_MAPPING:=${CONFIGDIR}/package-mapping.conf}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
59
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
60 # shellcheck disable=SC1091 # does not exist -- cannot read
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
61 [ -r "${CONFIGDIR}/pkgtools.conf" ] && . "${CONFIGDIR}/pkgtools.conf"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
62
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
63
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
64 # no unset variables
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
65 set -u
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
66
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
67
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
68 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
69 #: Implementation of the "deptree" command.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
70 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
71 command_deptree() {
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
72 local opt_reversed opt_maxlevel opt_flat
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
73 # $@
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
74
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
75 local opt
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
76
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
77 opt_maxlevel=0
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
78 opt_reversed=no
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
79 opt_flat=no
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
80 while getopts "l:rt-:" opt; do
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
81 postprocess_getopts_for_long "l:rt-:" opt "maxlevel=" "reverse" "list" "transitive" ""
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
82 case "${opt}" in
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
83 l|maxlevel)
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
84 opt_maxlevel=$(($OPTARG + 0));;
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
85 r|reverse)
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
86 # shellcheck disable=SC2034
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
87 opt_reversed=yes;;
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
88 t|list|transitive)
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
89 opt_flat=yes;;
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
90 \?)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
91 exit 2;;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
92 *)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
93 fatal 2 "option handling failed";;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
94 esac
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
95 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
96 shift $((OPTIND-1))
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
97 OPTIND=1
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
98
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
99 if checkyesno opt_reversed; then
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
100 _command_deptree_reversed "${opt_maxlevel}" "${opt_flat}" "$@"
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
101 else
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
102 _command_deptree_normal "${opt_maxlevel}" "${opt_flat}" "$@"
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
103 fi
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
104 }
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
105
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
106
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
107 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
108 #: Implementation of printing a "normal" dependency tree
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
109 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
110 _command_deptree_normal() {
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
111 local maxlevel flat # $@
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
112
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
113 local pkgdeps pkgqueue curdeps pkg n v flatdeps
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
114
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
115 maxlevel="${1}"
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
116 flat="${2}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
117 shift 2
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
118
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
119 # shellcheck disable=SC2034 # pkgqueue seems unused
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
120 pkgqueue=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
121 farray_create pkgqueue # queue (array) of packages that are queued for
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
122 # resolution
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
123
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
124 for pkg in "$@"; do
788
7ca4a36e9e8d fports, ports.subr: Use the variable PKG as path to /usr/bin/pkg
Franz Glasner <fzglas.hg@dom66.de>
parents: 787
diff changeset
125 if ! "${PKG}" query '%n' "${pkg}" 1>/dev/null 2>/dev/null ; then
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
126 farray_release pkgqueue
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
127 fatal "${EX_DATAERR}" "Package not found: ${pkg}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
128 fi
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
129 farray_append pkgqueue "${pkg}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
130 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
131 pkgdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
132 falist_create pkgdeps # alist of packagges with its direct dependencies
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
133 while farray_pop pkg pkgqueue 1; do
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
134 if ! falist_contains pkgdeps "${pkg}"; then
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
135 curdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
136 farray_create curdeps
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
137 while IFS=$' \t\n' read -r n v; do
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
138 [ -z "${n}" ] || [ -z "${v}" ] && continue
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
139 farray_append curdeps "${n}=${v}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
140 farray_append pkgqueue "${n}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
141 done <<EOF_01a8cebe-8659-4e32-87a4-bbce117e386b
788
7ca4a36e9e8d fports, ports.subr: Use the variable PKG as path to /usr/bin/pkg
Franz Glasner <fzglas.hg@dom66.de>
parents: 787
diff changeset
142 $(LC_ALL=C.UTF-8 "${PKG}" query '%dn %dv' "${pkg}")
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
143 EOF_01a8cebe-8659-4e32-87a4-bbce117e386b
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
144 falist_set pkgdeps "${pkg}" "${curdeps}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
145 farray_release curdeps
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
146 curdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
147 fi
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
148 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
149 farray_release pkgqueue
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
150 # falist_debug pkgdeps
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
151 if checkyesno flat; then
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
152 for pkg in "$@"; do
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
153 _flatten_pkgdeps flatdeps "${pkgdeps}" "${pkg}"
788
7ca4a36e9e8d fports, ports.subr: Use the variable PKG as path to /usr/bin/pkg
Franz Glasner <fzglas.hg@dom66.de>
parents: 787
diff changeset
154 _print_flatdeps '-->' "${pkg}" "$(LC_ALL=C.UTF-8 "${PKG}" query '%v' "${pkg}")" "${flatdeps}"
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
155 falist_release "${flatdeps}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
156 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
157 else
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
158 for pkg in "$@"; do
788
7ca4a36e9e8d fports, ports.subr: Use the variable PKG as path to /usr/bin/pkg
Franz Glasner <fzglas.hg@dom66.de>
parents: 787
diff changeset
159 _print_dependency_tree 0 "${maxlevel}" '-->' "${pkg}" "$(LC_ALL=C.UTF-8 "${PKG}" query '%v' "${pkg}")" "${pkgdeps}"
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
160 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
161 fi
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
162 falist_release pkgdeps
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
163 }
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
164
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
165
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
166 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
167 #: Implementation of printing a reversed dependency tree
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
168 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
169 _command_deptree_reversed() {
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
170 local maxlevel flat # $@
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
171
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
172 local pkgdeps pkgqueue curdeps pkg n v flatdeps
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
173
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
174 maxlevel="${1}"
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
175 # shellcheck disable=SC2034 # appears unused
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
176 flat="${2}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
177 shift 2
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
178
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
179 # shellcheck disable=SC2034 # pkgqueue seems unused
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
180 pkgqueue=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
181 farray_create pkgqueue # queue (array) of packages that are queued for
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
182 # resolution
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
183
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
184 for pkg in "$@"; do
788
7ca4a36e9e8d fports, ports.subr: Use the variable PKG as path to /usr/bin/pkg
Franz Glasner <fzglas.hg@dom66.de>
parents: 787
diff changeset
185 if ! "${PKG}" query '%n' "${pkg}" 1>/dev/null 2>/dev/null ; then
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
186 farray_release pkgqueue
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
187 fatal "${EX_DATAERR}" "Package not found: ${pkg}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
188 fi
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
189 farray_append pkgqueue "${pkg}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
190 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
191 pkgdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
192 falist_create pkgdeps # alist of packagges with its direct dependencies
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
193 while farray_pop pkg pkgqueue 1; do
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
194 if ! falist_contains pkgdeps "${pkg}"; then
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
195 curdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
196 farray_create curdeps
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
197 while IFS=$' \t\n' read -r n v; do
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
198 [ -z "${n}" ] || [ -z "${v}" ] && continue
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
199 farray_append curdeps "${n}=${v}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
200 farray_append pkgqueue "${n}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
201 done <<EOF_5079e996-c6d2-4e6d-825d-53183a64ab06
788
7ca4a36e9e8d fports, ports.subr: Use the variable PKG as path to /usr/bin/pkg
Franz Glasner <fzglas.hg@dom66.de>
parents: 787
diff changeset
202 $(LC_ALL=C.UTF-8 "${PKG}" query '%rn %rv' "${pkg}")
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
203 EOF_5079e996-c6d2-4e6d-825d-53183a64ab06
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
204 falist_set pkgdeps "${pkg}" "${curdeps}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
205 farray_release curdeps
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
206 curdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
207 fi
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
208 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
209 farray_release pkgqueue
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
210 # falist_debug pkgdeps
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
211 if checkyesno flat; then
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
212 for pkg in "$@"; do
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
213 _flatten_pkgdeps flatdeps "${pkgdeps}" "${pkg}"
788
7ca4a36e9e8d fports, ports.subr: Use the variable PKG as path to /usr/bin/pkg
Franz Glasner <fzglas.hg@dom66.de>
parents: 787
diff changeset
214 _print_flatdeps '<--' "${pkg}" "$(LC_ALL=C.UTF-8 "${PKG}" query '%v' "${pkg}")" "${flatdeps}"
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
215 falist_release "${flatdeps}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
216 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
217 else
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
218 for pkg in "$@"; do
788
7ca4a36e9e8d fports, ports.subr: Use the variable PKG as path to /usr/bin/pkg
Franz Glasner <fzglas.hg@dom66.de>
parents: 787
diff changeset
219 _print_dependency_tree 0 "${maxlevel}" '<--' "${pkg}" "$(LC_ALL=C.UTF-8 "${PKG}" query '%v' "${pkg}")" "${pkgdeps}"
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
220 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
221 fi
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
222 falist_release pkgdeps
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
223 }
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
224
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
225
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
226 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
227 #: Internal helper to print an indented dependency list for a package.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
228 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
229 #: Args:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
230 #: $1 (int): The (indentation) level where a level of `0` is the root level
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
231 #: $2 (int): The maximum level (`$1`) to print to
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
232 #: $3 (str): The package tag to use to for non-root-levels
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
233 #: $4 (str): The package name
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
234 #: $5 (str): The package version
785
43cebff4ea0d fports: Fix typo in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 770
diff changeset
235 #: $6 (alist): The alist of resolved packages and their dependencies
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
236 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
237 _print_dependency_tree() {
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
238 # $1 $2 $3 $4 $5 $6
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
239
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
240 local i pkg ver curdeps
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
241
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
242 if [ "${2}" -ge 1 ]; then
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
243 [ "${1}" -gt "${2}" ] && return 0
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
244 fi
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
245
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
246 i="${1}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
247 while [ "${i}" -gt 1 ]; do
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
248 printf '%s' ' '
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
249 i=$((i - 1))
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
250 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
251 [ "${1}" -ne 0 ] && printf '%s ' "${3}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
252 printf '%s v%s\n' "${4}" "${5}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
253 falist_get curdeps "${6}" "${pkg}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
254 i=1
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
255 while farray_tryget pkg "${curdeps}" "${i}"; do
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
256 ver="${pkg#*=}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
257 pkg="${pkg%%=*}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
258 _print_dependency_tree $(($1 + 1)) "${2}" "${3}" "${pkg}" "${ver}" "${6}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
259 i=$((i + 1))
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
260 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
261 farray_release curdeps
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
262 }
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
263
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
264
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
265 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
266 #: Args:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
267 #: $1 (str): The package tag to use
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
268 #: $2 (str): The root package name
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
269 #: $3 (str): The package version of the root package in `$3`
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
270 #: $4 (alist): The alist of the flattened dependencies
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
271 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
272 _print_flatdeps() {
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
273 # $1 $2 $3 $4
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
274
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
275 local pkgnames i n v
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
276
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
277 printf '%s v%s\n' "${2}" "${3}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
278
787
004c676c3415 fports: Improve script help "-h" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 786
diff changeset
279 # shellcheck disable=SC2034 # appears unused
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
280 pkgnames=''
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
281 farray_create pkgnames
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
282 falist_keys pkgnames "$4"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
283 farray_sort pkgnames
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
284 i=1
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
285 while farray_tryget n pkgnames "${i}"; do
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
286 falist_get v "${4}" "${n}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
287 printf '%s %s v%s\n' "${1}" "${n}" "${v}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
288 i=$((i + 1))
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
289 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
290
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
291 farray_release pkgnames
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
292 }
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
293
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
294
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
295 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
296 #: Flatten a package dependency alist.
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
297 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
298 #: Args:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
299 #: $1 (str): The variable name where to store the flattened dependencies
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
300 #: into. This object (alist) must be released by the caller.
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
301 #: $2 (str): The alist with all packages and its dependencies
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
302 #: $3 (str): The package for which to flatten its dependencies
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
303 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
304 _flatten_pkgdeps() {
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
305 local pkgdeps rootpkg # and $1
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
306
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
307 local alldeps queue pkg curdeps i depname depver
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
308
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
309 pkgdeps="${2}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
310 rootpkg="${3}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
311
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
312 falist_contains pkgdeps "${rootpkg}" || fatal "${EX_SOFTWARE}" "given package \`${rootpkg}' not in the given package dependency map"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
313
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
314 queue=''
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
315 farray_create queue # array with package names to be flattened
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
316
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
317 farray_append queue "${rootpkg}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
318
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
319 alldeps=''
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
320 falist_create alldeps # alist with pkgname -> version
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
321 while farray_pop pkg queue 1; do
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
322 if ! falist_contains alldeps "${pkg}"; then
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
323 curdeps=''
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
324 falist_get curdeps pkgdeps "${pkg}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
325 i=1
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
326 while farray_tryget depname curdeps "${i}"; do
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
327 depver="${depname#*=}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
328 depname="${depname%%=*}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
329 if ! falist_contains alldeps "${depname}"; then
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
330 falist_set alldeps "${depname}" "${depver}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
331 fi
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
332 farray_append queue "${depname}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
333 i=$((i + 1))
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
334 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
335 farray_release curdeps
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
336 fi
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
337 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
338
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
339 farray_release "${queue}"
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
340
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
341 setvar "${1}" "${alldeps}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
342 }
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
343
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
344
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
345 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
346 #: Implementation of the "detail" command.
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
347 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
348 command_detail() {
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
349 local opt_noauto opt_mapped
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
350 # $@
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
351
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
352 local package \
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
353 repositories packagemapping instver instrepo \
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
354 repo title_printed indexfile _dummy opt acookie \
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
355 pkglabel pkgdescr pkgversion mapped_package
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
356
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
357 opt_noauto=no
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
358 opt_mapped=no
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
359 while getopts "nm-:" opt; do
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
360 postprocess_getopts_for_long "nm-:" opt "noauto" "no-auto" "mapped" ""
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
361 case "${opt}" in
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
362 n|noauto|no-auto)
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
363 # shellcheck disable=SC2034 # appears unused
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
364 opt_noauto=yes;;
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
365 m|mapped)
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
366 # shellcheck disable=SC2034 # appears unused
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
367 opt_mapped=yes;;
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
368 \?)
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
369 exit 2;;
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
370 *)
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
371 fatal 2 "option handling failed";;
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
372 esac
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
373 done
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
374 shift $((OPTIND-1))
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
375 OPTIND=1
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
376
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
377 if checkyesno opt_noauto || checkyesno opt_mapped; then
802
31ff8e5efdd6 fports: FIX: Typo "now" -> "not"
Franz Glasner <fzglas.hg@dom66.de>
parents: 801
diff changeset
378 [ $# -gt 0 ] && fatal "${EX_USAGE}" "packages are not allowed for options -n or -m"
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
379 if checkyesno opt_noauto && checkyesno opt_mapped; then
801
8167b2a8b4fe fports: Change option characters "-A" -> "-n" and "-M" -> "-m"
Franz Glasner <fzglas.hg@dom66.de>
parents: 800
diff changeset
380 fatal "${EX_USAGE}" "cannot use -n and -m together"
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
381 fi
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
382 fi
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
383
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
384 repositories=''
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
385 get_active_repositories repositories
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
386 packagemapping=''
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
387 init_package_mapping packagemapping
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
388 indexfile="$(get_local_index_file)"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
389
800
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
390 if checkyesno opt_noauto; then
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
391 for package in $(LC_ALL=C.UTF-8 "${PKG}" query -e '%a = 0' '%n'); do
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
392 _package_max_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}"
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
393 done
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
394 elif checkyesno opt_mapped; then
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
395 acookie="$(falist_cookie_first packagemapping)"
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
396 while falist_tryget_key_at package "${acookie}"; do
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
397 _package_max_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}"
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
398 acookie="$(falist_cookie_next "${acookie}")"
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
399 done
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
400 else
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
401 for package in "$@"; do
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
402 _package_max_detail "${package}" "${packagemapping}" "${repositories}" "${indexfile}"
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
403 done
1c4d729963dc fports: Implement "fports detail -A" and "fports detail -M".
Franz Glasner <fzglas.hg@dom66.de>
parents: 799
diff changeset
404 fi
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
405
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
406 falist_release "${packagemapping}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
407 farray_release "${repositories}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
408 }
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
409
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
410
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
411 #:
797
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
412 #: Implementation of printing the most details possible for a package.
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
413 #:
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
414 #: Implements all the repeating stuff for a package for e.g. `command_detail`.
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
415 #:
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
416 #: Args:
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
417 #: $1 (str): The name of the package
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
418 #: $2 (alist): The
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
419 #: $3 (array): The array with all the configured/active repositories
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
420 #: $4 (str, null): The local index file if it exists
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
421 #:
799
96631c3886d9 fports: Rename _package_detail() to _package_max_detail()
Franz Glasner <fzglas.hg@dom66.de>
parents: 798
diff changeset
422 _package_max_detail() {
797
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
423 local package packagemapping repositories indexfile
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
424
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
425 local instver instrepo repo title_printed _dummy \
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
426 pkglabel pkgdescr pkgversion mapped_package
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
427
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
428 package="${1}"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
429 packagemapping="${2}"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
430 repositories="${3}"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
431 indexfile="${4}"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
432
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
433 # shellcheck disable=SC2034 # appears unused
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
434 title_printed=no
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
435 IFS='|' read -r instver instrepo <<EOF_e9bd7819-b4c5-4a86-b984-f5226db58cb1
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
436 $(LC_ALL=C.UTF-8 "${PKG}" query '%v|%R' "${package}")
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
437 EOF_e9bd7819-b4c5-4a86-b984-f5226db58cb1
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
438 print_title title_printed "${package}" "${instver}" "${instrepo}"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
439 if [ -n "${indexfile}" ]; then
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
440 read -r _dummy pkglabel pkgdescr <<EOF_b1f225bd-d234-4a23-8a2a-40c2e5b7ff3c
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
441 $(LC_ALL=C.UTF-8 "${PKG}" version -U -I -n "${package}" -v "${indexfile}")
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
442 EOF_b1f225bd-d234-4a23-8a2a-40c2e5b7ff3c
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
443 pkgversion="$(parse_index_file_for_package_version "${indexfile}" "${package}")"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
444 print_detail_item "INDEX" "${pkgversion}" "${pkglabel}" "${pkgdescr}"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
445 fi
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
446 farray_for_each repositories _package_repository_detail "${package}" 0
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
447 mapped_package="$(get_package_mapping "${packagemapping}" "${package}")"
798
e48b38cf7bb1 fports: FIX: Remove debug setting with regard to mapped packages
Franz Glasner <fzglas.hg@dom66.de>
parents: 797
diff changeset
448 if [ -n "${mapped_package}" ]; then
797
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
449 printf '%18s %s\n' "--------------->" "${mapped_package}"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
450 if [ -n "${indexfile}" ]; then
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
451 pkgversion="$(parse_index_file_for_package_version "${indexfile}" "${mapped_package}")"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
452 pkglabel="$(LC_ALL=C.UTF-8 "${PKG}" version --test-version "${instver}" "${pkgversion}")"
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
453 print_detail_item "INDEX" "${pkgversion}" "${pkglabel}" '' 19
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
454 fi
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
455 farray_for_each repositories _mapped_package_repository_detail "${mapped_package}" "{instver}" 19
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
456 fi
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
457 }
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
458
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
459
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
460 #:
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
461 #: Array callback to print package details with regard to a repository.
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
462 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
463 #: Args:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
464 #: $1 (str): The repositories array
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
465 #: $2 (int): The current index
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
466 #: $3: The element value (i.e. repository name)
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
467 #: $4 (str): The (master) package name
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
468 #: $5 (int): The extra indent value to forward to called functions
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
469 #:
797
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
470 _package_repository_detail() {
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
471 local repositories idx reponame package extraindent
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
472
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
473 local _dummy \
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
474 pkglabel pkgdescr pkgversion
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
475
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
476 repositories="${1}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
477 # shellcheck disable=SC2034 # appears unused (yes, accept it)
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
478 idx="${2}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
479 reponame="${3}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
480 package="${4}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
481 extraindent="${5:-0}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
482
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
483 read -r _dummy pkglabel pkgdescr <<EOF_19cf2d80-4eb9-4cda-bd4d-96b04e769206
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
484 $(LC_ALL=C.UTF-8 "${PKG}" version -U -R -r "${reponame}" -n "${package}" -v)
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
485 EOF_19cf2d80-4eb9-4cda-bd4d-96b04e769206
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
486 pkgversion="$(LC_ALL=C.UTF-8 "${PKG}" rquery -U -r "${reponame}" '%v' "${package}")"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
487 print_detail_item "${reponame}" "${pkgversion}" "${pkglabel}" "${pkgdescr}" "${extraindent}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
488 }
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
489
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
490
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
491 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
492 #: Array callback to print package details for a mapped package with regard
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
493 #: to a repository.
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
494 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
495 #: Args:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
496 #: $1 (str): The repositories array
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
497 #: $2 (int): The current index
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
498 #: $3: The element value (i.e. repository name)
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
499 #: $4 (str): The mapped package name
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
500 #: $5 (str): The parent package version
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
501 #: $6 (int): The extra indent value to forward to called functions
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
502 #:
797
7f64b4420703 fports: Refactor: split up command_detail(): make a function that is called for each package
Franz Glasner <fzglas.hg@dom66.de>
parents: 796
diff changeset
503 _mapped_package_repository_detail() {
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
504 local repositories idx reponame package parent_pkgversion extraindent
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
505
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
506 local _dummy \
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
507 pkglabel pkgversion
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
508
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
509 repositories="${1}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
510 # shellcheck disable=SC2034 # appears unused (yes, accept it)
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
511 idx="${2}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
512 reponame="${3}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
513 package="${4}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
514 parent_pkgversion="${5}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
515 extraindent="${6:-0}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
516
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
517 pkgversion="$(LC_ALL=C.UTF-8 "${PKG}" rquery -U -r "${reponame}" '%v' "${package}")"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
518 pkglabel="$(LC_ALL=C.UTF-8 "${PKG}" version --test-version "${parent_pkgversion}" "${pkgversion}")"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
519 print_detail_item "${reponame}" "${pkgversion}" "${pkglabel}" '' "${extraindent}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
520 }
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
521
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
522
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
523 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
524 #: Print the output title line for a package.
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
525 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
526 #: Args:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
527 #: $1 (str): The name of the variable where to get or store the flag
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
528 #: whether the title for the package in `$2` has already been
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
529 #: printed.
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
530 #: $2 (str): The package name
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
531 #: $3 (str): The package version
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
532 #: $4 (str): The repository name from which the package has been installed
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
533 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
534 #: Output (stdout):
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
535 #: The formatted title line
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
536 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
537 print_title() {
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
538 local varname_title_printed package version repo
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
539
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
540 varname_title_printed="${1}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
541 package="${2}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
542 version="${3}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
543 repo="${4}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
544
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
545 if ! checkyes "${varname_title_printed}"; then
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
546 if [ -n "${version}" ]; then
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
547 # The package is installed
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
548 printf '%-36s %-17s (%s)\n' "${package}" "${version}" "${repo}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
549 else
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
550 # The package is not installed
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
551 printf '%-36s NOT INSTALLED\n' "${package}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
552 fi
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
553 setvar "${varname_title_printed}" 'yes'
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
554 fi
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
555 }
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
556
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
557
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
558 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
559 #: Print a detail item to stdout.
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
560 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
561 #: The description `_descr` will not be printed if the label `_label`
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
562 #: is ``?``.
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
563 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
564 #: Args:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
565 #: $1 (str): The repository name
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
566 #: $2 (str): The version number to print to
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
567 #: $3 (str): The label (aka comparison character) to print to
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
568 #: $4 (str): The description to print to
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
569 #: $5 (int, optional): The extra indentation to use. (Default 0)
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
570 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
571 #: Output (stdout):
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
572 #: The formatted detail line
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
573 #:
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
574 print_detail_item() {
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
575 local repo version label descr indent
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
576
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
577 local real_descr
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
578
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
579 repo="${1}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
580 version="${2}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
581 label="${3}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
582 descr="${4}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
583 indent="${5:-0}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
584
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
585 if [ "${label}" = '?' ]; then
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
586 real_descr=''
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
587 else
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
588 real_descr="${descr}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
589 fi
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
590
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
591 printf '%-*s %-15s: %-17s %s %s\n' $((indent)) '' "${repo}" "${version}" "${label}" "${real_descr}"
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
592 }
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
593
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
594
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
595 #
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
596 # Global option handling
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
597 #
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
598 while getopts "Vh-:" _opt ; do
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
599 postprocess_getopts_for_long "Vh-:" _opt "version" "help" ""
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
600 case "${_opt}" in
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
601 V|version)
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
602 printf 'fports %s\n' '@@SIMPLEVERSIONSTR@@'
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
603 exit 0
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
604 ;;
804
f406b3b76b62 fports: Implemented also long commandline options
Franz Glasner <fzglas.hg@dom66.de>
parents: 802
diff changeset
605 h|help)
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
606 echo "${USAGE}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
607 exit 0
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
608 ;;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
609 \?)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
610 exit 2;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
611 ;;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
612 *)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
613 fatal 2 "option handling failed"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
614 ;;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
615 esac
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
616 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
617
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
618 #
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
619 # Reset the Shell's option handling system to prepare for handling
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
620 # command-local options.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
621 #
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
622 shift $((OPTIND-1))
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
623 OPTIND=1
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
624
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
625 command="${1-}"
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
626 shift
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
627
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
628 case "${command}" in
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
629 '') fatal 2 "no command given";;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
630 deptree)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
631 command_deptree "$@";;
796
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
632 detail)
e48d173534ec fports: Implement "fports detail" to print the status of all given packages in the most detail possible
Franz Glasner <fzglas.hg@dom66.de>
parents: 788
diff changeset
633 command_detail "$@";;
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
634 *)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
635 fatal 2 "unknown command \`${command}'";;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
636 esac