summaryrefslogtreecommitdiff
path: root/distrib
diff options
context:
space:
mode:
authorTodd T. Fries <todd@cvs.openbsd.org>2009-05-07 03:43:03 +0000
committerTodd T. Fries <todd@cvs.openbsd.org>2009-05-07 03:43:03 +0000
commitcaafa8002519442d0d9a9929c9dcce73c0576c5f (patch)
tree5acade7d6a525909e43bb942786efec771ced646 /distrib
parent88a3f270fc80192ef8689fa03b9ac260c39cd66b (diff)
o use 'ls -C' to speed and simplify both sets viewing and timezone selection
o use a tzlist instead of a tzdir o as a bonus, sets lists are now sorted top-down instead of left-right o use stty to calculate 4char padding surrounding sets lists collaboration with Alexander Hall halex@ ok deraadt@
Diffstat (limited to 'distrib')
-rw-r--r--distrib/miniroot/install.sh8
-rw-r--r--distrib/miniroot/install.sub95
-rw-r--r--distrib/miniroot/maketz.sh11
3 files changed, 53 insertions, 61 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh
index c97ec77df46..f37ba777ec6 100644
--- a/distrib/miniroot/install.sh
+++ b/distrib/miniroot/install.sh
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: install.sh,v 1.185 2009/05/06 08:35:24 deraadt Exp $
+# $OpenBSD: install.sh,v 1.186 2009/05/07 03:43:02 todd Exp $
# $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
@@ -215,11 +215,13 @@ fi
mount_fs "-o async"
-[[ $MODE == install ]] && set_timezone /var/tzdir/
+[[ $MODE == install ]] && set_timezone /var/tzlist
install_sets
-[[ $MODE == install ]] && set_timezone /mnt/usr/share/zoneinfo/
+[[ $MODE == install && ! -n $TZ ]] &&
+ (cd /mnt/usr/share/zoneinfo&&ls -1dF `tar cvf /dev/null [A-Za-y]*`)>/tmp/tzlist && \
+ set_timezone /tmp/tzlist
# Remount all filesystems in /etc/fstab with the options from /etc/fstab, i.e.
# without any options such as async which may have been used in the first
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index d288eab8b54..de704be1072 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.535 2009/05/06 22:48:03 sthen Exp $
+# $OpenBSD: install.sub,v 1.536 2009/05/07 03:43:02 todd Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback
@@ -422,6 +422,21 @@ bsort() {
bsort $_l
}
+# show a list (passed via ordered arguments) in column output using ls
+showcols() {
+ local _l _cdir=/tmp/cdir
+ set -A _clist
+ mkdir -p $_cdir
+ rm -rf -- $_cdir/*
+ while read _l; do
+ [ "$_l" ] || continue
+ mkdir -p /tmp/cdir/"$_l"
+ _clist[${#_clist[*]}]="$_l"
+ done
+ (cd $_cdir; ls -Cdf "${_clist[@]}")
+ rm -rf -- $_cdir
+}
+
# Offer to shell out for manual network configuration, and do so if
# the user accepts the offer.
manual_net_cfg() {
@@ -467,8 +482,9 @@ addhostent() {
#
# Set $resp to list of selected sets.
select_sets() {
- local _avail=$1 _selected=$2 _f _action _col _p
- typeset -L18 _l
+ local _avail=$1 _selected=$2 _f _action _col=$COLUMNS
+ # account for 4 spaces added to the sets list
+ let COLUMNS=_col-8
cat <<__EOT
@@ -478,37 +494,9 @@ sets are labelled '[X]'.
__EOT
while :; do
_action=
- _col=0
for _f in $_avail; do
- if isin $_f $_selected; then
- _p="[X] $_f"
- else
- _p="[ ] $_f"
- fi
- if (( _col == 0 )); then
- echo -n ' '
- fi
- if (( ${#_p} > 18 )); then
- # probably site##-hostname.tgz, so print the
- # long version and force a newline
- print -n "$_p"
- _col=2
- else
- _l="$_p"
- print -n "$_l"
- fi
- let _col=_col+1
- if (( _col == 3 )); then
- # end of a column
- echo
- _col=0
- fi
- done
- if (( _col % 3 )); then
- # complete a partial column
- echo
- fi
-
+ isin $_f $_selected && echo "[X] $_f" || echo "[ ] $_f"
+ done|showcols|sed 's/^/ /'
ask "Set name? (or 'abort' or 'done')" done
case $resp in
abort) _selected=
@@ -534,6 +522,7 @@ __EOT
esac"
done
done
+ COLUMNS=$_col
resp=$_selected
}
@@ -1328,12 +1317,12 @@ install_tape() {
}
set_timezone() {
- local _zoneroot=$1 _zonepath _tz
+ local _zonefile=$1 _zonepath _zsed _tz _zoneroot=/usr/share/zoneinfo
- # If the timezone directory structure is not
- # available, return immediately.
+ # If the timezone file is not available,
+ # return immediately.
- [[ ! -d $_zoneroot ]] && return
+ [[ ! -f $_zonefile ]] && return
# If configured in a previous call, return immediately
[[ -n $TZ ]] && return
@@ -1353,32 +1342,32 @@ set_timezone() {
echo
while :; do
- _zonepath=$_zoneroot
+ _zonepath=""
ask "What timezone are you in? ('?' for list)" "$TZ"
- if [[ $resp == "?" ]]; then
- ls -F ${_zonepath}
- continue;
+ if [[ $resp = "?" ]]; then
+ sed -n "/^$_zonepath/{s,^$_zonepath/,,;/\/.*\//d;/\/./d;/./p;}" $_zonefile|showcols
+ continue
fi
+ _zonepath=$_zonepath$resp
- _zonepath=${_zonepath}${resp}
-
- while [[ -d $_zonepath ]]; do
- ask "What sub-timezone of '${_zonepath#$_zoneroot}' are you in? ('?' for list)"
+ while isin $_zonepath/ $(cat $_zonefile); do
+ ask "What sub-timezone of '$_zonepath' are you in? ('?' for list)"
+ _zsed=$(echo $_zonepath|sed 's/\//\\\//g')
case $resp in
"") ;;
- "?") ls -F $_zonepath ;;
+ "?") sed -n "/^$_zsed/{s,^$_zsed/,,;/\/.*\//d;/\/./d;/./p;}" $_zonefile|showcols;;
*) _zonepath=$_zonepath/$resp ;;
esac
done
-
- if [[ -f $_zonepath ]]; then
+
+ if isin $_zonepath $(cat $_zonefile); then
TZ=${_zonepath#$_zoneroot}
return
fi
- echo -n "'${_zonepath#$_zoneroot}'"
+ echo -n "'${_zonepath}'"
echo " is not a valid timezone on this system."
done
}
@@ -1826,10 +1815,14 @@ done
# in SANESETS.
SANESETS="${SANESETS:-bsd} base${VERSION}.tgz etc${VERSION}.tgz"
+# prepare COLUMNS sanely
+COLUMNS=$(stty -a | sed -n '/columns/{s/^.* \([0-9]*\) columns.*$/\1/;p;}')
+[ COLUMNS -eq 0 ] && COLUMNS=80
+
# decide upon an editor
: ${EDITOR:=ed}
[[ -x /usr/bin/vi ]] && EDITOR=vi
-export EDITOR
+export EDITOR COLUMNS
# umount all filesystems, just in case we are re-running install or upgrade.
[[ -f /etc/fstab ]] && umount -av 1>/dev/null 2>&1
@@ -1860,7 +1853,7 @@ if [[ $MODE == install ]]; then
donetconfig
if [[ $nifs == 0 ]]; then
- set_timezone /var/tzdir/
+ set_timezone /var/tzlist
else
startftplist
fi
diff --git a/distrib/miniroot/maketz.sh b/distrib/miniroot/maketz.sh
index 9c11cadccfd..d0b3c709129 100644
--- a/distrib/miniroot/maketz.sh
+++ b/distrib/miniroot/maketz.sh
@@ -7,10 +7,7 @@ if [ $# -lt 1 ]; then
exit 0
fi
-mkdir -p var/tzdir
-cd var/tzdir
-
-touch FOO
-(cd $destdir/usr/share/zoneinfo; find . -type d -print0) | xargs -0 mkdir -p
-(cd $destdir/usr/share/zoneinfo; find . -type f -print0) | xargs -0 -n 1 ln FOO
-rm FOO
+(
+ cd $destdir/usr/share/zoneinfo
+ ls -1dF `tar cvf /dev/null [A-Za-y]*`
+) > var/tzlist