=================================================================== RCS file: /cvs/openbsd/sxxu/Attic/install.sxxu,v retrieving revision 1.11 retrieving revision 1.19 diff -u -r1.11 -r1.19 --- openbsd/sxxu/Attic/install.sxxu 2010/04/22 21:36:24 1.11 +++ openbsd/sxxu/Attic/install.sxxu 2013/04/20 22:34:57 1.19 @@ -1,5 +1,5 @@ #!/bin/ksh - -# $Id: install.sxxu,v 1.11 2010/04/22 20:36:24 andrew Exp $ +# $Id: install.sxxu,v 1.19 2013/04/20 21:34:57 andrew Exp $ # Copyright (c) 2010 Andrew Fresh # @@ -25,11 +25,11 @@ export PKG_PATH do_pre() { - # nothing to do + echo 'Running post install from sxxu' } do_post() { - # nothing to do + echo 'See /var/log/install.log for install messages.' } process_roles() { @@ -42,12 +42,15 @@ fi local _roles + unset _roles set -A _roles local _role while read _role; do - if [ -n "${_role}" ]; then - _roles[${#_roles[@]}]="$_role" - fi + if [ -n "${_role}" ]; then + _role=${_role%%#*} # strip comments + test -z "$_role" && continue + _roles[${#_roles[@]}]="$_role" + fi done < roles for _role in "${_roles[@]}"; do @@ -59,18 +62,19 @@ append_pkg_path() { - [ ! -e pkg_path ] && return + [ -e pkg_path -o -d packages ] || return echo ' ==> Setting PKG_PATH' + [ -d packages ] && PKG_PATH="${PKG_PATH}:${PWD}/packages" + [ -e pkg_path ] || return; local _line while read _line; do - if [ -z "${PKG_PATH}" ]; then - PKG_PATH="$_line" - else - PKG_PATH="${PKG_PATH}:${_line}" - fi + _line=${_line%%#*} # strip comments + [ -z "$_line" ] && continue + PKG_PATH="${PKG_PATH}:${_line}" done < pkg_path - PKG_PATH=`eval echo $PKG_PATH` + + PKG_PATH=`eval echo $PKG_PATH | sed -e 's/^:*//'` } run_command_lists() { @@ -84,9 +88,11 @@ echo " ==> Running $_cmd $_args" local _line while read _line; do - echo " => ${_line}" + _line=${_line%%#*} # strip comments + test -z "$_line" && continue + echo " => ${_cmd} ${_args} ${_line}" eval ${_cmd} ${_args} ${_line} - done < ${_f} + done < "${_f}" done } @@ -101,7 +107,7 @@ # -N Always assume a forward patch. # -t Never prompt; assume the user is expert # -p0 full path, always - patch -N -t -p0 -d / < $_p + patch -N -t -p0 -d / < "$_p" done } @@ -123,7 +129,7 @@ return fi - echo "===> Applying ${_role}" + echo "===> Applying role ${_role}" cd "${_rolepwd}" if [ -e ./siteXXrc ]; then @@ -156,6 +162,6 @@ exit fi -do_pre -process_roles -do_post +do_pre 2>&1 | /usr/bin/tee /var/log/install.log +process_roles 2>&1 | /usr/bin/tee -a /var/log/install.log | grep '^...>' +do_post 2>&1 | /usr/bin/tee -a /var/log/install.log