[Lunar-commits] <lunar> make `lin moonbase` do the right thing for git moonbases, etc.

Auke Kok sofar at foo-projects.org
Fri Apr 27 05:47:48 CEST 2012


commit 6c877784a795de5c3ca302b40d6618e59174ecea
Author: Auke Kok <sofar at foo-projects.org>
Date:   Thu Apr 26 20:47:48 2012 -0700

    make `lin moonbase` do the right thing for git moonbases, etc.
    
    This fixes a long standing bug for folks using a git moonbase. The
    new code properly skips downloading a moonbase now if you `lin
    moonbase`, and instead creates caches and indexes reflecting the
    state of the custom moonbase, instead of the system one.
    
    a REQUIREMENT is that you do NOT use /var/lib/lunar/moonbase anymore,
    but instead do `lunar set MOONBASE /some/path/where/your/stuff/is`.
    If you store a custom moonbase at the old location, it will be
    overwritten.
    
    You still need to lin moonbase to update the caches and indexes.
---
 var/lib/lunar/functions/moonbase.lunar |   72 ++++++++++++++++----------------
 1 file changed, 35 insertions(+), 37 deletions(-)

diff --git a/var/lib/lunar/functions/moonbase.lunar b/var/lib/lunar/functions/moonbase.lunar
index 305a0ed..4b0342b 100644
--- a/var/lib/lunar/functions/moonbase.lunar
+++ b/var/lib/lunar/functions/moonbase.lunar
@@ -25,14 +25,10 @@ get_moonbase () {
 
   # the following overrides run_details:
   run_details() {
-    debug_msg "  run_details ($@)"
+  debug_msg "  run_details ($@)"
         MODULE=moonbase
        VERSION=`date -u +%Y%m%d.%H`
-    if [ "$MOONBASE_TYPE" == "unstable" ]; then
         SOURCE=$MODULE.tar.bz2
-    else
-        SOURCE=$MODULE-stable.tar.bz2
-    fi
     SOURCE_URL=$MOONBASE_URL
        PARTIAL=off
    CLEAR_CACHE=on
@@ -50,45 +46,47 @@ get_moonbase () {
     mkdir -p $SYSTEM_MOONBASE/zlocal
   fi
 
-  push_uniq_id
-  if download_module $MODULE ; then
-    message "${MESSAGE_COLOR}Preparing to install ${FILE_COLOR}${SOURCE}" \
-            "${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                           &&
-    lrm moonbase                                                 &&
-    mkdir $SYSTEM_MOONBASE                                       &&
-    mv /var/lib/lunar/.zlocal-backup $SYSTEM_MOONBASE/zlocal     &&
-    message "${MESSAGE_COLOR}Extracting ${FILE_COLOR}${SOURCE}" \
-            "${DEFAULT_COLOR}${MESSAGE_COLOR}...${DEFAULT_COLOR}"       &&
-    bzcat $SOURCE_CACHE/$SOURCE | tar xv -C /var/lib/lunar | \
-          sed "s:^:/var/lib/lunar/:g" > $INSTALL_LOGS/$MODULE-$VERSION  &&
-    echo $INSTALL_LOGS/$MODULE-$VERSION >> $INSTALL_LOGS/$MODULE-$VERSION &&
-    OUTCOME=success || OUTCOME=failed
-
-    if [ "$OUTCOME" == "success" ] ; then
-      echo "$MD5SUM_LOGS/$MODULE-$VERSION" >> $INSTALL_LOGS/$MODULE-$VERSION
+  if [ "$SYSTEM_MOONBASE" == "$MOONBASE" ]; then
+    push_uniq_id
+    if ! download_module $MODULE ; then
+      OUTCOME=failed
+      INFO="Could not download a fresh moonbase"
+    else
+      message "${MESSAGE_COLOR}Preparing to install ${FILE_COLOR}${SOURCE}" \
+              "${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                           &&
+      lrm moonbase                                                 &&
+      mkdir $SYSTEM_MOONBASE                                       &&
+      mv /var/lib/lunar/.zlocal-backup $SYSTEM_MOONBASE/zlocal     &&
+      message "${MESSAGE_COLOR}Extracting ${FILE_COLOR}${SOURCE}" \
+              "${DEFAULT_COLOR}${MESSAGE_COLOR}...${DEFAULT_COLOR}"       &&
+      bzcat $SOURCE_CACHE/$SOURCE | tar xv -C /var/lib/lunar | \
+            sed "s:^:/var/lib/lunar/:g" > $INSTALL_LOGS/$MODULE-$VERSION  &&
+      echo $INSTALL_LOGS/$MODULE-$VERSION >> $INSTALL_LOGS/$MODULE-$VERSION &&
+      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}"
-
+              "${DEFAULT_COLOR}${MESSAGE_COLOR}${DEFAULT_COLOR}" &&
       # create an md5sum log
       create_md5sum_log &&
 
       add_module $MODULE installed $VERSION $(du -ks $SYSTEM_MOONBASE | cut -f1)KB &&
-      # 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 ||
-      OUTCOME=failed
+      OUTCOME=success || OUTCOME=failed
     fi
-  else
-    OUTCOME=failed
-    INFO="Could not download a fresh moonbase"
   fi
+  
+  if [ "$OUTCOME" != "failed" ] ; then
+    # 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 &&
+    OUTCOME=success || OUTCOME=failed
+  fi
+
   activity_log "lin" "moonbase" "$VERSION" "$OUTCOME" "$INFO"
   if [ "$OUTCOME" == "failed" ] ; then
     return 1


More information about the Lunar-commits mailing list