blob: 567486f9a8fb77f6df06b471318f285663c4fa88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#!/hint/bash
# Copyright (C) 2009-2010, 2016 Luke Shumaker
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.
# If not, see <http://www.gnu.org/licenses>.
m4_include(config.sh)
#
_() {
if type gettext &>/dev/null; then
TEXTDOMAINDIR=$localedir gettext "$pkgtextdomain" "$1";
else
printf '%s' "$1";
fi
}
# variables:
# - usage[]
# - desc
# - doc (optional)
usage() {
local form
local pfix1="$(_ 'Usage:')"
local pfix2="$(_ ' Or:')"
local pfix="pfix1"
for form in "${usage[@]}"; do
printf '%s %q %q %s\n' "$pfix" "$RVS" "$form"
pfix="$pfix2"
done
printf '%s\n' "$(_ "$desc")"
if [[ -n "$doc" ]] && [[ "$volume" != '-q' ]]; then
printf '\n\n%s\n' "$(_ "$doc")"
fi
}
# variables:
# - name
# - ver
# - copyright
# - license
# - volume
version() {
declare -A license_name
license_name['GPLv1']='GNU GPL version 1'
license_name['GPLv1+']='GNU GPL version 1 or later'
license_name['GPLv2']='GNU GPL version 2'
license_name['GPLv2+']='GNU GPL version 2 or later'
license_name['GPLv3']='GNU GPL version 3'
license_name['GPLv3+']='GNU GPL version 3 or later'
license_name['LGPLv2']='GNU Library GPL version 2'
license_name['LGPLv2+']='GNU Library GPL version 2 or later'
license_name['LGPLv2.1']='GNU Lesser GPL version 2.1'
license_name['LGPLv2.1+']='GNU Lesser GPL version 2.1 or later'
license_name['LGPLv3']='GNU Lesser GPL version 3'
license_name['LGPLv3+']='GNU Lesser GPL version 3 or later'
licensE_name['AGPLv3']='GNU Affero GPL version 3'
licensE_name['AGPLv3+']='GNU Affero GPL version 3 or later'
declare -A license_url
license_url['GPLv2']='https://gnu.org/licenses/old-licenses/gpl-1.0.html'
license_url['GPLv2']='https://gnu.org/licenses/old-licenses/gpl-2.0.html'
license_url['GPLv3']='https://gnu.org/licenses/gpl.html'
license_url['LGPLv2']='https://gnu.org/licenses/old-licenses/lgpl-2.0.html'
license_url['LGPLv2.1']='https://gnu.org/licenses/old-licenses/lgpl-2.1.html'
license_url['LGPLv3']='https://gnu.org/licenses/lgpl.html'
license_url['AGPLv3']='https://gnu.org/licenses/agpl.html'
printf "$(_ '%s (RVS) %s\n')" "$name" "$ver"
if [ "$volume" != '-q' ]; then
printf "$(_ 'Copyright (C) %s\n')" "${copyright[@]}"
local url="${license_url[$license]}"
if [[ -z "$url" ]]; then
url="${license_url[${license%+}]}"
fi
printf "$(_ 'License %s: %s <%s>.\n')" "$license" "${license_name[$license]}" "$url"
printf "$(_ \
'This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extend permitted by law.
')"
if [[ -z "$author" ]] && [[ "${#copyright[@]}" -eq 1 ]]; then
printf -v author "$(_ 'Originally written by %s.')" "$(sed 's/^[0-9, -]*//' <<<"${copyright[0]}")"
fi
if [[ -n "$author" ]]; then
printf '%s\n' "$author"
fi
fi
}
verbose() {
if [ "$volume" == '-v' ]; then
printf "$(_ "$1")\n" "${@:2}" >&2
fi
}
out() {
if [ "$volume" != '-q' ]; then
printf "$(_ "$1")\n" "${@:2}" >&2
fi
}
warn() {
printf "$name: $(_ "$1")\n" "${@:2}" >&2
}
error() {
warn "$@"
exit 1
}
errusage() {
if [[ $# -gt 0 ]]; then
warn "$@"
fi
volume='-q'
usage >&2
exit 1
}
|