[Lunar-commits] r14735 - in lunar/trunk/var/lib/lunar: functions plugins

Auke Kok sofar at lunar-linux.org
Sun May 15 18:20:58 UTC 2005


Author: sofar
Date: 2005-05-15 18:20:54 +0000 (Sun, 15 May 2005)
New Revision: 14735

Added:
   lunar/trunk/var/lib/lunar/plugins/initd.plugin
   lunar/trunk/var/lib/lunar/plugins/postbuild-generic.plugin
Modified:
   lunar/trunk/var/lib/lunar/functions/aliases.lunar
   lunar/trunk/var/lib/lunar/functions/build.lunar
   lunar/trunk/var/lib/lunar/functions/check.lunar
   lunar/trunk/var/lib/lunar/functions/config.lunar
   lunar/trunk/var/lib/lunar/functions/connect.lunar
   lunar/trunk/var/lib/lunar/functions/depends.lunar
   lunar/trunk/var/lib/lunar/functions/download.lunar
   lunar/trunk/var/lib/lunar/functions/edit.lunar
   lunar/trunk/var/lib/lunar/functions/kernel.lunar
   lunar/trunk/var/lib/lunar/functions/locking.lunar
   lunar/trunk/var/lib/lunar/functions/logging.lunar
   lunar/trunk/var/lib/lunar/functions/main.lunar
   lunar/trunk/var/lib/lunar/functions/messages.lunar
   lunar/trunk/var/lib/lunar/functions/misc.lunar
   lunar/trunk/var/lib/lunar/functions/modules.lunar
   lunar/trunk/var/lib/lunar/functions/optimize.lunar
   lunar/trunk/var/lib/lunar/functions/plugins.lunar
   lunar/trunk/var/lib/lunar/functions/prune.lunar
   lunar/trunk/var/lib/lunar/functions/sizes.lunar
   lunar/trunk/var/lib/lunar/functions/sources.lunar
   lunar/trunk/var/lib/lunar/functions/temp.lunar
   lunar/trunk/var/lib/lunar/functions/tracking.lunar
   lunar/trunk/var/lib/lunar/functions/uniqid.lunar
   lunar/trunk/var/lib/lunar/functions/updatelog.lunar
   lunar/trunk/var/lib/lunar/functions/useradd.lunar
Log:
Lots of stuff changed:
1. added 5 new BUILD_ plugin hooks
2. make plugins out of all non-core post-build code
3. moved bash and xinetd plugin code into moonbase to make it really pluggable
4. Cleaned up a few small pieces of code
5. added 'local' declarations as much as possible everywhere!!!
6. removed the dummy calls to update_lilo/grub


Modified: lunar/trunk/var/lib/lunar/functions/aliases.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/aliases.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/aliases.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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-)

Modified: lunar/trunk/var/lib/lunar/functions/build.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/build.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/build.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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 @@
 
 
 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 @@
 
 
 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 @@
 
 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 @@
     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_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_build() {
+  local CPAN_MODULE
   debug_msg "default_cpan_build ($@)"
   prepare_install
   verbose_msg "running \"default_cpan_build\""
@@ -236,9 +245,7 @@
         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 @@
     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 @@
   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 @@
     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 @@
   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 @@
 
   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_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

Modified: lunar/trunk/var/lib/lunar/functions/check.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/check.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/check.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -23,10 +23,12 @@
 
 # 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=$(NEVER_ASK=1 DEPS_ONLY= unalias $1)
     if module_exiled $DEP ; then
@@ -41,6 +43,7 @@
   }
                                                                                 
   depends()  {
+    local DEP
     debug_msg "  depends ($@)"
     DEP=$(NEVER_ASK=1 DEPS_ONLY= unalias $1)
     if ! module_installed $DEP && ! module_held $DEP ; then
@@ -82,6 +85,7 @@
 
 # fix_depends : single pass to fix depends database
 fix_depends () {
+  local LIST
   debug_msg "fix_depends  ($@)"
   
   if [ -n "$1" ] ; then
@@ -97,6 +101,7 @@
                                                                                 
 
 run_fix()  {
+  local MODULES MODULE
   debug_msg "run_fix ($@)"
   MODULES=$*
 
@@ -140,3 +145,4 @@
   done
 }
 
+

Modified: lunar/trunk/var/lib/lunar/functions/config.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/config.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/config.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -20,6 +20,7 @@
 
 
 set_config() {
+  local LINE NEW
   debug_msg "set_config ($@)"
 
   LINE=$(cat $1 | grep -w "$2=.*")

Modified: lunar/trunk/var/lib/lunar/functions/connect.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/connect.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/connect.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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]"

Modified: lunar/trunk/var/lib/lunar/functions/depends.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/depends.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/depends.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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 @@
 # 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 @@
   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 @@
                                                                                 
   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,6 +245,7 @@
 # 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 OPTS LINE
   debug_msg "satisfy_depends ($@)"
   if [ -n "$DEPS_ONLY" ] ; then 
     return 0
@@ -296,6 +302,7 @@
 
 # conflicts... remove conflicting modules
 conflicts() {
+  local DEP
   debug_msg "conflicts ($@)"
   DEP=$1
   if module_installed $DEP ; then
@@ -356,6 +363,7 @@
 
 create_depends_cache()
 {(
+  local TMP_DEP_CACHE DEPFILES DEPFILE MODULE
   debug_msg "create_depends_cache($@)"
 
   if [ ! -w $DEPENDS_CACHE -a -e $DEPENDS_CACHE ] ; then
@@ -404,6 +412,7 @@
 
 # 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

Modified: lunar/trunk/var/lib/lunar/functions/download.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/download.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/download.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -34,6 +34,7 @@
 
 
 download_url() {
+    local RETVAL
 	debug_msg "download_url($@)"
 	verbose_msg "trying to download \"$URL\""
 	connect &&
@@ -49,6 +50,7 @@
 
 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 @@
 
 
 testpack () {
+	local FILENAME
 	debug_msg "testpack ($@)"
 	if [ -f "$1" ]; then
 		FILENAME=$1
@@ -144,8 +147,7 @@
 		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 @@
 
 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

Modified: lunar/trunk/var/lib/lunar/functions/edit.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/edit.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/edit.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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 @@
 # 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 @@
 # purpose  : to edit a file
 edit_file() {
   debug_msg "edit_file ($@)"
-  ${EDITOR:-nano}  $1
+  ${EDITOR:-nano} $1
 }
 
 

Modified: lunar/trunk/var/lib/lunar/functions/kernel.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/kernel.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/kernel.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -44,15 +44,3 @@
 }
 
 
-# dummy caller:
-update_lilo() {
-	update_bootloader $1 $2
-}
-
-# dummy stub:
-update_grub() {
-	:
-}
-
-
-

Modified: lunar/trunk/var/lib/lunar/functions/locking.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/locking.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/locking.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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!!

Modified: lunar/trunk/var/lib/lunar/functions/logging.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/logging.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/logging.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -51,16 +51,8 @@
 
 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
 }
 

Modified: lunar/trunk/var/lib/lunar/functions/main.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/main.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/main.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -84,6 +84,7 @@
 
 
 rebuild()  {
+  local LIST QUEUE TMP_QUEUE
   debug_msg "rebuild ($@)"
 
   message  "${MESSAGE_COLOR}Starting non-recursive rebuild${DEFAULT_COLOR}"

Modified: lunar/trunk/var/lib/lunar/functions/messages.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/messages.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/messages.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -51,11 +51,11 @@
 
 
 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 @@
 # 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 @@
 
 # function : report FILE [description] MODULE VERSION
 report() {
+  local TMP_MAIL
   debug_msg "report ($@)"
   if [ ! -f "$1" ] ; then
     return
@@ -129,6 +131,7 @@
 
 
 query() {
+  local RESPONSE
   debug_msg "query ($@)"
   # 2 arguments
   # query "what do you want?  "  DEFAULT
@@ -204,15 +207,14 @@
 }
 
 
-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
 }
 
 

Modified: lunar/trunk/var/lib/lunar/functions/misc.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/misc.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/misc.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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 @@
 # 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 @@
 # 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 @@
 # 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 @@
 # 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 @@
 # 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

Modified: lunar/trunk/var/lib/lunar/functions/modules.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/modules.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/modules.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -59,6 +59,7 @@
 # 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 @@
 # 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 @@
 # 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 @@
 # 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 @@
 # 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 @@
       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 @@
 # 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 @@
       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 @@
 # 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 @@
         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 @@
 # 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 @@
       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 @@
   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 @@
   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 @@
 # 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 @@
 # 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 @@
 # 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,31 +551,7 @@
 }
 
 
-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 ($@)"
   # Copyrighted Jason Johnston  2002 under GPLv2
@@ -587,8 +574,7 @@
   # 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

Modified: lunar/trunk/var/lib/lunar/functions/optimize.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/optimize.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/optimize.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -631,6 +631,7 @@
 
 # Set up the Linker optimizations
 optimize_ld() {
+  local WL
   debug_msg "optimize_ld ($@)"
   if [[ $LDFLAGS ]]; then
     unset LDFLAGS

Modified: lunar/trunk/var/lib/lunar/functions/plugins.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/plugins.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/plugins.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -23,12 +23,18 @@
 	# 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_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 @@
 			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_plugins() {
+	local MODULE
 	debug_msg "update_plugins($@)"
 	# rework all plugins	
 	verbose_msg "Updating plugins"

Modified: lunar/trunk/var/lib/lunar/functions/prune.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/prune.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/prune.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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

Modified: lunar/trunk/var/lib/lunar/functions/sizes.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/sizes.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/sizes.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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`

Modified: lunar/trunk/var/lib/lunar/functions/sources.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/sources.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/sources.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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 @@
 
 
 unpack() {
+  local FILENAME
   debug_msg "unpack ($@)"
 
   FILENAME=$SOURCE_CACHE/$1
@@ -159,6 +161,7 @@
 
 
 rm_source_dir() {
+  local DEAD_DIR
   debug_msg "rm_source_dir ($@)"
 
   if [ "$KEEP_SOURCE" == "on" ] ; then
@@ -180,6 +183,7 @@
 
 
 mk_source_dir() {
+  local NEW_DIR
   debug_msg "mk_source_dir ($@)"
 
   # yes this sounds weird but it might happen: no dir $BUILD_DIRECTORY on

Modified: lunar/trunk/var/lib/lunar/functions/temp.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/temp.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/temp.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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

Modified: lunar/trunk/var/lib/lunar/functions/tracking.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/tracking.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/tracking.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -49,6 +49,7 @@
 # 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 @@
 # 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_md5sum_log()  {
+  local FILE
   debug_msg "create_md5sum_log ($@)"
 
   rm -f $MD5SUM_LOGS/$MODULE-$VERSION &> /dev/null

Modified: lunar/trunk/var/lib/lunar/functions/uniqid.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/uniqid.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/uniqid.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -22,6 +22,7 @@
 
 
 create_uniq_id() {
+  local OS HASH IFACE
   debug_msg "create_uniq_id ($@)"
   if [ -n "$UNIQID" ]; then 
     return

Modified: lunar/trunk/var/lib/lunar/functions/updatelog.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/updatelog.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/updatelog.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -34,6 +34,7 @@
 # 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)
@@ -63,6 +64,7 @@
 # usage    : display_moonbase_changes
 # purpose  : display a list of modules added or removed during this update
 display_moonbase_changes()  {
+  local MODULE_CHANGES NEW_MODULES DEL_MODULES MOV_MODULES M
   debug_msg "display_moonbase_changes ($@)"
 
   if [ -e "$MODULE_INDEX" ] && [ -e "$TMP_MODULE_INDEX" ]; then

Modified: lunar/trunk/var/lib/lunar/functions/useradd.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/useradd.lunar	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/functions/useradd.lunar	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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

Added: lunar/trunk/var/lib/lunar/plugins/initd.plugin
===================================================================
--- lunar/trunk/var/lib/lunar/plugins/initd.plugin	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/plugins/initd.plugin	2005-05-15 18:20:54 UTC (rev 14735)
@@ -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

Added: lunar/trunk/var/lib/lunar/plugins/postbuild-generic.plugin
===================================================================
--- lunar/trunk/var/lib/lunar/plugins/postbuild-generic.plugin	2005-05-15 18:15:04 UTC (rev 14734)
+++ lunar/trunk/var/lib/lunar/plugins/postbuild-generic.plugin	2005-05-15 18:20:54 UTC (rev 14735)
@@ -0,0 +1,108 @@
+#!/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 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.
+  debug_msg "gather_docs ($@)"
+
+  # Bail if the user doesn't want to install any extra documentation
+  if [ "$GARBAGE" != "on" ] ; then
+    return 2
+  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
+  (
+    invoke_installwatch
+    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
+    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 gather_docs
+plugin_register BUILD_POST_BUILD plugin_archive_module



More information about the Lunar-commits mailing list