[Lunar-commits] <lunar> Merge with theedge: - alias fixes - update plugin framework to include new plugin types - ENV var protection enabled using 'local' - moonbase update changes display fixes

Auke Kok sofar at lunar-linux.org
Mon Jul 2 04:43:02 CEST 2012


commit 9639f59039e4b682b4c1da6494770b7954be6171
Author: Auke Kok <sofar at lunar-linux.org>
Date:   Fri May 20 08:42:19 2005 +0000

    Merge with theedge:
    - alias fixes
    - update plugin framework to include new plugin types
    - ENV var protection enabled using 'local'
    - moonbase update changes display fixes
---
 var/lib/lunar/functions/aliases.lunar          |    1 +
 var/lib/lunar/functions/build.lunar            |   87 +++-----
 var/lib/lunar/functions/check.lunar            |   25 ++-
 var/lib/lunar/functions/config.lunar           |    1 +
 var/lib/lunar/functions/connect.lunar          |    1 +
 var/lib/lunar/functions/depends.lunar          |   19 +-
 var/lib/lunar/functions/download.lunar         |    7 +-
 var/lib/lunar/functions/edit.lunar             |    6 +-
 var/lib/lunar/functions/kernel.lunar           |   12 --
 var/lib/lunar/functions/locking.lunar          |    1 +
 var/lib/lunar/functions/logging.lunar          |   10 +-
 var/lib/lunar/functions/main.lunar             |    1 +
 var/lib/lunar/functions/messages.lunar         |   20 +-
 var/lib/lunar/functions/misc.lunar             |    8 +-
 var/lib/lunar/functions/modules.lunar          |   66 +++---
 var/lib/lunar/functions/optimize.lunar         |    1 +
 var/lib/lunar/functions/plugins.lunar          |   24 ++-
 var/lib/lunar/functions/postbuild.lunar        |  271 ------------------------
 var/lib/lunar/functions/prune.lunar            |    1 +
 var/lib/lunar/functions/sizes.lunar            |    2 +
 var/lib/lunar/functions/sources.lunar          |    4 +
 var/lib/lunar/functions/temp.lunar             |    1 +
 var/lib/lunar/functions/tracking.lunar         |    4 +-
 var/lib/lunar/functions/uniqid.lunar           |    1 +
 var/lib/lunar/functions/updatelog.lunar        |   50 +++--
 var/lib/lunar/functions/useradd.lunar          |    1 +
 var/lib/lunar/plugins/initd.plugin             |   86 ++++++++
 var/lib/lunar/plugins/postbuild-generic.plugin |  111 ++++++++++
 28 files changed, 386 insertions(+), 436 deletions(-)

diff --git a/var/lib/lunar/functions/aliases.lunar b/var/lib/lunar/functions/aliases.lunar
index e8c521f..6e5ec3b 100644
--- a/var/lib/lunar/functions/aliases.lunar
+++ b/var/lib/lunar/functions/aliases.lunar
@@ -12,6 +12,7 @@
 # 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
   if [ "${1:0:1}" == "%" ] ; then
     debug_msg "unalias($@)"
     TARGETS=$(grep "^$1:" $ALIASES | cut -d: -f2-)
diff --git a/var/lib/lunar/functions/build.lunar b/var/lib/lunar/functions/build.lunar
index 223250c..6107aa4 100644
--- a/var/lib/lunar/functions/build.lunar
+++ b/var/lib/lunar/functions/build.lunar
@@ -28,6 +28,7 @@
 
 
 save_libraries()  {
+  local OLD_VERSION OLD_LOG OLD_LIBS SAVED LINE
   debug_msg "save_libraries ($@)"
 
   [ "$MODULE" == "glibc" ] && return 0
@@ -75,6 +76,7 @@ save_libraries()  {
 
 
 release_saved_libraries()  {
+  local OLD_LIBS SAVED FILE
   debug_msg "release_saved_libraries ($@)"
   OLD_LIBS=$SOURCE_DIRECTORY/old.libraries
   SAVED=$OLD_LIBS/$MODULE.saved.libraries
@@ -91,6 +93,7 @@ release_saved_libraries()  {
 
 
 export_ld()  {
+  local DIRECTORY
   debug_msg "export_ld ($@)"
   for DIRECTORY in $* ; do
     if file -b $DIRECTORY/*.so* | grep  -q  "shared object" ; then
@@ -106,7 +109,7 @@ export_ld()  {
 
 prepare_install() {
   debug_msg "prepare_install ($@)"
-  if  module_installed $MODULE  || module_held $MODULE ; then
+  if module_installed $MODULE || module_held $MODULE ; then
     message  "${MESSAGE_COLOR}Preparing to install"  \
              "${MODULE_COLOR}${MODULE}${DEFAULT_COLOR}"
     save_libraries
@@ -114,8 +117,12 @@ prepare_install() {
     lrm --upgrade $MODULE
     true
   fi
-  # turn on tracking now
+  # turn on tracking now 
   invoke_installwatch
+  plugin_call BUILD_INSTALL $MODULE
+  if [ $? == 2 ]; then
+    return 0
+  fi
 }
 
 
@@ -212,6 +219,7 @@ default_cvs_build() {
 
 
 default_cpan_pre_build() {
+  local CPAN_MODULE CPAN_SOURCE_BRANCH
   debug_msg "default_cpan_pre_build ($@)"
   mk_source_dir $SOURCE_DIRECTORY
   cd $SOURCE_DIRECTORY
@@ -223,6 +231,7 @@ default_cpan_pre_build() {
 
 
 default_cpan_build() {
+  local CPAN_MODULE
   debug_msg "default_cpan_build ($@)"
   prepare_install
   verbose_msg "running \"default_cpan_build\""
@@ -236,9 +245,7 @@ default_cpan_build() {
         o conf keep_source_where $SOURCE_DIRECTORY
 	install $CPAN_MODULE
 	quit" | /usr/bin/cpan || exit 1
-  RESULT=$?
   rm_source_dir $SOURCE_DIRECTORY
-
 } > $C_FIFO 2>&1
 
 
@@ -249,59 +256,39 @@ default_post_build() {
     message "${PROBLEM_COLOR}WARNING: ${DEFAULT_COLOR}${FILE_COLOR}BUILD${DEFAULT_COLOR}${PROBLEM_COLOR} does not call prepare_install or installs zero files!${DEFAULT_COLOR}"
   fi
 
-  invoke_installwatch
-
-  {
-    gather_docs
-
-    install_pam_confs
-    install_services
-    install_xinetd_confs
-    install_bashmisc
-  } | tee -a $C_LOG
-  
-  install_initd
   update_plugin $MODULE install
 
-  devoke_installwatch
+  plugin_call BUILD_POST_BUILD $MODULE
+  if [ $? != 2 ]; then
+    message "${PROBLEM_COLOR}ERROR: problems running POST_BUILD plugins!${PROBLEM_COLOR}"
+    return 1
+  fi
+
   ldconfig
   release_saved_libraries
-  cd  /
+  cd /
 }
 
 
 syms_not_owned()  {
+  local DEST
   debug_msg "syms_not_owned ($@)"
-
-  cat  $1  |
   while read ITEM ; do
-
-    if  [  -h  "$ITEM"  ]   &&
-        [  -f  "$ITEM"  ];  then
-
-      DEST=$(  basename  $(  ls   -la  "$ITEM"  |
-                             cut  -d  '>'  -f2  |
-                             cut  -c  2-
-                          )
-            )
-
-      if  !  grep  -q  "$DEST"  "$1"
-      then   echo  -n  "$ITEM\|"
-             echo      "$ITEM"  >>  $TMPDIR/$MODULE.rejected.symlinks
+    if [ -h "$ITEM" ] && [ -f "$ITEM" ]; then
+      DEST=$(basename $(ls -la "$ITEM" | cut -d '>' -f2 | cut -c 2- ) )
+      if ! grep -q "$DEST" "$1" ; then
+	    echo -n "$ITEM\|"
+        echo "$ITEM" >> $TMPDIR/$MODULE.rejected.symlinks
       fi
-
     fi
-
-  done
-
+  done < $1
 }
 
 
 prepare_module_config()  {
   debug_msg "prepare_module_config ($@)"
-  if [ ! -x "$MODULE_CONFIG" ] ; then
-    touch $MODULE_CONFIG
-    chmod a+x $MODULE_CONFIG
+  if [ ! -e "$MODULE_CONFIG" ] ; then
+    > $MODULE_CONFIG
   fi
 }
 
@@ -316,12 +303,6 @@ run_configure() {
   fi
 
   prepare_module_config
-
-  if ! use_xinetd ; then
-    if [ -n "$RECONFIGURE" ] || ! grep -q INITDSCRIPTS $MODULE_CONFIG ; then
-      use_initd
-    fi
-  fi
   grep -q "^"$MODULE"\$" $TEMP_PREPAREDDEPS 2>/dev/null && return 0
 
   # add custom passed OPTS before retreiving them
@@ -329,6 +310,7 @@ run_configure() {
     OPTS="$(get_module_config OPTS) $PASS_OPTS"
     set_module_config OPTS "$OPTS"
   fi
+  plugin_call BUILD_CONFIGURE $MODULE
   run_module_file $MODULE CONFIGURE
 }
 
@@ -340,6 +322,7 @@ run_pre_build() {
   cd $BUILD_DIRECTORY
 
   if verify_all_sources $MODULE ; then
+    plugin_call BUILD_PRE_BUILD $MODULE
     if [ -s $SCRIPT_DIRECTORY/PRE_BUILD ] ; then
       run_module_file $MODULE PRE_BUILD
     else
@@ -361,6 +344,7 @@ run_build()  {
 
   verbose_msg "building \"$MODULE\" version \"$VERSION\" in `pwd`"
   
+  plugin_call BUILD_BUILD $MODULE
   if [ -s $SCRIPT_DIRECTORY/BUILD ] ; then
     run_module_file $MODULE BUILD
   else
@@ -381,16 +365,7 @@ run_post_build() {
 
 run_post_install() {
   debug_msg "run_post_install ($@)"
-  # keep a record of the module scripts used for every install
-  (
-    if [ ! -e /var/state/lunar/module_history ]; then
-      mkdir /var/state/lunar/module_history
-    fi
-    SCRIPT_DATE=$(date -u +%Y%m%d)                      &&
-    MH_NAME=$MODULE-$VERSION-$SCRIPT_DATE.tar.bz2  &&
-    cd $MOONBASE/$SECTION                               &&
-    tar -cjf /var/state/lunar/module_history/$MH_NAME $MODULE
-  )
+  plugin_call BUILD_POST_INSTALL $MODULE
   if [ -s $SCRIPT_DIRECTORY/POST_INSTALL ] ; then
     run_module_file $MODULE POST_INSTALL
   fi
diff --git a/var/lib/lunar/functions/check.lunar b/var/lib/lunar/functions/check.lunar
index f2ed4a0..9c5ff6c 100644
--- a/var/lib/lunar/functions/check.lunar
+++ b/var/lib/lunar/functions/check.lunar
@@ -23,12 +23,14 @@ run_checks() {
 
 # rework_module : check depends database for a module
 rework_module() {
+  local MODULE
   debug_msg "rework_module ($@)"
                                                                                 
   # we declare these local to override the systems default ones:
   optional_depends()  {
+    local DEP
     debug_msg "  optional_depends ($@)"
-    DEP=$(unalias $1)
+    DEP=$(NEVER_ASK=1 DEPS_ONLY= unalias $1)
     if module_exiled $DEP ; then
       echo "$MODULE:$DEP:off:optional:$2:$3"
     else
@@ -41,8 +43,9 @@ rework_module() {
   }
                                                                                 
   depends()  {
+    local DEP
     debug_msg "  depends ($@)"
-    DEP=$(unalias $1)
+    DEP=$(NEVER_ASK=1 DEPS_ONLY= unalias $1)
     if ! module_installed $DEP && ! module_held $DEP ; then
       if ! is_depends $DEP && module_exiled $DEP ; then
         return  1
@@ -59,7 +62,7 @@ rework_module() {
    (
     if run_details $1 &> /dev/null ; then
       if [ -s "$SCRIPT_DIRECTORY/DEPENDS" ] ; then
-      run_module_file $MODULE DEPENDS
+      run_module_file $MODULE DEPENDS | grep -v '%'
       fi
     fi
    ) 
@@ -73,15 +76,16 @@ rework_module() {
   lock_file $DEPENDS_STATUS_BACKUP                              &&
   lock_file $DEPENDS_STATUS                                     &&
   grep -v "^$MODULE:" $DEPENDS_STATUS_BACKUP > $DEPENDS_STATUS  &&
-  run_depends $MODULE >> $DEPENDS_STATUS                        &&
-  cat $DEPENDS_STATUS > $DEPENDS_STATUS_BACKUP                  &&
-  unlock_file $DEPENDS_STATUS                                   &&
+  run_depends $MODULE >> $DEPENDS_STATUS
+  cat $DEPENDS_STATUS > $DEPENDS_STATUS_BACKUP
+  unlock_file $DEPENDS_STATUS
   unlock_file $DEPENDS_STATUS_BACKUP
 }
 
 
 # fix_depends : single pass to fix depends database
 fix_depends () {
+  local LIST
   debug_msg "fix_depends  ($@)"
   
   if [ -n "$1" ] ; then
@@ -97,6 +101,7 @@ fix_depends () {
                                                                                 
 
 run_fix()  {
+  local MODULES MODULE
   debug_msg "run_fix ($@)"
   MODULES=$*
 
@@ -121,13 +126,16 @@ run_fix()  {
           if [ -n "$NOFIX" ] ; then
             continue
           fi
-          satisfy_depends      &&
-          FIX= satisfy_depends &&
+          NEVER_ASK=1 DEPS_ONLY= satisfy_depends      &&
+          NEVER_ASK=1 DEPS_ONLY= FIX= satisfy_depends &&
 
           if ! run_checks $MODULE ; then
+		    verbose_msg "Attempting to recompile \"$MODULE\""
             if ! FIX= lin --compile $MODULE ; then
+		      verbose_msg "Attempt to recompile \"$MODULE\" FAILED"
               continue
             elif ! run_checks $MODULE ; then
+		      verbose_msg "Attempt to recompile \"$MODULE\" succeeded but \"$MODULE\" still is broken!"
 			  continue
             fi
           fi
@@ -137,3 +145,4 @@ run_fix()  {
   done
 }
 
+
diff --git a/var/lib/lunar/functions/config.lunar b/var/lib/lunar/functions/config.lunar
index fae63a4..76ee9b3 100644
--- a/var/lib/lunar/functions/config.lunar
+++ b/var/lib/lunar/functions/config.lunar
@@ -20,6 +20,7 @@
 
 
 set_config() {
+  local LINE NEW
   debug_msg "set_config ($@)"
 
   LINE=$(cat $1 | grep -w "$2=.*")
diff --git a/var/lib/lunar/functions/connect.lunar b/var/lib/lunar/functions/connect.lunar
index 87190c0..b7b4e5d 100644
--- a/var/lib/lunar/functions/connect.lunar
+++ b/var/lib/lunar/functions/connect.lunar
@@ -34,6 +34,7 @@
 
 
 connect()  {
+  local TIMEOUT
   debug_msg "connect ($@)"
 
   if ! ifconfig | grep -q "^eth[0-9]\|^wlan[0-9]\|^ppp[0-9]\|^ath[0-9]\|^tun[0-9]\|ra[0-9]"
diff --git a/var/lib/lunar/functions/depends.lunar b/var/lib/lunar/functions/depends.lunar
index 78084ee..a4f5833 100644
--- a/var/lib/lunar/functions/depends.lunar
+++ b/var/lib/lunar/functions/depends.lunar
@@ -25,9 +25,11 @@
 # usage    : find_depends "module name"
 # purpose  : recursive dependency finder, no need to be installed
 function find_depends() {
+  local TMP_FDEPS
   debug_msg "find_depends ($@)"
 
   find_depends_intern() {
+    local DEP STATE LINE
     grep "^$1:" $DEPENDS_CACHE | while read LINE ; do
       DEP=$(echo $LINE | cut -d: -f2)
       DEP=$(unalias $DEP)
@@ -57,6 +59,7 @@ function find_depends() {
 # usage    : LIST=$(sort_by_dependency $LIST)
 # purpose  : return a LIST sorted by dependency
 sort_by_dependency() {
+  local TMP_LIST TMP_ALL TMP_TSRT A B
   debug_msg "sort_by_dependency ($@)"
 
   TMP_LIST=$(temp_create "deptree.in")
@@ -155,6 +158,7 @@ run_depends() {
   debug_msg "run_depends ($@)"
   # local definitions of depends and optional_depends!
   depends() {
+    local DEP
     debug_msg "  depends ($@)"
     DEP=$(unalias $1)
     if grep -q "^$DEP\$" $TEMP_PREPAREDDEPS 2>/dev/null ; then
@@ -181,6 +185,7 @@ run_depends() {
                                                                                 
   optional_depends()  {
   debug_msg "  optional_depends ($@)"
+    local DEP DEFAULT DEPMOD_AVAIL
     # parameters:  $1 = module name
     #              $2 = configure parameter if module wanted
     #              $3 = configure parameter if module declined
@@ -240,11 +245,13 @@ run_depends() {
 # NOTE: this is where a missing dependency gets installed! IOW we really do
 # "satisfy" any dependencies here!
 satisfy_depends()  {
+  local TMP_FILE DEP_MODULE DEP_STATUS DEP_ON DEP_OFF LINE
   debug_msg "satisfy_depends ($@)"
   if [ -n "$DEPS_ONLY" ] ; then 
     return 0
   fi
   
+  # make sure we start with clean OPTS here:
   unset OPTS
 
   if [ -s "$MODULE_CONFIG" ] ; then
@@ -255,7 +262,7 @@ satisfy_depends()  {
   grep "^$MODULE:" $DEPENDS_STATUS > $TMP_FILE
 
   # first recursively check if all required dependencies are installed
-  for DEP_MODULE in $(find_depends $MODULE) ; do
+  for DEP_MODULE in $(find_depends $MODULE | grep -v '%') ; do
     if [ $DEP_MODULE != $MODULE ]; then
       if ! module_installed $DEP_MODULE ; then
         if ! SINGLE_MODULE=1 lin $SILENT $COMPILE $DEP_MODULE ; then
@@ -296,6 +303,7 @@ satisfy_depends()  {
 
 # conflicts... remove conflicting modules
 conflicts() {
+  local DEP
   debug_msg "conflicts ($@)"
   DEP=$1
   if module_installed $DEP ; then
@@ -354,7 +362,9 @@ build_depends()  {
 }
 
 
-create_depends_cache() {
+create_depends_cache()
+{(
+  local TMP_DEP_CACHE DEPFILES DEPFILE MODULE
   debug_msg "create_depends_cache($@)"
 
   if [ ! -w $DEPENDS_CACHE -a -e $DEPENDS_CACHE ] ; then
@@ -398,11 +408,12 @@ create_depends_cache() {
   else
     verbose_msg "Skipping depends cache regeneration"
   fi
-}
+)}
 
 
 # list all installed modules depending on $1
 list_installed_depending() {
+  local SUBDEP
   debug_msg "list_installed_depending($2)"
   for SUBDEP in $(grep ":$1:" $DEPENDS_CACHE | cut -d: -f1) ; do
     if $(module_installed $SUBDEP ) ; then
@@ -411,3 +422,5 @@ list_installed_depending() {
     fi
   done
 }
+
+
diff --git a/var/lib/lunar/functions/download.lunar b/var/lib/lunar/functions/download.lunar
index 7e6d288..7d7571b 100644
--- a/var/lib/lunar/functions/download.lunar
+++ b/var/lib/lunar/functions/download.lunar
@@ -34,6 +34,7 @@ lget_unlock() {
 
 
 download_url() {
+    local RETVAL
 	debug_msg "download_url($@)"
 	verbose_msg "trying to download \"$URL\""
 	connect &&
@@ -49,6 +50,7 @@ download_url() {
 
 download_module() {
 (
+	local MAX_SOURCES SRC ALL_URLS URLS URL MLIST ALT REST HIT
 	debug_msg "download_module ($@)"
 	if ! run_details $1 ; then
 		exit 1
@@ -137,6 +139,7 @@ download_module() {
 
 
 testpack () {
+	local FILENAME
 	debug_msg "testpack ($@)"
 	if [ -f "$1" ]; then
 		FILENAME=$1
@@ -144,8 +147,7 @@ testpack () {
 		FILENAME=$SOURCE_CACHE/$1
 	fi
 	if [ -f "$FILENAME" ] ; then
-		COMPRESSOR=$(file -b $FILENAME | cut -d ' ' -f1)
-		case $COMPRESSOR in
+		case $(file -b $FILENAME | cut -d ' ' -f1) in
 			bzip2)
 				bzip2 -tf $FILENAME > /dev/null 2>&1
 				;;
@@ -171,6 +173,7 @@ testpack () {
 
 show_downloading()
 {
+	local DOWNLOAD_PID DOWNLOAD_LOG
 	debug_msg "show_downloading ($@)"
 	DOWNLOAD_PID=$(grep ^$MODULE: $TEMP_DOWNLOAD_PIDS | cut -d: -f2)
 	if [ -n "$DOWNLOAD_PID" ]; then
diff --git a/var/lib/lunar/functions/edit.lunar b/var/lib/lunar/functions/edit.lunar
index 26789e3..e51f211 100644
--- a/var/lib/lunar/functions/edit.lunar
+++ b/var/lib/lunar/functions/edit.lunar
@@ -16,6 +16,7 @@
 # purpose  : calls "patch -px < $filename", where filename may be a variety
 #            of formats
 patch_it () { 
+  local PATCH TARCMD GZCMD TMPFILE1 TMPFILE2
   verbose_msg "patch_it \"$1\" \"$2\"";
 
   # get patch from $SOURCE_CACHE automatically
@@ -66,7 +67,8 @@ patch_it () {
 # function : sedit
 # usage    : sedit sed-statement file [file [file] ...]
 # purpose  : edit [files] with a sed function
-sedit () { 
+sedit () {
+  local SEDIT
   debug_msg "sedit ($@)"
   SEDIT=$1
   shift
@@ -82,7 +84,7 @@ sedit () {
 # purpose  : to edit a file
 edit_file() {
   debug_msg "edit_file ($@)"
-  ${EDITOR:-nano}  $1
+  ${EDITOR:-nano} $1
 }
 
 
diff --git a/var/lib/lunar/functions/kernel.lunar b/var/lib/lunar/functions/kernel.lunar
index 7c1e548..fa4072c 100644
--- a/var/lib/lunar/functions/kernel.lunar
+++ b/var/lib/lunar/functions/kernel.lunar
@@ -44,15 +44,3 @@ update_bootloader() {
 }
 
 
-# dummy caller:
-update_lilo() {
-	update_bootloader $1 $2
-}
-
-# dummy stub:
-update_grub() {
-	:
-}
-
-
-
diff --git a/var/lib/lunar/functions/locking.lunar b/var/lib/lunar/functions/locking.lunar
index cfe2fb6..5620dba 100644
--- a/var/lib/lunar/functions/locking.lunar
+++ b/var/lib/lunar/functions/locking.lunar
@@ -20,6 +20,7 @@
 # usage   : lock_file <absolute file name>
 # purpose : locks a file or wait until. Better use as lock_file <file> && || etc
 function lock_file() {
+   local TEMPFILE LOCKFILE STALE_PID
    debug_msg "lock_file ($@)"
    function file_lock() {
       #locking is disabled if ln or rm not found!!
diff --git a/var/lib/lunar/functions/logging.lunar b/var/lib/lunar/functions/logging.lunar
index a9bb1e7..5a46a8c 100644
--- a/var/lib/lunar/functions/logging.lunar
+++ b/var/lib/lunar/functions/logging.lunar
@@ -51,16 +51,8 @@ activate_voyeur()  {
 
 activity_log()  {
   debug_msg "activity_log ($@)"
-
-    DATE=`date  -u  +%Y%m%d-%T`
-  COMMAND=$1
-   MODULE=$2
-  VERSION=$3
-  OUTCOME=$4
-     INFO=$5
-
   lock_file $ACTIVITY_LOG &&
-  echo "$DATE	$COMMAND	$MODULE	$VERSION	$OUTCOME	$INFO"  >> $ACTIVITY_LOG &&
+  echo -e "$(date -u +%Y%m%d-%T)\t$1\t$2\t$3\t$4\t$5" >> $ACTIVITY_LOG
   unlock_file $ACTIVITY_LOG
 }
 
diff --git a/var/lib/lunar/functions/main.lunar b/var/lib/lunar/functions/main.lunar
index 016db06..cc4cff9 100644
--- a/var/lib/lunar/functions/main.lunar
+++ b/var/lib/lunar/functions/main.lunar
@@ -84,6 +84,7 @@ update() {
 
 
 rebuild()  {
+  local LIST QUEUE TMP_QUEUE
   debug_msg "rebuild ($@)"
 
   message  "${MESSAGE_COLOR}Starting non-recursive rebuild${DEFAULT_COLOR}"
diff --git a/var/lib/lunar/functions/messages.lunar b/var/lib/lunar/functions/messages.lunar
index ec16163..ae95e3c 100644
--- a/var/lib/lunar/functions/messages.lunar
+++ b/var/lib/lunar/functions/messages.lunar
@@ -51,11 +51,11 @@ verbose_msg() {
 
 
 debug_msg() {
+  local PLUSSES
   if [ -n "$LUNAR_DEBUG" ] ; then
     if [ "$LUNAR_DEBUG" -ge "2" ] ; then
 	  PLUSSES="+++++++++++++++++++++++++*"
 	  echo -n "${PLUSSES:0:${#FUNCNAME[@]}} " >&2
-	  unset PLUSSES
 	fi
     if [ "$LUNAR_DEBUG" -ge "4" ] ; then
       echo -n "$(basename $0)[$$]: " >&2
@@ -91,6 +91,7 @@ debug_msg() {
 # usage : xterm_msg MESSAGE
 # purpose : To display a short message in the title bar of a X terminal
 xterm_msg() {
+  local MSG
   debug_msg "xterm_bar ($@)"
   case $TERM in
     xterm*|gnome*|konsole*|rxvt*)
@@ -102,6 +103,7 @@ xterm_msg() {
 
 # function : report FILE [description] MODULE VERSION
 report() {
+  local TMP_MAIL
   debug_msg "report ($@)"
   if [ ! -f "$1" ] ; then
     return
@@ -129,6 +131,7 @@ report() {
 
 
 query() {
+  local RESPONSE
   debug_msg "query ($@)"
   # 2 arguments
   # query "what do you want?  "  DEFAULT
@@ -204,15 +207,14 @@ color()  {
 }
 
 
-sound()  {
+sound()
+{
   debug_msg "sound ($@)"
-  case  $SOUND  in
-    on)  SOUND_FILE=$SOUND_DIRECTORY/$SOUND_THEME/$1
-         if  [  -e "$SOUND_FILE" ] ; then
-           (  cd  /  ;  play  $SOUND_FILE  & )
-         fi
-    ;;
-  esac
+  if [ "$SOUND" == "on" ]; then
+    if [ -f "$SOUND_DIRECTORY/$SOUND_THEME/$1" ]; then
+	  ( cd / ; play "$SOUND_DIRECTORY/$SOUND_THEME/$1" & )
+	fi
+  fi
 }
 
 
diff --git a/var/lib/lunar/functions/misc.lunar b/var/lib/lunar/functions/misc.lunar
index 04c2a93..f2c5e81 100644
--- a/var/lib/lunar/functions/misc.lunar
+++ b/var/lib/lunar/functions/misc.lunar
@@ -30,6 +30,7 @@
 # usage    : VARIABLE=`directories < dirlistfile`
 # purpose  : to determine the directories from a given list
 directories() {
+  local ITEM
   debug_msg "directories ($@)"
   while read ITEM ; do
     if [ -d "$ITEM" ] && [ ! -h "$ITEM" ] ; then
@@ -43,6 +44,7 @@ directories() {
 # usage    : VARIABLE=`files < dirlistfile`
 # purpose  : to determine the ordinary files from a given list
 files() {
+  local ITEM
   debug_msg "files ($@)"
   while read ITEM ; do
     if [ -f "$ITEM" ] && [ ! -h "$ITEM" ] ; then
@@ -56,6 +58,7 @@ files() {
 # usage    : VARIABLE=`symlinks < dirlistfile`
 # purpose  : to determine the symbolic links from a given list
 symlinks() {
+  local ITEM
   debug_msg "symlinks ($@)"
   while read ITEM ; do
     if [ -h "$ITEM" ] ; then
@@ -69,6 +72,7 @@ symlinks() {
 # usage    : VARIABLE=`dirnames < dirlistfile`
 # purpose  : info about the real locations of symlinks
 dirnames() {
+  local FILE
   debug_msg "dirnames ($@)"
   while read FILE ; do
     dirname "$FILE"
@@ -80,6 +84,7 @@ dirnames() {
 # usage    : VARIABLE=`exists < dirlistfile`
 # purpose  : filter out the non-existent files in a list
 exists() {
+  local ITEM
   debug_msg "exists ($@)"
   while read ITEM ; do
     if [ -e "$ITEM" ] ; then
@@ -93,10 +98,11 @@ exists() {
 # usage    : filter $FILE
 # purpose  : filter stdin with files/dirs/symlinks provided in file $1.
 filter() {
+  local TMP_GREPRE
   debug_msg "filter ($@)"
   if [ -f "$1" ] ; then
     TMP_GREPRE=$(temp_create "fgrep")
-    directories < $1 | sed -e 's:^:^:g' -e 's:$:/:g'   >> $TMP_GREPRE
+    directories < $1 | sed -e 's:^:^:g' -e 's:$:/:g'   > $TMP_GREPRE
     files       < $1 | sed -e 's:^:^:g' -e 's:$:\$:g' >> $TMP_GREPRE
     symlinks    < $1 | sed -e 's:^:^:g' -e 's:$:\$:g' >> $TMP_GREPRE
     read
diff --git a/var/lib/lunar/functions/modules.lunar b/var/lib/lunar/functions/modules.lunar
index b7b0127..bdc32d3 100644
--- a/var/lib/lunar/functions/modules.lunar
+++ b/var/lib/lunar/functions/modules.lunar
@@ -59,6 +59,7 @@ list_modules() {
 # usage    : list_moonbase
 # purpose  : returns the names of all modules in moonbase
 list_moonbase() {
+  local SECTION
   debug_msg "list_moonbase ($@)"
   for SECTION in $(list_sections) ; do
     list_modules $SECTION
@@ -79,6 +80,7 @@ list_installed() {
 # usage   : create_module_index
 # purpose : created an index file of module:section pair list
 create_module_index() {
+  local TMP_INDEX
   debug_msg "create_module_index ($@)"
   # make sure it exists before trying to see it's writeable
   # this also assures that depends.cache gets remade
@@ -150,6 +152,7 @@ function check_module_index() {
 # purpose  : finds the section of a given module as parameter
 # returns  : (0) on success, (1) on failure, errors on stdout
 find_section() {
+  local SECTION SECTIONS
   debug_msg "find_section ($@)"
 
   ZLOCAL_OVERRIDES=${ZLOCAL_OVERRIDES:=off}
@@ -202,6 +205,7 @@ find_section() {
 # purpose  : runs the DETAILS file of a module
 # returns  : (0) on success, (1) on failure, error messages on stdout
 run_details() {
+  local TMP_DETAILS
   debug_msg "run_details ($@)"
   # Note: run_details doesn't EXIT the code, but merely drops a warning
   # (return 1), which means that the calling code needs to decide 
@@ -313,6 +317,7 @@ module_version() {
 # usage    : hold_modules $MODULE [$MODULE....]
 # purpose  : put modules on hold
 hold_modules() {
+  local MODULE
   debug_msg "hold_modules ($@)"
   if [ -n "$1" ] ; then
     lock_file $MODULE_STATUS_BACKUP &&
@@ -321,8 +326,8 @@ hold_modules() {
       grep -v "^$MODULE:" $MODULE_STATUS > $MODULE_STATUS_BACKUP
       grep "^$MODULE:" $MODULE_STATUS | sed "s:installed:held:" >> $MODULE_STATUS_BACKUP
       cp $MODULE_STATUS_BACKUP $MODULE_STATUS
-    done &&
-    unlock_file $MODULE_STATUS &&
+    done
+    unlock_file $MODULE_STATUS
     unlock_file $MODULE_STATUS_BACKUP
   fi
 }
@@ -332,6 +337,7 @@ hold_modules() {
 # usage    : unhold_modules $MODULE [$MODULE....]
 # purpose  : put modules on hold back to normal
 unhold_modules () {
+  local MODULE
   debug_msg "unhold_modules  ($@)"
   if [ -n "$1" ] ; then
     lock_file $MODULE_STATUS_BACKUP &&
@@ -340,8 +346,8 @@ unhold_modules () {
       grep -v "^$MODULE:" $MODULE_STATUS > $MODULE_STATUS_BACKUP
       grep "^$MODULE:" $MODULE_STATUS | sed "s:held:installed:" >> $MODULE_STATUS_BACKUP
       cp $MODULE_STATUS_BACKUP $MODULE_STATUS
-    done &&
-    unlock_file $MODULE_STATUS &&
+    done
+    unlock_file $MODULE_STATUS
     unlock_file $MODULE_STATUS_BACKUP
   fi
 }
@@ -351,6 +357,7 @@ unhold_modules () {
 # usage    : exile_modules $MODULE [$MODULE....]
 # purpose  : put modules on exile
 exile_modules() {
+  local MODULE
   debug_msg "exile_modules ($@)"
   if [ -n "$1" ] ; then
     lock_file $MODULE_STATUS_BACKUP &&
@@ -363,8 +370,8 @@ exile_modules() {
         echo "$MODULE::exiled:0.0" >> $MODULE_STATUS_BACKUP
       fi
       cp $MODULE_STATUS_BACKUP $MODULE_STATUS
-    done &&
-    unlock_file $MODULE_STATUS &&
+    done
+    unlock_file $MODULE_STATUS
     unlock_file $MODULE_STATUS_BACKUP
   fi
 }
@@ -374,6 +381,7 @@ exile_modules() {
 # usage    : unexile_modules $MODULE [$MODULE....]
 # purpose  : put modules on exile back to normal
 unexile_modules () {
+  local MODULE
   debug_msg "unexile_modules  ($@)"
   if [ -n "$1" ] ; then
     lock_file $MODULE_STATUS_BACKUP &&
@@ -382,8 +390,8 @@ unexile_modules () {
       grep -v "^$MODULE:" $MODULE_STATUS > $MODULE_STATUS_BACKUP
       grep "^$MODULE:" $MODULE_STATUS | sed "s:exiled:installed:" >> $MODULE_STATUS_BACKUP
       cp $MODULE_STATUS_BACKUP $MODULE_STATUS
-    done &&
-    unlock_file $MODULE_STATUS &&
+    done
+    unlock_file $MODULE_STATUS
     unlock_file $MODULE_STATUS_BACKUP
   fi
 }
@@ -405,16 +413,16 @@ remove_module() {
   lock_file $MODULE_STATUS                                     && 
   grep  -v  "^$1:" $MODULE_STATUS_BACKUP  >  $MODULE_STATUS 2>/dev/null
   cat $MODULE_STATUS >  $MODULE_STATUS_BACKUP               2>/dev/null
-  unlock_file $MODULE_STATUS                                   &&
-  unlock_file $MODULE_STATUS_BACKUP                            &&
+  unlock_file $MODULE_STATUS
+  unlock_file $MODULE_STATUS_BACKUP
 
   if [ -n "$EXILE" ] ; then
      exile_modules "$1"                                  &&
      lock_file $DEPENDS_STATUS_BACKUP                    &&
      lock_file $DEPENDS_STATUS                           &&
      grep  -v  ":$1:" $DEPENDS_STATUS_BACKUP  >   $DEPENDS_STATUS  &&
-     cat $DEPENDS_STATUS >  $DEPENDS_STATUS_BACKUP       &&
-     unlock_file $DEPENDS_STATUS                         &&
+     cat $DEPENDS_STATUS >  $DEPENDS_STATUS_BACKUP
+     unlock_file $DEPENDS_STATUS
      unlock_file $DEPENDS_STATUS_BACKUP
   fi
 }
@@ -436,8 +444,8 @@ add_module()  {
   lock_file $MODULE_STATUS                                    &&
   grep -v "^$1:" $MODULE_STATUS_BACKUP > $MODULE_STATUS 2>/dev/null &&
   echo "$1:$(date -u +%Y%m%d):$2:$3:$4" >> $MODULE_STATUS     &&
-  cp $MODULE_STATUS $MODULE_STATUS_BACKUP                     &&
-  unlock_file $MODULE_STATUS                                  &&
+  cp $MODULE_STATUS $MODULE_STATUS_BACKUP
+  unlock_file $MODULE_STATUS
   unlock_file $MODULE_STATUS_BACKUP
 }
 
@@ -446,6 +454,7 @@ add_module()  {
 # usage    : purge_modules
 # purpose  : purge modules that were removed from moonbase
 purge_modules() {
+  local MODULE
   debug_msg "purge_modules ($@)"
   verbose_msg "Discovering modules that were removed from moonbase"
   for MODULE in $(list_installed | grep -v "^moonbase$") ; do
@@ -492,6 +501,7 @@ module_is_expired() {
 # usage    : list_expired_modules
 # purpose  : return a list of modules that need to be updated
 list_expired_modules() {
+  local MODULE
   debug_msg "list_expired_modules ($@)"
   for MODULE in $(list_installed) ; do
     if $(module_is_expired $MODULE) ; then
@@ -505,6 +515,7 @@ list_expired_modules() {
 # usage    : update_modules
 # purpose  : update all installed modules that need to be updated
 update_modules() {
+  local IFS LIST QUEUE MODULE
   debug_msg "update_modules ($@)"
 
   export IFS="$STANDARD_IFS"
@@ -540,30 +551,6 @@ update_modules() {
 }
 
 
-find_pam_aware()  {
-  debug_msg "find_pam_aware ($@)"
-
-  cat  $MODULE_STATUS_BACKUP  |
-  while  read  LINE;  do
-                        
-    MODULE="`echo  $LINE  |  cut  -d  :  -f1`"
-    STATUS="`echo  $LINE  |  cut  -d  :  -f3`"
-                                              
-    if  [  "$STATUS"  ==  "installed"  ]   ||
-        [  "$STATUS"  ==  "held"       ];  then
-
-      SECTION=`find_section  $MODULE`
-                                    
-      if    [  -d  "$MOONBASE/$SECTION/$MODULE/pam.d"  ]  &&
-            [  "$MODULE"  !=  "Linux-PAM"              ]
-      then  echo  $MODULE
-      fi
-
-    fi
-  done
-
-}
-
 
 check_blacklist() {
   debug_msg "check_blacklist ($@)"
@@ -587,8 +574,7 @@ check_blacklist() {
   # Usage check_checklist $MODULES
   PLATFORM=${PLATFORM:-x86}
   if [ -f /var/state/lunar/blacklist.$PLATFORM ] ; then
-    BLKLST=$(grep ^$MODULE$ /var/state/lunar/blacklist.$PLATFORM)
-    if [ "$BLKLST" == "$MODULE" ] ; then
+    if grep "^$MODULE$" /var/state/lunar/blacklist.$PLATFORM ; then
       message "${PROBLEM_COLOR}! Module ${DEFAULT_COLOR}${MODULE_COLOR}$MODULE${DEFAULT_COLOR}${PROBLEM_COLOR} is blacklisted and will not be installed${DEFAULT_COLOR}"
       exit 0
     fi
diff --git a/var/lib/lunar/functions/optimize.lunar b/var/lib/lunar/functions/optimize.lunar
index 38d144e..bc6fed2 100644
--- a/var/lib/lunar/functions/optimize.lunar
+++ b/var/lib/lunar/functions/optimize.lunar
@@ -631,6 +631,7 @@ optimize_fp() {
 
 # Set up the Linker optimizations
 optimize_ld() {
+  local WL
   debug_msg "optimize_ld ($@)"
   if [[ $LDFLAGS ]]; then
     unset LDFLAGS
diff --git a/var/lib/lunar/functions/plugins.lunar b/var/lib/lunar/functions/plugins.lunar
index 831d06e..95ffcfd 100644
--- a/var/lib/lunar/functions/plugins.lunar
+++ b/var/lib/lunar/functions/plugins.lunar
@@ -23,12 +23,18 @@ plugin_register() {
 	# first arg: plugin type
 	# second arg: function hook name
 	# Defined plugin types:
-	# 1 - SOURCE_DOWNLOAD - download some source code
-	# 2 - SOURCE_NEEDREFRESH - source exists but needs refresh
-    # 3 - SOURCE_VERIFY - perform intergity verification on a file
-	# 4 - SOURCE_UNPACK - unpack a certain file to $(PWD)
-	# 5 - MODULE_CHECK - perform integrity checking on installed modules
-	# 6 - KERNEL_UPDATEBOOTLOADER - automate bootloader maintenance
+	#  1 - SOURCE_DOWNLOAD         download some source code
+	#  2 - SOURCE_NEEDREFRESH      source exists but needs refresh
+    #  3 - SOURCE_VERIFY           perform intergity verification on a file
+	#  4 - SOURCE_UNPACK           unpack a certain file to $(PWD)
+	#  5 - MODULE_CHECK            integrity checking on installed modules
+	#  6 - KERNEL_UPDATEBOOTLOADER automate bootloader maintenance
+	#  7 - BUILD_CONFIGURE         called before running CONFIGURE
+	#  8 - BUILD_PRE_BUILD           ,,     ,,     ,,    PRE_BUILD 
+	#  9 - BUILD_BUILD               ,,     ,,     ,,    BUILD
+	# 10 - BUILD_INSTALL             ,,     ,,     ,,    INSTALL
+	# 11 - BUILD_POST_BUILD          ,,     ,,     ,,    POST_BUILD
+	# 12 - BUILD_POST_INSTALL        ,,     ,,     ,,    POST_INSTALL
 	LUNAR_PLUGINS=(${LUNAR_PLUGINS[@]} "$1:$2")
 	((LUNAR_PLUGIN_COUNT++))
 	debug_msg "Registered plugin #$LUNAR_PLUGIN_COUNT, $1 -> $2()"
@@ -36,6 +42,7 @@ plugin_register() {
 
 
 plugin_call() {
+    local REQUESTED_TYPE COUNT THIS_TYPE THIS_HANDLER RETVAL
 	debug_msg "plugin_call($@)"
 	# scan available plugins for plugin_type $1 and pass args to it
 	REQUESTED_TYPE=$1
@@ -50,16 +57,18 @@ plugin_call() {
 			if [ $RETVAL -eq 2 ]; then
 				continue
 			else
+				debug_msg "plugin $THIS_HANDLER returned \"$RETVAL\""
 				return $RETVAL
 			fi
 		fi
 	done
-	debug_msg "Finished running all plugins for type \"$1\""
+	debug_msg "Finished running all plugins for type \"$REQUESTED_TYPE\""
 	return 2
 }
 
 
 update_plugin() {
+	local SECTION PLUGIN
 	debug_msg "update_plugin($@)"
 	# update plugins of all modules or a specific one
 	#
@@ -91,6 +100,7 @@ update_plugin() {
 
 
 update_plugins() {
+	local MODULE
 	debug_msg "update_plugins($@)"
 	# rework all plugins	
 	verbose_msg "Updating plugins"
diff --git a/var/lib/lunar/functions/postbuild.lunar b/var/lib/lunar/functions/postbuild.lunar
deleted file mode 100644
index 87453ef..0000000
--- a/var/lib/lunar/functions/postbuild.lunar
+++ /dev/null
@@ -1,271 +0,0 @@
-#!/bin/bash
-#                                                          #
-# postbuild.lunar - Lunar install extensions               #
-#                                                          #
-############################################################
-#                                                          #
-# parts of these functions come from subroutines and were  #
-# part of sorcerer GNU/Linux. SGL is no longer             #
-# available with GPL license.                              #
-#                                                          #
-# the code is re-written for Lunar. The previous Copyright #
-# notices are kept; just in case some code is left :=)     #
-# Kagan Kongar <kongar at tsrsb.org.tr>, 20020519             #
-#                                                          #
-############################################################
-#                                                          #
-# Parts Copyrighted Kyle Sallee 2001                       #
-#                                                          #
-# Parts Copyrighted Hendrik Visage 2002 under GPLv2        #
-#                                                          #
-# Parts Copyrighted Kagan Kongar 2002 under GPLv2          #
-#                                                          #
-# Parts Copyrighted Auke Kok 2002 under GPLv2              #
-#                                                          #
-############################################################
-
-
-# function : gather_docs
-# usage 1  : gather_docs
-# usage 2  : gather_docs LIST OF FILES
-# purpose  : Installs extra documentation that came with the
-#            module's source package into the module's
-#            document directory (defined as Lunar's base
-#            document directory plus the module name).  This
-#            function is called from default_post_install as
-#            usage 1, which installs a default (read: common)
-#            set of docs.  If the developer is not happy with
-#            just those doc s/he can call this function from
-#            a module script (like BUILD) with a list of
-#            additional files (usage 2) to install into the
-#            module's document directory.
-# pre-conditions : user must have $GARBAGE="on" to have any
-#                  of this actually happen.
-gather_docs() {
-  debug_msg "gather_docs ($@)"
-
-  # Bail if the user doesn't want to install any extra documentation
-  if [ "$GARBAGE" != "on" ] ; then
-    return
-  fi
-
-  DOC_DIR=${DOCUMENT_DIRECTORY}/${MODULE}
-  mkdir -p $DOC_DIR
-
-  # This is the list of default extra documentation that is to be 
-  # installed automatically if the user has $GARBAGE=on.  Any other
-  # docs are left up to the module writer to get installed.
-  DEFAULT_DOCS="README* INSTALL* FAQ* CHAN* doc* DOC* *doc \
-                *sample* conf SETUP NEWS Change* manual* Manual*"
-
-  if [ -d "$SOURCE_DIRECTORY" ] ; then
-  (
-    cd $SOURCE_DIRECTORY
-
-    # Check if we are being called with parameters or not
-    if [ ${#} -gt 0 ] ; then
-      # For each parameter that is an existing file
-      for FILE in ${@}; do
-        if [ -e ${FILE} -a -f ${FILE} ] ; then
-          # copy it over to the doc directory creating directories as needed
-          verbose_msg "Installing extra documentation to: ${DOC_DIR}/${FILE}"
-          install -D -m 644 ${FILE} ${DOC_DIR}/${FILE}
-        fi
-      done
-    else
-      # No parameters were passed in, install the default docs
-      for FILE in ${DEFAULT_DOCS}; do
-        # copy all of the default docs (prune Makefiles)
-        if [ -e $FILE -a ! -f ${FILE}/Makefile ] ; then
-          verbose_msg "Installing default documentation to: ${DOC_DIR}/${FILE}"
-          cp -a $FILE $DOC_DIR 2> /dev/null
-	fi
-      done
-    fi
-  )
-  fi
-}
-
-install_pam_confs()  {
-  debug_msg "install_pam_confs ($@)"
-  if [ -d "$SCRIPT_DIRECTORY/pam.d" ] ; then
-    verbose_msg "handling pam config files"
-    cd "$SCRIPT_DIRECTORY/pam.d"
-
-    if [ ! -d /etc/pam.d ] ; then
-		  mkdir -p /etc/pam.d
-		fi
-
-    for FILE in [!CVS]* ; do
-      if [ ! -f /etc/pam.d/$FILE ] ; then
-        /usr/bin/install -g 0 -o 0 -m 0600 $FILE /etc/pam.d
-      fi
-    done
-  fi
-}
-
-
-install_xinetd_confs()  { (
-  unset IFS
-  debug_msg "install_xinetd_confs ($@)"
-  if  [  -d  "$SCRIPT_DIRECTORY/xinetd.d"  ];  then
-    cd       "$SCRIPT_DIRECTORY/xinetd.d"
-    verbose_msg "handling xinetd config files"
-
-    [ -d /etc/xinetd.d ] || mkdir  -p  /etc/xinetd.d
-
-    for  SERVICE  in  $SERVICES;  do
-      for  FILE  in  [!CVS]* ;  do
-        if    grep  -q  "service $SERVICE"   $FILE  ; then
-          if [ ! -f /etc/xinetd.d/$FILE ] ; then
-            /usr/bin/install --backup=numbered -g 0 -o 0 -m 600 $FILE /etc/xinetd.d
-          fi
-        fi
-      done
-    done
-
-    if  [  -n  "$SERVICES"  ];  then
-      devoke_installwatch
-      [ ! -x /etc/init.d/xinetd ] || /etc/init.d/xinetd  restart
-      invoke_installwatch
-    fi
-  fi
-) }
-
-
-use_xinetd()  {
-  debug_msg "use_xinetd ($@)"
-  if  [  -d  $SCRIPT_DIRECTORY/xinetd.d  ]  &&
-      !  grep  -q  "SERVICES="  $MODULE_CONFIG
-  then
-    ALL_SERVICES=`cat  $SCRIPT_DIRECTORY/xinetd.d/[!CVS]*  |
-                  grep  "service"                          |
-                  sed   "s/service //"`
-
-    for SERVICE in $ALL_SERVICES ; do
-      if query  "Invoke $SERVICE via xinetd?"  y ; then
-        SERVICES="$SERVICE $SERVICES"
-      else
-        RETURN=1
-      fi
-    done
-
-    for SERVICE in $SERVICES; do
-      for FILE in $SCRIPT_DIRECTORY/xinetd.d/[!CVS]* ; do
-        if  grep  -q   "service $SERVICE"  $FILE   &&
-            grep  -q   "stunnel"           $FILE;  then
-          add_depends  "$MODULE"  "stunnel"  "on"  "optional"
-        fi
-      done
-    done
-
-    if [ -n "$SERVICES" ] ; then
-      add_depends  "$MODULE"  "xinetd"  "on"   "optional"
-    else  
-      add_depends  "$MODULE"  "xinetd"  "off"  "optional"
-    fi
-
-    set_module_config "SERVICES" "$SERVICES"
-    if [ "$RETURN" == "1" ] ; then
-      return 1
-    else
-      return 0
-    fi
-
-  else
-    return 1
-  fi
-}
-
-
-install_initd()  {
-  debug_msg "install_initd ($@)"
-  [ -d /etc/init.d ] || mkdir -p /etc/init.d
-
-  if  [ -d  $SCRIPT_DIRECTORY/init.d  ] ; then
-    verbose_msg "handling init.d scripts" | tee -a $C_LOG
-    cd $SCRIPT_DIRECTORY/init.d
-    SCRIPTS=[!CVS]*
-    ALL_INITDSCRIPTS=$(grep -l "# chkconfig: " $SCRIPTS | cut -d/ -f2)
-
-    for INITDSCRIPT in $ALL_INITDSCRIPTS; do
-      if [ ! -f /etc/init.d/$INITDSCRIPT ] ; then
-        /usr/bin/install -g 0 -o 0 -m 700 $SCRIPT_DIRECTORY/init.d/$INITDSCRIPT /etc/init.d/
-      fi
-    done
-    cd $SCRIPT_DIRECTORY
-  fi
-
-  for INITDSCRIPT in $INITDSCRIPTS; do
-    ls /etc/rc?.d/???$INITDSCRIPT > /dev/null 2>&1 &&
-        rm -f /etc/rc?.d/???$INITDSCRIPT
-    chkconfig --add $INITDSCRIPT
-
-    CHKCONFIG=`grep '^# chkconfig:' /etc/init.d/$INITDSCRIPT | cut -d : -f 2-2`
-    if `echo $CHKCONFIG | grep -q $(/sbin/runlevel | cut -d ' ' -f 2-2) -`
-    then
-      devoke_installwatch
-      ( cd / && /etc/init.d/$INITDSCRIPT stop )
-      ( cd / && /etc/init.d/$INITDSCRIPT start )
-      invoke_installwatch
-    fi
-
-  done
-}
-
-
-use_initd()  {
-  debug_msg "use_initd ($@)"
-  if  [  -d  $SCRIPT_DIRECTORY/init.d  ] ; then
-    cd $SCRIPT_DIRECTORY/init.d
-
-    SCRIPTS=[!CVS]*
-    INITDSCRIPTS=$(grep -l "# chkconfig: " $SCRIPTS | cut -d/ -f2)
-
-    for  INITDSCRIPT  in  $INITDSCRIPTS;  do
-      if    query  "Invoke $INITDSCRIPT via init.d automatically at boot ?"  y
-      then
-        INSTALLED_INIDSCRIPTS=$(echo $INSTALLED_INIDSCRIPTS $INITDSCRIPT)
-      else
-        if [ -f /etc/init.d/$INITDSCRIPT ] ;
-        then
-          chkconfig --del $INITDSCRIPT
-          ls /etc/rc?.d/???$INITDSCRIPT > /dev/null 2>&1 &&
-                rm -f /etc/rc?.d/???$INITDSCRIPT
-        fi
-      fi
-    done
-    cd $SCRIPT_DIRECTORY
-
-    set_module_config "INITDSCRIPTS" "$INSTALLED_INIDSCRIPTS"
-  fi
-}
-
-
-install_services()  {
-  debug_msg "install_services ($@)"
-  if  [  -f  $SCRIPT_DIRECTORY/services  ];  then
-    export  IFS="$ENTER_IFS"
-    cat  $SCRIPT_DIRECTORY/services  |
-    while  read  LINE;  do
-      grep  -q  "$LINE"      /etc/services  ||
-      echo      "$LINE"  >>  /etc/services
-    done
-  fi
-}
-
-
-install_bashmisc () {
-  debug_msg "install_bashmisc ($@)"
-  if [ -d $SCRIPT_DIRECTORY/profile.d ] ; then
-    [ -d /etc/profile.d ] || mkdir -p /etc/profile.d
-    install -g 0 -o 0 -m 644 $SCRIPT_DIRECTORY/profile.d/*.rc /etc/profile.d
-    message "\n${MESSAGE_COLOR}Please log out and log in again to make changes in your shell\nenvironment take effect.${DEFAULT_COLOR}\n"
-  fi
-  if [ -d $SCRIPT_DIRECTORY/skel ]; then
-    [ -d /etc/skel ] || mkdir -p /etc/skel
-    cp $SCRIPT_DIRECTORY/skel/[!CVS]* /etc/skel &> /dev/null
-    cp $SCRIPT_DIRECTORY/skel/.* /etc/skel &> /dev/null
-  fi
-}
-
diff --git a/var/lib/lunar/functions/prune.lunar b/var/lib/lunar/functions/prune.lunar
index bd5910c..ab2167c 100644
--- a/var/lib/lunar/functions/prune.lunar
+++ b/var/lib/lunar/functions/prune.lunar
@@ -13,6 +13,7 @@
 # usage    : prune
 # purpose  : prune all old logs, source copy's, install caches
 prune() {
+  local TMP_SPOOL_KEEP TMP_CACHE_KEEP MODULE SOURCE VERSION FILE LOGS
   debug_msg "prune ($@)"
 
   if [ -z "$BUILD" ] ; then
diff --git a/var/lib/lunar/functions/sizes.lunar b/var/lib/lunar/functions/sizes.lunar
index 997c547..77a44a9 100644
--- a/var/lib/lunar/functions/sizes.lunar
+++ b/var/lib/lunar/functions/sizes.lunar
@@ -20,9 +20,11 @@
 # usage   : find_module_size <module> |version|
 # purpose : finds the installed size of module in KB
 find_module_size() {
+   local VERSION LINE SIZE0 SIZE
    #this functions checks the modules file if there is already size entry
    module_size()
    {
+      local SIZE
       unset SIZE
       [ -e "$MODULE_STATUS" ] &&
       SIZE=`grep  "^$1\:" $MODULE_STATUS | cut -d ":" -f 5-5`
diff --git a/var/lib/lunar/functions/sources.lunar b/var/lib/lunar/functions/sources.lunar
index 19f9be9..b1a2ea0 100644
--- a/var/lib/lunar/functions/sources.lunar
+++ b/var/lib/lunar/functions/sources.lunar
@@ -20,6 +20,7 @@
 
 
 verify_source() {
+  local VERIFIED SOURCE_FILE
   debug_msg "verify_source ($@)"
   VERIFIED="true"
   for SOURCE_FILE in $@ ; do
@@ -76,6 +77,7 @@ erase()  {
 
 
 unpack() {
+  local FILENAME
   debug_msg "unpack ($@)"
 
   FILENAME=$SOURCE_CACHE/$1
@@ -159,6 +161,7 @@ verify_all_sources() {
 
 
 rm_source_dir() {
+  local DEAD_DIR
   debug_msg "rm_source_dir ($@)"
 
   if [ "$KEEP_SOURCE" == "on" ] ; then
@@ -180,6 +183,7 @@ rm_source_dir() {
 
 
 mk_source_dir() {
+  local NEW_DIR
   debug_msg "mk_source_dir ($@)"
 
   # yes this sounds weird but it might happen: no dir $BUILD_DIRECTORY on
diff --git a/var/lib/lunar/functions/temp.lunar b/var/lib/lunar/functions/temp.lunar
index 53cceeb..4904f00 100644
--- a/var/lib/lunar/functions/temp.lunar
+++ b/var/lib/lunar/functions/temp.lunar
@@ -18,6 +18,7 @@
 
 
 temp_create() {
+  local TMPFILE
   debug_msg "temp_create ($@)"
   TMPFILE=$MODULE
   if TMPFILE=$(mktemp -p "$TMPDIR" -t lunar.`basename $0`.$$.$TMPFILE.XXXXXXXXXX ) ; then
diff --git a/var/lib/lunar/functions/tracking.lunar b/var/lib/lunar/functions/tracking.lunar
index 9199038..6f19979 100644
--- a/var/lib/lunar/functions/tracking.lunar
+++ b/var/lib/lunar/functions/tracking.lunar
@@ -49,6 +49,7 @@ devoke_installwatch() {
 # usage    : parse_iw
 # purpose  : remove unwanted accesses from the installwatch file
 parse_iw() {
+  local OMIT_IN
   debug_msg "parse_iw ($@)"
   OMIT_IN="	rename\|	symlink\|	unlink"
 
@@ -61,7 +62,7 @@ parse_iw() {
 # usage    : create_install_log
 # purpose  : create an install log
 create_install_log() {
-
+  local TMP_INST_LOG INST_LOG IFS MISOWNED_SYMLINKS
   debug_msg "create_install_log ($@)"
 
   TMP_INST_LOG=$(temp_create "install-log")
@@ -91,6 +92,7 @@ create_install_log() {
 
 
 create_md5sum_log()  {
+  local FILE
   debug_msg "create_md5sum_log ($@)"
 
   rm -f $MD5SUM_LOGS/$MODULE-$VERSION &> /dev/null
diff --git a/var/lib/lunar/functions/uniqid.lunar b/var/lib/lunar/functions/uniqid.lunar
index e803507..596a935 100644
--- a/var/lib/lunar/functions/uniqid.lunar
+++ b/var/lib/lunar/functions/uniqid.lunar
@@ -22,6 +22,7 @@ push_uniq_id() {
 
 
 create_uniq_id() {
+  local OS HASH IFACE
   debug_msg "create_uniq_id ($@)"
   if [ -n "$UNIQID" ]; then 
     return
diff --git a/var/lib/lunar/functions/updatelog.lunar b/var/lib/lunar/functions/updatelog.lunar
index db78cf3..c27eeef 100644
--- a/var/lib/lunar/functions/updatelog.lunar
+++ b/var/lib/lunar/functions/updatelog.lunar
@@ -34,6 +34,7 @@ display_update_log() {
 # usage    : display_success_info update|rebuild
 # purpose  : display a list of update successes and failures
 display_success_info() {
+  local NUMSUCCESS NUMFAILURES
   debug_msg "display_success_info ($@)"
 
   NUMSUCCESS=$(cat $TMP_LIN_SUCCESS | wc -l)
@@ -62,37 +63,56 @@ display_success_info() {
 # function : display_moonbase_changes
 # usage    : display_moonbase_changes
 # purpose  : display a list of modules added or removed during this update
-display_moonbase_changes()  {  
+display_moonbase_changes()  {
+  local MODULE_CHANGES NEW_MODULES DEL_MODULES MOV_MODULES M
   debug_msg "display_moonbase_changes ($@)"
-  MODULE_CHANGES=$(temp_create "module-changes")
 
   if [ -e "$MODULE_INDEX" ] && [ -e "$TMP_MODULE_INDEX" ]; then
-    diff -y $MODULE_INDEX $TMP_MODULE_INDEX | sort > $MODULE_CHANGES
+    MODULE_CHANGES=$(temp_create "module-changes")
+    diff -U0 $TMP_MODULE_INDEX $MODULE_INDEX | grep -v -e '^@@' -e '^---' -e '^+++' > $MODULE_CHANGES
 
-    NEW_MODULES=$(grep '<' $MODULE_CHANGES | wc -l)
-    DEL_MODULES=$(grep '>' $MODULE_CHANGES | wc -l)
-    MOV_MODULES=$(grep '|' $MODULE_CHANGES | wc -l)
-    message
+    MODULES=$(cat $MODULE_CHANGES | cut -d: -f1 | sed 's:^[+-]::' | sort -t : | uniq)
+	for M in $MODULES; do
+	  IN=$(grep "^-$M:" $MODULE_CHANGES)
+	  OUT=$(grep "^+$M:" $MODULE_CHANGES)
+	  if [ -z "$IN" -a -n "$OUT" ] ; then
+	    # new module:
+		NEW_MODULES="$NEW_MODULES $M"
+	  elif [ -n "$IN" -a -z "$OUT" ] ; then
+	    # removed module:
+		DEL_MODULES="$DEL_MODULES $M"
+	  else
+	    # moved module
+		MOV_MODULES="$MOV_MODULES $M"
+	  fi
+	done
 
-    if [ "$NEW_MODULES" != "0" ]; then
+    if [ -n "$NEW_MODULES" ]; then
       message "${MESSAGE_COLOR}New modules:${DEFAULT_COLOR}"
-      grep '<' $MODULE_CHANGES | tr -d '<' | sort -t : -k 2
+	  for M in $NEW_MODULES; do
+	   message "  $M"
+	  done
       message
     fi
 
-    if [ "$DEL_MODULES" != "0" ]; then
+    if [ -n "$DEL_MODULES" ]; then
       message "${MESSAGE_COLOR}Removed modules:${DEFAULT_COLOR}"
-      grep '>' $MODULE_CHANGES | tr -d '>\t ' | sort -t : -k 2
+	  for M in $DEL_MODULES; do
+	    message "  $M"
+	  done
       message
     fi
 
-    if [ "$MOV_MODULES" != "0" ]; then
+    if [ -n "$MOV_MODULES" ]; then
       message "${MESSAGE_COLOR}Moved modules:${DEFAULT_COLOR}"
-      grep '|' $MODULE_CHANGES | tr -d '>\t ' | sed -e 's#\(.*\):\(.*\)|\(.*\):\(.*\)#\1: \2 -> \4#g' | sort -t - -k 2
+	  for M in $MOV_MODULES; do
+	    INS=$(grep "^[-]$M:" $MODULE_CHANGES | cut -d: -f2)
+		OUTS=$(grep "^[+]$M:" $MODULE_CHANGES | cut -d: -f2)
+		message "  $M: $INS -> $OUTS"
+	  done
       message
     fi
-  fi
-
   temp_destroy $MODULE_CHANGES
+  fi
 }
 
diff --git a/var/lib/lunar/functions/useradd.lunar b/var/lib/lunar/functions/useradd.lunar
index 5bac41b..1e3e184 100644
--- a/var/lib/lunar/functions/useradd.lunar
+++ b/var/lib/lunar/functions/useradd.lunar
@@ -20,6 +20,7 @@
 # usage   : add_priv_user username:groupname [adduseropts [adduseropts]...]
 # info    : adds username:groupname and passes adduseropts to 'adduser'
 function add_priv_user() {
+  local USERNAME GROUPNAME
   debug_msg "function add_priv_user ($@)"
 
   if [ -n "$INSTALLWATCHFILE" ] ; then
diff --git a/var/lib/lunar/plugins/initd.plugin b/var/lib/lunar/plugins/initd.plugin
new file mode 100644
index 0000000..8e972df
--- /dev/null
+++ b/var/lib/lunar/plugins/initd.plugin
@@ -0,0 +1,86 @@
+#!/bin/bash
+#############################################################
+#                                                           #
+# initd.plugin - handling of initd.d files                  #
+#                                                           #
+#############################################################
+#                                                           #
+# Copyright 2005 by Auke Kok under GPLv2                    #
+#                                                           #
+#############################################################
+
+
+plugin_initd_configure()
+{
+  local SCRIPTS INITDSCRIPTS INSTALLED_INITDSCRIPTS
+  debug_msg "plugin_initd_configure ($@)"
+  if ! grep -q INITDSCRIPTS $DEPENDS_CONFIG/$MODULE && 
+      [ -d $SCRIPT_DIRECTORY/init.d ]; then
+    cd $SCRIPT_DIRECTORY/init.d
+
+    SCRIPTS=$(ls -1)
+    INITDSCRIPTS=$(grep -l "# chkconfig: " $SCRIPTS | cut -d/ -f2)
+
+    for INITDSCRIPT in $INITDSCRIPTS; do
+      if query "Invoke $INITDSCRIPT via init.d automatically at boot ?"  y
+      then
+        INSTALLED_INIDSCRIPTS=$(echo $INSTALLED_INIDSCRIPTS $INITDSCRIPT)
+      else
+        if [ -f /etc/init.d/$INITDSCRIPT ]; then
+          chkconfig --del $INITDSCRIPT
+          ls /etc/rc?.d/???$INITDSCRIPT > /dev/null 2>&1 &&
+                rm -f /etc/rc?.d/???$INITDSCRIPT
+        fi
+      fi
+    done
+    cd $SCRIPT_DIRECTORY
+
+    set_module_config "INITDSCRIPTS" "$INSTALLED_INIDSCRIPTS"
+  fi
+  return 2
+}
+
+
+plugin_initd_post_build()
+{
+  local SCRIPTS ALL_INITDSCRIPTS CHKCONFIG
+  debug_msg "plugin_initd_post_build ($@)"
+  [ -d /etc/init.d ] || mkdir -p /etc/init.d
+
+  if [ -d $SCRIPT_DIRECTORY/init.d ]; then
+    invoke_installwatch
+    verbose_msg "handling init.d scripts" | tee -a $C_LOG
+    cd $SCRIPT_DIRECTORY/init.d
+    SCRIPTS=$(ls -1)
+    ALL_INITDSCRIPTS=$(grep -l "# chkconfig: " $SCRIPTS | cut -d/ -f2)
+
+    for INITDSCRIPT in $ALL_INITDSCRIPTS; do
+      if [ ! -f /etc/init.d/$INITDSCRIPT ] ; then
+        /usr/bin/install -g 0 -o 0 -m 700 $SCRIPT_DIRECTORY/init.d/$INITDSCRIPT /etc/init.d/
+      fi
+    done
+    cd $SCRIPT_DIRECTORY
+    devoke_installwatch
+  fi
+
+  for INITDSCRIPT in $INITDSCRIPTS; do
+    ls /etc/rc?.d/???$INITDSCRIPT > /dev/null 2>&1 &&
+        rm -f /etc/rc?.d/???$INITDSCRIPT
+    invoke_installwatch
+    chkconfig --add $INITDSCRIPT
+    devoke_installwatch
+
+    CHKCONFIG=`grep '^# chkconfig:' /etc/init.d/$INITDSCRIPT | cut -d : -f 2-2`
+    if `echo $CHKCONFIG | grep -q $(/sbin/runlevel | cut -d ' ' -f 2-2) -`
+    then
+      ( cd / && /etc/init.d/$INITDSCRIPT stop )
+      ( cd / && /etc/init.d/$INITDSCRIPT start )
+    fi
+
+  done
+  return 2
+}
+
+
+plugin_register BUILD_CONFIGURE plugin_initd_configure
+plugin_register BUILD_POST_BUILD plugin_initd_post_build
diff --git a/var/lib/lunar/plugins/postbuild-generic.plugin b/var/lib/lunar/plugins/postbuild-generic.plugin
new file mode 100644
index 0000000..8555d79
--- /dev/null
+++ b/var/lib/lunar/plugins/postbuild-generic.plugin
@@ -0,0 +1,111 @@
+#!/bin/bash
+#############################################################
+#                                                           #
+# postbuild-generic.plugin - postbuild handling of non-     #
+#                            module related files           #
+#                                                           #
+#############################################################
+#                                                           #
+# Copyright 2005 by Auke Kok under GPLv2                    #
+#                                                           #
+#############################################################
+
+
+plugin_services_post_build()
+{
+  local IFS LINE
+  debug_msg "plugin_services_post_build ($@)"
+  if [ -f $SCRIPT_DIRECTORY/services ]; then
+    export IFS="$ENTER_IFS"
+    while read LINE; do
+      grep -q "$LINE" /etc/services || echo "$LINE" >> /etc/services
+    done < $SCRIPT_DIRECTORY/services
+  fi
+  return 2
+}
+
+
+gather_docs()
+{
+  # function : gather_docs
+  # usage    : gather_docs LIST OF FILES
+  # purpose  : Installs extra documentation that came with the
+  #            module's source package into the module's
+  #            document directory (defined as Lunar's base
+  #            document directory plus the module name).
+  debug_msg "gather_docs ($@)"
+
+  DOC_DIR=${DOCUMENT_DIRECTORY}/${MODULE}
+  if [ -d "$SOURCE_DIRECTORY" ] ; then
+    cd $SOURCE_DIRECTORY
+    invoke_installwatch
+    mkdir -p $DOC_DIR
+    # For each parameter that is an existing file
+    for FILE in ${@}; do
+      if [ -e ${FILE} -a -f ${FILE} ] ; then
+        # copy it over to the doc directory creating directories as needed
+        verbose_msg "Installing extra documentation to: ${DOC_DIR}/${FILE}"
+        install -D -m 644 ${FILE} ${DOC_DIR}/${FILE}
+      fi
+    done
+    devoke_installwatch
+	# do not return 2 here: this function is called directly and
+	# must return true (0) here
+	return 0
+  fi
+  return 2
+}
+
+
+plugin_postbuild_gather_docs()
+{
+  # pre-conditions : user must have $GARBAGE="on" to have any
+  #                  of this actually happen.
+  debug_msg "plugin_postbuild_gather_docs ($@)"
+
+  DOC_DIR=${DOCUMENT_DIRECTORY}/${MODULE}
+
+  # This is the list of default extra documentation that is to be 
+  # installed automatically if the user has $GARBAGE=on.  Any other
+  # docs are left up to the module writer to get installed.
+  DEFAULT_DOCS="README* INSTALL* FAQ* CHAN* doc* DOC* *doc \
+                *sample* conf SETUP NEWS Change* manual* Manual*"
+
+  if [ -d "$SOURCE_DIRECTORY" ] ; then
+    cd $SOURCE_DIRECTORY
+
+    # Bail if the user doesn't want to install any extra documentation
+    if [ "$GARBAGE" != "on" ] ; then
+      return 2
+    fi
+    invoke_installwatch
+    mkdir -p $DOC_DIR
+    # No parameters were passed in, install the default docs
+    for FILE in ${DEFAULT_DOCS}; do
+      # copy all of the default docs (prune Makefiles)
+      if [ -e $FILE -a ! -f ${FILE}/Makefile ] ; then
+        verbose_msg "Installing default documentation to: ${DOC_DIR}/${FILE}"
+        cp -a $FILE $DOC_DIR 2> /dev/null
+      fi
+    done
+    devoke_installwatch
+  fi
+  return 2
+}
+
+
+plugin_archive_module()
+{
+  debug_msg "plugin_archive_module($@)"
+  # keep a record of the module scripts used for every install
+  if [ ! -e /var/state/lunar/module_history ]; then
+    mkdir -p /var/state/lunar/module_history
+  fi
+  tar -cj -C $MOONBASE/$SECTION -f /var/state/lunar/module_history/$MODULE-$VERSION-$(date -u +%Y%m%d).tar.bz2 $MODULE
+  return 2
+}
+
+
+plugin_register BUILD_POST_BUILD plugin_services_post_build
+plugin_register BUILD_POST_BUILD plugin_postbuild_gather_docs
+plugin_register BUILD_POST_BUILD plugin_archive_module


More information about the Lunar-commits mailing list