]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - usr.sbin/bsdconfig/share/packages/categories.subr
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / usr.sbin / bsdconfig / share / packages / categories.subr
1 if [ ! "$_PACKAGES_CATEGORIES_SUBR" ]; then _PACKAGES_CATEGORIES_SUBR=1
2 #
3 # Copyright (c) 2013 Devin Teske
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 #    notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 #    notice, this list of conditions and the following disclaimer in the
13 #    documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 # SUCH DAMAGE.
26 #
27 # $FreeBSD$
28 #
29 ############################################################ INCLUDES
30
31 BSDCFG_SHARE="/usr/share/bsdconfig"
32 . $BSDCFG_SHARE/common.subr || exit 1
33 f_dprintf "%s: loading includes..." packages/categories.subr
34 f_include $BSDCFG_SHARE/strings.subr
35
36 BSDCFG_LIBE="/usr/libexec/bsdconfig"
37 f_include_lang $BSDCFG_LIBE/include/messages.subr
38
39 ############################################################ GLOBALS
40
41 CATEGORIES=
42
43 ############################################################ FUNCTIONS
44
45 # f_category_desc_get $category [$var_to_set]
46 #
47 # Fetch the description of a given category. Returns success if a match was
48 # found, otherwise failure.
49 #
50 # If $var_to_set is missing or NULL, the category description is printed to
51 # standard out for capturing in a sub-shell (which is less-recommended because
52 # of performance degredation; for example, when called in a loop).
53 #
54 f_category_desc_get()
55 {
56         local __category="$1" __var_to_set="$2" __cat __varcat
57
58         # Return failure if $category
59         [ "$__category" ] || return $FAILURE
60
61         for __cat in $CATEGORIES; do
62                 [ "$__cat" = "$__category" ] || continue
63                 f_str2varname $__cat __varcat
64                 f_getvar _category_$__varcat $__var_to_set
65                 return $?
66         done
67         return $FAILURE
68 }
69
70 # f_category_desc_set $category $desc
71 #
72 # Store a description in-association with a category. $category should be
73 # alphanumeric and can include the underscore [_] but should not contain
74 # whitespace. Returns success unless $category is NULL or no arguments. Use the
75 # f_category_desc_get() routine with the same $category to retrieve the stored
76 # description.
77 #
78 f_category_desc_set()
79 {
80         local category="$1" desc="$2"
81         local cat varcat found=
82         [ "$category" ] || return $FAILURE
83         for cat in $CATEGORIES; do
84                 [ "$cat" = "$category" ] || continue
85                 f_str2varname $cat varcat
86                 f_isset _category_$varcat || continue
87                 found=1 && break
88         done
89         if [ ! "$found" ]; then
90                 CATEGORIES="$CATEGORIES $category"
91         fi
92         f_str2varname $category varcat
93         setvar "_category_$varcat" "$desc"
94         # Export the variable for awk(1) ENVIRON visibility
95         export "_category_$varcat"
96         return $SUCCESS
97 }
98
99 ############################################################ MAIN
100
101 #
102 # Load descriptions for package categories. Note that we don't internationalize
103 # category names because this would be confusing for people used to browsing
104 # the FTP mirrors or are otherwise familiar with an interface that does not
105 # provide internationalized names. The descriptions can be used to provide i18n
106 # users a description of the non-i18n category name.
107 #
108 f_category() { f_category_desc_set "$1" "$2"; }
109 f_category All           "$msg_all_desc"
110 f_category accessibility "$msg_accessibility_desc"
111 f_category afterstep     "$msg_afterstep_desc"
112 f_category arabic        "$msg_arabic_desc"
113 f_category archivers     "$msg_archivers_desc"
114 f_category astro         "$msg_astro_desc"
115 f_category audio         "$msg_audio_desc"
116 f_category benchmarks    "$msg_benchmarks_desc"
117 f_category biology       "$msg_biology_desc"
118 f_category cad           "$msg_cad_desc"
119 f_category chinese       "$msg_chinese_desc"
120 f_category comms         "$msg_comms_desc"
121 f_category converters    "$msg_converters_desc"
122 f_category databases     "$msg_databases_desc"
123 f_category deskutils     "$msg_deskutils_desc"
124 f_category devel         "$msg_devel_desc"
125 f_category dns           "$msg_dns_desc"
126 f_category docs          "$msg_docs_desc"
127 f_category editors       "$msg_editors_desc"
128 f_category elisp         "$msg_elisp_desc"
129 f_category emulators     "$msg_emulators_desc"
130 f_category enlightenment "$msg_enlightenment_desc"
131 f_category finance       "$msg_finance_desc"
132 f_category french        "$msg_french_desc"
133 f_category ftp           "$msg_ftp_desc"
134 f_category games         "$msg_games_desc"
135 f_category geography     "$msg_geography_desc"
136 f_category german        "$msg_german_desc"
137 f_category gnome         "$msg_gnome_desc"
138 f_category gnustep       "$msg_gnustep_desc"
139 f_category graphics      "$msg_graphics_desc"
140 f_category hamradio      "$msg_hamradio_desc"
141 f_category haskell       "$msg_haskell_desc"
142 f_category hebrew        "$msg_hebrew_desc"
143 f_category hungarian     "$msg_hungarian_desc"
144 f_category ipv6          "$msg_ipv6_desc"
145 f_category irc           "$msg_irc_desc"
146 f_category japanese      "$msg_japanese_desc"
147 f_category java          "$msg_java_desc"
148 f_category kde           "$msg_kde_desc"
149 f_category kld           "$msg_kld_desc"
150 f_category korean        "$msg_korean_desc"
151 f_category lang          "$msg_lang_desc"
152 f_category linux         "$msg_linux_desc"
153 f_category lisp          "$msg_lisp_desc"
154 f_category mail          "$msg_mail_desc"
155 f_category math          "$msg_math_desc"
156 f_category mbone         "$msg_mbone_desc"
157 f_category misc          "$msg_misc_desc"
158 f_category multimedia    "$msg_multimedia_desc"
159 f_category net           "$msg_net_desc"
160 f_category net-im        "$msg_net_im_desc"
161 f_category net-mgmt      "$msg_net_mgmt_desc"
162 f_category net-p2p       "$msg_net_p2p_desc"
163 f_category news          "$msg_news_desc"
164 f_category palm          "$msg_palm_desc"
165 f_category parallel      "$msg_parallel_desc"
166 f_category pear          "$msg_pear_desc"
167 f_category perl5         "$msg_perl5_desc"
168 f_category plan9         "$msg_plan9_desc"
169 f_category polish        "$msg_polish_desc"
170 f_category ports-mgmt    "$msg_ports_mgmt_desc"
171 f_category portuguese    "$msg_portuguese_desc"
172 f_category print         "$msg_print_desc"
173 f_category python        "$msg_python_desc"
174 f_category ruby          "$msg_ruby_desc"
175 f_category rubygems      "$msg_rubygems_desc"
176 f_category russian       "$msg_russian_desc"
177 f_category scheme        "$msg_scheme_desc"
178 f_category science       "$msg_science_desc"
179 f_category security      "$msg_security_desc"
180 f_category shells        "$msg_shells_desc"
181 f_category spanish       "$msg_spanish_desc"
182 f_category sysutils      "$msg_sysutils_desc"
183 f_category tcl           "$msg_tcl_desc"
184 f_category textproc      "$msg_textproc_desc"
185 f_category tk            "$msg_tk_desc"
186 f_category ukrainian     "$msg_ukrainian_desc"
187 f_category vietnamese    "$msg_vietnamese_desc"
188 f_category windowmaker   "$msg_windowmaker_desc"
189 f_category www           "$msg_www_desc"
190 f_category x11           "$msg_x11_desc"
191 f_category x11-clocks    "$msg_x11_clocks_desc"
192 f_category x11-drivers   "$msg_x11_drivers_desc"
193 f_category x11-fm        "$msg_x11_fm_desc"
194 f_category x11-fonts     "$msg_x11_fonts_desc"
195 f_category x11-servers   "$msg_x11_servers_desc"
196 f_category x11-themes    "$msg_x11_themes_desc"
197 f_category x11-toolkits  "$msg_x11_toolkits_desc"
198 f_category x11-wm        "$msg_x11_wm_desc"
199 f_category xfce          "$msg_xfce_desc"
200 f_category zope          "$msg_zope_desc"
201
202 f_dprintf "%s: Initialized %u package category descriptions." \
203           packages/categories.subr "$( set -- $CATEGORIES; echo $# )"
204
205 f_dprintf "%s: Successfully loaded." packages/categories.subr
206
207 fi # ! $_PACKAGES_CATEGORIES_SUBR