From d070a548a46303addaab14a820041a11cc2b0776 Mon Sep 17 00:00:00 2001 From: "Tom G. Christensen" Date: Fri, 22 Oct 2004 12:41:29 +0000 Subject: [PATCH] Moved all the reg code out of the build.sh script an into a function library instead. --- build.sh.functions | 58 ++++++++++++++++++++++++++++++++++++++++++++++ build.sh.generic | 54 ++++-------------------------------------- 2 files changed, 62 insertions(+), 50 deletions(-) create mode 100644 build.sh.functions diff --git a/build.sh.functions b/build.sh.functions new file mode 100644 index 0000000..2f9bcd1 --- /dev/null +++ b/build.sh.functions @@ -0,0 +1,58 @@ +# +# Function library for build.sh +# +# This is only for build.sh helper functions. +# +# The concept of "method" registering and the logic that implements it was +# stolen from jhlj's Compile.sh script :) +# + +# Define script functions and register them +METHODS="" +reg() { + METHODS="$METHODS $1" +} + +all() +{ + for METHOD in $METHODS + do + case $METHOD in + all*|*clean) ;; + *) $METHOD + ;; + esac + done + +} + +usage() { + echo Usage $0 "{"$(echo $METHODS | tr " " "|")"}" + exit 1 +} + +build_sh() { + # Register internal functions last + # The empty reg is trickery to get exactly 1 space at each end of the METHODS string + reg all + reg + # + local OK=0 + for METHOD in $* + do + METHOD=" $METHOD *" + if [ "${METHODS%$METHOD}" == "$METHODS" ] ; then + usage + fi + OK=1 + done + + if [ $OK = 0 ] ; then + usage; + fi + + for METHOD in $* + do + ( $METHOD ) + done +} diff --git a/build.sh.generic b/build.sh.generic index 122e16e..09700ae 100644 --- a/build.sh.generic +++ b/build.sh.generic @@ -3,9 +3,10 @@ # This is a generic build.sh script # It can be used nearly unmodified with many packages # -# The concept of "method" registering and the logic that implements it was shamelessly -# stolen from jhlj's Compile.sh script :) +# build.sh helper functions +. ${BUILDPKG_BASE}/scripts/build.sh.functions # +########################################################### # Check the following 4 variables before running the script topdir= version= @@ -17,15 +18,6 @@ patch[0]= # Source function library . ${BUILDPKG_BASE}/scripts/buildpkg.functions -# Fill in pkginfo values if necessary -# using pkgname,name,pkgcat,pkgvendor & pkgdesc - -# Define script functions and register them -METHODS="" -reg() { - METHODS="$METHODS $1" -} - reg prep prep() { @@ -59,42 +51,4 @@ distclean() ################################################### # No need to look below here ################################################### - -reg all -all() -{ - for METHOD in $METHODS - do - case $METHOD in - all*|*clean) ;; - *) $METHOD - ;; - esac - done - -} - -reg -usage() { - echo Usage $0 "{"$(echo $METHODS | tr " " "|")"}" - exit 1 -} - -OK=0 -for METHOD in $* -do - METHOD=" $METHOD *" - if [ "${METHODS%$METHOD}" == "$METHODS" ] ; then - usage - fi - OK=1 -done - -if [ $OK = 0 ] ; then - usage; -fi - -for METHOD in $* -do - ( $METHOD ) -done +build_sh $*