CVS: theedge/sbin lget, 1.21, 1.22 lin, 1.61, 1.62 lrm, 1.17,
1.18 lunar, 1.20, 1.21
sofar at lunar-linux.org
sofar at lunar-linux.org
Wed Aug 6 23:12:49 GMT 2003
Update of /var/cvs/lunar/theedge/sbin
In directory dbguin.lunar-linux.org:/tmp/cvs-serv1904/sbin
Modified Files:
lget lin lrm lunar
Log Message:
Uniformizing parameter passing using getopt, making this a LOT simpler, cleaner and simply pwetty.
QOTD:
The man who understands one woman is qualified to understand pretty well
everything.
-- Yeats
Index: lget
===================================================================
RCS file: /var/cvs/lunar/theedge/sbin/lget,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- lget 28 Jul 2003 21:51:51 -0000 1.21
+++ lget 6 Aug 2003 23:12:46 -0000 1.22
@@ -33,8 +33,8 @@
Lget downloads single or multiple module source files.
-Example: lget nano hdparm sudo
-Usage: lget [parameters] [modules]
+Example : lget nano hdparm sudo
+Usage : lget [parameters] [modules]
Typing lget with no modules causes lget to download
every available source specified in the moonbase.
@@ -50,51 +50,10 @@
}
-process_parameters() {
-
- while [ -n "$1" ]; do
-
- if echo "" $1 | grep -q "^ -"; then
-
- case $1 in
- --from) SOURCE_CACHE=$2; shift 2 ;;
- --help) help; exit 1 ;;
- --url) BASE_URL="$2"; shift 2 ;;
- --debug) (( LUNAR_DEBUG++ )) ; export LUNAR_DEBUG; shift 1 ;;
- *) help ;;
- esac
-
- else shift
- fi
-
- done
-
-}
-
-
-strip_parameters() {
- while [ -n "$1" ] ; do
- if echo "" $1 | grep -q "^ -" ; then
- case $1 in
- --from) shift 2 ;;
- --help) shift 1 ;;
- --url) shift 2 ;;
- --debug) shift 1 ;;
- *) shift 1 ;;
- esac
- else
- echo $1
- shift
- fi
- done
-}
-
-
main() {
-
cd /tmp
- process_parameters $@
- MODULES=$(strip_parameters $@)
+
+ MODULES="$@"
if [ -z "$MODULES" ] ; then
verbose_msg "downloading entire moonbase"
@@ -124,9 +83,28 @@
. /etc/lunar/config
-root_check
-enviro_check
-set_priority
+GETOPT_ARGS=$(getopt -q -n lget -o "dfhuv" -l "debug,from,help,url,verbose" -- "$@")
-main $*
+if [ -z "$?" ] ; then
+ help | view_file
+ exit
+else
+ eval set -- $GETOPT_ARGS
+
+ root_check
+ enviro_check
+ set_priority
+ while true ; do
+ case "$1" in
+ -d|--debug ) (( LUNAR_DEBUG++ )) ; export LUNAR_DEBUG ; shift ;;
+ -f|--from ) export SOURCE_CACHE=$2 ; shift 2 ;;
+ -h|--help ) help ; exit 1 ;;
+ -u|--url ) export BASE_URL="$2" ; shift 2 ;;
+ -v|--verbose ) export VERBOSE="on" ; shift ;;
+ --) shift ; break ;;
+ *) help ; exit ;;
+ esac
+ done
+ main $@
+fi
Index: lin
===================================================================
RCS file: /var/cvs/lunar/theedge/sbin/lin,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- lin 4 Aug 2003 23:19:42 -0000 1.61
+++ lin 6 Aug 2003 23:12:46 -0000 1.62
@@ -61,65 +61,8 @@
}
-process_parameters() {
- while [ -n "$1" ]; do
- if echo "" $1 | grep -q "^ -"; then
- case $1 in
- --deps) export DEPS_ONLY="$1"; shift 1 ;;
- -r|--reconfigure) export RECONFIGURE="$1"; shift 1 ;;
- -c|--compile) export COMPILE="$1"; shift 1 ;;
- -p|--probe) export PROBE="$1"; shift 1 ;;
- --from) export SOURCE_CACHE=$2; shift 2 ;;
- --silent) export SILENT="$1"; shift 1 ;;
- -f|--fix) export FIX="$1"; shift 1 ;;
- -n|--nofix) export FIX="--fix"
- export NOFIX="$1"; shift 1 ;;
- -d|--fixdepends) export FIXDEPENDS="$1"
- export FIX="$1"; shift 1 ;;
- -s) export SEPARATE="$1"; shift 1 ;;
- --url) export BASE_URL="$2"; shift 2 ;;
- --debug) (( LUNAR_DEBUG++ ))
- export LUNAR_DEBUG; shift 1 ;;
- --pam) lin -c $(find_pam_aware); shift 1 ;;
- *) help ;;
- esac
- else
- shift
- fi
- done
-}
-
-
-strip_parameters() {
- while [ -n "$1" ]; do
- if echo "" $1 | grep -q "^ -"; then
- case $1 in
- --deps) shift 1 ;;
- --debug) shift 1 ;;
- -r|--reconfigure) shift 1 ;;
- --from) shift 2 ;;
- --silent) shift 1 ;;
- -f|--fix) shift 1 ;;
- -n|--nofix) shift 1 ;;
- -d|--fixdepends) shift 1 ;;
- -c|--compile) shift 1 ;;
- -p|--probe) shift 1 ;;
- -s) shift 1 ;;
- --url) shift 2 ;;
- --pam) shift 1 ;;
- *) shift 1 ;;
- esac
- else
- echo $1
- shift
- fi
- done
-}
-
-
-main() {
- process_parameters $@
- MODULES=$(strip_parameters $@)
+main() {
+ MODULES="$@"
if echo $MODULES | grep -qw moonbase ; then
# just update moonbase, no other modules
@@ -136,122 +79,139 @@
return
fi
- if [ -n "$FIX" ] ; then
- run_fix $MODULES
- else
- # different approaches for multiple modules (start up downloads first)
- # and single modules (plain install)
- if [ $(echo $MODULES | wc -w) -gt 1 ] ; then
+ # different approaches for multiple modules (start up downloads first)
+ # and single modules (plain install)
+ if [ $(echo $MODULES | wc -w) -gt 1 ] ; then
- if [ ! -n "$TEMP_DOWNLOADLOG" ] ; then
- export TEMP_DOWNLOADLOG=$(temp_create "${MODULE}.download-log")
- fi
+ if [ ! -n "$TEMP_DOWNLOADLOG" ] ; then
+ export TEMP_DOWNLOADLOG=$(temp_create "${MODULE}.download-log")
+ fi
- if [ ! -n "$TEMP_PREPAREDDEPS" ] ; then
- export TEMP_PREPAREDDEPS=$(temp_create "${MODULE}.prepared-depends")
- fi
+ if [ ! -n "$TEMP_PREPAREDDEPS" ] ; then
+ export TEMP_PREPAREDDEPS=$(temp_create "${MODULE}.prepared-depends")
+ fi
- # pass 1 : run full dependency checking
- # This pass does configuration and dependency identification.
- if ! build_depends $MODULES ; then
- temp_destroy $TEMP_DOWNLOADLOG
- temp_destroy $TEMP_PREPAREDDEPS
- verbose_msg "Unexpected errors, bailing out!"
- exit 1
- elif [ -n "$DEPS_ONLY" ] ; then
- temp_destroy $TEMP_DOWNLOADLOG
- temp_destroy $TEMP_PREPAREDDEPS
- exit 0
- fi
+ # pass 1 : run full dependency checking
+ # This pass does configuration and dependency identification.
+ if ! build_depends $MODULES ; then
+ temp_destroy $TEMP_DOWNLOADLOG
+ temp_destroy $TEMP_PREPAREDDEPS
+ verbose_msg "Unexpected errors, bailing out!"
+ exit 1
+ elif [ -n "$DEPS_ONLY" ] ; then
+ temp_destroy $TEMP_DOWNLOADLOG
+ temp_destroy $TEMP_PREPAREDDEPS
+ exit 0
+ fi
- # pass 2 : hit the download manager button and grab a beer
- # this runs as a background process, so we are off to step #3 right away
- verbose_msg "Spawning download manager"
- lget $MODULES >> $TEMP_DOWNLOADLOG 2>&1 &
+ # pass 2 : hit the download manager button and grab a beer
+ # this runs as a background process, so we are off to step #3 right away
+ verbose_msg "Spawning download manager"
+ lget $MODULES >> $TEMP_DOWNLOADLOG 2>&1 &
- # pass 3 : compile/install
- # no strange stuff should happen here anymore
- for MODULE in $MODULES ; do
- verbose_msg "starting installation of \"$MODULE\""
- if ! module_installed $MODULE || [ ! -n "$PROBE" ] ; then
- if ! module_held $MODULE ; then
- linING="/var/lock/installing.$MODULE"
- if [ -n "$COMPILE" ] ||
- [ -n "$RECONFIGURE" ] ||
- module_installed $MODULE ||
- ! resurrect $MODULE; then
- if ! lin $DEPS_ONLY $RECONFIGURE $COMPILE $PROBE $SILENT $FIX $NOFIX $FIXDEPENDS $SEPARATE $MODULE ; then
- if [ -e "$TMP_LIN_FAIL" ] ; then
- echo "$MODULE" >> $TMP_LIN_FAIL
- fi
- lin_EXIT_STATUS=1;
- else
- if [ -e "$TMP_LIN_SUCCESS" ] ; then
- echo "$MODULE" >> $TMP_LIN_SUCCESS
- fi
+ # pass 3 : compile/install
+ # no strange stuff should happen here anymore
+ for MODULE in $MODULES ; do
+ verbose_msg "starting installation of \"$MODULE\""
+ if ! module_installed $MODULE || [ ! -n "$PROBE" ] ; then
+ if ! module_held $MODULE ; then
+ linING="/var/lock/installing.$MODULE"
+ if [ -n "$COMPILE" ] ||
+ [ -n "$RECONFIGURE" ] ||
+ module_installed $MODULE ||
+ ! resurrect $MODULE; then
+ if ! lin $DEPS_ONLY $RECONFIGURE $COMPILE $PROBE $SILENT $MODULE ; then
+ if [ -e "$TMP_LIN_FAIL" ] ; then
+ echo "$MODULE" >> $TMP_LIN_FAIL
+ fi
+ lin_EXIT_STATUS=1;
+ else
+ if [ -e "$TMP_LIN_SUCCESS" ] ; then
+ echo "$MODULE" >> $TMP_LIN_SUCCESS
fi
fi
- else
- verbose_msg "Skipping compile and install for held module \"$MODULE\""
fi
+ else
+ verbose_msg "Skipping compile and install for held module \"$MODULE\""
fi
- done
+ fi
+ done
- # cleanups that we need to do
- temp_destroy $TEMP_DOWNLOADLOG
- temp_destroy $TEMP_PREPAREDDEPS
+ # cleanups that we need to do
+ temp_destroy $TEMP_DOWNLOADLOG
+ temp_destroy $TEMP_PREPAREDDEPS
- else
- if [ -z "$TEMP_PREPAREDDEPS" ] ; then
- FLAG_PREPAREDDEPS_SET=on
- export TEMP_PREPAREDDEPS=$(temp_create "prepared-depends")
- fi
- # we are only doing one module, drop down to:
- MODULE=$MODULES
- if ! module_held $MODULE ; then
- if [ -n "$PROBE" ] ; then
- if ! module_installed $MODULE ; then
- build_depends $MODULE &&
- if [ ! -n "$DEPS_ONLY" ] ; then
- if ! lin_module $MODULE ; then
- temp_destroy $TEMP_PREPAREDDEPS
- exit 1
- fi
- fi
- fi
- else
- build_depends $MODULE &&
- if [ ! -n "$DEPS_ONLY" ] ; then
+ else
+ if [ -z "$TEMP_PREPAREDDEPS" ] ; then
+ FLAG_PREPAREDDEPS_SET=on
+ export TEMP_PREPAREDDEPS=$(temp_create "prepared-depends")
+ fi
+ # we are only doing one module, drop down to:
+ MODULE=$MODULES
+ if ! module_held $MODULE ; then
+ if [ -n "$PROBE" ] ; then
+ if ! module_installed $MODULE ; then
+ build_depends $MODULE &&
+ if [ ! -n "$DEPS_ONLY" ] ; then
if ! lin_module $MODULE ; then
temp_destroy $TEMP_PREPAREDDEPS
- exit 1
- fi
- fi
- fi
+ exit 1
+ fi
+ fi
+ fi
else
- verbose_msg "Skipping held module \"$MODULE\""
- fi
- if [ -n "$FLAG_PREPAREDDEPS_SET" ] ; then
- temp_destroy $TEMP_PREPAREDDEPS
- unset FLAG_PREPAREDDEPS_SET
+ build_depends $MODULE &&
+ if [ ! -n "$DEPS_ONLY" ] ; then
+ if ! lin_module $MODULE ; then
+ temp_destroy $TEMP_PREPAREDDEPS
+ exit 1
+ fi
+ fi
fi
+ else
+ verbose_msg "Skipping held module \"$MODULE\""
+ fi
+ if [ -n "$FLAG_PREPAREDDEPS_SET" ] ; then
+ temp_destroy $TEMP_PREPAREDDEPS
+ unset FLAG_PREPAREDDEPS_SET
fi
fi
+
}
. /etc/lunar/config
-export IFS="$STANDARD_IFS"
-
-root_check
-enviro_check
-set_priority
+GETOPT_ARGS=$(getopt -q -n lin -o "cdfhprRsv" -l "compile,debug,deps,from,help,probe,reconfigure,resurrect,silent,verbose" -- "$@")
-if [ $# == 0 ] ; then
+if [ -z "$?" ] ; then
help | view_file
exit
else
+ eval set -- $GETOPT_ARGS
+ export IFS="$STANDARD_IFS"
+
+ root_check
+ enviro_check
+ set_priority
+
+ while true ; do
+ case "$1" in
+ -c|--compile ) export COMPILE="$1" ; shift ;;
+ -d|--debug ) (( LUNAR_DEBUG++ )) ; export LUNAR_DEBUG ; shift ;;
+ --deps ) export DEPS_ONLY="$1" shift ;;
+ -f|--from ) export SOURCE_CACHE=$2; shift 2 ;;
+ -h|--help ) help ; exit ;;
+ -p|--probe ) export PROBE="$1" ; shift ;;
+ -r|--reconfigure ) export RECONFIGURE="$1" ; shift ;;
+ -R|--resurrect ) export RESURRECT="$1" ; shift ;;
+ -s|--silent ) export SILENT="$1" ; shift ;;
+ -v|--verbose ) export VERBOSE="on" ; shift ;;
+ --) shift ; break ;;
+ *) help ; break ;;
+ esac
+ done
+
main $@
fi
Index: lrm
===================================================================
RCS file: /var/cvs/lunar/theedge/sbin/lrm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- lrm 28 Jul 2003 21:51:51 -0000 1.17
+++ lrm 6 Aug 2003 23:12:46 -0000 1.18
@@ -325,47 +325,43 @@
. /etc/lunar/config
-root_check
-enviro_check
-set_priority
-[ "$#" == "0" ] && help
-LRM_OPT=`getopt -q -o d:ehstvVk \
- --long debug,downgrade:,help,nosustain,test,keepconfig \
- -n lrm -- "$@"`
+GETOPT_ARGS=$(getopt -q -n lin -o "dD:hknv" -l "debug,downgrade:,help,keepconfig,nosustain,verbose" -- "$@")
-[ "$?" == "0" ] || help
+if [ -z "$?" ] ; then
+ help | view_file
+ exit
+else
+ eval set -- $GETOPT_ARGS
-eval set -- "$LRM_OPT"
+ root_check
+ enviro_check
+ set_priority
-while true ; do
+ while true ; do
case "$1" in
- -d|--downgrade ) export DOWNGRADE=on;
- export MODULE="$2"
- shift 3
- downgrade "${@#-}"
- exit
- break;;
- -h|--help ) help ;;
- -s|--nosustain ) export NOSUSTAIN=on; shift ;;
- -k|--keepconfig ) export KEEPCONFIG=on; shift ;;
- -t|--test ) export TEST=on; shift ;;
- --debug ) (( LUNAR_DEBUG++ ))
- export LUNAR_DEBUG; shift ;;
- --) shift; break ;;
- *) help; break ;;
+ -d|--debug ) (( LUNAR_DEBUG++ )) ; export LUNAR_DEBUG ; shift ;;
+ -D|--downgrade ) export DOWNGRADE="on"
+ export MODULE="$2"
+ shift 3
+ downgrade "${@#-}"
+ exit
+ break;;
+ -h|--help ) help ;;
+ -k|--keepconfig ) export KEEPCONFIG="on" ; shift ;;
+ -n|--nosustain ) export NOSUSTAIN="on" ; shift ;;
+ -v|--verbose ) export VERBOSE="on" ; shift ;;
+ --) shift; break ;;
+ *) help; break ;;
esac
-done
-
+ done
-[ "$TEST" != "on" ] && {
- trap "" INT QUIT TERM
- verbose_msg "signals TERM, INT and QUIT are trapped"
-}
+ verbose_msg "signals TERM, INT and QUIT are trapped"
+ trap "trap_proc" INT QUIT TERM
-[ "$TEST" == "on" ] && trap "trap_proc" INT QUIT TERM
-create_lrm_queue "${@#-}"
-process_lrm_queue
-exit_proc
+ create_lrm_queue "${@#-}"
+ process_lrm_queue
+ exit_proc
+fi
Index: lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/sbin/lunar,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- lunar 4 Aug 2003 23:19:42 -0000 1.20
+++ lunar 6 Aug 2003 23:12:46 -0000 1.21
@@ -759,47 +759,67 @@
}
-main() {
- case $1 in
- prune) prune ;;
- renew) renew ;;
- update) update ;;
- rebuild) rebuild ;;
- optimize) optimize_architecture ;;
- resurrect) shift && resurrect_modules $@ ;;
- install) shift && lin $@ ;;
- remove) shift && lrm $@ ;;
- hold) shift && hold_modules $@ ;;
- unhold) shift && unhold_modules $@ ;;
- exile) shift && exile_modules $@ ;;
- unexile) shift && unexile_modules $@ ;;
- *) main_menu ;;
- esac
-}
-
DIALOG="dialog
--backtitle
Lunar Module Management Utility
--stdout"
-. /etc/lunar/config
+main() {
+ #lets load the menu code
+ if [ -n "$MENUS" ]; then
+ for FILE in $(echo $MENUS/*.menu) ; do
+ [ -s "$FILE" ] && . "$FILE"
+ done
+ fi
-#lets load the menu code
-if [ -n "$MENUS" ]; then
- for FILE in $(echo $MENUS/*.menu) ; do
- [ -s "$FILE" ] && . "$FILE"
- done
-fi
+ export IFS="$TAB_ENTER_IFS"
-root_check
-enviro_check
-set_priority
+ LUNAR_MODULE=${LUNAR_MODULE:=lunar}
+ LUNAR_VERSION=$(run_details $LUNAR_MODULE && echo $UPDATED)
-export IFS="$TAB_ENTER_IFS"
+ main_menu
+}
+
+. /etc/lunar/config
-LUNAR_MODULE=${LUNAR_MODULE:=lunar}
-LUNAR_VERSION=$(run_details $LUNAR_MODULE && echo $UPDATED)
+GETOPT_ARGS=$(getopt -q -n lunar -o "dv" -l "debug,verbose" -- "$@")
-main $*
+if [ -z "$?" ] ; then
+ help | view_file
+ exit
+else
+ eval set -- $GETOPT_ARGS
+ root_check
+ enviro_check
+ set_priority
+
+ while true ; do
+ case "$1" in
+ -d|--debug ) (( LUNAR_DEBUG++ )) ; export LUNAR_DEBUG ; shift ;;
+ -h|--help ) help ; exit 1 ;;
+ -v|--verbose ) export VERBOSE="on" ; shift ;;
+ --) shift ; break ;;
+ *) help ; break ;;
+ esac
+ done
+
+ case "$1" in
+ prune ) prune ;;
+ renew ) renew ;;
+ update ) update ;;
+ rebuild ) rebuild ;;
+ optimize ) optimize_architecture ;;
+ fix ) shift && run_fix $@ ;;
+ fixdepends) shift && fix_depends $@ ;;
+ resurrect) shift && resurrect_modules $@ ;;
+ install ) shift && lin $@ ;;
+ remove ) shift && lrm $@ ;;
+ hold ) shift && hold_modules $@ ;;
+ unhold ) shift && unhold_modules $@ ;;
+ exile ) shift && exile_modules $@ ;;
+ unexile ) shift && unexile_modules $@ ;;
+ *) main ;;
+ esac
+fi
More information about the Lunar-commits
mailing list