Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
annotate sbin/fports @ 785:43cebff4ea0d
fports: Fix typo in docs
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 28 Oct 2024 14:41:15 +0100 |
| parents | 56ab5c012d5f |
| children | b78815b47d5e |
| 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() { |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
67 local opt opt_reversed opt_maxlevel |
|
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 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
72 while getopts "l:r" 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
|
73 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
|
74 l) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
75 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
|
76 r) |
|
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_reversed=yes;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
78 \?) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
79 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
|
80 *) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
81 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
|
82 esac |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
83 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
84 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
|
85 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
|
86 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
87 if checkyesno opt_reversed; then |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
88 _command_deptree_reversed "${opt_maxlevel}" "$@" |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
89 else |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
90 _command_deptree_normal "${opt_maxlevel}" "$@" |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
91 fi |
|
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 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
94 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
95 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
96 #: 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
|
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 _command_deptree_normal() { |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
99 local maxlevel # $@ |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
100 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
101 local pkgdeps pkgqueue curdeps pkg 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
|
102 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
103 maxlevel="${1}" |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
104 shift |
|
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 # 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
|
107 pkgqueue='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
108 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
|
109 # resolution |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
110 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
111 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
|
112 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
|
113 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
|
114 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
|
115 fi |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
116 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
|
117 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
118 pkgdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 curdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
123 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
|
124 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
|
125 [ -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
|
126 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
|
127 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
|
128 done <<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
|
129 $(LC_ALL=C.UTF-8 pkg query '%dn %dv' "${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 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
|
131 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
|
132 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
|
133 curdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
134 fi |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
135 done |
|
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_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
|
137 # falist_debug pkgdeps |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
138 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
|
139 _print_dependency_tree 0 "${maxlevel}" '-->' "${pkg}" "$(LC_ALL=C.UTF-8 pkg query '%v' "${pkg}")" "${pkgdeps}" |
|
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 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
|
142 } |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
143 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
144 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
145 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
146 #: 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
|
147 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
148 _command_deptree_reversed() { |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
149 local maxlevel # $@ |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
150 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
151 local pkgdeps pkgqueue curdeps pkg 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
|
152 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
153 maxlevel="${1}" |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
154 shift |
|
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 # 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
|
157 pkgqueue='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
158 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
|
159 # resolution |
|
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 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
|
162 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
|
163 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
|
164 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
|
165 fi |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
166 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
|
167 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
168 pkgdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 curdeps='' |
|
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 curdeps |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
174 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
|
175 [ -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
|
176 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
|
177 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
|
178 done <<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
|
179 $(LC_ALL=C.UTF-8 pkg query '%rn %rv' "${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 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
|
181 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
|
182 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
|
183 curdeps='' |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
184 fi |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
185 done |
|
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 # falist_debug pkgdeps |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
188 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
|
189 _print_dependency_tree 0 "${maxlevel}" '<--' "${pkg}" "$(LC_ALL=C.UTF-8 pkg query '%v' "${pkg}")" "${pkgdeps}" |
|
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 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
|
192 } |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
193 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
194 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
195 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
196 #: 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
|
197 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
198 #: Args: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
199 #: $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
|
200 #: $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
|
201 #: $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
|
202 #: $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
|
203 #: $5 (str): The package version |
|
785
43cebff4ea0d
fports: Fix typo in docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
770
diff
changeset
|
204 #: $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
|
205 #: |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
206 _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
|
207 # $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
|
208 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
209 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
|
210 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
211 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
|
212 [ "${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
|
213 fi |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
214 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
215 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
|
216 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
|
217 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
|
218 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
|
219 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
220 [ "${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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 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
|
227 _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
|
228 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
|
229 done |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
230 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
|
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 |
|
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 # |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
235 # 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
|
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 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
|
238 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
|
239 V) |
|
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 '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
|
241 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
|
242 ;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
243 h) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
244 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
|
245 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
|
246 ;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
247 \?) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
248 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
|
249 ;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
250 *) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
251 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
|
252 ;; |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
253 esac |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
254 done |
|
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 # |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
257 # 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
|
258 # 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
|
259 # |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
260 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
|
261 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
|
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 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
|
264 shift |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
265 |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
266 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
|
267 '') 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
|
268 deptree) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
269 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
|
270 *) |
|
56ab5c012d5f
fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
271 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
|
272 esac |
