3 # --------------------------------------------------------------------
4 # Copyright (C) 2005 Georgia Public Library Service
5 # Bill Erickson <highfalutin@gmail.com>
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 # --------------------------------------------------------------------
19 # --------------------------------------------------------------------
21 # --------------------------------------------------------------------
22 CONFIG_FILE="install.conf";
23 DEFAULT_CONFIG_FILE="install.conf.default";
24 verbose="-s" #clear this to get full build output
27 # --------------------------------------------------------------------
28 # Loads all of the path information from the user setting
29 # install variables as it goes
30 # --------------------------------------------------------------------
34 echo "A build error occured: $MSG";
39 #function postMessage {
42 # --------------------------------------------------------------------
49 # --------------------------------------------------------------------
50 # Makes sure the install directories exist and are writable
51 # --------------------------------------------------------------------
55 [ "$?" != "0" ] && fail "Error creating $1";
56 [ ! -w "$1" ] && fail "We don't have write access to $1";
59 function mkInstallDirs {
61 installing && mkDir "$PREFIX";
62 building && mkDir "$TMP";
63 installing && mkDir "$SOCK";
64 installing && mkDir "$PID";
65 installing && mkDir "$LOG";
68 # add the opensrf user and group
70 if [ ! $(grep "^opensrf:" /etc/group) ]; then groupadd opensrf; fi
71 if [ ! $(grep "^opensrf:" /etc/passwd) ]; then useradd -g opensrf opensrf; fi
77 if [ -z "$INSTALLING" ]; then return 1; fi;
82 if [ -z "$BUILDING" ]; then return 1; fi;
87 if [ -z "$TESTING" ]; then return 1; fi;
92 # --------------------------------------------------------------------
93 # Loads the config file. If it can't fine CONFIG_FILE, it attempts to
94 # use DEFAULT_CONFIG_FILE. If it can't find that, it fails.
95 # --------------------------------------------------------------------
97 if [ ! -f "$CONFIG_FILE" ]; then
98 if [ -f "$DEFAULT_CONFIG_FILE" ]; then
99 echo "+ + + Copying $DEFAULT_CONFIG_FILE to $CONFIG_FILE and using its settings...";
100 cp "$DEFAULT_CONFIG_FILE" "$CONFIG_FILE";
102 fail "config file \"$CONFIG_FILE\" cannot be found";
105 source "$CONFIG_FILE";
111 function runInstall {
113 # pass the collected variables to make
114 for target in ${TARGETS[@]:0}; do
117 echo "-------------- [ $target ] -------------------------------------------";
120 MAKE="make $verbose APXS2=$APXS2 PREFIX=$PREFIX TMP=$TMP APR_HEADERS=$APR_HEADERS \
121 APACHE2_HEADERS=$APACHE2_HEADERS LIBXML2_HEADERS=$LIBXML2_HEADERS DBPORT=$DBPORT\
122 BINDIR=$BINDIR DBI_LIBS=$DBI_LIBS LIBDIR=$LIBDIR PERLDIR=$PERLDIR EG_PYTHON_INSTALL=$EG_PYTHON_INSTALL INCLUDEDIR=$INCLUDEDIR \
123 WEBDIR=$WEBDIR TEMPLATEDIR=$TEMPLATEDIR ETCDIR=$ETCDIR REPORTERDIR=$REPORTERDIR\
124 OPENSRF_HEADERS=$OPENSRF_HEADERS OPENSRF_LIBS=$OPENSRF_LIBS OPENILSDIR=$OPENILSDIR EVERGREENDIR=$EVERGREENDIR \
125 CIRCRULESDIR=$CIRCRULESDIR CATALOGSCRIPTDIR=$CATALOGSCRIPTDIR CGIDIR=$CGIDIR \
126 DBDRVR=$DBDRVR DBHOST=$DBHOST DBVER=$DBVER DATADIR=$DATADIR ADMINDIR=$ADMINDIR\
127 PENALTYRULESDIR=$PENALTYRULESDIR DBNAME=$DBNAME DBUSER=$DBUSER DBPW=$DBPW XSLDIR=$XSLDIR NEW_OPAC_URL=$NEW_OPAC_URL \
128 NEW_XUL_PACKAGE_NAME=$NEW_XUL_PACKAGE_NAME NEW_XUL_PACKAGE_LABEL=$NEW_XUL_PACKAGE_LABEL";
136 if building; then $MAKE -C "$OPENILSDIR" all; fi;
137 if testing; then $MAKE -C "$OPENILSDIR/../examples" test; fi;
138 if installing; then $MAKE -C "$OPENILSDIR" install; fi;
143 $MAKE -C "$OPENILSDIR" "c_apps";
144 $MAKE -C "$OPENILSDIR" "python-build";
147 $MAKE -C "$OPENILSDIR" "perl-install";
148 $MAKE -C "$OPENILSDIR" "python-install";
149 $MAKE -C "$OPENILSDIR" "string-templates-install";
150 $MAKE -C "$OPENILSDIR" "xsl-install";
151 $MAKE -C "$OPENILSDIR" "c_apps-install";
152 $MAKE -C "$OPENILSDIR" "circ_rules-install";
153 $MAKE -C "$OPENILSDIR" "autojs-install";
158 if building; then $MAKE -C "$OPENILSDIR" "mod_xmlent"; fi;
159 #if building; then $MAKE -C "$OPENILSDIR" "mod_ils_rest_gateway"; fi;
161 $MAKE -C "$OPENILSDIR" "web-install";
162 $MAKE -C "$OPENILSDIR" "cgi-bootstrap";
163 $MAKE -C "$OPENILSDIR" "reporter-install";
167 "openils_marcdumper" )
168 if building; then $MAKE -C "$OPENILSDIR" "marcdumper"; fi;
169 if installing; then $MAKE -C "$OPENILSDIR" "marcdumper-install"; fi;
174 $MAKE -C "$OPENILSDIR" "storage-bootstrap";
180 $MAKE -C "$OPENILSDIR" "reporter-install";
184 "openils_client_xul" )
186 $MAKE -C "$OPENILSDIR" "client-xul";
190 "openils_server_xul" )
192 $MAKE -C "$OPENILSDIR" "server-xul";
199 if installing; then $MAKE -C "$EVERGREENDIR" "install"; fi;
202 "evergreen_xul_client" )
203 if building; then $MAKE -C "$EVERGREENDIR" xul; fi;
207 *) fail "Unknown target: $target";;
214 echo -e "\nNow run: chown -R opensrf:opensrf $PREFIX"
219 # --------------------------------------------------------------------
220 # Checks command line parameters for special behavior
221 # Supported params are:
222 # clean - cleans all build files
223 # build - builds the specified sources
224 # install - installs the specified sources
225 # test - tests the specified sources
226 # --------------------------------------------------------------------
227 function checkParams {
229 if [ -z "$1" ]; then usage; fi;
252 *) fail "Unknown option => $arg";
256 if [ "$lastArg" = "clean" ]; then exit 0; fi;
262 make "TMP=$TMP" -s -C "$OPENILSDIR" clean;
263 make "TMP=$TMP" -s -C "$EVERGREENDIR" clean;
264 make "TMP=$TMP" -s -C "$OPENILSDIR/../xul/staff_client" clean;
268 echo "usage: $0 [ build | install | clean ]";
274 if building; then echo "Building..."; fi;
275 if testing; then echo "Testing..."; fi;
276 if installing; then echo "Installing..."; fi;
279 # --------------------------------------------------------------------
281 # --------------------------------------------------------------------