annotate sbin/fports @ 787:004c676c3415

fports: Improve script help "-h" somewhat
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 29 Oct 2024 11:07:36 +0100
parents b78815b47d5e
children 7ca4a36e9e8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 #!/bin/sh
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2 # -*- indent-tabs-mode: nil; -*-
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
3 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4 #: Check the version status of installed ports and compare them to
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5 #: version in remote repositories and the local ports index.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
7 #: :Author: Franz Glasner
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8 #: :Copyright: (c) 2017-2024 Franz Glasner.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 #: All rights reserved.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 #: :License: BSD 3-Clause "New" or "Revised" License.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
11 #: See LICENSE for details.
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 #: If you cannot find LICENSE see
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13 #: <https://opensource.org/licenses/BSD-3-Clause>
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
14 #: :ID: @(#)@@SIMPLEVERSIONTAG@@
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17 : # separator for shellcheck: no module-level directives below
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
19 # shellcheck disable=SC2034 # VERSION appears unused
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
20 VERSION='@@VERSION@@'
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22 # shellcheck disable=SC2016 # no expansion
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 USAGE='
787
004c676c3415 fports: Improve script help "-h" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 786
diff changeset
24 USAGE: fports -h
004c676c3415 fports: Improve script help "-h" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 786
diff changeset
25 fports -V
004c676c3415 fports: Improve script help "-h" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 786
diff changeset
26 fports deptree [-l maxlevel] [-r] [-t] package...
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
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 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
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 -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
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 -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
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
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
36
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
37 _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
38 [ "${_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
39 . "${_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
40 . "${_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
41 . "${_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
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
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 #: 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
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 : "${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
48
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 #: 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
51 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
52 #: Note:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
53 #: 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
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 : "${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
56
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
57 # 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
58 [ -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
59
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
60
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
61 # 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
62 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
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
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 #: 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
67 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
68 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
69 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
70 # $@
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
71
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
72 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
73 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
74 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
75 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
76 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
77 l)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
78 opt_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
79 r)
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
80 # 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
81 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
82 t)
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
83 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
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 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
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 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
88 esac
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
89 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
90 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
91 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
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 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
94 _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
95 else
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
96 _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
97 fi
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
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 #: 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
103 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
104 _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
105 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
106
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
107 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
108
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
109 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
110 flat="${2}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
111 shift 2
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
112
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
113 # 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
114 pkgqueue=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
115 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
116 # resolution
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
117
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
118 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
119 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
120 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
121 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
122 fi
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_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
124 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
125 pkgdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
126 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
127 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
128 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
129 curdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
130 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
131 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
132 [ -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
133 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
134 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
135 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
136 $(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
137 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
138 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
139 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
140 curdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
141 fi
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
142 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
143 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
144 # 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
145 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
146 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
147 _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
148 _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
149 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
150 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
151 else
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
152 for pkg in "$@"; do
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
153 _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
154 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
155 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
156 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
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
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 #: 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
162 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
163 _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
164 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
165
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
166 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
167
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
168 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
169 # 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
170 flat="${2}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
171 shift 2
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
172
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
173 # 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
174 pkgqueue=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
175 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
176 # resolution
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
177
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
178 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
179 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
180 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
181 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
182 fi
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
183 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
184 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
185 pkgdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
186 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
187 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
188 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
189 curdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
190 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
191 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
192 [ -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
193 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
194 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
195 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
196 $(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
197 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
198 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
199 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
200 curdeps=''
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
201 fi
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
202 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
203 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
204 # 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
205 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
206 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
207 _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
208 _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
209 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
210 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
211 else
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
212 for pkg in "$@"; do
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
213 _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
214 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
215 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
216 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
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
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 #: 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
222 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
223 #: Args:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
224 #: $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
225 #: $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
226 #: $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
227 #: $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
228 #: $5 (str): The package version
785
43cebff4ea0d fports: Fix typo in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 770
diff changeset
229 #: $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
230 #:
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
231 _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
232 # $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
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 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
235
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
236 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
237 [ "${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
238 fi
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
239
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
240 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
241 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
242 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
243 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
244 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
245 [ "${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
246 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
247 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
248 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
249 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
250 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
251 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
252 _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
253 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
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 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
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
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
258
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
259 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
260 #: Args:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
261 #: $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
262 #: $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
263 #: $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
264 #: $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
265 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
266 _print_flatdeps() {
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
267 # $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
268
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
269 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
270
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
271 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
272
787
004c676c3415 fports: Improve script help "-h" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 786
diff changeset
273 # shellcheck disable=SC2034 # appears unused
786
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
274 pkgnames=''
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
275 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
276 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
277 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
278 i=1
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
279 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
280 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
281 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
282 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
283 done
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 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
286 }
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
287
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 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
290 #: 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
291 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
292 #: Args:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
293 #: $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
294 #: 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
295 #: $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
296 #: $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
297 #:
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
298 _flatten_pkgdeps() {
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
299 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
300
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
301 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
302
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
303 pkgdeps="${2}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
304 rootpkg="${3}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
305
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
306 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
307
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
308 # 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
309 queue=''
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
310 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
311
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
312 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
313
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
314 alldeps=''
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
315 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
316 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
317 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
318 curdeps=''
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
319 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
320 i=1
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
321 while farray_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
322 depver="${depname#*=}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
323 depname="${depname%%=*}"
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
324 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
325 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
326 fi
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
327 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
328 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
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 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
331 fi
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
332 done
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
333
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
334 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
335
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
336 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
337 }
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
338
b78815b47d5e fports: deptree has now an option to print a flattened tree.
Franz Glasner <fzglas.hg@dom66.de>
parents: 785
diff changeset
339
770
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
340 #
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
341 # 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
342 #
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
343 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
344 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
345 V)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
346 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
347 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
348 ;;
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
349 h)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
350 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
351 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
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 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
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 *)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
357 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
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 esac
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
360 done
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
361
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 # 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
364 # 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
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 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
367 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
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 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
370 shift
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
371
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
372 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
373 '') 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
374 deptree)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
375 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
376 *)
56ab5c012d5f fports: Begin a new command "fports" and fully implemented its subcommand "fports deptree".
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
377 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
378 esac