[Lunar-commits] r22026 - lunar/branches/stable/var/lib/lunar/functions
Auke Kok
sofar at lunar-linux.org
Thu Nov 2 00:28:01 CET 2006
Author: sofar
Date: 2006-11-02 00:28:01 +0100 (Thu, 02 Nov 2006)
New Revision: 22026
Modified:
lunar/branches/stable/var/lib/lunar/functions/aliases.lunar
lunar/branches/stable/var/lib/lunar/functions/depends.lunar
lunar/branches/stable/var/lib/lunar/functions/moonbase.lunar
lunar/branches/stable/var/lib/lunar/functions/plugins.lunar
lunar/branches/stable/var/lib/lunar/functions/tracking.lunar
lunar/branches/stable/var/lib/lunar/functions/useradd.lunar
Log:
[MERGE] merge theedge into lunar. We're fully synced now.
Modified: lunar/branches/stable/var/lib/lunar/functions/aliases.lunar
===================================================================
--- lunar/branches/stable/var/lib/lunar/functions/aliases.lunar 2006-11-01 23:23:19 UTC (rev 22025)
+++ lunar/branches/stable/var/lib/lunar/functions/aliases.lunar 2006-11-01 23:28:01 UTC (rev 22026)
@@ -12,13 +12,20 @@
# 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
+ local TARGET TARGETS TARGETBYNUM N CHOICE CACHED_ALIAS
# quick exit code
if [ "${1:0:1}" != "%" ] ; then
echo $1
return
fi
+ # lookup in cache
+ CACHED_ALIAS=$(get_local_config `echo LUNAR_ALIAS_${1:1}`)
+ if [ -n "$CACHED_ALIAS" ]; then
+ echo $CACHED_ALIAS
+ return
+ fi
+
debug_msg "unalias($@)"
# try to figure out where the aliases file is:
if [[ -z "$ALIASES" ]] || [[ ! -f "$ALIASES" ]]; then
@@ -28,47 +35,8 @@
ALIASES="/var/lib/lunar/aliases"
fi
fi
-
+
TARGETS=$(awk -F: -v mod=$1 '{if ($1==mod){print $2}}' $ALIASES)
- # 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: in the satisfy_depends stage we should NOT ask this again
- if [[ -z "$DEPS_ONLY" ]] ; then
- # first we check if this dependency is already existant in the exact
- # way: does this MODULE depends on TARGET already ?
- for TARGET in $TARGETS ; do
- if in_depends $MODULE $TARGET ; then
- debug_msg "unaliased \"$1\"->\"$TARGET\""
- echo $TARGET
- return
- fi
- done
- # not so... other possibility is that something else already depends
- # on TARGET?
- for TARGET in $TARGETS ; do
- if is_depends $TARGET ; then
- debug_msg "unaliased \"$1\"->\"$TARGET\""
- echo $TARGET
- return
- fi
- done
- # also not so. our last attempt is for a DISABLED dependency, but
- # we can only use this method for OPTIONAL dependencies
- for TARGET in $TARGETS ; do
- # there's no function for this yet
- if grep -q ":$TARGET:off:" $DEPENDS_STATUS ; then
- debug_msg "unaliased \"$1\"->\"$TARGET\""
- echo $TARGET
- return
- fi
- done
- fi
# shortcut out when explicitly instructed so
if [[ -n "$NEVER_ASK" ]] ; then
@@ -90,10 +58,14 @@
read CHOICE
# test directly first
if echo $TARGETS | grep -qw "$CHOICE" ; then
+ verbose_msg "Stored alias mapping $1 -> $TARGET"
+ set_local_config `echo LUNAR_ALIAS_${1:1}` $TARGET
echo $TARGET
return
# then the number
elif [[ -n "$CHOICE" ]] && [[ -n "${TARGETBYNUM[$CHOICE]}" ]] ; then
+ verbose_msg "Stored alias mapping $1 -> ${TARGETBYNUM[$CHOICE]}"
+ set_local_config `echo LUNAR_ALIAS_${1:1}` ${TARGETBYNUM[$CHOICE]}
echo ${TARGETBYNUM[$CHOICE]}
return
fi
Modified: lunar/branches/stable/var/lib/lunar/functions/depends.lunar
===================================================================
--- lunar/branches/stable/var/lib/lunar/functions/depends.lunar 2006-11-01 23:23:19 UTC (rev 22025)
+++ lunar/branches/stable/var/lib/lunar/functions/depends.lunar 2006-11-01 23:28:01 UTC (rev 22026)
@@ -29,19 +29,19 @@
debug_msg "find_depends ($@)"
find_depends_intern() {
- local DEP STATE LINE
- awk -F: -v mod=$1 '{if ($1==mod){print $2,$3}}' $DEPENDS_CACHE | while read DEP STATE ; do
- DEP=$(unalias $DEP)
+ local DEP LINE
+ 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 [[ "$STATE" == "required" ]] ; then
- echo $DEP
- find_depends_intern $DEP
- elif module_installed $DEP ; then
- echo $DEP
- find_depends_intern $DEP
+ if [[ "$(grep "^$1:$DEP:" $DEPENDS_CACHE | cut -d: -f3)" == "required" ]] ; then
+ echo "$DEP"
+ find_depends_intern "$DEP"
+ elif module_installed "$DEP" ; then
+ echo "$DEP"
+ find_depends_intern "$DEP"
fi
fi
done
@@ -105,14 +105,14 @@
# Was $2 presented as a dependency for module $1
return $(grep -q "^$1:$2:on:" $DEPENDS_STATUS)
}
-
-
+
+
remove_depends() {
debug_msg "remove_depends ($@)"
lock_file $DEPENDS_STATUS_BACKUP &&
lock_file $DEPENDS_STATUS ||
return 1
-
+
if [ -n "$2" ] ; then
if grep -q "^$1:$2:" $DEPENDS_STATUS ; then
grep -v "^$1:$2:" $DEPENDS_STATUS_BACKUP > $DEPENDS_STATUS
@@ -125,12 +125,12 @@
fi
cp $DEPENDS_STATUS $DEPENDS_STATUS_BACKUP
-
+
unlock_file $DEPENDS_STATUS &&
unlock_file $DEPENDS_STATUS_BACKUP
}
-
+
add_depends() {
debug_msg "add_depends ($@)"
if ! grep -q "^$1:$2:$3:$4:$5:$6$" $DEPENDS_STATUS ; then
@@ -141,15 +141,15 @@
else
verbose_msg "adding \"$4\" depends for \"$1\" on \"$2\" ($3)"
fi
-
+
echo "$1:$2:$3:$4:$5:$6" >> $DEPENDS_STATUS &&
cp $DEPENDS_STATUS $DEPENDS_STATUS_BACKUP &&
unlock_file $DEPENDS_STATUS &&
unlock_file $DEPENDS_STATUS_BACKUP
fi
}
-
-
+
+
run_depends() {
debug_msg "run_depends ($@)"
# local definitions of depends and optional_depends!
@@ -178,7 +178,7 @@
fi
fi
}
-
+
optional_depends() {
debug_msg " optional_depends ($@)"
local DEP DEFAULT DEPMOD_AVAIL
@@ -189,7 +189,7 @@
DEP=$(unalias $1)
if ! grep -q "^$MODULE:$DEP:" $DEPENDS_STATUS ; then
-
+
if module_exiled $DEP ; then
verbose_msg "\"$MODULE\" optionally depends on exiled module \"$DEP\""
add_depends "$MODULE" "$DEP" "off" "optional" "$2" "$3"
@@ -221,7 +221,7 @@
fi
fi
}
-
+
grep -q "^"$MODULE"\$" $TEMP_PREPAREDDEPS 2>/dev/null && return 0
if has_module_file $MODULE DEPENDS ; then
if [ -n "$SINGLE_MODULE" ] ; then
@@ -267,14 +267,14 @@
fi
fi
done
-
+
# then parse $OPTS
while read LINE; do
DEP_MODULE=$(echo $LINE | cut -d: -f2)
DEP_STATUS=$(echo $LINE | cut -d: -f3)
DEP_ON=$(echo $LINE | cut -d: -f5)
DEP_OFF=$(echo $LINE | cut -d: -f6)
-
+
if [ -n "$FIX" ] ; then
if DEP_STATUS="on" ; then
lin $FIX $DEP_MODULE
@@ -292,7 +292,7 @@
OPTS="$OPTS $DEP_ON"
fi
done < $TMP_FILE
-
+
temp_destroy $TMP_FILE
}
@@ -398,10 +398,10 @@
# fast method for re-creating the depends.cache, might take long though
for DEPFILE in $DEPFILES ; do
- MODULE=$(echo $DEPFILE | sed -e "s:$MOONBASE/::g" -e "s:/DEPENDS::g" -e 's/.*\/\([^\/]*\)$/\1/') . $DEPFILE
+ TMP=${DEPFILE%/*} MODULE=${TMP##*/} . $DEPFILE
done > $TMP_DEP_CACHE &&
install -m644 $TMP_DEP_CACHE $DEPENDS_CACHE
-
+
temp_destroy $TMP_DEP_CACHE
else
verbose_msg "Skipping depends cache regeneration"
Modified: lunar/branches/stable/var/lib/lunar/functions/moonbase.lunar
===================================================================
--- lunar/branches/stable/var/lib/lunar/functions/moonbase.lunar 2006-11-01 23:23:19 UTC (rev 22025)
+++ lunar/branches/stable/var/lib/lunar/functions/moonbase.lunar 2006-11-01 23:28:01 UTC (rev 22026)
@@ -52,8 +52,8 @@
"${DEFAULT_COLOR}${MESSAGE_COLOR}...${DEFAULT_COLOR}" &&
mv $SYSTEM_MOONBASE/zlocal/ /var/lib/lunar/.zlocal-backup &&
rm -rf $SYSTEM_MOONBASE &&
- TMP_MODULE_INDEX=$(temp_create "temp.module.index") &&
- cp $MODULE_INDEX $TMP_MODULE_INDEX &&
+ TMP_MODULE_INDEX=$(temp_create "temp.module.index") &&
+ cp $MODULE_INDEX $TMP_MODULE_INDEX &&
lrm moonbase &&
mkdir $SYSTEM_MOONBASE &&
mv /var/lib/lunar/.zlocal-backup $SYSTEM_MOONBASE/zlocal &&
@@ -68,20 +68,18 @@
echo "$MD5SUM_LOGS/$MODULE-$VERSION" >> $INSTALL_LOGS/$MODULE-$VERSION
message "${MESSAGE_COLOR}Created ${FILE_COLOR}$INSTALL_LOGS/$MODULE-$VERSION" \
"${DEFAULT_COLOR}${MESSAGE_COLOR}${DEFAULT_COLOR}"
-
+
# create an md5sum log
- message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$MD5SUM_LOGS/$MODULE-$VERSION${DEFAULT_COLOR}"
- for file in $(cat /var/log/lunar/install/moonbase-$VERSION) ; do
- test -f "$file" && md5sum "$file"
- done >> $MD5SUM_LOGS/$MODULE-$VERSION
-
- add_module $MODULE installed $VERSION $(du -hs $SYSTEM_MOONBASE | cut -f1)
+ create_md5sum_log &&
+
+ add_module $MODULE installed $VERSION $(du -hs $SYSTEM_MOONBASE | cut -f1) &&
# get ready to regenerate the module index cache file
- create_module_index
- create_depends_cache
- update_plugins
- display_moonbase_changes
- temp_destroy $TMP_MODULE_INDEX
+ create_module_index &&
+ create_depends_cache &&
+ update_plugins &&
+ display_moonbase_changes &&
+ temp_destroy $TMP_MODULE_INDEX ||
+ OUTCOME=failed
fi
else
OUTCOME=failed
Modified: lunar/branches/stable/var/lib/lunar/functions/plugins.lunar
===================================================================
--- lunar/branches/stable/var/lib/lunar/functions/plugins.lunar 2006-11-01 23:23:19 UTC (rev 22025)
+++ lunar/branches/stable/var/lib/lunar/functions/plugins.lunar 2006-11-01 23:28:01 UTC (rev 22026)
@@ -105,10 +105,10 @@
update_plugins() {
local MODULE
debug_msg "update_plugins($@)"
- # rework all plugins
+ # find all plugins in moonbase and run update_plugin() on them
verbose_msg "Updating plugins"
- for MODULE in $(list_moonbase); do
- update_plugin $MODULE
+ find $MOONBASE -wholename "*/plugin.d/*.plugin" | while read PLUGIN ; do
+ update_plugin `basename $(echo $PLUGIN | sed 's/\/plugin.d\/.*//g')`
done
}
Modified: lunar/branches/stable/var/lib/lunar/functions/tracking.lunar
===================================================================
--- lunar/branches/stable/var/lib/lunar/functions/tracking.lunar 2006-11-01 23:23:19 UTC (rev 22025)
+++ lunar/branches/stable/var/lib/lunar/functions/tracking.lunar 2006-11-01 23:28:01 UTC (rev 22026)
@@ -96,13 +96,9 @@
debug_msg "create_md5sum_log ($@)"
rm -f $MD5SUM_LOGS/$MODULE-$VERSION &> /dev/null
-
message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$MD5SUM_LOGS/$MODULE-$VERSION${DEFAULT_COLOR}"
- files < $INSTALL_LOGS/$MODULE-$VERSION | while read FILE ; do
- md5sum "$FILE" >> $MD5SUM_LOGS/$MODULE-$VERSION
- done
-
+ files < $INSTALL_LOGS/$MODULE-$VERSION | xargs md5sum >> $MD5SUM_LOGS/$MODULE-$VERSION
}
create_install_cache() {
@@ -124,7 +120,7 @@
create_install_log &&
create_md5sum_log &&
create_install_cache &&
-
+
add_module $MODULE installed $VERSION $(find_module_size $MODULE $VERSION)
verbose_msg "module size is $(find_module_size $MODULE $VERSION)"
}
Modified: lunar/branches/stable/var/lib/lunar/functions/useradd.lunar
===================================================================
--- lunar/branches/stable/var/lib/lunar/functions/useradd.lunar 2006-11-01 23:23:19 UTC (rev 22025)
+++ lunar/branches/stable/var/lib/lunar/functions/useradd.lunar 2006-11-01 23:28:01 UTC (rev 22026)
@@ -11,11 +11,51 @@
# #
############################################################
# #
-# Copyrighted Auke Kok 2003 under GPLv2 #
+# Copyrighted Auke Kok 2006 under GPLv2 #
# #
############################################################
+# function: add_priv_group
+# usage : add_priv_group groupname [addgroupopts [addgroupopts]...]
+# info : adds groupname and passes addgroupopts to 'addgroup'
+function add_priv_group() {
+ local GROUPNAME
+ debug_msg "function add_priv_group ($@)"
+
+ if [ -n "$INSTALLWATCHFILE" ] ; then
+ devoke_installwatch
+ fi
+ GROUPNAME=$1
+
+ if [ -z "$GROUPNAME" ] ; then
+ message "${PROBLEM_COLOR}!add_priv_user: no groupname specified${DEFAULT_COLOR}"
+ exit 1
+ fi
+
+ if grep -q "^$GROUPNAME:" /etc/group ; then
+ verbose_msg "group \"$GROUPNAME\" already exists, not creating"
+ else
+ # add the group:
+ for (( N=0 ; N<100 ; N++)) ; do
+ if [ -z "$(cat /etc/group | cut -d: -f3 | grep "^$N$" )" ] ; then
+ break
+ fi
+ done
+ if [ "$N" == "100" ] ; then
+ message "${PROBLEM_COLOR}!add_priv_user: no more group id's left under gid=100, bailing out!${DEFAULT_COLOR}"
+ exit 1
+ fi
+ verbose_msg "creating group \"$GROUPNAME\" with id=\"$N\""
+ groupadd -g $N $GROUPNAME
+ fi
+
+ if [ -n "$INSTALLWATCHFILE" ] ; then
+ invoke_installwatch
+ fi
+}
+
+
# function: add_priv_user
# usage : add_priv_user username:groupname [adduseropts [adduseropts]...]
# info : adds username:groupname and passes adduseropts to 'adduser'
@@ -45,22 +85,11 @@
if grep -q "^$GROUPNAME:" /etc/group ; then
verbose_msg "group \"$GROUPNAME\" already exists, not creating"
else
-
- # add the group:
- for (( N=0 ; N<100 ; N++)) ; do
- if [ -z "$(cat /etc/group | cut -d: -f3 | grep "^$N$" )" ] ; then
- break
- fi
- done
- if [ "$N" == "100" ] ; then
- message "${PROBLEM_COLOR}!add_priv_user: no more group id's left under gid=100, bailing out!${DEFAULT_COLOR}"
- exit 1
+ if ! add_priv_group $GROUPNAME ; then
+ exit 1
fi
- verbose_msg "creating group \"$GROUPNAME\" with id=\"$N\""
- groupadd -g $N $GROUPNAME
-
fi
-
+
# add the user:
for (( N=0 ; N<100 ; N++)) ; do
if [ -z "$(cat /etc/passwd | cut -d: -f3 | grep "^$N$" )" ] ; then
@@ -71,12 +100,12 @@
message "${PROBLEM_COLOR}!add_priv_user: no more user id's left under uid=100, bailing out!${DEFAULT_COLOR}"
exit 1
fi
-
+
shift
-
+
verbose_msg "creating user \"$USERNAME\" (opts=\"-u $N -g $GROUPNAME $@\")"
useradd -u $N -g $GROUPNAME $USERNAME $@
-
+
fi
if [ -n "$INSTALLWATCHFILE" ] ; then
More information about the Lunar-commits
mailing list