[Lunar-commits] CVS: theedge/var/lib/lunar/functions postbuild.lunar, 1.13, 1.14

Chad Kittel v3rt1g0 at lunar-linux.org
Wed Oct 13 02:31:46 UTC 2004


Update of /var/cvs/lunar/theedge/var/lib/lunar/functions
In directory espresso.foo-projects.org:/tmp/cvs-serv8387

Modified Files:
	postbuild.lunar 
Log Message:
I'm finally getting around to committing the approved modification to 
gather_docs() I proposed to Lunar-Dev ML about a month ago.

As a refresher (or introduction for some) this is what the change is all 
about.  It's an extended version of the already existing function 
gather_docs().  It allows a module writer/maintainer to be able to easily 
install any extra documentation (above and beyond what is already 
automatically copied over) they feel would be nice to add to the module's 
default document directory.

A common usage would be a line like this found at the end of a BUILD file:

gather_docs TODO INDEX Notes extras/*
                                      
Which would copy the files TODO, INDEX, Notes, and create a subdirectory 
called extras and copy any files found in that directory to the new 
directory under the module's default document directory.

It obeys (checks for) $GARBAGE=on for you, so you don't need to worry about
that when writing the module. The files in the file list must all reside in
or below the $SOURCE_DIRECTORY and must be referenced relative to said 
directory.

There is no harm in implementing this now within the moonbase at will.  If
the user does not have the extended version of gather_docs() (and they have
verbose on) s/he will see the default documentation be coppied twice but 
nothing more.


Index: postbuild.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/postbuild.lunar,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- postbuild.lunar	4 Jun 2004 12:21:51 -0000	1.13
+++ postbuild.lunar	13 Oct 2004 02:31:44 -0000	1.14
@@ -25,32 +25,67 @@
 ############################################################
 
 
-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.
+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
+  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
-      for FILE in \
-        README* INSTALL* FAQ* CHAN* doc* DOC* *doc *sample* \
-        conf SETUP NEWS Change* manual* Manual* ; do
-	# copy all but prune stuff which obviously is code
-        if [ -e $FILE -a ! -f $FILE/Makefile ] ; then
-          verbose_msg "installing docs: \"$DOC_DIR/$FILE\""
-          cp -ar $FILE $DOC_DIR 2> /dev/null
+  (
+    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



More information about the Lunar-commits mailing list