2 # --------------------------------------------------------------------
3 # Copyright (C) 2005 Georgia Public Library Service
4 # Bill Erickson <highfalutin@gmail.com>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 # --------------------------------------------------------------------
18 # --------------------------------------------------------------------
20 # --------------------------------------------------------------------
21 CONFIG_FILE="install.conf";
22 DEFAULT_CONFIG_FILE="install.conf.default";
23 verbose="-s" #clear this to get full build output
26 # --------------------------------------------------------------------
27 # Loads all of the path information from the user setting
28 # install variables as it goes
29 # --------------------------------------------------------------------
33 echo "A build error occured: $MSG";
38 #function postMessage {
41 # --------------------------------------------------------------------
48 # --------------------------------------------------------------------
49 # Makes sure the install directories exist and are writable
50 # --------------------------------------------------------------------
54 [ "$?" != "0" ] && fail "Error creating $1";
55 [ ! -w "$1" ] && fail "We don't have write access to $1";
58 function mkInstallDirs {
60 installing && mkDir "$PREFIX";
61 building && mkDir "$TMP";
62 installing && mkDir "$SOCK";
63 installing && mkDir "$PID";
64 installing && mkDir "$LOG";
67 # add the opensrf user and group
69 if [ ! $(grep "^opensrf:" /etc/group) ]; then groupadd opensrf; fi
70 if [ ! $(grep "^opensrf:" /etc/passwd) ]; then useradd -g opensrf opensrf; fi
71 # add opensrf to the opensrf group
72 gpasswd -a opensrf opensrf
78 if [ -z "$INSTALLING" ]; then return 1; fi;
83 if [ -z "$BUILDING" ]; then return 1; fi;
89 # --------------------------------------------------------------------
90 # Loads the config file. If it can't fine CONFIG_FILE, it attempts to
91 # use DEFAULT_CONFIG_FILE. If it can't find that, it fails.
92 # --------------------------------------------------------------------
94 if [ ! -f "$CONFIG_FILE" ]; then
95 if [ -f "$DEFAULT_CONFIG_FILE" ]; then
96 echo "+ + + Copying $DEFAULT_CONFIG_FILE to $CONFIG_FILE and using its settings...";
97 cp "$DEFAULT_CONFIG_FILE" "$CONFIG_FILE";
99 fail "config file \"$CONFIG_FILE\" cannot be found";
102 source "$CONFIG_FILE";
108 function runInstall {
110 # pass the collected variables to make
111 for target in ${TARGETS[@]:0}; do
114 echo "-------------- [ $target ] -------------------------------------------";
117 MAKE="make $verbose APXS2=$APXS2 PREFIX=$PREFIX TMP=$TMP APR_HEADERS=$APR_HEADERS \
118 APACHE2_HEADERS=$APACHE2_HEADERS LIBXML2_HEADERS=$LIBXML2_HEADERS DBPORT=$DBPORT\
119 BINDIR=$BINDIR LIBDIR=$LIBDIR PERLDIR=$PERLDIR INCLUDEDIR=$INCLUDEDIR \
120 WEBDIR=$WEBDIR TEMPLATEDIR=$TEMPLATEDIR ETCDIR=$ETCDIR REPORTERDIR=$REPORTERDIR\
121 OPENSRFDIR=$OPENSRFDIR OPENILSDIR=$OPENILSDIR EVERGREENDIR=$EVERGREENDIR \
122 CIRCRULESDIR=$CIRCRULESDIR CATALOGSCRIPTDIR=$CATALOGSCRIPTDIR CGIDIR=$CGIDIR \
123 DBDRVR=$DBDRVR DBHOST=$DBHOST DATADIR=$DATADIR\
124 PENALTYRULESDIR=$PENALTYRULESDIR DBNAME=$DBNAME DBUSER=$DBUSER DBPW=$DBPW XSLDIR=$XSLDIR NEW_OPAC_URL=$NEW_OPAC_URL \
125 NEW_XUL_PACKAGE_NAME=$NEW_XUL_PACKAGE_NAME NEW_XUL_PACKAGE_LABEL=$NEW_XUL_PACKAGE_LABEL";
133 if building; then $MAKE -C "$OPENSRFDIR" all; fi;
134 if installing; then $MAKE -C "$OPENSRFDIR" install; fi;
138 if building; then $MAKE -C "$OPENSRFDIR" "jserver"; fi;
139 if installing; then $MAKE -C "$OPENSRFDIR" "jserver-install"; fi;
143 if building; then $MAKE -C "$OPENSRFDIR" "router"; fi;
144 if installing; then $MAKE -C "$OPENSRFDIR" "router-install"; fi;
148 if building; then $MAKE -C "$OPENSRFDIR" "gateway"; fi;
149 if installing; then $MAKE -C "$OPENSRFDIR" "gateway-install"; fi;
153 if building; then $MAKE -C "$OPENSRFDIR" "srfsh"; fi;
154 if installing; then $MAKE -C "$OPENSRFDIR" "srfsh-install"; fi;
158 if building; then $MAKE -C "$OPENSRFDIR" libstack/opensrf; fi;
159 if installing; then $MAKE -C "$OPENSRFDIR" "perl-install"; fi;
166 if building; then $MAKE -C "$OPENILSDIR" all; fi;
167 if installing; then $MAKE -C "$OPENILSDIR" install; fi;
171 if building; then $MAKE -C "$OPENILSDIR" "c_apps"; fi;
173 $MAKE -C "$OPENILSDIR" "perl-install";
174 $MAKE -C "$OPENILSDIR" "string-templates-install";
175 $MAKE -C "$OPENILSDIR" "xsl-install";
176 $MAKE -C "$OPENILSDIR" "c_apps-install";
177 $MAKE -C "$OPENILSDIR" "circ_rules-install";
178 $MAKE -C "$OPENILSDIR" "autojs-install";
183 if building; then $MAKE -C "$OPENILSDIR" "mod_xmlent"; fi;
184 #if building; then $MAKE -C "$OPENILSDIR" "mod_ils_rest_gateway"; fi;
186 $MAKE -C "$OPENILSDIR" "web-install";
187 $MAKE -C "$OPENILSDIR" "cgi-bootstrap";
188 $MAKE -C "$OPENILSDIR" "reporter-install";
192 "openils_marcdumper" )
193 if building; then $MAKE -C "$OPENILSDIR" "marcdumper"; fi;
194 if installing; then $MAKE -C "$OPENILSDIR" "marcdumper-install"; fi;
199 $MAKE -C "$OPENILSDIR" "storage-bootstrap";
205 $MAKE -C "$OPENILSDIR" "reporter-install";
209 "openils_client_xul" )
211 $MAKE -C "$OPENILSDIR" "client-xul";
215 "openils_server_xul" )
217 $MAKE -C "$OPENILSDIR" "server-xul";
224 if installing; then $MAKE -C "$EVERGREENDIR" "circ-install"; fi;
225 if installing; then $MAKE -C "$EVERGREENDIR" "iplist-install"; fi;
226 if installing; then $MAKE -C "$EVERGREENDIR" "perl-install"; fi;
229 "evergreen_xul_client" )
230 if building; then $MAKE -C "$EVERGREENDIR" xul; fi;
234 *) fail "Unknown target: $target";;
241 echo -e "\nNow run: chown -R opensrf:opensrf $PREFIX"
246 # --------------------------------------------------------------------
247 # Checks command line parameters for special behavior
248 # Supported params are:
249 # clean - cleans all build files
250 # build - builds the specified sources
251 # install - installs the specified sources
252 # --------------------------------------------------------------------
253 function checkParams {
255 if [ -z "$1" ]; then usage; fi;
275 *) fail "Unknown option => $arg";
279 if [ "$lastArg" = "clean" ]; then exit 0; fi;
285 make "TMP=$TMP" -s -C "$OPENSRFDIR" clean;
286 make "TMP=$TMP" -s -C "$OPENILSDIR" clean;
287 make "TMP=$TMP" -s -C "$EVERGREENDIR" clean;
291 echo "usage: $0 [ build | install | clean ]";
297 if building; then echo "Building..."; fi;
298 if installing; then echo "Installing..."; fi;
301 # --------------------------------------------------------------------
303 # --------------------------------------------------------------------