Deleted Added
full compact
index.subr (250410) index.subr (250538)
1if [ ! "$_PACKAGES_INDEX_SUBR" ]; then _PACKAGES_INDEX_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:

--- 10 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INLUDING, 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#
1if [ ! "$_PACKAGES_INDEX_SUBR" ]; then _PACKAGES_INDEX_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:

--- 10 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INLUDING, 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: head/usr.sbin/bsdconfig/share/packages/index.subr 250410 2013-05-09 16:09:39Z dteske $
27# $FreeBSD: head/usr.sbin/bsdconfig/share/packages/index.subr 250538 2013-05-12 00:46:18Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." packages/index.subr
34f_include $BSDCFG_SHARE/device.subr
35f_include $BSDCFG_SHARE/media/common.subr

--- 71 unchanged lines hidden (view full) ---

107f_index_read()
108{
109 local var_to_get="${1:-PACKAGE_INDEX}"
110
111 # Export variables required by awk(1) below
112 export msg_no_description_provided
113 export msg_all msg_all_desc
114 export VALID_VARNAME_CHARS
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." packages/index.subr
34f_include $BSDCFG_SHARE/device.subr
35f_include $BSDCFG_SHARE/media/common.subr

--- 71 unchanged lines hidden (view full) ---

107f_index_read()
108{
109 local var_to_get="${1:-PACKAGE_INDEX}"
110
111 # Export variables required by awk(1) below
112 export msg_no_description_provided
113 export msg_all msg_all_desc
114 export VALID_VARNAME_CHARS
115 export msg_packages
115
116 eval "$( debug= f_getvar "$var_to_get" | awk -F'|' '
117 function asorti(src, dest)
118 {
119 # Copy src indices to dest and calculate array length
120 nitems = 0; for (i in src) dest[++nitems] = i
121
122 # Sort the array of indices (dest) using insertion sort method

--- 12 unchanged lines hidden (view full) ---

135 }
136 function print_category(category, npkgs, desc)
137 {
138 cat = category
139 # Accent the category if the first page has been
140 # cached (also acting as a visitation indicator)
141 if ( ENVIRON["_index_page_" varcat "_1"] )
142 cat = cat "*"
116
117 eval "$( debug= f_getvar "$var_to_get" | awk -F'|' '
118 function asorti(src, dest)
119 {
120 # Copy src indices to dest and calculate array length
121 nitems = 0; for (i in src) dest[++nitems] = i
122
123 # Sort the array of indices (dest) using insertion sort method

--- 12 unchanged lines hidden (view full) ---

136 }
137 function print_category(category, npkgs, desc)
138 {
139 cat = category
140 # Accent the category if the first page has been
141 # cached (also acting as a visitation indicator)
142 if ( ENVIRON["_index_page_" varcat "_1"] )
143 cat = cat "*"
143 printf "'\''%s'\'' '\''%s packages'\'' '\''%s'\''\n",
144 printf "'\''%s'\'' '\''%s " packages "'\'' '\''%s'\''\n",
144 cat, npkgs, desc
145 }
146 BEGIN {
147 valid_chars = ENVIRON["VALID_VARNAME_CHARS"]
148 default_desc = ENVIRON["msg_no_description_provided"]
145 cat, npkgs, desc
146 }
147 BEGIN {
148 valid_chars = ENVIRON["VALID_VARNAME_CHARS"]
149 default_desc = ENVIRON["msg_no_description_provided"]
150 packages = ENVIRON["msg_packages"]
149 tpkgs = 0
150 prefix = ""
151 }
152 {
153 tpkgs++
154 varpkg = $1
155 gsub("[^" valid_chars "]", "_", varpkg)
156 print "_categories_" varpkg "=\"" $7 "\""

--- 59 unchanged lines hidden (view full) ---

216{
217 local var_to_get="$1" var_basename="$2" pagesize="$3"
218 local category="$4" # Optional
219
220 eval "$(
221 debug= f_getvar "$var_to_get" | awk -F'|' \
222 -v cat="$category" \
223 -v pagesize="$pagesize" \
151 tpkgs = 0
152 prefix = ""
153 }
154 {
155 tpkgs++
156 varpkg = $1
157 gsub("[^" valid_chars "]", "_", varpkg)
158 print "_categories_" varpkg "=\"" $7 "\""

--- 59 unchanged lines hidden (view full) ---

218{
219 local var_to_get="$1" var_basename="$2" pagesize="$3"
220 local category="$4" # Optional
221
222 eval "$(
223 debug= f_getvar "$var_to_get" | awk -F'|' \
224 -v cat="$category" \
225 -v pagesize="$pagesize" \
224 -v var_basename="$var_basename" '
226 -v var_basename="$var_basename" \
227 -v i18n_all="$msg_all" '
225 BEGIN { n = page = 0 }
226 /'\''/{ gsub(/'\''/, "'\''\\'\'\''") }
227 {
228 BEGIN { n = page = 0 }
229 /'\''/{ gsub(/'\''/, "'\''\\'\'\''") }
230 {
228 if ( cat !~ /(^$|^All$)/ && $7 !~ \
231 if ( cat !~ "(^$|^" i18n_all "$)" && $7 !~ \
229 "(^|[[:space:]])" cat "([[:space:]]|$)" ) next
230 starting_new_page = (n++ == (pagesize * page))
231 if ( starting_new_page )
232 printf "%s%s", ( n > 1 ? "'\''\n" : "" ),
233 var_basename "_" ++page "='\''"
234 printf "%s%s", ( starting_new_page ? "" : "\n" ), $0
235 }
236 END { if ( n > 0 ) print "'\''" }'
237 )"
238}
239
240############################################################ MAIN
241
242f_dprintf "%s: Successfully loaded." packages/index.subr
243
244fi # ! $_PACKAGES_INDEX_SUBR
232 "(^|[[:space:]])" cat "([[:space:]]|$)" ) next
233 starting_new_page = (n++ == (pagesize * page))
234 if ( starting_new_page )
235 printf "%s%s", ( n > 1 ? "'\''\n" : "" ),
236 var_basename "_" ++page "='\''"
237 printf "%s%s", ( starting_new_page ? "" : "\n" ), $0
238 }
239 END { if ( n > 0 ) print "'\''" }'
240 )"
241}
242
243############################################################ MAIN
244
245f_dprintf "%s: Successfully loaded." packages/index.subr
246
247fi # ! $_PACKAGES_INDEX_SUBR