[open-ils-commits] r13269 - in trunk/Open-ILS/src: . extras (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun May 31 11:04:43 EDT 2009


Author: dbs
Date: 2009-05-31 11:04:41 -0400 (Sun, 31 May 2009)
New Revision: 13269

Modified:
   trunk/Open-ILS/src/Makefile.am
   trunk/Open-ILS/src/extras/autogen.sh
Log:
Make autogen.sh a bit more robust and informative
  * Default to sysconfdir as configured at build time
  * Return an error message and value if the specified config file is not found
  * Support legacy option of using $1 as the config file value, without breaking "autogen.sh -u"


Modified: trunk/Open-ILS/src/Makefile.am
===================================================================
--- trunk/Open-ILS/src/Makefile.am	2009-05-30 15:07:12 UTC (rev 13268)
+++ trunk/Open-ILS/src/Makefile.am	2009-05-31 15:04:41 UTC (rev 13269)
@@ -222,8 +222,9 @@
 	sed -i 's|LOCALSTATEDIR|@localstatedir@|g' '$(DESTDIR)@sysconfdir@/opensrf.xml.example'
 	sed -i 's|SYSCONFDIR|@sysconfdir@|g' '$(DESTDIR)@sysconfdir@/opensrf.xml.example'
 	sed -i 's|LIBDIR|@libdir@|g' '$(DESTDIR)@sysconfdir@/opensrf.xml.example'
+	sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/autogen.sh'
+	sed -i 's|LOCALSTATEDIR|@localstatedir@|g' '$(DESTDIR)@bindir@/autogen.sh'
 	sed -i 's|SYSCONFDIR|@sysconfdir@|g' '$(DESTDIR)@bindir@/autogen.sh'
-	sed -i 's|LOCALSTATEDIR|@localstatedir@|g' '$(DESTDIR)@bindir@/autogen.sh'
 	sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/reshelving_complete.srfsh'
 	sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/juv_to_adult.srfsh'
 	sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/long-overdue-status-update.pl'

Modified: trunk/Open-ILS/src/extras/autogen.sh
===================================================================
--- trunk/Open-ILS/src/extras/autogen.sh	2009-05-30 15:07:12 UTC (rev 13268)
+++ trunk/Open-ILS/src/extras/autogen.sh	2009-05-31 15:04:41 UTC (rev 13269)
@@ -16,6 +16,11 @@
 
 # vim:noet:ts=4
 
+# Exit script if any statement returns a non-true return value
+set -e
+# Throw an error for uninitialized variables
+set -u
+
 # ---------------------------------------------------------------------------
 # Make sure we're running as the correct user
 # ---------------------------------------------------------------------------
@@ -23,39 +28,36 @@
 
 function usage {
 	echo "";
-	echo "usage: $0 [-u] -c <c_config>";
+	echo "usage: $0 [-u] [-c <c_config>]";
 	echo "";
-	echo "Mandatory parameters:";
-	echo -e "  -c\t\tfull path to C configuration file (opensrf_core.xml)";
+	echo "Updates the Evergreen organization tree and fieldmapper IDL.";
+	echo "Run this every time you change the Evergreen organization tree";
+	echo "or update fm_IDL.xml";
 	echo "";
 	echo "Optional parameters:";
+	echo -e "  -c\t\tfull path to C configuration file (opensrf_core.xml)";
+	echo -e "    \t\t - defaults to SYSCONFDIR/opensrf_core.xml";
 	echo -e "  -u\t\tupdate proximity of library sites in organization tree";
 	echo -e "    \t\t(this is expensive for a large organization tree)";
 	echo "";
 	echo "Examples:";
 	echo "";
-	echo "  Update organization tree:";
+	echo "  Update organization tree and fieldmapper IDL:";
 	echo "    $0 -c SYSCONFDIR/opensrf_core.xml";
-	echo "    $0 SYSCONFDIR/opensrf_core.xml";
 	echo "";
 	echo "  Update organization tree and refresh proximity:";
 	echo "    $0 -u -c SYSCONFDIR/opensrf_core.xml";
 	echo "";
-	exit;
 }
 
 (
 
-BASEDIR=${0%/*}
-if test "$BASEDIR" = "$0" ; then
-	BASEDIR="$(which $0)"
-	BASEDIR=${BASEDIR%/*}
-fi
+cd "BINDIR"
 
-cd "$BASEDIR"
+# Initialize our variables
+CONFIG="";
+PROXIMITY="";
 
-CONFIG="$1";
-
 # ---------------------------------------------------------------------------
 # Load the command line options and set the global vars
 # ---------------------------------------------------------------------------
@@ -63,16 +65,33 @@
 	case $flag in	
 		"c")		CONFIG="$OPTARG";;
 		"u")		PROXIMITY="REFRESH";;
-		"h")		usage;;
+		"h")		usage && exit;;
 	esac;
+	shift $((OPTIND - 1))
 done
 
-[ -z "$CONFIG" ] && usage;
+if [ -z "$CONFIG" ] && [[ ! -z "${1:-}" ]]; then
+	# Support "autogen.sh /path/to/opensrf_core.xml" for legacy invocation
+	CONFIG="$1";
+fi
+if [ -z "$CONFIG" ]; then
+	# Fall back to the configured default
+	CONFIG="SYSCONFDIR/opensrf_core.xml";
+fi
+if [ ! -f "$CONFIG" ]; then
+	echo "ERROR: could not find configuration file '$CONFIG'";
+	echo "";
+	usage;
+	exit 1;
+fi;
 
 JSDIR="LOCALSTATEDIR/web/opac/common/js/";
 FMDOJODIR="LOCALSTATEDIR/web/js/dojo/fieldmapper/";
 SLIMPACDIR="LOCALSTATEDIR/web/opac/extras/slimpac/";
 
+echo "Updating Evergreen organization tree and IDL using '$CONFIG'"
+echo ""
+
 echo "Updating fieldmapper";
 perl fieldmapper.pl "$CONFIG"	> "$JSDIR/fmall.js";
 cp "$JSDIR/fmall.js" "$FMDOJODIR/"
@@ -94,7 +113,7 @@
 perl org_lasso_js.pl "$CONFIG" > "$JSDIR/OrgLasso.js";
 cp "$JSDIR/OrgLasso.js" "$FMDOJODIR/"
 
-if [ "$PROXIMITY" ]
+if [ ! -z "$PROXIMITY" ]
 then
 	echo "Refreshing proximity of org units";
 	perl org_tree_proximity.pl "$CONFIG";



More information about the open-ils-commits mailing list