[Lunar-commits] r22955 - lunar/trunk/var/lib/lunar/functions
Auke Kok
sofar at lunar-linux.org
Tue Jan 16 07:25:10 CET 2007
Author: sofar
Date: 2007-01-16 07:25:09 +0100 (Tue, 16 Jan 2007)
New Revision: 22955
Modified:
lunar/trunk/var/lib/lunar/functions/aliases.lunar
lunar/trunk/var/lib/lunar/functions/config.lunar
lunar/trunk/var/lib/lunar/functions/depends.lunar
lunar/trunk/var/lib/lunar/functions/modules.lunar
Log:
Speed up work: eliminate forks, use smart grep's etc.
Brings 'lin -p gtk+-2' down from 2.4s to 1.9s average.
Modified: lunar/trunk/var/lib/lunar/functions/aliases.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/aliases.lunar 2007-01-16 04:00:43 UTC (rev 22954)
+++ lunar/trunk/var/lib/lunar/functions/aliases.lunar 2007-01-16 06:25:09 UTC (rev 22955)
@@ -12,13 +12,13 @@
# translate %ALIAS if needed to a module name that is installed
# and add it to the dependency chain if needed
unalias() {
- local TARGET TARGETS TARGETBYNUM N CHOICE CACHED_ALIAS
# quick exit code
- if [ "${1:0:1}" != "%" ] ; then
+ if [[ "${1:0:1}" != "%" ]] ; then
echo $1
return
fi
+ local TARGET TARGETS TARGETBYNUM N CHOICE CACHED_ALIAS
# lookup in cache
CACHED_ALIAS=$(get_local_config `echo LUNAR_ALIAS_${1:1}`)
if [ -n "$CACHED_ALIAS" ]; then
Modified: lunar/trunk/var/lib/lunar/functions/config.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/config.lunar 2007-01-16 04:00:43 UTC (rev 22954)
+++ lunar/trunk/var/lib/lunar/functions/config.lunar 2007-01-16 06:25:09 UTC (rev 22955)
@@ -18,107 +18,114 @@
############################################################
+set_config()
+{
+ local LINE NEW
+ debug_msg "set_config ($@)"
-set_config() {
- local LINE NEW
- debug_msg "set_config ($@)"
+ LINE=$(grep -w "$2=.*" $1)
+ if [ "$1" == "$LOCAL_CONFIG" ] ; then
+ NEW=$(printf "%16s=%s" "$2" "$3")
+ else
+ NEW="$2=\"$3\""
+ fi
- LINE=$(cat $1 | grep -w "$2=.*")
- if [ "$1" == "$LOCAL_CONFIG" ] ; then
- NEW=$(printf "%16s=%s" "$2" "$3")
- else
- NEW="$2=\"$3\""
- fi
+ # on-demand creation
+ if [ ! -f $1 ] ; then
+ touch $1
+ fi
- # on-demand creation
- if [ ! -f $1 ] ; then
- touch $1
- fi
-
- lock_file $1 &&
- if [ -n "$LINE" ] ; then
- # make sure we escape those ':' characters:
- LINE=$(echo $LINE | sed 's/:/\\:/g')
- NEW=$(echo $NEW | sed 's/:/\\:/g')
- sedit "s:$LINE:$NEW:" $1
- else
- echo "$NEW" >> $1
- fi
- unlock_file $1
+ lock_file $1 &&
+ if [ -n "$LINE" ] ; then
+ # make sure we escape those ':' characters:
+ LINE=$(echo $LINE | sed 's/:/\\:/g')
+ NEW=$(echo $NEW | sed 's/:/\\:/g')
+ sedit "s:$LINE:$NEW:" $1
+ else
+ echo "$NEW" >> $1
+ fi
+ unlock_file $1
}
-unset_config() {
- debug_msg "unset_config ($@)"
-
- # on-demand creation
- if [ ! -f $1 ] ; then
- touch $1
- fi
+unset_config()
+{
+ debug_msg "unset_config ($@)"
- lock_file $1 &&
- if [ -n "$2" ] ; then
- # make sure we escape those ':' characters:
- sedit "/^[ ]*$2=/d" $1
- fi
- unlock_file $1
+ # on-demand creation
+ if [ ! -f $1 ] ; then
+ touch $1
+ fi
+
+ lock_file $1 &&
+ if [ -n "$2" ] ; then
+ # make sure we escape those ':' characters:
+ sedit "/^[ ]*$2=/d" $1
+ fi
+ unlock_file $1
}
-get_config() {
- if [ -f $1 ] ; then
- cat $1 | grep -w "$2=.*" | cut -d= -f2- | sed -e 's/^"//' -e 's/"$//'
- fi
+get_config()
+{
+ if [[ -f $1 ]] ; then
+ grep -w "$2=.*" $1 | cut -d= -f2- | sed -e 's/^"//' -e 's/"$//'
+ fi
}
-set_local_config() {
- debug_msg "set_local_config ($@)"
- set_config "$LOCAL_CONFIG" "$1" "$2"
+set_local_config()
+{
+ debug_msg "set_local_config ($@)"
+ set_config "$LOCAL_CONFIG" "$1" "$2"
}
-unset_local_config() {
- debug_msg "unset_local_config ($@)"
- unset_config "$LOCAL_CONFIG" "$1"
+unset_local_config()
+{
+ debug_msg "unset_local_config ($@)"
+ unset_config "$LOCAL_CONFIG" "$1"
}
get_local_config() {
- debug_msg "get_local_config ($@)"
- get_config "$LOCAL_CONFIG" "$1"
+ get_config "$LOCAL_CONFIG" "$1"
}
-set_module_config() {
- debug_msg "set_module_config ($@)"
- if [ -n "$MODULE" ] ; then
- set_config "$DEPENDS_CONFIG/$MODULE" "$1" "$2"
- fi
+set_module_config()
+{
+ debug_msg "set_module_config ($@)"
+ if [ -n "$MODULE" ] ; then
+ set_config "$DEPENDS_CONFIG/$MODULE" "$1" "$2"
+ fi
}
-unset_module_config() {
- debug_msg "unset_module_config ($@)"
- if [ -n "$MODULE" ] ; then
- unset_config "$DEPENDS_CONFIG/$MODULE" "$1"
- fi
+unset_module_config()
+{
+ debug_msg "unset_module_config ($@)"
+ if [ -n "$MODULE" ] ; then
+ unset_config "$DEPENDS_CONFIG/$MODULE" "$1"
+ fi
}
-get_module_config() {
- debug_msg "get_module_config ($@)"
- if [ -n "$MODULE" ] ; then
- get_config "$DEPENDS_CONFIG/$MODULE" "$1"
- fi
+get_module_config()
+{
+ debug_msg "get_module_config ($@)"
+ if [ -n "$MODULE" ] ; then
+ get_config "$DEPENDS_CONFIG/$MODULE" "$1"
+ fi
}
-get_other_module_config() {
- debug_msg "get_other_module_config ($@)"
- if [ -n "$1" ] ; then
- get_config "$DEPENDS_CONFIG/$1" "$2"
- fi
+get_other_module_config()
+{
+ debug_msg "get_other_module_config ($@)"
+ if [ -n "$1" ] ; then
+ get_config "$DEPENDS_CONFIG/$1" "$2"
+ fi
}
Modified: lunar/trunk/var/lib/lunar/functions/depends.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/depends.lunar 2007-01-16 04:00:43 UTC (rev 22954)
+++ lunar/trunk/var/lib/lunar/functions/depends.lunar 2007-01-16 06:25:09 UTC (rev 22955)
@@ -21,7 +21,7 @@
############################################################
-# function : find_depends
+# function : find_depends
# usage : find_depends "module name"
# purpose : recursive dependency finder, no need to be installed
function find_depends() {
@@ -29,14 +29,13 @@
debug_msg "find_depends ($@)"
find_depends_intern() {
- local DEP LINE
+ local DEP
for DEP in $(awk -F: -v mod=$1 '{if ($1==mod){print $2}}' $DEPENDS_CACHE) ; do
DEP=$(unalias "$DEP")
# this is our shortcut out:
if ! grep -qx "$DEP" $TMP_FDEPS ; then
- debug_msg "$DEP"
echo "$DEP" >> $TMP_FDEPS
- if [[ "$(grep "^$1:$DEP:" $DEPENDS_CACHE | cut -d: -f3)" == "required" ]] ; then
+ if grep -q "^$1:$DEP:required:" $DEPENDS_CACHE ; then
echo "$DEP"
find_depends_intern "$DEP"
elif module_installed "$DEP" ; then
Modified: lunar/trunk/var/lib/lunar/functions/modules.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/modules.lunar 2007-01-16 04:00:43 UTC (rev 22954)
+++ lunar/trunk/var/lib/lunar/functions/modules.lunar 2007-01-16 06:25:09 UTC (rev 22955)
@@ -280,15 +280,16 @@
. $SCRIPT_DIRECTORY/$2.$PLATFORM
elif [[ -e "$SCRIPT_DIRECTORY/$2" ]]; then
. $SCRIPT_DIRECTORY/$2
- fi
+ fi
}
# function : module_installed
# usage : module_installed $MODULE
# purpose : check if $MODULE is installed (or held)
-module_installed() {
- $(cut -d: -f1,3 $MODULE_STATUS | grep -q -e "^$1:installed" -e "^$1:held")
+module_installed()
+{
+ grep -q "^$1:[[:digit:]]*:installed:\|^$1:[[:digit:]]*:held:" $MODULE_STATUS
}
@@ -296,8 +297,8 @@
# usage : module_held $MODULE
# purpose : check if $MODULE is held
module_held() {
- debug_msg "module_held ($@)"
- $(cut -d: -f1,3 $MODULE_STATUS | grep -q "^$1:held")
+ debug_msg "module_held ($@)"
+ grep -q "^$1:[[:digit:]]*:held:" $MODULE_STATUS
}
More information about the Lunar-commits
mailing list