[Lunar-commits] CVS: theedge/var/lib/lunar/functions config.lunar, 1.6, 1.7 optimize.lunar, 1.47, 1.48 uniqid.lunar, 1.7, 1.8

Auke Kok sofar at lunar-linux.org
Wed Mar 17 22:58:13 GMT 2004


Update of /var/cvs/lunar/theedge/var/lib/lunar/functions
In directory dbguin.lunar-linux.org:/tmp/cvs-serv28469/var/lib/lunar/functions

Modified Files:
	config.lunar optimize.lunar uniqid.lunar 
Log Message:
New config concept: atomic config operations:
- get/set_module_config: get/sets a var for a module
- get_set_local_config: get/sets a var in /etc/lunar/local/config
- rewrote menu's and optimization code to fit (contained a bug sinces
last week resulting in optimize menu's not working properly - fixed)
- tested mildly, the concept is sound but I may have dropped a thread!!!
(This commit is ON THE EDGE. You are warned)
- implemented lunar set [VAR [VAL]] for easy access to system vars
- forgot to recode all of moonbase to use these methods. things break. get over it, or help me fix it in the next weekend.
- gone to bed. sleeping while your boxes die.


Index: config.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/config.lunar,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- config.lunar	23 Feb 2004 21:15:53 -0000	1.6
+++ config.lunar	17 Mar 2004 22:58:11 -0000	1.7
@@ -1,4 +1,5 @@
 #!/bin/bash
+############################################################
 #                                                          #
 # This code is written for Lunar Linux, see                #
 # http://www.lunar-linux.org                               #
@@ -6,109 +7,67 @@
 ############################################################
 #                                                          #
 # $FUNCTIONS/config                                        #
-# includes write_config function                           #
-#                                                          #
-# 20020713                                                 #
+# set_config, get_config                                   #
+# set_local_config, get_local_config                       #
+# set_module_config, get_module_config                     #
 #                                                          #
 ############################################################
 #                                                          #
-# Copyrighted Kagan Kongar 2002 under GPLv2                #
+# Copyrighted Auke Kok 2004 under GPLv2                    #
 #                                                          #
 ############################################################
 
-# function: write_config
-# usage   : write_config <line to remove> [<line to add>]
-# purpose : removes a line from the $LOCAL_CONFIG and adds another (if given)
-function write_config() {
-   [ -z "$1" ] && return 1        
 
-   TMP_LOCAL_CONFIG="/tmp/lunar.localconfig.$$"
-   rm -f $TMP_LOCAL_CONFIG 2>/dev/null
 
-   LOCAL_CONFIG_BACKUP="/tmp/lunar.localconfigbackup.$$"
-   rm -f $LOCAL_CONFIG_BACKUP 2>/dev/null
-
-   function handle_trap() {
-      cp $LOCAL_CONFIG_BACKUP $LOCAL_CONFIG 2>/dev/null     
-      unlock_file $LOCAL_CONFIG        
-      rm -f $TMP_LOCAL_CONFIG 2>/dev/null
-      rm -f $LOCAL_CONFIG_BACKUP 2>/dev/null
-      exit 1
-   }
-
-
-   [ -f "$LOCAL_CONFIG" ] || {
-           touch $LOCAL_CONFIG     &&
-           chmod 644 $LOCAL_CONFIG &&
-           chown 0:0 $LOCAL_CONFIG
-   }
+set_config() {
+  debug_msg "set_config ($@)"
 
-   cp $LOCAL_CONFIG $LOCAL_CONFIG_BACKUP 2>/dev/null || return 1
+  LINE=$(cat $1 | grep -w "$2=.*")
+  if [ "$1" == "$LOCAL_CONFIG" ] ; then
+    NEW=$(printf "%16s=%s" "$2" "$3")
+  else
+    NEW="$2=$3"
+  fi
+  lock_file $1 &&
+  if [ -n "$LINE" ] ; then
+    sedit "s:$LINE:$NEW:" $1
+  else
+    echo "$NEW" >> $1
+  fi
+  unlock_file $1
+}
 
-   trap "handle_trap" INT QUIT TERM
 
-   lock_file $LOCAL_CONFIG
+get_config() {
+  cat $1 | grep -w "$2=.*" | cut -d= -f2-
+}
 
-   grep -v $1 $LOCAL_CONFIG 2>/dev/null > $TMP_LOCAL_CONFIG        
 
-   cat $TMP_LOCAL_CONFIG 2>/dev/null > $LOCAL_CONFIG || return 1
-   
-   [ -n "$2" ] && {
-      echo $2  >> $LOCAL_CONFIG || return 1
-   }
+set_local_config() {
+  debug_msg "set_local_config ($@)"
+  set_config "$LOCAL_CONFIG" "$1" "$2"
+}
 
-   unlock_file $LOCAL_CONFIG
 
-   rm -f $TMP_LOCAL_CONFIG 2>/dev/null
-   rm -f $LOCAL_CONFIG_BACKUP 2>/dev/null
-   trap INT QUIT TERM
+get_local_config() {
+  debug_msg "get_local_config ($@)"
+  get_config "$LOCAL_CONFIG" "$1"
 }
 
-# function: get_module_configured
-#    usage: get_module_configured <date of config implement>
-#  purpose: This function is to implement a standard method 
-#           to specify a CONFIGURATION file format change in 
-#           the moonbase.  the date passed should be the unix date 
-#           that the format was last changed.  This is so that when 
-#           a CONFIGURE file has changed we can inform the user 
-#           instead of ignoring changes.
 
-get_module_configured(){
-  debug_msg "module_configured ($@)"
-  if [ "$#" -ne "1" ] ; then
-    message "${PROBLEM_COLOR}Configuration date missing, assuming unconfigured."
-    message "${MESSAGE_COLOR}Please inform the lunar devlopers of this issue. ${DEFAULT_COLOR}"
-    return false
+set_module_config() {
+  debug_msg "set_module_config ($@)"
+  if [ -n "$MODULE" ] ; then
+    set_config "$DEPENDS_CONFIG/$MODULE" "$1" "$2"
   fi
+}
 
-  # Check for file, return false for missing
-  if [ ! -f "$MODULE_CONFIG" ] ; then
-    debug_msg "Config file for $MODULE not found"
-    return false
-  fi
 
-  # Check for configured date flag
-  MC_CONFIG_DATE=$(grep "CONFIGURED=" $MODULE_CONFIG | sed "s:.*=\([0-9]*\)[^0-9]*:\1:")
-  if [ -n "$MC_CONFIG_DATE" ] ; then
-    if [ "$MC_CONFIG_DATE" -le "$1" ] ; then
-      # the file is old, reconfigure
-      return false
-    else
-      # configuration current
-      return true
-    fi
+get_module_config() {
+  debug_msg "get_module_config ($@)"
+  if [ -n "$MODULE" ] ; then
+    get_config "$DEPENDS_CONFIG/$MODULE" "$1"
   fi
-  # other error?
-  return false
 }
 
 
-# function: set_module_configured
-#    usage: set_module_configured [<quoted list of lines to append to file>]   -#  purpose: to freshen the module configuration file with current config date
-set_module_configured() {
-  debug_msg "set_module_configured ($@)"
-  echo "CONFIGURED=$(date -u +%Y%m%d)" > $MODULE_CONFIG
-  for line in $@ ; do
-    echo "$line" >> $MODULE_CONFIG
-  done
-}

Index: optimize.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/optimize.lunar,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- optimize.lunar	15 Mar 2004 22:54:34 -0000	1.47
+++ optimize.lunar	17 Mar 2004 22:58:11 -0000	1.48
@@ -492,11 +492,7 @@
         Profiling) if [[ $GCCVER == "3" ]] ; then
                      CFLAGS="$CFLAGS -fprofile-arcs"
                      CXXFLAGS="$CXXFLAGS -fprofile-arcs"
-		     if ! [[ `grep KEEP_SOURCE=on /etc/lunar/local/config` ]]; then
-		       echo "KEEP_SOURCE=yes" >> /etc/lunar/local/config
-		     elif [[ `grep KEEP_SOURCE=off /etc/lunar/local/config` ]]; then
-		       sedit "s/KEEP_SOURCE=off/KEEP_SOURCE=on/" /etc/lunar/local/config
-		     fi
+		     set_local_config "KEEP_SOURCE" "on"
                    else
                      CFLAGS="$CFLAGS"
                      CXXFLAGS="$CXXFLAGS"
@@ -847,7 +843,7 @@
   help compiler_help          &&
   compiler_options            &&
   menu radiolist              &&
-  COMPILER=$RESULT
+  GCCVER=$RESULT
   
   help cc_help                &&
   cc_options                  &&
@@ -924,6 +920,8 @@
 		"Enter the number to set the stack to, leave empty for default."  \
 		0 55 $STACK`
 
+  set_optimize
+
 }
 
 

Index: uniqid.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/uniqid.lunar,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- uniqid.lunar	25 Nov 2003 23:22:38 -0000	1.7
+++ uniqid.lunar	17 Mar 2004 22:58:11 -0000	1.8
@@ -46,7 +46,7 @@
 
   verbose_msg "id(\"$IFACE\")=\"$UNIQID\""
 
-  echo  "      UNIQID=$UNIQID"   >>   $LOCAL_CONFIG
+  set_local_config "UNIQID" "$UNIQID"
 
 }
 



More information about the Lunar-commits mailing list