summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
committersjg <sjg@FreeBSD.org>2014-08-19 06:50:54 +0000
commitd7cd1d425cc1ea9451fa235e3af9b6625c3e0de2 (patch)
treeb04f4bd7cd887f50e7d98af35f46b9834ff86c80 /usr.sbin/bsdconfig
parent3c8e37b1d04827f33c0c9a7594bd1b1ef7cdb3d3 (diff)
parent4fbde208c6460d576f64d6dc3cdc6cab085a4283 (diff)
downloadFreeBSD-src-d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2.zip
FreeBSD-src-d7cd1d425cc1ea9451fa235e3af9b6625c3e0de2.tar.gz
Merge head from 7/28
Diffstat (limited to 'usr.sbin/bsdconfig')
-rw-r--r--usr.sbin/bsdconfig/bsdconfig.82
-rwxr-xr-xusr.sbin/bsdconfig/dot/dot65
-rw-r--r--usr.sbin/bsdconfig/dot/include/messages.subr1
-rw-r--r--usr.sbin/bsdconfig/examples/Makefile2
-rwxr-xr-xusr.sbin/bsdconfig/examples/add_some_packages.sh13
-rwxr-xr-xusr.sbin/bsdconfig/examples/browse_packages_ftp.sh25
-rwxr-xr-xusr.sbin/bsdconfig/examples/browse_packages_http.sh37
-rw-r--r--usr.sbin/bsdconfig/include/messages.subr9
-rw-r--r--usr.sbin/bsdconfig/share/common.subr6
-rw-r--r--usr.sbin/bsdconfig/share/media/common.subr3
-rw-r--r--usr.sbin/bsdconfig/share/media/http.subr7
-rw-r--r--usr.sbin/bsdconfig/share/media/httpproxy.subr2
-rw-r--r--usr.sbin/bsdconfig/share/packages/Makefile2
-rw-r--r--[-rwxr-xr-x]usr.sbin/bsdconfig/share/packages/categories.subr0
-rw-r--r--[-rwxr-xr-x]usr.sbin/bsdconfig/share/packages/index.subr83
-rw-r--r--usr.sbin/bsdconfig/share/packages/musthavepkg.subr87
-rw-r--r--[-rwxr-xr-x]usr.sbin/bsdconfig/share/packages/packages.subr9
17 files changed, 182 insertions, 171 deletions
diff --git a/usr.sbin/bsdconfig/bsdconfig.8 b/usr.sbin/bsdconfig/bsdconfig.8
index b99cac2..3f25c95c 100644
--- a/usr.sbin/bsdconfig/bsdconfig.8
+++ b/usr.sbin/bsdconfig/bsdconfig.8
@@ -236,7 +236,7 @@ first appeared in
.Fx 9.2 .
.Sh AUTHORS
.An Ron McDowell
-.An Devin Teske Aq dteske@FreeBSD.org
+.An Devin Teske Aq Mt dteske@FreeBSD.org
.Sh BUGS
The docsinstall and diskmgmt modules call bsdinstall.
Bugs found in these modules should be considered those of bsdinstall, not
diff --git a/usr.sbin/bsdconfig/dot/dot b/usr.sbin/bsdconfig/dot/dot
index 9093d63..f71c0e8 100755
--- a/usr.sbin/bsdconfig/dot/dot
+++ b/usr.sbin/bsdconfig/dot/dot
@@ -249,6 +249,7 @@ if [ "$SHOW_INCLUDES" ]; then
$menu_program_list \
$submenu_program_list \
$cmd_program_list \
+ $BSDCFG_SHARE/script.subr \
; do
[ -e "$file" ] && echo $file
done | sort -u
@@ -299,12 +300,6 @@ if [ "$SHOW_INCLUDES" ]; then
fi
#
-# Add script.subr to includes if it exists
-#
-[ -f $BSDCFG_SHARE/script.subr ] &&
- include_file_list="$include_file_list script.subr"
-
-#
# Start the directional-graph (digraph) output
#
printf 'strict digraph "" { // Empty name to prevent SVG Auto-Tooltip\n'
@@ -352,7 +347,7 @@ printf '\tnode [\n'
printf '\t\tfontname = "Times-Roman",\n'
printf '\t\tfontsize = 12,\n'
printf '\t\twidth = 2.5, // arbitrary minimum width for all nodes\n'
-printf '\t\tfixedsize, // turn minimum width into exact width\n'
+printf '\t\tfixedsize = true, // turn minimum width into exact width\n'
printf '\t];\n'
#
@@ -546,34 +541,36 @@ printf '\t\tbgcolor = "%s";\n' "$bgcolor_bsdconfig"
printf '\t\tlabel = "bsdconfig(8)";\n'
printf '\t\ttooltip = "bsdconfig(8)";\n'
print_node "bsdconfig"
+end_nodelist
if [ "$SHOW_INCLUDES" ]; then
- printf '\t\tsubgraph "cluster_includes" {\n'
- printf '\t\t\tbgcolor = "%s";\n' "$bgcolor_includes"
- printf '\t\t\tlabel = "%s";\n' "$msg_includes"
-
for include_file in $include_file_list; do
echo $include_file
- done | awk -v bgcolor="$bgcolor_bsdconfig" '
- BEGIN { created = 0 }
- function end_subgraph() { printf "\t\t\t};\n" }
- ( $0 !~ "/" ) {
- if ( ! created )
- {
- printf "\t\t\tsubgraph \"%s\" {\n",
- "cluster_bsdconfig_includes"
- printf "\t\t\t\tbgcolor = \"%s\";\n", bgcolor
- printf "\t\t\t\tlabel = \"bsdconfig\";\n"
- created++
+ done | awk \
+ -v bgcolor="$bgcolor_bsdconfig" \
+ -v msg_subroutines="$msg_subroutines" \
+ '
+ BEGIN { created = 0 }
+ function end_subgraph() { printf "\t};\n" }
+ ( $0 !~ "/" ) {
+ if ( ! created )
+ {
+ printf "\tsubgraph \"%s\" {\n",
+ "cluster_bsdconfig_includes"
+ printf "\t\tbgcolor = \"%s\";\n", bgcolor
+ printf "\t\tlabel = \"bsdconfig %s\";\n",
+ msg_subroutines
+ created++
+ }
+ printf "\t\t\"%s\";\n", $1
}
- printf "\t\t\t\t\"%s\";\n", $1
- }
- END { created && end_subgraph() }'
+ END { created && end_subgraph() }
+ ' # END-QUOTE
for include_file in $include_file_list; do
echo $include_file
- done | awk '
+ done | awk -v msg_subroutines="$msg_subroutines" '
BEGIN { created = 0 }
- function end_subgraph() { printf "\t\t\t};\n" }
+ function end_subgraph() { printf "\t};\n" }
( $0 ~ "/" ) {
include_dir_tmp = $1
sub("/[^/]*$", "", include_dir_tmp)
@@ -588,20 +585,18 @@ if [ "$SHOW_INCLUDES" ]; then
if ( ! created )
{
include_dir = include_dir_tmp
- printf "\t\t\tsubgraph \"cluster_%s_includes\" {\n",
+ printf "\tsubgraph \"cluster_%s_includes\" {\n",
include_dir
- printf "\t\t\t\tbgcolor = \"white\";\n"
- printf "\t\t\t\tlabel = \"%s\";\n", include_dir
+ printf "\t\tbgcolor = \"thistle\";\n"
+ printf "\t\tlabel = \"%s %s\";\n", include_dir,
+ msg_subroutines
created++
}
- printf "\t\t\t\t\"%s\";\n", $1
+ printf "\t\t\"%s\";\n", $1
}
END { created && end_subgraph() }'
-
- printf '\t\t};\n'
fi
-end_nodelist
for INDEX in */INDEX; do
menu_title=
menu_help=
@@ -676,7 +671,7 @@ for INDEX in */INDEX; do
end_nodelist
done
-printf '\n};\n'
+printf '\n}\n'
################################################################################
# END
diff --git a/usr.sbin/bsdconfig/dot/include/messages.subr b/usr.sbin/bsdconfig/dot/include/messages.subr
index 527f308..f1095f7 100644
--- a/usr.sbin/bsdconfig/dot/include/messages.subr
+++ b/usr.sbin/bsdconfig/dot/include/messages.subr
@@ -28,3 +28,4 @@ msg_graph_label_with_command="bsdconfig(8)\\\ndot(1) output generated by \`\`%s'
msg_graph_label_with_command_and_date="bsdconfig(8)\\\ndot(1) output generated by \`\`%s'' on\\\n%s"
msg_includes="Includes"
msg_shortcuts="Shortcuts"
+msg_subroutines="Subroutines"
diff --git a/usr.sbin/bsdconfig/examples/Makefile b/usr.sbin/bsdconfig/examples/Makefile
index d8813ce..156ccaf 100644
--- a/usr.sbin/bsdconfig/examples/Makefile
+++ b/usr.sbin/bsdconfig/examples/Makefile
@@ -3,7 +3,7 @@
NO_OBJ=
FILESDIR= ${SHAREDIR}/examples/bsdconfig
-FILES= browse_packages_ftp.sh browse_packages_http.sh bsdconfigrc
+FILES= add_some_packages.sh browse_packages_http.sh bsdconfigrc
beforeinstall:
mkdir -p ${DESTDIR}${FILESDIR}
diff --git a/usr.sbin/bsdconfig/examples/add_some_packages.sh b/usr.sbin/bsdconfig/examples/add_some_packages.sh
new file mode 100755
index 0000000..8750908
--- /dev/null
+++ b/usr.sbin/bsdconfig/examples/add_some_packages.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# $FreeBSD$
+#
+# This sample installs a short list of packages from the main HTTP site.
+#
+[ "$_SCRIPT_SUBR" ] || . /usr/share/bsdconfig/script.subr || exit 1
+nonInteractive=1
+_httpPath=http://pkg.freebsd.org
+mediaSetHTTP
+mediaOpen
+for package in wget bash rsync; do
+ packageAdd
+done
diff --git a/usr.sbin/bsdconfig/examples/browse_packages_ftp.sh b/usr.sbin/bsdconfig/examples/browse_packages_ftp.sh
deleted file mode 100755
index 015d799..0000000
--- a/usr.sbin/bsdconfig/examples/browse_packages_ftp.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-# $FreeBSD$
-#
-# This sample downloads the package INDEX file from FTP to /tmp (if it doesn't
-# already exist) and then displays the package configuration/management screen
-# using the local INDEX file (results in faster browsing of packages from-start
-# since the INDEX can be loaded from local media).
-#
-# NOTE: Packages cannot be installed unless staged to /tmp/packages/All
-#
-. /usr/share/bsdconfig/script.subr
-nonInteractive=1
-TMPDIR=/tmp
-if [ ! -e "$TMPDIR/packages/INDEX" ]; then
- [ -d "$TMPDIR/packages" ] || mkdir -p "$TMPDIR/packages" || exit 1
- _ftpPath=ftp://ftp.freebsd.org
- # For older releases, use ftp://ftp-archive.freebsd.org
- mediaSetFTP
- mediaOpen
- f_show_info "Downloading packages/INDEX from\n %s" "$_ftpPath"
- f_device_get device_media packages/INDEX > $TMPDIR/packages/INDEX
-fi
-_directoryPath=$TMPDIR
-mediaSetDirectory
-configPackages
diff --git a/usr.sbin/bsdconfig/examples/browse_packages_http.sh b/usr.sbin/bsdconfig/examples/browse_packages_http.sh
index a0e6801..91b928d 100755
--- a/usr.sbin/bsdconfig/examples/browse_packages_http.sh
+++ b/usr.sbin/bsdconfig/examples/browse_packages_http.sh
@@ -1,25 +1,32 @@
#!/bin/sh
# $FreeBSD$
#
-# This sample downloads the package INDEX file from HTTP to /tmp (if it doesn't
-# already exist) and then displays the package configuration/management screen
-# using the local INDEX file (results in faster browsing of packages from-start
-# since the INDEX can be loaded from local media).
+# This sample downloads the package digests.txz and packagesite.txz files from
+# HTTP to /tmp (if they don't already exist) and then displays the package
+# configuration/management screen using the local files (resulting in faster
+# browsing of packages from-start since digests.txz/packagesite.txz can be
+# loaded from local media).
#
-# NOTE: Packages cannot be installed unless staged to /tmp/packages/All
+# NOTE: Packages cannot be installed unless staged to
+# /tmp/packages/$PKG_ABI/All
#
-. /usr/share/bsdconfig/script.subr
+[ "$_SCRIPT_SUBR" ] || . /usr/share/bsdconfig/script.subr || exit 1
nonInteractive=1
+f_musthavepkg_init # Make sure we have a usable pkg(8) with $PKG_ABI
TMPDIR=/tmp
-if [ ! -e "$TMPDIR/packages/INDEX" ]; then
- [ -d "$TMPDIR/packages" ] || mkdir -p "$TMPDIR/packages" || exit 1
- _httpPath=http://ftp.freebsd.org
- # For older releases, use http://ftp-archive.freebsd.org
- mediaSetHTTP
- mediaOpen
- f_show_info "Downloading packages/INDEX from\n %s" "$_httpPath"
- f_device_get device_media packages/INDEX > $TMPDIR/packages/INDEX
-fi
+PKGDIR=$TMPDIR/packages/$PKG_ABI
+[ -d "$PKGDIR" ] || mkdir -p "$PKGDIR" || exit 1
+for file in digests.txz packagesite.txz; do
+ [ -s "$PKGDIR/$file" ] && continue
+ if [ ! "$HTTP_INITIALIZED" ]; then
+ _httpPath=http://pkg.freebsd.org
+ mediaSetHTTP
+ mediaOpen
+ fi
+ f_show_info "Downloading %s from\n %s" "$file" "$_httpPath"
+ f_device_get device_media "/$PKG_ABI/latest/$file" > $PKGDIR/$file ||
+ exit 1
+done
_directoryPath=$TMPDIR
mediaSetDirectory
configPackages
diff --git a/usr.sbin/bsdconfig/include/messages.subr b/usr.sbin/bsdconfig/include/messages.subr
index bf16e08..3d6aad0 100644
--- a/usr.sbin/bsdconfig/include/messages.subr
+++ b/usr.sbin/bsdconfig/include/messages.subr
@@ -57,6 +57,7 @@ msg_back="Back"
msg_becoming_root_via_sudo="Becoming root via sudo(8)..."
msg_benchmarks_desc="Utilities for measuring system performance."
msg_biology_desc="Software related to biology."
+msg_bootstrapping_pkg="Bootstrapping pkg(8)..."
msg_brazil="Brazil"
msg_building_package_menus="Building package menu(s)..."
msg_cad_desc="Computer Aided Design utilities."
@@ -142,8 +143,6 @@ msg_generating_index_from_pkg_database="Generating INDEX from pkg(8) database\n(
msg_geography_desc="Geography-related software."
msg_german_desc="Ported software for Germanic countries."
msg_germany="Germany"
-msg_getting_package_categories_via_pkg_rquery="Getting package categories via pkg-rquery(8)..."
-msg_getting_package_dependencies_via_pkg_rquery="Getting package dependencies via pkg-rquery(8)\n(this can take a while)..."
msg_gnome_desc="Components of the Gnome Desktop environment."
msg_gnustep_desc="Software for GNUstep desktop environment."
msg_graphics_desc="Graphics libraries and utilities."
@@ -219,6 +218,7 @@ msg_misc_desc="Miscellaneous utilities."
msg_missing_ftp_host_or_directory="Missing FTP host or directory specification. FTP media not initialized."
msg_multimedia_desc="Multimedia software."
msg_must_be_root_to_execute="%s: must be root to execute"
+msg_must_have_pkg_to_execute="%s: must have pkg(8) to execute"
msg_must_specify_a_host_name_of_some_sort="Must specify a host name of some sort!"
msg_name_server="Name server"
msg_net_desc="Networking utilities."
@@ -274,6 +274,7 @@ msg_perl5_desc="Utilities/modules for the PERL5 language."
msg_permission_denied="%s: %s: Permission denied"
msg_pkg_delete_failed="Warning: pkg-delete(8) of %s failed.\n Run with debugging for details."
msg_pkg_install_apparently_did_not_like_the_package="pkg-install(8) apparently did not like the %s package."
+msg_pkg_not_yet_installed_install_now="pkg(8) not yet installed. Install now?"
msg_plan9_desc="Software from the Plan9 operating system."
msg_please_check_the_url_and_try_again="No such directory: %s\nplease check the URL and try again.\n"
msg_please_enter_password="Please enter your password for sudo(8):"
@@ -376,15 +377,13 @@ msg_unable_to_get_proper_ftp_path="Unable to get proper FTP path. FTP media not
msg_unable_to_initialize_media_type_for_package_extract="Unable to initialize media type for package extract."
msg_unable_to_make_directory_mountpoint="Unable to make %s directory mountpoint for %s!"
msg_unable_to_open="Unable to open %s"
-msg_unable_to_pkg_rquery_package_categories="Unable to pkg-rquery(8) package categories!"
-msg_unable_to_pkg_rquery_package_dependencies="Unable to pkg-rquery(8) package dependencies!"
msg_unable_to_update_pkg_from_selected_media="Unable to update pkg(8) from selected media."
msg_uninstall="Uninstall"
msg_uninstall_desc="Mark this package for deletion"
msg_uninstalling_package_waiting_for_pkg_delete="Uninstalling %s package - waiting for pkg-delete(8)"
msg_unknown="unknown"
msg_unknown_user="Unknown user: %s"
-msg_url_was_not_found="%s was not found, maybe directory or release-version are wrong?"
+msg_url_was_not_found="%s was not found,\nmaybe directory or release-version are wrong?"
msg_usa="USA"
msg_usage="Usage"
msg_usb="USB"
diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr
index 762fd39..8fb9adaa 100644
--- a/usr.sbin/bsdconfig/share/common.subr
+++ b/usr.sbin/bsdconfig/share/common.subr
@@ -62,12 +62,6 @@ export UNAME_S="$( uname -s )" # Operating System (i.e. FreeBSD)
export UNAME_P="$( uname -p )" # Processor Architecture (i.e. i386)
export UNAME_M="$( uname -m )" # Machine platform (i.e. i386)
export UNAME_R="$( uname -r )" # Release Level (i.e. X.Y-RELEASE)
-if [ ! "${PKG_ABI+set}" ]; then
- export PKG_ABI="$(
- ASSUME_ALWAYS_YES=1 pkg -vv 2> /dev/null |
- awk '$1=="ABI"{print $3;exit}'
- )"
-fi
#
# Default behavior is to call f_debug_init() automatically when loaded.
diff --git a/usr.sbin/bsdconfig/share/media/common.subr b/usr.sbin/bsdconfig/share/media/common.subr
index 7a6ddaa..0bd420d 100644
--- a/usr.sbin/bsdconfig/share/media/common.subr
+++ b/usr.sbin/bsdconfig/share/media/common.subr
@@ -44,7 +44,8 @@ MOUNTPOINT=/dist
#
# Media probe values to use for `f_media_get_TYPE media $file $PROBE' or
-# `f_device_get media $file $PROBE' (where $PROBE is one of the below values).
+# `f_device_get device_media $file $PROBE' (where $PROBE is one of the below
+# values).
#
PROBE_EXIST=1
PROBE_SIZE=2
diff --git a/usr.sbin/bsdconfig/share/media/http.subr b/usr.sbin/bsdconfig/share/media/http.subr
index 6d6aa10..b928f7d 100644
--- a/usr.sbin/bsdconfig/share/media/http.subr
+++ b/usr.sbin/bsdconfig/share/media/http.subr
@@ -515,10 +515,7 @@ f_media_init_http()
fi
esac
- if [ $http_found -eq $SUCCESS ]; then
- HTTP_INITIALIZED=YES
- break
- fi
+ [ $http_found -eq $SUCCESS ] && HTTP_INITIALIZED=YES break
f_getvar $VAR_HTTP_PATH http_path
f_show_msg "$msg_please_check_the_url_and_try_again" \
@@ -668,7 +665,7 @@ f_media_get_http()
44) f_show_msg "$msg_url_was_not_found" "$url" ;;
4) f_show_msg "$msg_client_error" ;;
*) f_show_msg "$msg_error_when_requesting_url" "$url" ;;
- esac
+ esac 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
return $FAILURE
}
diff --git a/usr.sbin/bsdconfig/share/media/httpproxy.subr b/usr.sbin/bsdconfig/share/media/httpproxy.subr
index 66e5be4..1ef516f 100644
--- a/usr.sbin/bsdconfig/share/media/httpproxy.subr
+++ b/usr.sbin/bsdconfig/share/media/httpproxy.subr
@@ -452,7 +452,7 @@ f_media_get_http_proxy()
44) f_show_msg "$msg_url_was_not_found" "$url" ;;
4) f_show_msg "$msg_client_error" ;;
*) f_show_msg "$msg_error_when_requesting_url" "$url" ;;
- esac
+ esac 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
return $FAILURE
}
diff --git a/usr.sbin/bsdconfig/share/packages/Makefile b/usr.sbin/bsdconfig/share/packages/Makefile
index 2a02353..cb06b80 100644
--- a/usr.sbin/bsdconfig/share/packages/Makefile
+++ b/usr.sbin/bsdconfig/share/packages/Makefile
@@ -3,7 +3,7 @@
NO_OBJ=
FILESDIR= ${SHAREDIR}/bsdconfig/packages
-FILES= categories.subr index.subr packages.subr
+FILES= categories.subr index.subr musthavepkg.subr packages.subr
beforeinstall:
mkdir -p ${DESTDIR}${FILESDIR}
diff --git a/usr.sbin/bsdconfig/share/packages/categories.subr b/usr.sbin/bsdconfig/share/packages/categories.subr
index 474c41d..474c41d 100755..100644
--- a/usr.sbin/bsdconfig/share/packages/categories.subr
+++ b/usr.sbin/bsdconfig/share/packages/categories.subr
diff --git a/usr.sbin/bsdconfig/share/packages/index.subr b/usr.sbin/bsdconfig/share/packages/index.subr
index 9586501..35ef0da 100755..100644
--- a/usr.sbin/bsdconfig/share/packages/index.subr
+++ b/usr.sbin/bsdconfig/share/packages/index.subr
@@ -33,6 +33,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
f_dprintf "%s: loading includes..." packages/index.subr
f_include $BSDCFG_SHARE/device.subr
f_include $BSDCFG_SHARE/media/common.subr
+f_include $BSDCFG_SHARE/packages/musthavepkg.subr
f_include $BSDCFG_SHARE/strings.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig"
@@ -53,27 +54,6 @@ SQLITE_REPO="/var/db/pkg/repo-packagesite.sqlite"
#
PACKAGES_INDEX_CACHEFILE="/var/run/bsdconfig/packages_INDEX.cache"
-#
-# INDEX format for FreeBSD-6.0 or higher:
-#
-# package|port-origin|install-prefix|comment|port-desc-file|maintainer|
-# categories|build-deps|run-deps|www-site|reserve|reserve|reserve|disc
-#
-INDEX_FORMAT="%n-%v" # package
-INDEX_FORMAT="$INDEX_FORMAT|/usr/ports/%o" # port-origin
-INDEX_FORMAT="$INDEX_FORMAT|%p" # install-prefix
-INDEX_FORMAT="$INDEX_FORMAT|%c" # comment
-INDEX_FORMAT="$INDEX_FORMAT|/usr/ports/%o/pkg-descr" # port-desc-file
-INDEX_FORMAT="$INDEX_FORMAT|%m" # maintainer
-INDEX_FORMAT="$INDEX_FORMAT|@CATEGORIES@" # place-holder
-INDEX_FORMAT="$INDEX_FORMAT|" # build-deps
-INDEX_FORMAT="$INDEX_FORMAT|@RUNDEPS@" # place-holder
-INDEX_FORMAT="$INDEX_FORMAT|%w" # www-site
-INDEX_FORMAT="$INDEX_FORMAT|" # reserved
-INDEX_FORMAT="$INDEX_FORMAT|" # reserved
-INDEX_FORMAT="$INDEX_FORMAT|" # reserved
-INDEX_FORMAT="$INDEX_FORMAT|" # disc
-
############################################################ FUNCTIONS
# f_index_initialize [$var_to_set]
@@ -87,13 +67,16 @@ INDEX_FORMAT="$INDEX_FORMAT|" # disc
f_index_initialize()
{
local __funcname=f_index_initialize
- local __var_to_set="${2:-PACKAGE_INDEX}"
+ local __var_to_set="${1:-PACKAGE_INDEX}"
[ "$_INDEX_INITTED" ] && return $SUCCESS
# Got any media?
f_media_verify || return $FAILURE
+ # Make sure we have a usable pkg(8) with $PKG_ABI
+ f_musthavepkg_init
+
# Does it move when you kick it?
f_device_init device_media || return $FAILURE
@@ -126,9 +109,10 @@ f_index_initialize()
__site="file://$MOUNTPOINT/packages/$PKG_ABI"
esac
- export PACKAGESITE="$__site"
- f_dprintf "PACKAGESITE=[%s]" "$PACKAGESITE"
- if ! f_eval_catch $__funcname pkg "pkg update"; then
+ f_dprintf "PACKAGESITE=[%s]" "$__site"
+ if ! f_eval_catch $__funcname pkg \
+ 'PACKAGESITE="%s" pkg update' "$__site"
+ then
f_show_err "$msg_unable_to_update_pkg_from_selected_media"
f_device_shutdown device_media
return $FAILURE
@@ -195,53 +179,8 @@ f_index_initialize()
# If we reach this point, we need to generate the data from scratch
#
- f_show_info "$msg_getting_package_categories_via_pkg_rquery"
- if ! eval "$( pkg rquery "%n-%v %C" | awk '
- { categories[$1] = categories[$1] " " $2 }
- END {
- for (package in categories)
- {
- cats = categories[package]
- sub(/^ /, "", cats)
- gsub(/[^[:alnum:]_]/, "_", package)
- printf "local _%s_categories=\"%s\";\n", package, cats
- }
- }' )"; then
- f_show_err "$msg_unable_to_pkg_rquery_package_dependencies"
- f_device_shutdown device_media
- return $FAILURE
- fi
-
- f_show_info "$msg_getting_package_dependencies_via_pkg_rquery"
- if ! eval "$( pkg rquery "%n-%v %dn-%dv" | awk '
- { rundeps[$1] = rundeps[$1] " " $2 }
- END {
- for (package in rundeps)
- {
- deps = rundeps[package]
- sub(/^ /, "", deps)
- gsub(/[^[:alnum:]_]/, "_", package)
- printf "local _%s_rundeps=\"%s\";\n", package, deps
- }
- }' )"; then
- f_show_err "$msg_unable_to_pkg_rquery_package_dependencies"
- f_device_shutdown device_media
- return $FAILURE
- fi
-
f_show_info "$msg_generating_index_from_pkg_database"
- eval "$__var_to_set"='$( pkg rquery "$INDEX_FORMAT" |
- while read LINE; do
- package="${LINE%%|*}";
- f_str2varname "$package" varpkg;
- eval f_replaceall \"\$LINE\" \"\|@CATEGORIES@\|\" \
- \"\|\$_${varpkg}_categories\|\" LINE
- eval f_replaceall \"\$LINE\" \"\|@RUNDEPS@\|\" \
- \"\|\$_${varpkg}_rundeps\|\" LINE
- echo "$LINE"
- done
- )' # always returns true (status of last item in pipe-chain)
- eval "$__var_to_set"='$( debug= f_getvar "$__var_to_set" | sort )'
+ eval "$__var_to_set"='$( pkg rquery -I | sort )'
#
# Attempt to create the persistant on-disk cache
@@ -258,7 +197,7 @@ f_index_initialize()
# Finally, move the temporary file into place
case "$PACKAGES_INDEX_CACHEFILE" in
- */*) f_eval_catch -d $funcname mkdir \
+ */*) f_eval_catch -d $__funcname mkdir \
'mkdir -p "%s"' "${PACKAGES_INDEX_CACHEFILE%/*}"
esac
f_eval_catch -d $__funcname mv 'mv -f "%s" "%s"' \
diff --git a/usr.sbin/bsdconfig/share/packages/musthavepkg.subr b/usr.sbin/bsdconfig/share/packages/musthavepkg.subr
new file mode 100644
index 0000000..929823e
--- /dev/null
+++ b/usr.sbin/bsdconfig/share/packages/musthavepkg.subr
@@ -0,0 +1,87 @@
+if [ ! "$_PACKAGES_MUSTHAVEPKG_SUBR" ]; then _PACKAGES_MUSTHAVEPKG_SUBR=1
+#
+# Copyright (c) 2014 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/musthavepkg.subr
+f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/mustberoot.subr
+
+############################################################ FUNCTIONS
+
+# f_musthavepkg_init
+#
+# Validate pkg(8) is installed and set $PKG_ABI global if not already set.
+# Returns success unless pkg(8) is not installed and user refuses to install
+# it (upon prompt when running interactively).
+#
+f_musthavepkg_init()
+{
+ local funcname=f_musthavepkg_init
+ local pkg_abi_awk='$1~/^ABI/{print $NF; exit}'
+
+ if [ "$PKG_ABI" ]; then # Already set
+ f_dprintf "PKG_ABI=[%s]" "$PKG_ABI"
+ export PKG_ABI
+ f_quietly pkg -N -vv # return status (pkg(8) functional?)
+ return $?
+ fi
+
+ # Attempt to get PKG_ABI without prematurely bootstrapping pkg(8)
+ if f_eval_catch -k PKG_ABI $funcname pkg \
+ "pkg -N -vv | awk '%s'" "$pkg_abi_awk"
+ then
+ f_dprintf "PKG_ABI=[%s]" "$PKG_ABI"
+ export PKG_ABI
+ return $SUCCESS
+ fi
+
+ # pkg(8) not yet bootstrapped; ask for permission unless nonInteractive
+ f_dialog_yesno "$msg_pkg_not_yet_installed_install_now" ||
+ f_die 1 "$msg_must_have_pkg_to_execute" "$pgm"
+
+ f_mustberoot_init # Have to be root to install pkg(8)
+
+ # Bootstrap pkg(8)
+ f_dialog_info "$msg_bootstrapping_pkg"
+ f_eval_catch -k PKG_ABI $funcname pkg \
+ "ASSUME_ALWAYS_YES=1 pkg -vv | awk '%s'" "$pkg_abi_awk" ||
+ f_die 1 "$msg_must_have_pkg_to_execute" "$pgm"
+
+ f_dprintf "PKG_ABI=[%s]" "$PKG_ABI"
+ export PKG_ABI
+ return $SUCCESS
+}
+
+############################################################ MAIN
+
+f_dprintf "%s: Successfully loaded." packages/musthavepkg.subr
+
+fi # ! $_PACKAGES_MUSTHAVEPKG_SUBR
diff --git a/usr.sbin/bsdconfig/share/packages/packages.subr b/usr.sbin/bsdconfig/share/packages/packages.subr
index 6fc936f..a041fb6 100755..100644
--- a/usr.sbin/bsdconfig/share/packages/packages.subr
+++ b/usr.sbin/bsdconfig/share/packages/packages.subr
@@ -36,6 +36,7 @@ f_include $BSDCFG_SHARE/device.subr
f_include $BSDCFG_SHARE/media/common.subr
f_include $BSDCFG_SHARE/packages/categories.subr
f_include $BSDCFG_SHARE/packages/index.subr
+f_include $BSDCFG_SHARE/packages/musthavepkg.subr
f_include $BSDCFG_SHARE/strings.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig"
@@ -662,7 +663,7 @@ f_package_review()
f_package_config()
{
# Did we get an INDEX?
- f_index_initialize packages/INDEX || return $FAILURE
+ f_index_initialize || return $FAILURE
# Creates following variables (indirectly via f_index_read())
# CATEGORY_MENU_LIST _categories_{varpkg} _rundeps_{varpkg}
# PACKAGE_CATEGORIES _npkgs
@@ -839,7 +840,7 @@ f_package_add()
{ # Verify and initialize device media if-defined
f_media_verify &&
f_device_init device_media &&
- f_index_initialize packages/INDEX
+ f_index_initialize
} || return $FAILURE
# Now we have (indirectly via f_index_read()):
@@ -946,6 +947,8 @@ f_package_extract()
local device="$1" name="$2" depended="$3"
local devname=
+ f_musthavepkg_init # Make sure we have a usable pkg(8) with $PKG_ABI
+
$device get name devname
f_dprintf "$funcname: device=[%s] name=[%s] depended=[%s]" \
"$devname" "$name" "$depended"
@@ -1065,7 +1068,7 @@ f_package_delete()
{ # Verify and initialize device media if-defined
f_media_verify &&
f_device_init device_media &&
- f_index_initialize packages/INDEX
+ f_index_initialize
} || return $FAILURE
# Now we have (indirectly via f_index_read()):
OpenPOWER on IntegriCloud