[Lunar-commits] CVS: theedge/sbin lrm,1.24,1.25

Auke Kok sofar at lunar-linux.org
Fri May 21 19:51:29 GMT 2004


Update of /var/cvs/lunar/theedge/sbin
In directory dbguin.lunar-linux.org:/tmp/cvs-serv11881/sbin

Modified Files:
	lrm 
Log Message:
Feature: lrm --purge $MODULES / lrm -p $MODULES. for instance: lrm -p qt3 removes qt3 and all apps that require (*REQUIRE*) qt3


Index: lrm
===================================================================
RCS file: /var/cvs/lunar/theedge/sbin/lrm,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- lrm	21 May 2004 10:27:13 -0000	1.24
+++ lrm	21 May 2004 19:51:27 -0000	1.25
@@ -27,6 +27,8 @@
    -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
+   -p | --purge         Delete all modules that depend on the module(s)
+                          being removed as well
    
 lrm is a script for removing installed modules.
    If invoked without options, lrm will remove all installed files 
@@ -285,7 +287,7 @@
 . /etc/lunar/config
 
 
-GETOPT_ARGS=$(getopt -q -n lrm -o "dD:hknv" -l "debug,downgrade:,help,keepconfig,nosustain,verbose" -- "$@")
+GETOPT_ARGS=$(getopt -q -n lrm -o "dD:hknvp" -l "debug,downgrade:,help,keepconfig,nosustain,verbose,purge" -- "$@")
 
 if [ -z "$?" ] ; then
   help | view_file
@@ -310,6 +312,7 @@
      -k|--keepconfig ) export KEEPCONFIG="on" ; shift ;;
      -n|--nosustain  ) export NOSUSTAIN="on" ; shift ;;
      -v|--verbose    ) export VERBOSE="on" ; shift ;;
+     -p|--purge      ) export PURGE="on" ; shift ;;
      --) shift; break ;;
       *) help;  break ;;
    esac
@@ -317,7 +320,25 @@
 
   for MODULE in "${@#-}" ; do
     if check_status "$MODULE" ; then
-      LIST="$LIST $MODULE"
+      # assemble pureg list if requested
+      if [ "$PURGE" == "on" ] ; then
+        DEPS=$(list_installed_depending "$MODULE")
+        for DEP in $DEPS ; do
+          # skip held modules
+          if ! module_held $DEP ; then
+	    # no duplicates
+	    if ! $(echo $LIST | grep -qw $DEP) ; then
+              message "${MESSAGE_COLOR}Inserting ${MODULE_COLOR}$DEP${DEFAULT_COLOR}${MESSAGE_COLOR} into the removal queue${DEFAULT_COLOR}"
+              LIST="$LIST $DEP"
+	    fi
+          fi
+        done
+	# last append the module itself
+	LIST="$LIST $MODULE"
+      else
+        # no fancy checks, just add to the list
+        LIST="$LIST $MODULE"
+      fi
     fi
   done
   for MODULE in $LIST ; do



More information about the Lunar-commits mailing list