[Lunar-commits] <lunar> Merge pull request #8 from cavalier38/zlocal-depends

Auke Kok sofar+github at foo-projects.org
Mon Jul 9 23:59:00 CEST 2012


commit df7186c50d484abf63e413be88f07d8f7bc4913d
Author: Auke Kok <sofar+github at foo-projects.org>
Date: Mon, 09 Jul 2012 14:59:00 -0700
URL: https://github.com/lunar-linux/lunar/commit/df7186c50d484abf63e413be88f07d8f7bc4913d

Merge pull request #8 from cavalier38/zlocal-depends

Zlocal depends
---
  libs/depends.lunar                                           +40/-6    
  libs/modules.lunar                                           +7/-4     
  2 files changed, 0 insertions (+), 0 deletions (-)

--- a/libs/depends.lunar
+++ b/libs/depends.lunar
@@ -29,8 +29,36 @@ function find_depends() {
   debug_msg "find_depends ($@)"
 
   find_depends_intern() {
-    local DEP
-    for DEP in $(awk -F: -v mod=$1 '{if ($1==mod){print $2}}' "$DEPENDS_CACHE") ; do
+    local DEP DEPS DEPFILE SECTION
+    SECTION=$(find_section $1)
+    if echo $SECTION | grep -q '^zlocal' ; then
+      # this module lives in zlocal
+      # now we need to run the depends file
+
+      # you guessed it: local decls.
+      depends() {
+	echo "$1"
+      }
+
+      optional_depends() {
+	# No quotes, this prevent us from parsing newlines
+	# if someone by accident add a newline in optional_depends
+	echo $1
+      }
+
+      # yeah, this sucks:
+      message() {
+	:
+      }
+
+      DEPFILE=$MOONBASE/$SECTION/$1/DEPENDS
+      if [ -e $DEPFILE ] ; then
+        DEPS=$(MODULE=$1 . $DEPFILE)
+      fi
+    else
+      DEPS=$(awk -F: -v mod=$1 '{if ($1==mod){print $2}}' "$DEPENDS_CACHE")
+    fi
+    for DEP in $DEPS ; do
       DEP=$(unalias "$DEP")
       # this is our shortcut out:
       if ! grep -qx "$DEP" "$TMP_FDEPS" ; then
@@ -72,7 +100,7 @@ sort_by_dependency() {
     B=$(MODULE=$A NEVER_ASK=1 DEPS_ONLY= unalias $B)
     echo "$A $B" >> $TMP_TSRT
   done
-  tsort $TMP_TSRT 2> /dev/null | tac > $TMP_ALL
+  tsort "$TMP_TSRT" 2> /dev/null | tac > $TMP_ALL
   temp_destroy $TMP_TSRT
 
   # append all modules that do not have a DEPENDS file at all at the end
@@ -275,7 +303,7 @@ satisfy_depends()  {
        DEP_OFF=$(echo $LINE | cut -d: -f6)
 
     if [ -n "$FIX" ] ; then
-      if DEP_STATUS="on" ; then
+      if [ $DEP_STATUS == "on" ] ; then
         lin $FIX $DEP_MODULE
       fi
     elif [ "$DEP_STATUS" == "off" ] || module_exiled $DEP_MODULE ; then
@@ -392,9 +420,15 @@ create_depends_cache()
     if [ "$MOONBASE" == "/var/lib/lunar/moonbase" ] ; then
       DEPFILES=$(grep "/DEPENDS$" "$INSTALL_LOGS/moonbase-$(installed_version moonbase)")
       # don't forget zlocal:
-      DEPFILES="$DEPFILES $(find $MOONBASE/zlocal -type f -name DEPENDS)"
+      if [ "$ZLOCAL_OVERRIDES" == "on" ] ; then
+        DEPFILES="$DEPFILES $(find $MOONBASE/zlocal -type f -name DEPENDS)"
+      fi
     else
-      DEPFILES=$(find $MOONBASE -type f -name DEPENDS)
+      if [ "$ZLOCAL_OVERRIDES" != "on" ] ; then
+        DEPFILES=$(find $MOONBASE -type f -name DEPENDS ! -regex "$MOONBASE/zlocal/.*")
+      else
+        DEPFILES=$(find $MOONBASE -type f -name DEPENDS)
+      fi
     fi
 
     # fast method for re-creating the depends.cache, might take long though
--- a/libs/modules.lunar
+++ b/libs/modules.lunar
@@ -145,14 +145,17 @@ function check_module_index() {
     create_depends_cache
     RESULT=0
   else
-    if [[ -n "$(find $MOONBASE -type f -name "DEPENDS" -cnewer $DEPENDS_CACHE)" ]]; then
-      create_depends_cache
-      RESULT=0
-    fi
     if [[ -n "$(find $MOONBASE -type f -name "DETAILS" -cnewer $MODULE_INDEX)" ]]; then
       create_module_index
       RESULT=0
     fi
+    if [[ -n "$(find $MOONBASE -type f -name "DEPENDS" -cnewer $DEPENDS_CACHE)" ]]; then
+      # the module index needs to be newer
+      # touch will assure this
+      touch $MODULE_INDEX
+      create_depends_cache
+      RESULT=0
+    fi
   fi
   return $RESULT
 )




More information about the Lunar-commits mailing list