[Lunar-commits] CVS: theedge/var/lib/lunar/functions aliases.lunar, NONE, 1.1 check.lunar, 1.17, 1.18 depends.lunar, 1.44, 1.45

Auke Kok sofar at lunar-linux.org
Tue Oct 12 11:29:08 UTC 2004


Update of /var/cvs/lunar/theedge/var/lib/lunar/functions
In directory espresso.foo-projects.org:/tmp/cvs-serv18211/var/lib/lunar/functions

Modified Files:
	check.lunar depends.lunar 
Added Files:
	aliases.lunar 
Log Message:
Merging aliases code with theedge!!!


--- NEW FILE: aliases.lunar ---
#!/bin/bash
############################################################
#                                                          #
# aliases.lunar - Lunar alias code                         #
#                                                          #
############################################################
#                                                          #
# Copyright 2004 by Auke Kok under GPLv2under GPLv2        #
#                                                          #
############################################################

# translate %ALIAS if needed to a module name that is installed
# and add it to the dependency chain if needed
unalias() {
  if [ "${1:0:1}" == "%" ] ; then
    debug_msg "unalias($@)"
    TARGETS=$(grep "^$1:" $ALIASES | cut -d: -f2-)
    # dumb algorithm: pick the first installed one
    for TARGET in $TARGETS ; do
      if $(module_installed $TARGET) ; then
        debug_msg "unaliased \"$1\"->\"$TARGET\""
        echo $TARGET
	return
      fi
    done
    # shortcut out when not installed and running lvu
    if [ "$(basename $0)" == "lvu" ] ; then
      echo $1
      return
    fi
    # shortcut out: in the satisfy_depends stage we should NOT ask this again
    if [ -z "$DEPS_ONLY" ] ; then
      for TARGET in $TARGETS ; do
        # the target should be present in the dependency database:
        if in_depends $MODULE $TARGET ; then
          debug_msg "unaliased \"$1\"->\"$TARGET\""
          echo $TARGET
          return
	fi
      done
    fi

    # propose one and let the user pick it from a list:
    debug_msg "unalias: starting selection loop"
    error_message "${MODULE_COLOR}$MODULE${DEFAULT_COLOR}${MESSAGE_COLOR} depends on ${DEFAULT_COLOR}${QUERY_COLOR}\"${1:1}\"${DEFAULT_COLOR}${MESSAGE_COLOR} which is an alias${DEFAULT_COLOR}"
    while true ; do
      error_message "${MESSAGE_COLOR}Please select a substitute ! Enter the number or the name of the module${DEFAULT_COLOR}"
      ((N=0))
      for TARGET in $TARGETS ; do
        ((N++))
	TARGETBYNUM[$N]=$TARGET
        error_message "  ${QUERY_COLOR}$N${MESSAGE_COLOR} - ${DEFAULT_COLOR}${MODULE_COLOR}$TARGET${DEFAULT_COLOR}"
      done
      read CHOICE
      # test directly first
      if $(echo $TARGETS | grep -qw "$CHOICE") ; then
        echo $TARGET
	return
      # then the number
      elif [ -n "$CHOICE" -a -n "${TARGETBYNUM[$CHOICE]}" ] ; then
        echo ${TARGETBYNUM[$CHOICE]}
        return
      fi
      error_message "${MESSAGE_COLOR}Sorry, I can't do anything with \"${DEFAULT_COLOR}${QUERY_COLOR}$CHOICE${DEFAULT_COLOR}${MESSAGE_COLOR}\", please try again${DEFAULT_COLOR}"
    done
  else
    echo $1
    return
  fi
}

Index: check.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/check.lunar,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- check.lunar	10 May 2004 15:31:53 -0000	1.17
+++ check.lunar	12 Oct 2004 11:29:06 -0000	1.18
@@ -237,28 +237,30 @@
   # we declare these local to override the systems default ones:
   optional_depends()  {
     debug_msg "  optional_depends ($@)"
-    if module_exiled $1 ; then
-      echo "$MODULE:$1:off:optional:$2:$3"
+    DEP=$(unalias $1)
+    if module_exiled $DEP ; then
+      echo "$MODULE:$DEP:off:optional:$2:$3"
     else
-      if module_installed $1 || module_held $1 ; then
-        echo "$MODULE:$1:on:optional:$2:$3"
+      if module_installed $DEP || module_held $DEP ; then
+        echo "$MODULE:$DEP:on:optional:$2:$3"
       else
-        echo "$MODULE:$1:off:optional:$2:$3"
+        echo "$MODULE:$DEP:off:optional:$2:$3"
       fi
     fi
   }
                                                                                 
   depends()  {
     debug_msg "  depends ($@)"
-    if ! module_installed $1 && ! module_held $1 ; then
-      if ! is_depends $1 && module_exiled $1 ; then
+    DEP=$(unalias $1)
+    if ! module_installed $DEP && ! module_held $DEP ; then
+      if ! is_depends $DEP && module_exiled $DEP ; then
         return  1
       else
-        CHANGED_MODULES="$CHANGED_MODULES $1"
+        CHANGED_MODULES="$CHANGED_MODULES $DEP"
       fi
     fi
 
-    echo "$MODULE:$1:on:required:$2:$3"
+    echo "$MODULE:$DEP:on:required:$2:$3"
   }
 
   run_depends() {
@@ -385,4 +387,3 @@
   done
 }
 
-

Index: depends.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/depends.lunar,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- depends.lunar	13 Jun 2004 12:52:07 -0000	1.44
+++ depends.lunar	12 Oct 2004 11:29:06 -0000	1.45
@@ -30,6 +30,7 @@
   find_depends_intern() {
     grep "^$1:" $DEPENDS_CACHE | while read LINE ; do
       DEP=$(echo $LINE | cut -d: -f2)
+      DEP=$(unalias $DEP)
       # this is our shortcut out:
       if ! grep -qx "$DEP" $TMP_FDEPS ; then
       debug_msg "$DEP"
@@ -47,7 +48,7 @@
   }
 
   TMP_FDEPS=$(temp_create "found.depends")
-  find_depends_intern $1
+  find_depends_intern $(unalias $1)
   temp_destroy $TMP_FDEPS
 }
 
@@ -66,7 +67,7 @@
   done
 
   # tsort the existing dep relations in all of moonbase
-  cat $DEPENDS_CACHE | awk -F: '{print $1" "$2}' | tsort 2> /dev/null | tac > $TMP_ALL
+  cat $DEPENDS_CACHE | awk -F: '{print $1" "$2}' | while read A B ; do echo $A $(unalias $B) ; done | tsort 2> /dev/null | tac > $TMP_ALL
   # append all modules that do not have a DEPENDS file at all at the end
   # note that this is logically WRONG, but it actually will help with
   # unincluded depends, and therefore is *better* behaviour
@@ -152,21 +153,27 @@
 run_depends() {
   debug_msg "run_depends ($@)"
   # local definitions of depends and optional_depends!
-  depends()  {
+  depends() {
     debug_msg "  depends ($@)"
-    grep -q "^"$1"\$" $TEMP_PREPAREDDEPS 2>/dev/null && return 0
+    DEP=$(unalias $1)
+    if grep -q "^$DEP\$" $TEMP_PREPAREDDEPS 2>/dev/null ; then
+      return 0
+    fi
 
-    if ! module_installed $1 && ! module_held $1 ; then
-      if ! is_depends $1 && module_exiled $1 ; then
-        message "${MODULE_COLOR}${MODULE}:${PROBLEM_COLOR} ! Error: required dependency ${MODULE_COLOR}${1}${DEFAULT_COLOR}${PROBLEM_COLOR} is exiled and cannot be installed${DEFAULT_COLOR}"
+    if module_installed $DEP ; then
+      add_depends "$MODULE" "$DEP" "on" "required" "$2" "$3"
+      echo "$DEP" >> $TEMP_PREPAREDDEPS
+    elif ! module_installed $DEP && ! module_held $DEP ; then
+      if module_exiled $DEP ; then
+        message "${MODULE_COLOR}${MODULE}:${PROBLEM_COLOR} ! Error: required dependency ${MODULE_COLOR}$DEP${DEFAULT_COLOR}${PROBLEM_COLOR} is exiled and cannot be installed${DEFAULT_COLOR}"
         return 1
       else
         message "${MODULE_COLOR}${MODULE}: ${DEFAULT_COLOR}" \
                 "Adding required dependency${FILE_COLOR}"   \
-                "$1 ${DEFAULT_COLOR}"
-        add_depends "$MODULE" "$1" "on" "required" "$2" "$3"
-        lin --deps $1
-        echo "$1" >> $TEMP_PREPAREDDEPS
+                "$DEP ${DEFAULT_COLOR}"
+        add_depends "$MODULE" "$DEP" "on" "required" "$2" "$3"
+        lin --deps $DEP
+        echo "$DEP" >> $TEMP_PREPAREDDEPS
       fi
     fi
   }
@@ -176,37 +183,38 @@
     # parameters:  $1 = module name
     #              $2 = configure parameter if module wanted
     #              $3 = configure parameter if module declined
-    #              $4 = description of why to use this module.
-                                                                                
-    if ! in_depends "$MODULE" "$1" ; then
+    #              $4 = description of why to use this module
+
+    DEP=$(unalias $1)
+    if ! in_depends "$MODULE" "$DEP" ; then
                                                                                
-      if module_exiled $1 ; then
-        verbose_msg "\"$MODULE\" optionally depends on exiled module \"$1\""
-        add_depends "$MODULE" "$1" "off" "optional" "$2" "$3"
+      if module_exiled $DEP ; then
+        verbose_msg "\"$MODULE\" optionally depends on exiled module \"$DEP\""
+        add_depends "$MODULE" "$DEP" "off" "optional" "$2" "$3"
       else
-        if module_installed $1 ; then
+        if module_installed $DEP ; then
           DEFAULT="y"
 	else
           DEFAULT="n"
         fi
 
-	if module_installed $1 ; then
-	  DEPMOD_AVAIL="Use optional ${MESSAGE_COLOR}(presently installed) module${QUERY_COLOR} $1"
+	if module_installed $DEP ; then
+	  DEPMOD_AVAIL="Use optional ${MESSAGE_COLOR}(presently installed) module${QUERY_COLOR} $DEP"
 	else
-	  DEPMOD_AVAIL="Install & use optional ${PROBLEM_COLOR}(not yet installed) ${MESSAGE_COLOR}module${QUERY_COLOR} $1"
+	  DEPMOD_AVAIL="Install & use optional ${PROBLEM_COLOR}(not yet installed) ${MESSAGE_COLOR}module${QUERY_COLOR} $DEP"
 	fi
 
         # this is shortcut case s1) as discussed in lunar-dev ML
-	if module_installed $1 && [ -z "$2" -a -z "$3" ] ; then
-	  verbose_msg "Auto-adding optional dependency \"$1\""
-          add_depends  "$MODULE"  "$1"  "on"   "optional"  "$2"  "$3"
-	  lin --deps $1
+	if module_installed $DEP && [ -z "$2" -a -z "$3" ] ; then
+	  verbose_msg "Auto-adding optional dependency \"$DEP\""
+          add_depends  "$MODULE"  "$DEP"  "on"   "optional"  "$2"  "$3"
+	  lin --deps $DEP
 	elif query  "$DEPMOD_AVAIL 
           dependency - purpose: $4? " $DEFAULT ; then
-          add_depends  "$MODULE"  "$1"  "on"   "optional"  "$2"  "$3"
-          lin --deps $1
+          add_depends  "$MODULE"  "$DEP"  "on"   "optional"  "$2"  "$3"
+          lin --deps $DEP
         else
-          add_depends  "$MODULE"  "$1"  "off"  "optional"  "$2"  "$3"
+          add_depends  "$MODULE"  "$DEP"  "off"  "optional"  "$2"  "$3"
 	fi
       fi
     fi
@@ -287,10 +295,11 @@
 # conflicts... remove conflicting modules
 conflicts() {
   debug_msg "conflicts ($@)"
-  if module_installed $1 ; then
-    message "${PROBLEM_COLOR}WARNING: ${DEFAULT_COLOR}${MODULE_COLOR}$1${DEFAULT_COLOR}${PROBLEM_COLOR} conflicts with module ${MODULE_COLOR}$MODULE${DEFAULT_COLOR}"
-    if query "Do you want to remove module ${DEFAULT_COLOR}${MODULE_COLOR}$1${DEFAULT_COLOR}${QUERY_COLOR} ? " n ; then
-      lrm $1
+  DEP=$1
+  if module_installed $DEP ; then
+    message "${PROBLEM_COLOR}WARNING: ${DEFAULT_COLOR}${MODULE_COLOR}$DEP${DEFAULT_COLOR}${PROBLEM_COLOR} conflicts with module ${MODULE_COLOR}$MODULE${DEFAULT_COLOR}"
+    if query "Do you want to remove module ${DEFAULT_COLOR}${MODULE_COLOR}$DEP${DEFAULT_COLOR}${QUERY_COLOR} ? " n ; then
+      lrm $DEP
     else
       message "${PROBLEM_COLOR}ERROR: Cannot continue installing conflicting modules, exiting!${DEFAULT_COLOR}"
       return 1



More information about the Lunar-commits mailing list