gather_docs() enhancement

Chad Kittel v3rt1g0 at lunar-linux.org
Sat Sep 18 21:42:10 UTC 2004


I have come up with a working example of something small I would like to see 
added to the tools the developers have when creating modules.  It's nothing 
major but I would like to get input on it from anyone that cares to provide 
input.

It's an extended version of the already existing function gather_docs() (found 
in postbuild.functions).  It would allow a module writer/maintainer to be 
able to install any extra documentation (above and beyond what is already 
automagiclly copied over) they feel would be nice to add to the module's 
document directoy. This just provides a standard (and quicker) way of doing 
this.

An example usage is in 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.  It also obays $GARBAGE=on as it currently does.  The files list 
are all to be relative to the #SOURCE_DIRECTORY


Below is the modified function (with comments), please feel free to respond 
with suggestions or code cleanups.
--------------
# 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-condidtions : 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 automaticly if the user has $GARABGE=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 boting called with paramaters or not
      if [ ${#} -gt 0 ] ; then

        # For each paramater that is a file and exists
        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 but prune stuff which
          # obviously is code
          if [ -e $FILE -a ! -f $FILE/Makefile ] ; then
            verbose_msg "Installing deafult documentation to: $DOC_DIR/$FILE"
            cp -a $FILE $DOC_DIR 2> /dev/null
          fi
        done
      fi
    )
  fi
}

Thanx,
 - v3rt1g0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lunar-linux.org/mailman/private/lunar-dev/attachments/20040918/ec7c84e3/attachment.bin


More information about the Lunar-dev mailing list