aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bsdconfig/share
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2014-11-19 01:07:58 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2014-11-19 01:07:58 +0000
commit9268022b74279434ed6300244e3f977e56a8ceb5 (patch)
tree377ac0ac449528621eb192cd245adadb5fd53668 /usr.sbin/bsdconfig/share
parent29c34e9d2781cf25403647fb5af7d7ddb23be7e1 (diff)
parent8c3d6a4ab2a4a95d864d9a32d0157d7de90498a4 (diff)
Notes
Diffstat (limited to 'usr.sbin/bsdconfig/share')
-rw-r--r--usr.sbin/bsdconfig/share/Makefile3
-rw-r--r--usr.sbin/bsdconfig/share/common.subr36
-rw-r--r--usr.sbin/bsdconfig/share/device.subr5
-rw-r--r--usr.sbin/bsdconfig/share/dialog.subr26
-rw-r--r--usr.sbin/bsdconfig/share/media/Makefile3
-rw-r--r--usr.sbin/bsdconfig/share/packages/Makefile3
-rw-r--r--usr.sbin/bsdconfig/share/packages/index.subr8
-rw-r--r--usr.sbin/bsdconfig/share/packages/packages.subr6
8 files changed, 66 insertions, 24 deletions
diff --git a/usr.sbin/bsdconfig/share/Makefile b/usr.sbin/bsdconfig/share/Makefile
index 5b81af4312126..400cc1111f2b0 100644
--- a/usr.sbin/bsdconfig/share/Makefile
+++ b/usr.sbin/bsdconfig/share/Makefile
@@ -9,7 +9,4 @@ FILES= common.subr device.subr dialog.subr geom.subr keymap.subr \
mustberoot.subr script.subr strings.subr struct.subr \
sysrc.subr variable.subr
-beforeinstall:
- mkdir -p ${DESTDIR}${FILESDIR}
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr
index 8fb9adaa8ff9d..b7f4ee7aa44d9 100644
--- a/usr.sbin/bsdconfig/share/common.subr
+++ b/usr.sbin/bsdconfig/share/common.subr
@@ -220,6 +220,36 @@ f_have()
f_quietly type "$@"
}
+# setvar $var_to_set [$value]
+#
+# Implement setvar for shells unlike FreeBSD sh(1).
+#
+if ! f_have setvar; then
+setvar()
+{
+ [ $# -gt 0 ] || return $SUCCESS
+ local __setvar_var_to_set="$1" __setvar_right="$2" __setvar_left=
+ case $# in
+ 1) unset "$__setvar_var_to_set"
+ return $? ;;
+ 2) : fall through ;;
+ *) f_err "setvar: too many arguments\n"
+ return $FAILURE
+ esac
+ case "$__setvar_var_to_set" in *[!0-9A-Za-z_]*)
+ f_err "setvar: %s: bad variable name\n" "$__setvar_var_to_set"
+ return 2
+ esac
+ while case "$__setvar_r" in *\'*) : ;; *) false ; esac
+ do
+ __setvar_left="$__setvar_left${__setvar_right%%\'*}'\\''"
+ __setvar_right="${__setvar_right#*\'}"
+ done
+ __setvar_left="$__setvar_left${__setvar_right#*\'}"
+ eval "$__setvar_var_to_set='$__setvar_left'"
+}
+fi
+
# f_which $anything [$var_to_set]
#
# A fast built-in replacement for syntaxes such as foo=$( which bar ). In a
@@ -233,10 +263,10 @@ f_which()
{
local __name="$1" __var_to_set="$2"
case "$__name" in */*|'') return $FAILURE; esac
- local __p IFS=":" __found=
+ local __p __exec IFS=":" __found=
for __p in $PATH; do
- local __exec="$__p/$__name"
- [ -f "$__exec" -a -x "$__exec" ] && __found=1 && break
+ __exec="$__p/$__name"
+ [ -f "$__exec" -a -x "$__exec" ] && __found=1 break
done
if [ "$__found" ]; then
if [ "$__var_to_set" ]; then
diff --git a/usr.sbin/bsdconfig/share/device.subr b/usr.sbin/bsdconfig/share/device.subr
index d93cd9b60251f..d95684dc702e5 100644
--- a/usr.sbin/bsdconfig/share/device.subr
+++ b/usr.sbin/bsdconfig/share/device.subr
@@ -1116,8 +1116,9 @@ f_device_shutdown()
f_device_sort_by_awk='
# Variables that should be defined on the invocation line:
# -v prop="property"
-function asorti(src, dest)
+function _asorti(src, dest)
{
+ k = nitems = 0
for (i in src) dest[++nitems] = i
for (i = 1; i <= nitems; k = i++) {
idx = dest[i]
@@ -1136,7 +1137,7 @@ function asorti(src, dest)
}
}
END {
- nitems = asorti(devices, devices_sorted)
+ nitems = _asorti(devices, devices_sorted)
for (i = 1; i <= nitems; i++) print devices[devices_sorted[i]]
}
'
diff --git a/usr.sbin/bsdconfig/share/dialog.subr b/usr.sbin/bsdconfig/share/dialog.subr
index e0dfe80636338..db99a70d46c13 100644
--- a/usr.sbin/bsdconfig/share/dialog.subr
+++ b/usr.sbin/bsdconfig/share/dialog.subr
@@ -1557,12 +1557,22 @@ f_dialog_info()
# EOF. This implies that you must execute this either as an rvalue to a pipe,
# lvalue to indirection or in a sub-shell that provides data on stdin.
#
+# To open an Xdialog(1) infobox that does not disappear until expeclitly dis-
+# missed, use the following:
+#
+# f_xdialog_info "$info_text" < /dev/tty &
+# pid=$!
+# # Perform some lengthy actions
+# kill $pid
+#
+# NB: Check $USE_XDIALOG if you need to support both dialog(1) and Xdialog(1).
+#
f_xdialog_info()
{
local info_text="$*" height width
f_dialog_infobox_size height width \
"$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$info_text"
- $DIALOG \
+ exec $DIALOG \
--title "$DIALOG_TITLE" \
--backtitle "$DIALOG_BACKTITLE" \
--no-close --no-buttons \
@@ -2099,9 +2109,14 @@ f_dialog_init()
#
# Process stored command-line arguments
#
+ # NB: Using backticks instead of $(...) for portability since Linux
+ # bash(1) balks at the right parentheses encountered in the case-
+ # statement (incorrectly interpreting it as the close of $(...)).
+ #
f_dprintf "f_dialog_init: ARGV=[%s] GETOPTS_STDARGS=[%s]" \
"$ARGV" "$GETOPTS_STDARGS"
- SECURE=$( set -- $ARGV
+ SECURE=`set -- $ARGV
+ OPTIND=1
while getopts \
"$GETOPTS_STDARGS$GETOPTS_EXTRA$GETOPTS_ALLFLAGS" \
flag > /dev/null; do
@@ -2109,8 +2124,9 @@ f_dialog_init()
S) echo 1 ;;
esac
done
- )
- USE_XDIALOG=$( set -- $ARGV
+ ` # END-BACKTICK
+ USE_XDIALOG=`set -- $ARGV
+ OPTIND=1
while getopts \
"$GETOPTS_STDARGS$GETOPTS_EXTRA$GETOPTS_ALLFLAGS" \
flag > /dev/null; do
@@ -2118,7 +2134,7 @@ f_dialog_init()
S|X) echo 1 ;;
esac
done
- )
+ ` # END-BACKTICK
f_dprintf "f_dialog_init: SECURE=[%s] USE_XDIALOG=[%s]" \
"$SECURE" "$USE_XDIALOG"
diff --git a/usr.sbin/bsdconfig/share/media/Makefile b/usr.sbin/bsdconfig/share/media/Makefile
index 64367492145ee..7be059bc1efef 100644
--- a/usr.sbin/bsdconfig/share/media/Makefile
+++ b/usr.sbin/bsdconfig/share/media/Makefile
@@ -7,7 +7,4 @@ FILES= any.subr cdrom.subr common.subr directory.subr dos.subr \
floppy.subr ftp.subr http.subr httpproxy.subr network.subr \
nfs.subr options.subr tcpip.subr ufs.subr usb.subr
-beforeinstall:
- mkdir -p ${DESTDIR}${FILESDIR}
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/share/packages/Makefile b/usr.sbin/bsdconfig/share/packages/Makefile
index cb06b80ff1ea3..81463467cabdf 100644
--- a/usr.sbin/bsdconfig/share/packages/Makefile
+++ b/usr.sbin/bsdconfig/share/packages/Makefile
@@ -5,7 +5,4 @@ NO_OBJ=
FILESDIR= ${SHAREDIR}/bsdconfig/packages
FILES= categories.subr index.subr musthavepkg.subr packages.subr
-beforeinstall:
- mkdir -p ${DESTDIR}${FILESDIR}
-
.include <bsd.prog.mk>
diff --git a/usr.sbin/bsdconfig/share/packages/index.subr b/usr.sbin/bsdconfig/share/packages/index.subr
index 35ef0dad14e14..f3c171355ba5a 100644
--- a/usr.sbin/bsdconfig/share/packages/index.subr
+++ b/usr.sbin/bsdconfig/share/packages/index.subr
@@ -241,10 +241,12 @@ f_index_read()
export msg_packages
eval "$( debug= f_getvar "$var_to_get" | awk -F'|' '
- function asorti(src, dest)
+ function _asorti(src, dest)
{
+ k = nitems = 0
+
# Copy src indices to dest and calculate array length
- nitems = 0; for (i in src) dest[++nitems] = i
+ for (i in src) dest[++nitems] = i
# Sort the array of indices (dest) using insertion sort method
for (i = 1; i <= nitems; k = i++)
@@ -290,7 +292,7 @@ f_index_read()
END {
print "_npkgs=" tpkgs # For convenience, total package count
- n = asorti(categories, categories_sorted)
+ n = _asorti(categories, categories_sorted)
# Produce package counts for each category
for (i = 1; i <= n; i++)
diff --git a/usr.sbin/bsdconfig/share/packages/packages.subr b/usr.sbin/bsdconfig/share/packages/packages.subr
index a041fb6437490..f3ec707738781 100644
--- a/usr.sbin/bsdconfig/share/packages/packages.subr
+++ b/usr.sbin/bsdconfig/share/packages/packages.subr
@@ -1029,9 +1029,11 @@ f_package_extract()
# Request the package be added via pkg-install(8)
if f_debugging; then
- f_eval_catch $funcname pkg 'pkg -d install -y "%s"' "$name"
+ f_eval_catch $funcname pkg \
+ 'pkg -d install -${depended:+A}y "%s"' "$name"
else
- f_eval_catch $funcname pkg 'pkg install -y "%s"' "$name"
+ f_eval_catch $funcname pkg \
+ 'pkg install -${depended:+A}y "%s"' "$name"
fi
if [ $? -ne $SUCCESS ]; then
$alert "$msg_pkg_install_apparently_did_not_like_the_package" \