]> git.evergreen-ils.org Git - Evergreen.git/blob - install.sh
committing to cvs so i can move it over to another machine and work on it :)
[Evergreen.git] / install.sh
1 #!/bin/bash
2 # --------------------------------------------------------------------
3 # Copyright (C) 2005  Georgia Public Library Service 
4 # Bill Erickson <highfalutin@gmail.com>
5 #
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.
10 #
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 # --------------------------------------------------------------------
16
17
18 # --------------------------------------------------------------------
19 # ILS install script
20 # --------------------------------------------------------------------
21 CONFIG_FILE="install.conf";
22 DEFAULT_CONFIG_FILE="install.conf.default";
23
24
25 # --------------------------------------------------------------------
26 # Loads all of the path information from the user setting 
27 # install variables as it goes
28 # --------------------------------------------------------------------
29
30 function fail {
31         MSG="$1";
32         echo "A build error occured: $MSG";
33         exit 99;
34 }
35
36
37 function verifyInstallPaths {
38
39         cat <<-WORDS
40
41         -----------------------------------------------------------------------
42         Verify the following install directories are sane.
43         Note: * indicates that you must have write privelages for the location
44         -----------------------------------------------------------------------
45
46         -----------------------------------------------------------------------
47         Install prefix            [$PREFIX]*
48         Temporary files directory [$TMP]*
49         Apache2 apxs binary       [$APXS2]
50         Apache2 header directory  [$APACHE2_HEADERS]
51         Libxml2 header directory  [$LIBXML2_HEADERS]
52         Building targets          [${TARGETS[@]:0}];
53         -----------------------------------------------------------------------
54
55         If these are not OK, use control-c to break out and fix the variables 
56         in install.config.  Otherwise, type enter.
57
58         To disable this message, run "./install.sh force".
59
60         WORDS
61         read OK;
62 }
63
64 #function postMessage {
65
66 #cat <<-WORDS
67 #       --------------------------------------------------------------------
68
69
70 #}
71
72 # --------------------------------------------------------------------
73 # Makes sure the install directories exist and are writable
74 # --------------------------------------------------------------------
75 function mkInstallDirs {
76
77         mkdir -p "$PREFIX";
78         if [ "$?" != "0" ]; then
79                 fail "Error creating $PREFIX";
80         fi
81
82         mkdir -p "$TMP";
83         if [ "$?" != "0" ]; then
84                 fail "Error creating $TMP";
85         fi
86
87         if [ ! -w "$PREFIX" ]; then
88                 fail "We don't have write access to $PREFIX";
89         fi
90
91         if [ ! -w "$TMP" ]; then
92                 fail "We don't have write access to $TMP";
93         fi
94
95 }
96
97 # --------------------------------------------------------------------
98 # Loads the config file.  If it can't fine CONFIG_FILE, it attempts to
99 # use DEFAULT_CONFIG_FILE.  If it can't find that, it fails.
100 # --------------------------------------------------------------------
101 function loadConfig {
102         if [ ! -f "$CONFIG_FILE" ]; then
103                 if [ -f "$DEFAULT_CONFIG_FILE" ];
104                         $CONFIG_FILE="$DEFAULT_CONFIG_FILE";
105                 else
106                         fail "config file \"$CONFIG_FILE\" cannot be found";
107         fi
108         source "$CONFIG_FILE";
109 }
110
111
112 function runInstall {
113
114
115         loadConfig;
116         [ ! -z "$NOFORCE" ] && verifyInstallPaths;
117         mkInstallDirs;
118
119         # pass the collected variables to make
120         for target in ${TARGETS[@]:0}; do
121
122                 cat <<-MSG
123
124                 --------------------------------------------------------------------
125                 Building $target
126                 --------------------------------------------------------------------
127
128                 MSG
129
130                 MAKE="make APXS2=$APXS2 PREFIX=$PREFIX TMP=$TMP APACHE2_HEADERS=$APACHE2_HEADERS LIBXML2_HEADERS=$LIBXML2_HEADERS"; 
131
132                 echo "Passing to sub-makes: $VARS"
133                         
134                 case "$target" in
135                         
136                         "jserver" | "router" | "gateway" | "srfsh" ) $MAKE -C "$OPENSRF_DIR" "$target" "$target-install";;
137
138                         *) fail "Unknown target: $target";;
139
140                 esac
141
142         done
143 }
144
145
146 # --------------------------------------------------------------------
147 # Checks command line parameters for special behavior
148 # Supported params are:
149 # clean - cleans all build files
150 # force - forces build without the initial message
151 # --------------------------------------------------------------------
152 function checkParams {
153
154         if [ -z "$1" ]; then return; fi;
155
156         for arg in "$*"; do
157
158                 case "$arg" in
159
160                         "clean") 
161                                 make -C OpenSRF/src clean
162                                 make -C Open-ILS/src clean
163                                 make -C Evergreen/src clean
164                                 exit 0;;
165
166                         "force")
167                                 FORCE="1";;
168
169                         *) fail "Unknown command line argument: $arg";;
170                 esac
171
172         done
173 }
174
175 # if user passes in the word 'clean' as the first shell arg, clean all
176 checkParams "$*";
177
178
179 # Kick it off...
180 runInstall;
181
182
183