Devin Teske 95d45410b5 Add example script `add_some_packages.sh', demonstrating how to install
a list of packages using the bsdconfig(8) API, providing dialog(8) based
user experience (versus plain console output were you to use pkg(8)
directly to install the same list of packages).

Remove example script `browse_packages_ftp.sh', made obsolete because
the digests.txz and packagesite.txz databases for pkg(8) are not
available via FTP (HTTP only to pkg.freebsd.org SRV hosts).

Update example script `browse_packages_http.sh', made to work with new
pkg(8) demonstrating how to generate a local package repository.

Fix a bug in `bsdconfig packages' where packages were listed twice. This
fix requires pkg(8) version 1.2.7_4 or higher.

NB: It is the introduction of pkg(8) 1.2.7_4 wherein I am also able to
drastically reduce the generation time of package dependencies prior to
the dialog display (by utilizing the new `-I' flag to pkg-rquery(8)).

While here, fix a positional argument nit for f_index_initialize() of
`packages/index.subr' include (the one and only argument is positional
argument 1 to state the by-ref handle, indicating the variable to set
in the caller's namespace; the nit I'm fixing here is that we were
querying positional argument 2 for this information incorrectly; caused
by a missing hunk back around SVN r257795).

Fix a bug in sysrc(8) described by PR bin/187458 "sysrc(8) silently and
unexpectedly bootstraps pkg". This was caused by an explicit entry in
`/usr/share/bsdconfig/common.subr' (used by sysrc(8)) that called pkg(8)
to populate the $PKG_ABI global (called in a way that allows implicit
bootstrap of pkg(8)). The solution to which was to find every place in
bsdconfig(8) that requires the $PKG_ABI global and add a layer of
protection by way of introducing the new API call f_musthavepkg_init()
(provided by new include, `/usr/share/bsdconfig/packages/musthavepkg.subr'
intented to mirror `/usr/share/bsdconfig/mustberoot.subr'). When the
$PKG_ABI global is required, you can use `f_musthavepkg_init' to cause
graceful premature termination in the event that pkg(8) has not yet been
bootstrapped, and thus cannot be used to populate $PKG_ABI.

NB: If running interactively ($nonInteractive is NULL or unset), the
f_musthavepkg_init() API call will attempt to bootstrap pkg(8), but only
if the user chooses "Yes" to a Yes/No dialog confirming it is ok to
bootstrap.

While here, simplify an if-conditional in `media/http.subr' include to
use sh(1) inline assignment-with-break.

Also, fix a bug in `media/http.subr' and `media/httpproxy.subr' wherein
the error messages for various HTTP failures were not finding their way
to the console (needed to pass stdout to pass-thru descriptor).

While here, remove the executable bit from `packages/categories.subr',
`packages/index.subr', and `packages/packages.subr' includes.

Fix issues where pkg(8) complains about PACKAGESITE being defined.
Previously, we would set $PACKAGESITE and export it. Now we only set
$PACKAGESITE for invocations of "pkg update" -- getting rid of all the
spurious warnings about PACKAGESITE being deprecated (it's still used
in the case of "pkg update" for simplicity versus having to configure
a config-file).

Remove the leading argument from invocations of f_index_initialize() in
`packages/packages.subr' include. The leading argument no longer means
what it used to, pre SVN r257995).

PR:		bin/187458
Reviewed by:	nwhitehorn
MFC after:	1 week
X-MFC-to:	stable/10, stable/9
2014-07-22 23:10:12 +00:00

210 lines
8.1 KiB
Plaintext

if [ ! "$_PACKAGES_CATEGORIES_SUBR" ]; then _PACKAGES_CATEGORIES_SUBR=1
#
# Copyright (c) 2013 Devin Teske
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
############################################################ INCLUDES
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
f_dprintf "%s: loading includes..." packages/categories.subr
f_include $BSDCFG_SHARE/strings.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig"
f_include_lang $BSDCFG_LIBE/include/messages.subr
############################################################ GLOBALS
CATEGORIES=
NCATEGORIES=0
############################################################ FUNCTIONS
# f_category_desc_get $category [$var_to_set]
#
# Fetch the description of a given category. Returns success if a match was
# found, otherwise failure.
#
# If $var_to_set is missing or NULL, the category description is printed to
# standard out for capturing in a sub-shell (which is less-recommended because
# of performance degredation; for example, when called in a loop).
#
f_category_desc_get()
{
local __category="$1" __var_to_set="$2" __cat __varcat
# Return failure if $category
[ "$__category" ] || return $FAILURE
for __cat in $CATEGORIES; do
[ "$__cat" = "$__category" ] || continue
f_str2varname $__cat __varcat
f_getvar _category_$__varcat $__var_to_set
return $?
done
return $FAILURE
}
# f_category_desc_set $category $desc
#
# Store a description in-association with a category. $category should be
# alphanumeric and can include the underscore [_] but should not contain
# whitespace. Returns success unless $category is NULL or no arguments. Use the
# f_category_desc_get() routine with the same $category to retrieve the stored
# description.
#
f_category_desc_set()
{
local category="$1" desc="$2"
local cat varcat found=
[ "$category" ] || return $FAILURE
for cat in $CATEGORIES; do
[ "$cat" = "$category" ] || continue
f_str2varname $cat varcat
f_isset _category_$varcat || continue
found=1 && break
done
if [ ! "$found" ]; then
CATEGORIES="$CATEGORIES $category"
fi
f_str2varname $category varcat
setvar "_category_$varcat" "$desc"
# Export the variable for awk(1) ENVIRON visibility
export "_category_$varcat"
return $SUCCESS
}
############################################################ MAIN
#
# Load descriptions for package categories. Note that we don't internationalize
# category names because this would be confusing for people used to browsing
# the FTP mirrors or are otherwise familiar with an interface that does not
# provide internationalized names. The descriptions can be used to provide i18n
# users a description of the non-i18n category name.
#
f_category() { f_category_desc_set "$1" "$2"; }
f_category All "$msg_all_desc"
f_category accessibility "$msg_accessibility_desc"
f_category afterstep "$msg_afterstep_desc"
f_category arabic "$msg_arabic_desc"
f_category archivers "$msg_archivers_desc"
f_category astro "$msg_astro_desc"
f_category audio "$msg_audio_desc"
f_category benchmarks "$msg_benchmarks_desc"
f_category biology "$msg_biology_desc"
f_category cad "$msg_cad_desc"
f_category chinese "$msg_chinese_desc"
f_category comms "$msg_comms_desc"
f_category converters "$msg_converters_desc"
f_category databases "$msg_databases_desc"
f_category deskutils "$msg_deskutils_desc"
f_category devel "$msg_devel_desc"
f_category dns "$msg_dns_desc"
f_category docs "$msg_docs_desc"
f_category editors "$msg_editors_desc"
f_category elisp "$msg_elisp_desc"
f_category emulators "$msg_emulators_desc"
f_category enlightenment "$msg_enlightenment_desc"
f_category finance "$msg_finance_desc"
f_category french "$msg_french_desc"
f_category ftp "$msg_ftp_desc"
f_category games "$msg_games_desc"
f_category geography "$msg_geography_desc"
f_category german "$msg_german_desc"
f_category gnome "$msg_gnome_desc"
f_category gnustep "$msg_gnustep_desc"
f_category graphics "$msg_graphics_desc"
f_category hamradio "$msg_hamradio_desc"
f_category haskell "$msg_haskell_desc"
f_category hebrew "$msg_hebrew_desc"
f_category hungarian "$msg_hungarian_desc"
f_category ipv6 "$msg_ipv6_desc"
f_category irc "$msg_irc_desc"
f_category japanese "$msg_japanese_desc"
f_category java "$msg_java_desc"
f_category kde "$msg_kde_desc"
f_category kld "$msg_kld_desc"
f_category korean "$msg_korean_desc"
f_category lang "$msg_lang_desc"
f_category linux "$msg_linux_desc"
f_category lisp "$msg_lisp_desc"
f_category mail "$msg_mail_desc"
f_category math "$msg_math_desc"
f_category mbone "$msg_mbone_desc"
f_category misc "$msg_misc_desc"
f_category multimedia "$msg_multimedia_desc"
f_category net "$msg_net_desc"
f_category net-im "$msg_net_im_desc"
f_category net-mgmt "$msg_net_mgmt_desc"
f_category net-p2p "$msg_net_p2p_desc"
f_category news "$msg_news_desc"
f_category palm "$msg_palm_desc"
f_category parallel "$msg_parallel_desc"
f_category pear "$msg_pear_desc"
f_category perl5 "$msg_perl5_desc"
f_category plan9 "$msg_plan9_desc"
f_category polish "$msg_polish_desc"
f_category ports-mgmt "$msg_ports_mgmt_desc"
f_category portuguese "$msg_portuguese_desc"
f_category print "$msg_print_desc"
f_category python "$msg_python_desc"
f_category ruby "$msg_ruby_desc"
f_category rubygems "$msg_rubygems_desc"
f_category russian "$msg_russian_desc"
f_category scheme "$msg_scheme_desc"
f_category science "$msg_science_desc"
f_category security "$msg_security_desc"
f_category shells "$msg_shells_desc"
f_category spanish "$msg_spanish_desc"
f_category sysutils "$msg_sysutils_desc"
f_category tcl "$msg_tcl_desc"
f_category textproc "$msg_textproc_desc"
f_category tk "$msg_tk_desc"
f_category ukrainian "$msg_ukrainian_desc"
f_category vietnamese "$msg_vietnamese_desc"
f_category windowmaker "$msg_windowmaker_desc"
f_category www "$msg_www_desc"
f_category x11 "$msg_x11_desc"
f_category x11-clocks "$msg_x11_clocks_desc"
f_category x11-drivers "$msg_x11_drivers_desc"
f_category x11-fm "$msg_x11_fm_desc"
f_category x11-fonts "$msg_x11_fonts_desc"
f_category x11-servers "$msg_x11_servers_desc"
f_category x11-themes "$msg_x11_themes_desc"
f_category x11-toolkits "$msg_x11_toolkits_desc"
f_category x11-wm "$msg_x11_wm_desc"
f_category xfce "$msg_xfce_desc"
f_category zope "$msg_zope_desc"
f_count NCATEGORIES $CATEGORIES
f_dprintf "%s: Initialized %u package category descriptions." \
packages/categories.subr $NCATEGORIES
f_dprintf "%s: Successfully loaded." packages/categories.subr
fi # ! $_PACKAGES_CATEGORIES_SUBR