Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
annotate sbin/fports @ 786:b78815b47d5e
fports: deptree has now an option to print a flattened tree.
The flattened tree is the transitive closure of all dependencies.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 29 Oct 2024 11:03:22 +0100 |
| parents | 43cebff4ea0d |
| children | 004c676c3415 |
| 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=' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
24 USAGE: fports [ GLOBAL-OPTIONS ] COMMAND [ COMMAND-OPTIONS ] |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
25 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
26 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
|
27 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
28 -V Print the program name and version number to stdout and exit |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
29 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
30 -h Print this help message to stdout and exit |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
31 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
32 ' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
33 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
34 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
35 _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
|
36 [ "${_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
|
37 . "${_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
|
38 . "${_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
|
39 . "${_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
|
40 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
41 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
42 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
43 #: 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
|
44 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
45 : "${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
|
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 #: 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
|
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 #: Note: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
51 #: 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
|
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 : "${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
|
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 # 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
|
56 [ -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
|
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 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
59 # 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
|
60 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
|
61 |
|
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 #: 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
|
65 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
66 command_deptree() { |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
67 local opt 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
|
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 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
70 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
|
71 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
|
72 opt_flat=no |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
73 while getopts "l:rt" opt; do |
|
770
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
74 case "${opt}" in |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
75 l) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
76 opt_maxlevel=$(($OPTARG + 0));; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
77 r) |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
78 # 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
|
79 opt_reversed=yes;; |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
80 t) |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
81 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
|
82 \?) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
83 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
|
84 *) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
85 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
|
86 esac |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
87 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
88 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
|
89 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
|
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 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
|
92 _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
|
93 else |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
94 _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
|
95 fi |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
96 } |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
97 |
|
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 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
100 #: 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
|
101 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
102 _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
|
103 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
|
104 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
105 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
|
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 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
|
108 flat="${2}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
109 shift 2 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
110 |
|
770
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
111 # 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
|
112 pkgqueue='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
113 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
|
114 # resolution |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
115 |
|
770
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
116 for pkg in "$@"; do |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
117 if ! pkg query '%n' "${pkg}" 1>/dev/null 2>/dev/null ; then |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
118 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
|
119 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
|
120 fi |
|
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_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
|
122 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
123 pkgdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
124 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
|
125 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
|
126 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
|
127 curdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
128 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
|
129 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
|
130 [ -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
|
131 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
|
132 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
|
133 done <<EOF_01a8cebe-8659-4e32-87a4-bbce117e386b |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
134 $(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
|
135 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
|
136 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
|
137 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
|
138 curdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
139 fi |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
140 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
141 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
|
142 # 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
|
143 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
|
144 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
|
145 _flatten_pkgdeps flatdeps "${pkgdeps}" "${pkg}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
146 _print_flatdeps '-->' "${pkg}" "$(LC_ALL=C.UTF-8 pkg query '%v' "${pkg}")" "${flatdeps}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
147 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
|
148 done |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
149 else |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
150 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
|
151 _print_dependency_tree 0 "${maxlevel}" '-->' "${pkg}" "$(LC_ALL=C.UTF-8 pkg query '%v' "${pkg}")" "${pkgdeps}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
152 done |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
153 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
|
154 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
|
155 } |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
156 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
157 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
158 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
159 #: 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
|
160 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
161 _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
|
162 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
|
163 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
164 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
|
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 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
|
167 # 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
|
168 flat="${2}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
169 shift 2 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
170 |
|
770
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
171 # 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
|
172 pkgqueue='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
173 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
|
174 # resolution |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
175 |
|
770
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
176 for pkg in "$@"; do |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
177 if ! pkg query '%n' "${pkg}" 1>/dev/null 2>/dev/null ; then |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
178 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
|
179 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
|
180 fi |
|
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_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
|
182 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
183 pkgdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
184 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
|
185 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
|
186 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
|
187 curdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
188 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
|
189 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
|
190 [ -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
|
191 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
|
192 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
|
193 done <<EOF_5079e996-c6d2-4e6d-825d-53183a64ab06 |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
194 $(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
|
195 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
|
196 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
|
197 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
|
198 curdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
199 fi |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
200 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
201 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
|
202 # 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
|
203 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
|
204 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
|
205 _flatten_pkgdeps flatdeps "${pkgdeps}" "${pkg}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
206 _print_flatdeps '<--' "${pkg}" "$(LC_ALL=C.UTF-8 pkg query '%v' "${pkg}")" "${flatdeps}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
207 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
|
208 done |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
209 else |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
210 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
|
211 _print_dependency_tree 0 "${maxlevel}" '<--' "${pkg}" "$(LC_ALL=C.UTF-8 pkg query '%v' "${pkg}")" "${pkgdeps}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
212 done |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
213 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
|
214 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
|
215 } |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
216 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
217 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
218 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
219 #: 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
|
220 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
221 #: Args: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
222 #: $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
|
223 #: $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
|
224 #: $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
|
225 #: $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
|
226 #: $5 (str): The package version |
|
785
43cebff4ea0d
fports: Fix typo in docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
770
diff
changeset
|
227 #: $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
|
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 _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
|
230 # $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
|
231 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
232 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
|
233 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
234 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
|
235 [ "${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
|
236 fi |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
237 |
|
770
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
238 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
|
239 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
|
240 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
|
241 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
|
242 done |
|
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}" -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
|
244 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
|
245 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
|
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 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
|
248 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
|
249 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
|
250 _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
|
251 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
|
252 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
253 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
|
254 } |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
255 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
256 |
|
786
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
257 #: |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
258 #: Args: |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
259 #: $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
|
260 #: $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
|
261 #: $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
|
262 #: $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
|
263 #: |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
264 _print_flatdeps() { |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
265 # $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
|
266 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
267 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
|
268 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
269 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
|
270 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
271 pkgnames='' |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
272 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
|
273 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
|
274 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
|
275 i=1 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
276 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
|
277 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
|
278 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
|
279 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
|
280 done |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
281 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
282 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
|
283 } |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
284 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
285 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
286 #: |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
287 #: 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
|
288 #: |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
289 #: Args: |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
290 #: $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
|
291 #: 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
|
292 #: $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
|
293 #: $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
|
294 #: |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
295 _flatten_pkgdeps() { |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
296 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
|
297 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
298 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
|
299 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
300 pkgdeps="${2}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
301 rootpkg="${3}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
302 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
303 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
|
304 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
305 # 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
|
306 queue='' |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
307 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
|
308 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
309 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
|
310 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
311 alldeps='' |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
312 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
|
313 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
|
314 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
|
315 curdeps='' |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
316 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
|
317 i=1 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
318 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
|
319 depver="${depname#*=}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
320 depname="${depname%%=*}" |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
321 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
|
322 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
|
323 fi |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
324 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
|
325 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
|
326 done |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
327 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
|
328 fi |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
329 done |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
330 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
331 farray_release queue |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
332 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
333 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
|
334 } |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
335 |
|
b78815b47d5e
fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents:
785
diff
changeset
|
336 |
|
770
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
337 # |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
338 # 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
|
339 # |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
340 while getopts "Vh" _opt ; do |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
341 case "${_opt}" in |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
342 V) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
343 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
|
344 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
|
345 ;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
346 h) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
347 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
|
348 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
|
349 ;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
350 \?) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
351 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
|
352 ;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
353 *) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
354 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
|
355 ;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
356 esac |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
357 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
358 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
359 # |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
360 # 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
|
361 # 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
|
362 # |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
363 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
|
364 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
|
365 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
366 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
|
367 shift |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
368 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
369 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
|
370 '') 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
|
371 deptree) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
372 command_deptree "$@";; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
373 *) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
374 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
|
375 esac |
