CVS: lunar/sbin lget, 1.8, 1.9 lin, 1.16, 1.17 lrm, 1.6, 1.7 lsh,
1.1, 1.2 lunar, 1.6, 1.7
csm at lunar-linux.org
csm at lunar-linux.org
Sun Aug 10 01:16:24 GMT 2003
Update of /var/cvs/lunar/lunar/sbin
In directory dbguin.lunar-linux.org:/tmp/cvs-serv1871/sbin
Modified Files:
lget lin lrm lsh lunar
Log Message:
merging theedge into lunar and removing subroutines
Index: lget
===================================================================
RCS file: /var/cvs/lunar/lunar/sbin/lget,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- lget 26 Mar 2003 23:20:54 -0000 1.8
+++ lget 10 Aug 2003 01:16:21 -0000 1.9
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
############################################################
# #
# lget - get sources from the net #
@@ -27,23 +27,25 @@
############################################################
-
help() {
cat << EOF
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.
Optional Parameters:
- --from directory Specify an alternate for $SOURCE_CACHE
- --url URL Specify an alternate download URL
+ -d | --debug Enables debug messages
+ -f | --from directory Specify an alternate for $SOURCE_CACHE
+ -h | --help Displays this help text
+ -u | --url URL Specify an alternate download URL
+ -v | --verbose Increases the level of message output
EOF
exit 1
@@ -51,68 +53,29 @@
}
-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 ;;
- *) 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 ;;
- *) shift 1 ;;
- esac
-
- else echo $1
- shift
- fi
-
- done
-
-}
-
-
main() {
+ cd /tmp
+
+ MODULES="$@"
- cd /tmp
- process_parameters $*
- MODULES=`strip_parameters $*`
-
- if [ -z "$MODULES" ]; then
+ if [ -z "$MODULES" ] ; then
verbose_msg "downloading entire moonbase"
MODULES=$(list_moonbase | sort)
fi
+ if echo $MODULES | grep -qw moonbase ; then
+ # just update moonbase, no other modules
+ get_moonbase
+ # remove moonbase rofm MODULES and continue
+ MODULES=$(echo $MODULES | sed 's/moonbase//g')
+ fi
+
for MODULE in $MODULES; do
- if ! lget_locked ; then
- lget_lock
-
- [ "$VEBOSE" == "on" ] && echo "+ downloading module \"$MODULE\""
- download_module
-
- lget_unlock
+ if ! lget_locked $MODULE ; then
+ lget_lock $MODULE
+ verbose_msg "downloading module \"$MODULE\""
+ download_module $MODULE
+ lget_unlock $MODULE
else
false
fi
@@ -123,8 +86,28 @@
. /etc/lunar/config
-root_check || exit 1
+GETOPT_ARGS=$(getopt -q -n lget -o "df:hu:v" -l "debug,from:,help,url:,verbose" -- "$@")
-renice +10 -p $$ >/dev/null
-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/lunar/sbin/lin,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- lin 26 Apr 2003 22:53:48 -0000 1.16
+++ lin 10 Aug 2003 01:16:21 -0000 1.17
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
############################################################
# #
# lin - install Lunar modules #
@@ -35,926 +35,178 @@
Optional Parameters:
--f | --fix Discover and fix broken modules
--n | --nofix Discover, but do not fix broken modules
[...1028 lines suppressed...]
- esac
+ main $@
fi
- true
-}
-. /etc/lunar/config
-
-export IFS="$STANDARD_IFS"
-
-root_check || exit 1
-
-if [ $# == 0 ]; then
- help | view_file
- exit
fi
- LUNAR_PRIORITY=${LUNAR_PRIORITY:="+10"}
- renice "$LUNAR_PRIORITY" -p $$ 2> /dev/null >/dev/null
- main $*
+
Index: lrm
===================================================================
RCS file: /var/cvs/lunar/lunar/sbin/lrm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- lrm 16 Apr 2003 19:47:09 -0000 1.6
+++ lrm 10 Aug 2003 01:16:21 -0000 1.7
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
############################################################
# #
# This code is written for Lunar Linux, see #
@@ -16,18 +16,15 @@
# #
############################################################
-help()
-{
+help() {
cat << END
usage: lrm [options] [module ...]
- -h --help displays this screen
- --debug debug output
- -d --downgrade [module] [version] downgrades a module
- -e --exile exiles modules
- -s --nosustain removes module(s) even if they are sustained
- -k --keepconfig remove module(s) but keep dependancies and config
- -t --test test only, do not actually do anything
- -V --version display version information and exit
+ -d | --debug Enables debug messages
+ -D | --downgrade [module] [version] downgrades a module
+ -h | --help Displays this help text
+ -k | --keepconfig remove module(s) but keep dependencies and config
+ -n | --nosustain removes module(s) even if they are sustained
+ -v | --verbose Increases the level of message output
lrm is a script for removing installed modules.
If invoked without options, lrm will remove all installed files
@@ -36,9 +33,6 @@
Downgrading a module means removing the current installed version
of the module and installing a specific version; given that the
specific version is already in $INSTALL_CACHE/.
- Exile is for removing the module and eliminating any possibilty
-for its re-installing via automatic processess. An exiled module can be
-un-exiled via linning it.
Some modules (such as bash and gcc) are marked "non-removable" by the
system. In order to remove "sustained" modules, use the nosustain option.
END
@@ -46,27 +40,24 @@
}
-exit_proc()
-{
- [ "$DEBUG" == "on" ] && echo "Clearing temporary files.. "
- rm -f $LRM_QUEUE 2>/dev/null
- rm -f $LRM_TEMP 2>/dev/null
- rm -f $TEMP_FILE 2>/dev/null
- rm -f $TEMP2_FILE 2>/dev/null
- exit
+exit_proc() {
+ debug_msg "exit_proc ($@)"
+ temp_destroy $LRM_QUEUE
+ temp_destroy $LRM_TEMP
+ temp_destroy $TEMP_FILE
+ temp_destroy $TEMP2_FILE
+ exit
}
-trap_proc()
-{
- verbose_msg "Trapped a signal! "
- exit_proc
-
+trap_proc() {
+ verbose_msg "Trapped a signal! "
+ exit_proc
}
-handle_config_files()
-{
+handle_config_files() {
+ debug_msg "handle_config_files ($@)"
TARGET="$1"
if dirname "$TARGET" | grep -q "^/etc" ; then
verbose_msg "Examining config file \"$TARGET\""
@@ -104,172 +95,113 @@
fi
}
-remove_something()
-{
+remove_something() {
+ debug_msg "remove_something ($@)"
if [ -z "$1" ]; then
- [ "$DEBUG" == "on" ] &&
- echo " Target parameter not passed, exiting"
- return 1
+ debug_msg "remove_something: No args, exiting"
+ return 1
fi
if ! [ -e "$1" ] && ! [ -L "$1" ] ; then
- [ "$DEBUG" == "on" ] &&
- echo " Target does not exist, exiting"
- return 1
+ debug_msg "remove_something: no such file $1, exiting"
+ return 1
fi
TARGET="$1"
- [ "$DEBUG" == "on" ] && echo -n " removing $TARGET.. "
-
- if [ "$TEST" == "on" ]
- then
- if [ "$DEBUG" == "on" ]
- then
- [ -w "$TARGET" ] &&
- echo "removed" ||
- echo "NOT removed!"
- fi
+ if [ -d "$TARGET" ] ; then
+ rmdir $TARGET 2> /dev/null
+ else
+ rm -f $TARGET 2>/dev/null
fi
- if [ "$TEST" != "on" ]
- then
- [ -d "$TARGET" ] &&
- rmdir $TARGET 2> /dev/null ||
- rm -f $TARGET 2>/dev/null
-
- TMP_VAR="$?"
-
- if [ "$DEBUG" == "on" ]
- then
- [ "$TMP_VAR" == "0" ] &&
- echo "removed" ||
- echo "NOT removed!"
- fi
+ if [ "$?" == "0" ] ; then
+ debug_msg "remove_something: removed $TARGET succesfully"
+ else
+ debug_msg "remove_something: removed $TARGET not succesful"
fi
}
-process_directories()
-{
- verbose_msg "processing directories..."
-
- if [ -z "$1" ]; then
- [ "$DEBUG" == "on" ] &&
- echo " Filename parameter not passed, exiting"
- return 1
- fi
-
- if ! [ -d "$1" ]; then
- [ "$DEBUG" == "on" ] &&
- echo " Filename does not exist, exiting"
- return 1
- fi
+process_directories() {
+ debug_msg "process_directories ($@)"
- cat $1 | sort -r > $2
+ if [ -z "$1" ]; then
+ debug_msg "process_directories: No args, exiting"
+ return 1
+ fi
- while read LINE
- do
- remove_something "$LINE"
- done < $2
+ cat $1 | sort -r | while read LINE ; do
+ remove_something "$LINE"
+ done
}
-process_lrm_queue()
-{
- export TEMP_FILE="/tmp/lrm.temp.`uuidgen`"
- rm -f $TEMP_FILE 2>/dev/null
-
- export TEMP2_FILE="/tmp/lrm.temp.`uuidgen`"
- rm -f $TEMP2_FILE 2>/dev/null
- [ "$DEBUG" == "on" ] &&
- [ -s "$LRM_QUEUE" ] &&
- echo -e "\nWill process the modules: `cat $LRM_QUEUE | xargs`"
+process_lrm_queue() {
+ debug_msg "process_lrm_queue ($@)"
- while [ -s "$LRM_QUEUE" ]
- do
- MODULE=`remove_queue $LRM_QUEUE`
- [ "$TEST" == "on" ] && TEMP="-- TEST MODE -- : "
- verbose_msg "${TEMP}removing \"$MODULE\""
+ export TEMP_FILE=$(temp_create "lrm")
+ export TEMP2_FILE=$(temp_create "lrm")
- run_details $MODULE &> /dev/null
+ while [ -s "$LRM_QUEUE" ]
+ do
+ MODULE=$(remove_queue $LRM_QUEUE)
+ verbose_msg "${TEMP}removing \"$MODULE\""
- if ! module_installed $MODULE
- then
- if module_exiled $MODULE
- then
- message "${MODULE_COLOR}${MODULE}" \
- "${PROBLEM_COLOR}is already exiled." \
- "${DEFAULT_COLOR}"
- continue
- fi
+ run_details $MODULE &> /dev/null
- [ "$EXILE" == "on" ] &&
- [ "$TEST" != "on" ] &&
- remove_module $MODULE
+ VERSION=$(installed_version $MODULE)
+ INST_LOG=$INSTALL_LOGS/$MODULE-$VERSION
+ MD5_LOG=$MD5SUM_LOGS/$MODULE-$VERSION
- verbose_msg "module $MODULE is exiled"
+ # time-out 1: PRE_REMOVE
+ run_module_file $MODULE PRE_REMOVE
- message "${LRM_COLOR}Exiled module:" \
- "${MODULE_COLOR}${MODULE}" \
- "${DEFAULT_COLOR}"
- continue
+ while read TARGET ; do
+ if ! [ -e "$TARGET" ] ; then
+ continue
fi
- VERSION=`installed_version $MODULE`
- INST_LOG=$INSTALL_LOGS/$MODULE-$VERSION
- MD5_LOG=$MD5SUM_LOGS/$MODULE-$VERSION
-
- run_module_file PRE_REMOVE
-
- while read TARGET ; do
- if ! [ -e "$TARGET" ] ; then
- continue
- fi
-
- if grep -q -w "$TARGET\$" $PROTECTED $EXCLUDED ; then
- verbose_msg "\"$TARGET\" is protected or excluded!!"
- continue
- fi
-
- if [ -d "$TARGET" ] ; then
- echo "$TARGET" >> $TEMP_FILE
- continue
- fi
+ if grep -q -w "$TARGET\$" $PROTECTED $EXCLUDED ; then
+ verbose_msg "\"$TARGET\" is protected or excluded!!"
+ continue
+ fi
- handle_config_files $TARGET
+ if [ -d "$TARGET" ] ; then
+ echo "$TARGET" >> $TEMP_FILE
+ continue
+ fi
- remove_something $TARGET
+ handle_config_files $TARGET
- done < $INST_LOG
+ remove_something $TARGET
- process_directories $TEMP_FILE $TEMP2_FILE
+ done < $INST_LOG
- run_module_file POST_REMOVE
+ process_directories $TEMP_FILE $TEMP2_FILE
- if [ "$KEEPCONFIG" == "on" ] ; then
- verbose_msg "skipping removal of dependancy listing and configs"
- else
- verbose_msg "removing module from dependency listing and configs"
- remove_depends $MODULE
- fi
+ # time-out 2: POST_REMOVE
+ run_module_file $MODULE POST_REMOVE
- verbose_msg "removing module from installed list.. "
-
- [ "$TEST" != "on" ] && remove_module $MODULE
+ if [ "$KEEPCONFIG" == "on" ] ; then
+ verbose_msg "skipping removal of dependency listing and configs"
+ else
+ verbose_msg "removing module from dependency listing and configs"
+ remove_depends $MODULE
+ fi
- [ "$EXILE" == "on" ] && EXTEMP=" and exiled"
+ # administration duty time:
+ verbose_msg "removing module from installed list.. "
+ remove_module $MODULE
- message "${LRM_COLOR}Removed${EXTEMP} module:" \
- "${MODULE_COLOR}${MODULE}" \
- "${DEFAULT_COLOR}"
+ message "${LRM_COLOR}Removed${EXTEMP} module:" \
+ "${MODULE_COLOR}${MODULE}${DEFAULT_COLOR}"
- [ "$TEST" != "on" ] &&
- activity_log "lrm" "$MODULE" "$VERSION" "success"
- done
+ activity_log "lrm" "$MODULE" "$VERSION" "success"
+ done
}
-check_status()
-{
+
+check_status() {
module_installed $MODULE || {
message "${MODULE_COLOR}${MODULE}" \
"${PROBLEM_COLOR}is not installed." \
@@ -290,96 +222,72 @@
true
}
-downgrade()
-{
- # a local function for listing the contents of install cache
- list_available_cache()
- {
- ls -1 $INSTALL_CACHE/$MODULE-* |
- while read LINE
- do
- echo " $LINE"
- done
- exit 1
- }
+
+downgrade() {
+ # a local function for listing the contents of install cache
+ list_available_cache() {
+ ls -1 $INSTALL_CACHE/$MODULE-* | while read LINE ; do
+ echo "$LINE"
+ done
+ exit 1
+ }
- if [ "$TEST" != "on" ]; then
- root_check || exit 1
- fi
+ root_check || exit 1
- verbose_msg "running \"$MODULE\" DETAILS file"
- run_details $MODULE &> /dev/null || return 1
+ verbose_msg "running \"$MODULE\" DETAILS file"
+ run_details $MODULE &> /dev/null || return 1
- [ -z "$1" ] && {
- echo "No version is entered. The below is the list of available files."
- list_available_cache
- }
+ if [ -z "$1" ] ; then
+ echo "No version is entered. The below is the list of available files."
+ list_available_cache
+ fi
- local FILENAME="$MODULE-$1-$BUILD.tar.bz2"
- [ -s $INSTALL_CACHE/$FILENAME ] || {
- echo "Desired version is not available. Here is the available files"
- list_available_cache
- }
+ if [ ! -s $INSTALL_CACHE/$MODULE-$1-$BUILD.tar.bz2 ] ; then
+ echo "Desired version is not available. Here is the available files"
+ list_available_cache
+ fi
- verbose_msg "checking if \"$MODULE\" is installed"
- local I_VERSION=`installed_version $MODULE`
- [ -n "$I_VERSION" ] &&
- {
- verbose_msg "\"$I_VERSION\" of \"$MODULE\" is installed at the moment"
+ verbose_msg "checking if \"$MODULE\" is installed"
- [ "$DEBUG" == "on" ] &&
- echo -n " Checking if desired version is the installed version..."
+ if [ -n "$(installed_version $MODULE)" ] ; then
+ verbose_msg "\"$(installed_version $MODULE)\" of \"$MODULE\" is installed at the moment"
- [ "$1" == "$I_VERSION" ] &&
- {
- [ "$DEBUG" == "on" ] && echo "YES!!"
- echo "The downgrade version is the same as the installed version"
- echo "Here is the available files."
- list_available_cache
- } ||
- {
- [ "$DEBUG" == "on" ] && echo "NO"
- }
+ if [ "$1" == "$I_VERSION" ] ; then
+ echo "The downgrade version is the same as the installed version"
+ echo "Here is the available files."
+ list_available_cache
+ fi
- verbose_msg "removing \"$MODULE-$I_VERSION\""
- [ "$TEST" == "on" ] && lrm -ts $MODULE || lrm -s $MODULE
+ verbose_msg "removing \"$MODULE-$(installed_version $MODULE)\""
+ lrm -ts $MODULE || lrm -s $MODULE
- } || {
- verbose_msg "\"$MODULE\" is NOT installed at the moment"
- }
+ else
+ verbose_msg "\"$MODULE\" is NOT installed at the moment"
+ fi
- verbose_msg "installing \"$MODULE-$1\""
- verbose_msg "extracting cached install file..."
- [ "$TEST" == "on" ] &&
- {
- [ "$DEBUG" == "on" ] &&
- bzcat $INSTALL_CACHE/$FILENAME | tar -kt $TAR_P -C / ||
- bzcat $INSTALL_CACHE/$FILENAME | tar -kt $TAR_P -C / >/dev/null
- verbose_msg "adding module to installed list"
- }
+ verbose_msg "installing \"$MODULE-$1\""
+ verbose_msg "extracting cached install file..."
+
+ bzcat $INSTALL_CACHE/$FILENAME | tar -kt $TAR_P -C / >/dev/null
+ verbose_msg "adding module to installed list"
- [ "$TEST" != "on" ] &&
- {
- [ "$DEBUG" == "on" ] &&
- bzcat $INSTALL_CACHE/$FILENAME | tar -kx $TAR_P -C / ||
- bzcat $INSTALL_CACHE/$FILENAME |
- tar -kx $TAR_P -C / 2>/dev/null >/dev/null
- verbose_msg "adding module to installed list"
- add_module $MODULE installed $1
- activity_log "lrm downgrade" "$MODULE" "$1" "success"
- }
- message "${RESURRECT_COLOR}Downgraded module:" \
- "${MODULE_COLOR}${MODULE}" \
- "${DEFAULT_COLOR}" \
- "version" \
- "${VERSION_COLOR}${1}" \
- "${DEFAULT_COLOR}"
+ bzcat $INSTALL_CACHE/$FILENAME |
+ tar -kx $TAR_P -C / 2>/dev/null >/dev/null
+ verbose_msg "adding module to installed list"
+ add_module $MODULE installed $1
+ activity_log "lrm downgrade" "$MODULE" "$1" "success"
+
+ message "${RESURRECT_COLOR}Downgraded module:" \
+ "${MODULE_COLOR}${MODULE}" \
+ "${DEFAULT_COLOR}" \
+ "version" \
+ "${VERSION_COLOR}${1}" \
+ "${DEFAULT_COLOR}"
- exit
+ exit
}
-create_lrm_queue()
-{
+create_lrm_queue() {
[ "$#" == "0" ] && help;
@@ -403,10 +311,8 @@
touch $PROTECTED
}
- export LRM_QUEUE="/tmp/lrm.queue.$$"
- export LRM_TEMP="/tmp/lrm.temp.$$"
- [ -f "$LRM_QUEUE" ] && rm -f $LRM_QUEUE 2>/dev/null
- [ -f "$LRM_TEMP" ] && rm -f $LRM_TEMP 2>/dev/null
+ export LRM_QUEUE=$(temp_create "lrm-queue")
+ export LRM_TEMP=$(temp_create "lrm")
MODULE_LIST="$@"
for MODULE in $MODULE_LIST
@@ -419,43 +325,42 @@
. /etc/lunar/config
-[ "$#" == "0" ] && help
-LRM_OPT=`getopt -q -o d:ehstvVk \
- --long debug,downgrade:,exile,help,nosustain,test,keepconfig \
- -n lrm -- "$@"`
+GETOPT_ARGS=$(getopt -q -n lrm -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;;
- -e|--exile ) export EXILE=on; shift ;;
- -h|--help ) help ;;
- -s|--nosustain ) export NOSUSTAIN=on; shift ;;
- -k|--keepconfig ) export KEEPCONFIG=on; shift ;;
- -t|--test ) export TEST=on; shift ;;
- --debug ) export DEBUG=on; 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: lsh
===================================================================
RCS file: /var/cvs/lunar/lunar/sbin/lsh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- lsh 15 Mar 2003 18:53:31 -0000 1.1
+++ lsh 10 Aug 2003 01:16:21 -0000 1.2
@@ -6,6 +6,8 @@
. /etc/lunar/config
+set_priority
+
message "\n ${PROBLEM_COLOR}Warning:${DEFAULT_COLOR}${MESSAGE_COLOR}" \
"lsh is potential hazardous to your system.${DEFAULT_COLOR}\n"
Index: lunar
===================================================================
RCS file: /var/cvs/lunar/lunar/sbin/lunar,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- lunar 26 Mar 2003 23:20:54 -0000 1.6
+++ lunar 10 Aug 2003 01:16:21 -0000 1.7
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
############################################################
# #
# lunar - Lunar module management utility #
@@ -27,8 +27,43 @@
############################################################
-show_modules()
-{
+help() {
+ cat << EOF
+Lunar -- a menu-driven software package management utility
+
+Example: lunar
+ This invokes the full-screen interface
+
+Usage: lunar [general options] [command [command parameters]]
+
+General options:
+
+-d | --debug Enables debug messages
+-h | --help Displays this help text
+-v | --verbose Increases the level of message output
+
+Commands:
+
+prune Removes old sources and install/compile logs
+renew Checks ver. against moonbase & recompiles if necessary
+update Fetches latest moonbase and then does a "renew"
+rebuild Recompiles all installed modules
+optimize Shortcut to the optimization menu
+fix Check and fix all modules and internal state of lunar
+nofix Check but do not fix modules and internal state
+fixdepends Check and fix the dependency database of lunar
+resurrect modulename(s) Force modulename(s) to be unpacked from /var/cache
+install modulename(s) Install a checklist of modules
+remove modulename(s) Remove a checklist of modules
+hold modulename(s) Place a hold on a checklist of modules
+unhold modulename(s) Remove a hold on a checklist of modules
+exile modulename(s) Remove a module and prevent it from being resurrected
+unexile modulename(s) Allows a module to be compiled|resurrected again
+EOF
+ exit 1
+}
+
+show_modules() {
for MODULE in `list_modules "$1"`; do
if ! module_installed $MODULE &&
! module_held $MODULE &&
@@ -36,7 +71,7 @@
then
SHORT="Short Description Unavailable"
(
- run_details
+ run_details $MODULE
echo $MODULE
echo $VERSION
echo $SHORT
@@ -63,7 +98,7 @@
--cancel-label "Exit" \
--menu \
"" \
- 0 0 10 \
+ 0 40 15 \
`show_sections`
}
@@ -129,27 +164,22 @@
show_installed_modules() {
- for LINE in `sort $MODULE_STATUS_BACKUP`; do
- MODULE=`echo "$LINE" | cut -d : -f1`
- STATUS=`echo "$LINE" | cut -d : -f3`
- VERSION=`echo "$LINE" | cut -d : -f4`
- SIZE=`echo "$LINE" | cut -d : -f5`
+ for LINE in $(sort $MODULE_STATUS_BACKUP) ; do
+ (
+ MODULE=`echo "$LINE" | cut -d : -f1`
+ STATUS=`echo "$LINE" | cut -d : -f3`
+ VERSION=`echo "$LINE" | cut -d : -f4`
+ SIZE=`echo "$LINE" | cut -d : -f5`
- if [ "$STATUS" == "installed" ] ||
- [ "$STATUS" == "held" ]; then
-
- [ -n "$SIZE" ] && SIZE=", $SIZE"
-
- SHORT="Short Description Unavailable"
- SECTION=`find_section $MODULE`
-
- [ -x $MOONBASE/$SECTION/$MODULE/DETAILS ] &&
- . $MOONBASE/$SECTION/$MODULE/DETAILS > /dev/null
-
- echo "$MODULE"
- echo "$VERSION$SIZE"
- echo "$SHORT"
+ # TODO THIS IS BROKEN
+ if module_installed $MODULE ; then
+ SHORT="Short Description Unavailable"
+ run_module_file $MODULE DETAILS &> /dev/null
+ echo -e "$MODULE\n"
+ echo -e "$VERSION,$SIZE\n"
+ echo -e "\"$SHORT\"\n"
fi
+ )
done
}
@@ -158,10 +188,10 @@
while
if [ -z "$INSTALLED_MODULES" ]; then
echo "Discovering installed modules..."
- INSTALLED_MODULES=`show_installed_modules`
+ INSTALLED_MODULES=$(show_installed_modules)
fi
- MODULE=`$DIALOG --title "Select module to remove please." \
+ MODULE=`$DIALOG --title "Select module to remove please." \
--item-help \
--ok-label "Select" \
--cancel-label "Exit" \
@@ -169,10 +199,7 @@
$INSTALLED_MODULES`
do
DESCRIPTION="Description unavailable"
- SECTION=`find_section $MODULE` &&
- if [ -x $MOONBASE/$SECTION/$MODULE/DETAILS ]; then
- DESCRIPTION=`$MOONBASE/$SECTION/$MODULE/DETAILS`
- fi
+ run_module_file $MODULE DETAILS
if $DIALOG --title "Removal $MODULE" \
--yesno "$DESCRIPTION" \
@@ -186,60 +213,12 @@
}
-update_pkgs() {
-
- if ps -C lin > /dev/null; then
- echo "Unable to update lunar concurrently while installing."
- sleep 5
- return 1
- fi
-
- lin moonbase
- if (( $(lvu installed $LUNAR_MODULE) < $(lvu version $LUNAR_MODULE) ))
- then
- lin $LUNAR_MODULE && lunar renew
- else
- lunar renew
- fi
-
-}
-
-
-rebuild() {
- rm -f $INSTALL_QUEUE
-
- message "To do a non recursive rebuild"
- message "all installed modules must be fixed first."
- sleep 3
- $LIN --fix
-
- for LINE in `cat $MODULE_STATUS_BACKUP`; do
- MODULE=`echo "$LINE" | cut -d : -f1`
- STATUS=`echo "$LINE" | cut -d : -f3`
- if [ "$STATUS" == "installed" ] &&
- [ "$MODULE" != "$LUNAR_MODULE" ]; then
- echo $MODULE >> $INSTALL_QUEUE
- fi
- done
-
- message "Sorting the dependencies, that may take some time"
- sort_install_queue
-
- unset MODULE
- if query "Edit Rebuild/Install Queue?" n
- then edit_file $INSTALL_QUEUE
- fi
-
- $LIN --compile `cat $INSTALL_QUEUE`
- rm -f $INSTALL_QUEUE
-}
-
make_checklist() {
for MODULE in `list_modules "$1"`; do
SHORT="Short Description Unavailable"
(
- run_details
+ run_details $MODULE
STATUS="OFF"
if module_installed $MODULE ||
@@ -293,28 +272,22 @@
make_hold_checklist() {
- for LINE in `sort $MODULE_STATUS_BACKUP`; do
- MODULE=`echo "$LINE" | cut -d : -f1`
- STATUS=`echo "$LINE" | cut -d : -f3`
- VERSION=`echo "$LINE" | cut -d : -f4`
-
- if [ "$STATUS" == "installed" ] ||
- [ "$STATUS" == "held" ]; then
-
- [ "$STATUS" == "held" ] &&
- HELD="on" ||
- HELD="off"
-
- if SECTION=`find_section $MODULE`; then
- SHORT="Short Description Unavailable"
- . $MOONBASE/$SECTION/$MODULE/DETAILS > /dev/null
-
- echo $MODULE
- echo $VERSION
- echo $HELD
- echo $SHORT
+ for LINE in $(sort $MODULE_STATUS_BACKUP) ; do
+ (
+ MODULE=$(echo "$LINE" | cut -d: -f1)
+ STATUS=$(echo "$LINE" | cut -d: -f3)
+ VERSION=$(echo "$LINE" | cut -d: -f4)
+ if [ "$STATUS" == "installed" ] || [ "$STATUS" == "held" ] ; then
+ [ "$STATUS" == "held" ] && HELD="on" || HELD="off"
+ SHORT="Short description unavailable"
+ if run_details $MODULE &> /dev/null ; then
+ echo $MODULE
+ echo $VERSION
+ echo $HELD
+ echo $SHORT
fi
fi
+ )
done
}
@@ -382,7 +355,7 @@
"U" "Update" "$U_HELP"`
do
case $COMMAND in
- U) update_pkgs ;;
+ U) update ;;
S) select_pkgs ;;
A) add_pkgs ;;
R) remove_pkgs ;;
@@ -467,10 +440,10 @@
maintenance_menu() {
while
- F_HELP="lin --fix: Check and fix all modules and internal state of lunar"
- N_HELP="lin --nofix: Check all modules but do not fix the internal state"
- D_HELP="lin --fixdepends: Check and fix the dependancy database of lunar"
- P_HELP="lunar prune: Prune old sources and install/compile logs"
+ F_HELP="Check and fix all modules and internal state of lunar"
+ N_HELP="Check all modules but do not fix the internal state"
+ D_HELP="Check and fix the dependency database of lunar"
+ P_HELP="Prune old sources and install/compile logs"
COMMAND=`$DIALOG --title "Maintenance Menu" \
--ok-label "Select" \
@@ -482,14 +455,14 @@
0 40 6 \
"F" "Fix everything" "$F_HELP" \
"N" "Check everything but don't fix" "$N_HELP" \
- "D" "Fix dependancies" "$D_HELP" \
+ "D" "Fix dependencies" "$D_HELP" \
"P" "Prune old sources and logs" "$P_HELP"`
do
case $COMMAND in
- F) lin --fix ;;
- N) lin --nofix ;;
- D) lin --fixdepends ;;
- P) lunar prune ;;
+ F) lunar fix ;;
+ N) lunar nofix ;;
+ D) lunar fixdepends ;;
+ P) lunar prune ;;
esac
message "${MESSAGE_COLOR}Press enter to return...${DEFAULT_COLOR}"
read
@@ -538,6 +511,7 @@
E_HELP="Remove files when lrm?"
F_HELP="Check for and repair broken programs after updating lunar?"
G_HELP="Install the garbage documentation? (extras like README, LICENSE etc)"
+ H_HELP="Automatically resurrect modules instead of compiling them?"
I_HELP="Create archives of installed software?"
K_HELP="Keep source code in /usr/src on good compiles? (gcc profiling needs it)"
M_HELP="Email reports?"
@@ -548,8 +522,10 @@
U_HELP="Automatically remove old sources and install caches upon lunar update?"
V_HELP="View compilation as it happens?"
W_HELP="Verbose display of compilation process?"
+ Z_HELP="Custom modules in zlocal override equally named ones (NOT RECOMMENDED) ?"
ARCHIVE=${ARCHIVE:=on}
+ AUTORESURRECT=${AUTORESURRECT:=on}
AUTOFIX=${AUTOFIX:=on}
AUTOPRUNE=${AUTOPRUNE:=off}
CABAL=${CABAL:=off}
@@ -576,26 +552,29 @@
--checklist \
"" \
0 40 14 \
- "ARCHIVE" "Toggle" "$ARCHIVE" "$I_HELP" \
- "AUTOFIX" "Toggle" "$AUTOFIX" "$F_HELP" \
- "AUTOPRUNE" "Toggle" "$AUTOPRUNE" "$U_HELP" \
- "CABAL" "Toggle" "$CABAL" "$B_HELP" \
- "COLOR" "Toggle" "$COLOR" "$C_HELP" \
- "KEEP_SOURCE" "Toggle" "$KEEP_SOURCE" "$K_HELP" \
- "GARBAGE" "Toggle" "$GARBAGE" "$G_HELP" \
- "MAIL_REPORTS" "Toggle" "$MAIL_REPORTS" "$M_HELP" \
- "PRESERVE" "Toggle" "$PRESERVE" "$P_HELP" \
- "SOUND" "Toggle" "$SOUND" "$S_HELP" \
- "SUSTAIN" "Toggle" "$SUSTAIN" "$T_HELP" \
- "VIEW_REPORTS" "Toggle" "$VIEW_REPORTS" "$R_HELP" \
- "VOYEUR" "Toggle" "$VOYEUR" "$V_HELP" \
- "REAP" "Toggle" "$REAP" "$E_HELP" \
- "TMPFS" "Toggle" "$TMPFS" "$D_HELP" \
- "VERBOSE" "Toggle" "$VERBOSE" "$W_HELP"`
+ "ARCHIVE" "Toggle" "$ARCHIVE" "$I_HELP" \
+ "AUTORESURRECT" "Toggle" "$AUTORESURRECT" "$H_HELP" \
+ "AUTOFIX" "Toggle" "$AUTOFIX" "$F_HELP" \
+ "AUTOPRUNE" "Toggle" "$AUTOPRUNE" "$U_HELP" \
+ "CABAL" "Toggle" "$CABAL" "$B_HELP" \
+ "COLOR" "Toggle" "$COLOR" "$C_HELP" \
+ "KEEP_SOURCE" "Toggle" "$KEEP_SOURCE" "$K_HELP" \
+ "GARBAGE" "Toggle" "$GARBAGE" "$G_HELP" \
+ "MAIL_REPORTS" "Toggle" "$MAIL_REPORTS" "$M_HELP" \
+ "PRESERVE" "Toggle" "$PRESERVE" "$P_HELP" \
+ "SOUND" "Toggle" "$SOUND" "$S_HELP" \
+ "SUSTAIN" "Toggle" "$SUSTAIN" "$T_HELP" \
+ "VIEW_REPORTS" "Toggle" "$VIEW_REPORTS" "$R_HELP" \
+ "VOYEUR" "Toggle" "$VOYEUR" "$V_HELP" \
+ "REAP" "Toggle" "$REAP" "$E_HELP" \
+ "TMPFS" "Toggle" "$TMPFS" "$D_HELP" \
+ "VERBOSE" "Toggle" "$VERBOSE" "$W_HELP" \
+ "ZLOCAL_OVERRIDES" "Toggle" "$ZLOCAL_OVERRIDES" "$Z_HELP"`
then
ARCHIVE=off
+ AUTORESURRECT=off
AUTOFIX=off
AUTOPRUNE=off
CABAL=off
@@ -611,10 +590,12 @@
GARBAGE=off
TMPFS=off
VERBOSE=off
+ZLOCAL_OVERRIDES=off
for TOGGLE in $TOGGLES; do
case $TOGGLE in
ARCHIVE) ARCHIVE=on ;;
+ AUTORESURRECT) AUTORESURRECT=on ;;
AUTOFIX) AUTOFIX=on ;;
AUTOPRUNE) AUTOPRUNE=on ;;
CABAL) CABAL=on ;;
@@ -630,11 +611,13 @@
GARBAGE) GARBAGE=on ;;
TMPFS) TMPFS=on ;;
VERBOSE) VERBOSE=on ;;
+ ZLOCAL_OVERRIDES) ZLOCAL_OVERRIDES=on ;;
esac
done
TEMP=`cat $LOCAL_CONFIG |
grep -v "ARCHIVE=" |
+ grep -v "AUTORESURRECT=" |
grep -v "AUTOFIX=" |
grep -v "AUTOPRUNE=" |
grep -v "CABAL=" |
@@ -649,25 +632,28 @@
grep -v "GARBAGE=" |
grep -v "color" |
grep -v "TMPFS=" |
- grep -v "VERBOSE="`
+ grep -v "VERBOSE=" |
+ grep -v "ZLOCAL_OVERRIDES="`
- echo "$TEMP" > $LOCAL_CONFIG
- echo " ARCHIVE=$ARCHIVE" >> $LOCAL_CONFIG
- echo " AUTOFIX=$AUTOFIX" >> $LOCAL_CONFIG
- echo " AUTOPRUNE=$AUTOPRUNE" >> $LOCAL_CONFIG
- echo " CABAL=$CABAL" >> $LOCAL_CONFIG
- echo " KEEP_SOURCE=$KEEP_SOURCE" >> $LOCAL_CONFIG
- echo "MAIL_REPORTS=$MAIL_REPORTS" >> $LOCAL_CONFIG
- echo " PRESERVE=$PRESERVE" >> $LOCAL_CONFIG
- echo " SOUND=$SOUND" >> $LOCAL_CONFIG
- echo " SUSTAIN=$SUSTAIN" >> $LOCAL_CONFIG
- echo "VIEW_REPORTS=$VIEW_REPORTS" >> $LOCAL_CONFIG
- echo " VOYEUR=$VOYEUR" >> $LOCAL_CONFIG
- echo " REAP=$REAP" >> $LOCAL_CONFIG
- echo " GARBAGE=$GARBAGE" >> $LOCAL_CONFIG
- echo " color $COLOR" >> $LOCAL_CONFIG
- echo " TMPFS=$TMPFS" >> $LOCAL_CONFIG
- echo " VERBOSE=$VERBOSE" >> $LOCAL_CONFIG
+ echo "$TEMP" > $LOCAL_CONFIG
+ echo " ARCHIVE=$ARCHIVE" >> $LOCAL_CONFIG
+ echo "AUTORESURRECT=$AUTORESURRECT" >> $LOCAL_CONFIG
+ echo " AUTOFIX=$AUTOFIX" >> $LOCAL_CONFIG
+ echo " AUTOPRUNE=$AUTOPRUNE" >> $LOCAL_CONFIG
+ echo " CABAL=$CABAL" >> $LOCAL_CONFIG
+ echo " KEEP_SOURCE=$KEEP_SOURCE" >> $LOCAL_CONFIG
+ echo " MAIL_REPORTS=$MAIL_REPORTS" >> $LOCAL_CONFIG
+ echo " PRESERVE=$PRESERVE" >> $LOCAL_CONFIG
+ echo " SOUND=$SOUND" >> $LOCAL_CONFIG
+ echo " SUSTAIN=$SUSTAIN" >> $LOCAL_CONFIG
+ echo " VIEW_REPORTS=$VIEW_REPORTS" >> $LOCAL_CONFIG
+ echo " VOYEUR=$VOYEUR" >> $LOCAL_CONFIG
+ echo " REAP=$REAP" >> $LOCAL_CONFIG
+ echo " GARBAGE=$GARBAGE" >> $LOCAL_CONFIG
+ echo " color $COLOR" >> $LOCAL_CONFIG
+ echo " TMPFS=$TMPFS" >> $LOCAL_CONFIG
+ echo " VERBOSE=$VERBOSE" >> $LOCAL_CONFIG
+ echo "ZLOCAL_OVERRIDES=$ZLOCAL_OVERRIDES" >> $LOCAL_CONFIG
fi
}
@@ -809,45 +795,68 @@
}
-main() {
- case $1 in
- prune) prune ;;
- renew) update_installed
- upgrade_install_queue ;;
- update) update_pkgs autoupdate ;;
- rebuild) rebuild ;;
- optimize) optimize_architecture ;;
- *) main_menu ;;
- esac
-}
-
DIALOG="dialog
--backtitle
Lunar Module Management Utility
--stdout"
+main() {
+ #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"
+
+ LUNAR_MODULE=${LUNAR_MODULE:=lunar}
+ LUNAR_VERSION=$(run_details $LUNAR_MODULE && echo $UPDATED)
+
+ main_menu
+}
+
. /etc/lunar/config
-#lets load the menu code
-if [ -n "$MENUS" ]; then
- for FILE in `echo $MENUS/*.menu`
- do
- [ -s "$FILE" ] && . "$FILE"
- done
-fi
-root_check || exit
+GETOPT_ARGS=$(getopt -q -n lunar -o "dhv" -l "debug,help,verbose" -- "$@")
-LUNAR_PRIORITY=${LUNAR_PRIORITY:="+10"}
-renice "$LUNAR_PRIORITY" -p $$ 2> /dev/null >/dev/null
+if [ -z "$?" ] ; then
+ help | view_file
+ exit
+else
+ eval set -- $GETOPT_ARGS
+ root_check
+ enviro_check
+ set_priority
-LUNAR_MODULE=${LUNAR_MODULE:=lunar}
-export IFS="$TAB_ENTER_IFS"
-# LUNAR_VERSION=`installed_version lunar`
-LUNAR_SECTION=`find_section $LUNAR_MODULE`
-LUNAR_DETAILS="$MOONBASE/$LUNAR_SECTION/$LUNAR_MODULE/DETAILS"
-LUNAR_VERSION=`grep "UPDATED=" $LUNAR_DETAILS |
-sed "s/UPDATED=//"`
+ 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
-main $*
+ case "$1" in
+ prune ) prune ;;
+ renew ) renew ;;
+ update ) update ;;
+ rebuild ) rebuild ;;
+ optimize ) optimize_architecture ;;
+ fix ) shift && run_fix $@ ;;
+ nofix ) shift && export NOFIX=on && 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