source: trunk/dsys/comBUILD@ 434

Last change on this file since 434 was 308, checked in by katerina, 14 years ago

Fix hardcoded temp directory in deployment scripts (ticket #230).

File size: 9.2 KB
Line 
1#########################################################################
2#
3# Subroutine for the 'build' command
4#
5#########################################################################
6#
7# Copyright Rainer Wichmann (2005)
8#
9# License Information:
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24
25commandBUILD() {
26 printINFO "About to run \"$action\""
27
28 if test -d "${basedir}/archpkg/${arch}"
29 then
30 :
31 else
32 if test -d "${basedir}/archpkg"
33 then
34 if test x"$simulate" = x0
35 then
36 mkdir "${basedir}/archpkg/${arch}"
37 else
38 printINFO "mkdir ${basedir}/archpkg/${arch}"
39 fi
40 else
41 if test x"$simulate" = x0
42 then
43 mkdir "${basedir}/archpkg" && mkdir "${basedir}/archpkg/${arch}"
44 else
45 printINFO "mkdir ${basedir}/archpkg && mkdir ${basedir}/archpkg/${arch}"
46 fi
47 fi
48 fi
49
50 if test -f "${basedir}/configs/${arch}.configure"
51 then
52 :
53 else
54 printFATAL "Configure options file ${basedir}/configs/${arch}.configure not found."
55 fi
56
57 local_test=`cat "${basedir}/configs/${arch}.configure" | tr -d '\n' | egrep "^ *'?--with-logserver=FQDN_MISSING"`
58 if test x"${local_test}" = x
59 then
60 :
61 else
62 printFATAL "Your configuration file has a bad --with-logserver option."
63 fi
64
65 if test x"$bd_packed" = x
66 then
67 printINFO "Building version: ${src_version}, host: ${host}, os: ${arch}, format: ${format}"
68 else
69 printINFO "Building version: ${src_version}, host: ${host}, os: ${arch}, format: ${format}, packed: password=${bd_packed}"
70 fi
71
72 tmpdir=`eval echo "${temp_dir}/sh_${src_version}_${arch}_${format}_$$"`
73
74 #---------------------------------------------------------------------
75 # Create temporary build directory on build host.
76 #---------------------------------------------------------------------
77 if test x"$simulate" = x0
78 then
79 ssh -x -l "${bd_user}" "${host}" '(umask 0077; mkdir "'${tmpdir}'")'
80 else
81 printINFO "ssh -x -l ${bd_user} ${host} (umask 0077; mkdir ${tmpdir})"
82 fi
83 if test x"$?" != x0
84 then
85 printFATAL "Could not create temporary build directory on host ${host}."
86 else
87 printLOG "Build directory ${tmpdir} created on host ${host}"
88 fi
89
90 #---------------------------------------------------------------------
91 # Copy source tarball to build host.
92 #---------------------------------------------------------------------
93 if test x"$simulate" = x0
94 then
95 rm -f "${basedir}/tmp/samhain-${src_version}.tar"
96 gunzip -c "${basedir}/source/samhain-${src_version}.tar.gz" > "${basedir}/tmp/samhain-${src_version}.tar"
97 else
98 printINFO "rm -f ${basedir}/tmp/samhain-${src_version}.tar"
99 printINFO "gunzip -c ${basedir}/source/samhain-${src_version}.tar.gz > ${basedir}/tmp/samhain-${src_version}.tar"
100 fi
101 if test x"$?" != x0
102 then
103 printFATAL "Could not gunzip source to ${basedir}/tmp/samhain-${src_version}.tar."
104 fi
105
106 if test x"$simulate" = x0
107 then
108 if test x"$silent" = x0
109 then
110 scp "${basedir}/tmp/samhain-${src_version}.tar" "${bd_user}@${host}:${tmpdir}/"
111 else
112 scp -q "${basedir}/tmp/samhain-${src_version}.tar" "${bd_user}@${host}:${tmpdir}/"
113 fi
114 else
115 if test x"$silent" = x0
116 then
117 printINFO "scp ${basedir}/tmp/samhain-${src_version}.tar ${bd_user}@${host}:${tmpdir}/"
118 else
119 printINFO "scp -q ${basedir}/tmp/samhain-${src_version}.tar ${bd_user}@${host}:${tmpdir}/"
120 fi
121 fi
122 if test x"$?" != x0
123 then
124 printFATAL "Could not copy source to host ${host}."
125 else
126 printINFO "Source copied to host ${host}."
127 fi
128
129 #---------------------------------------------------------------------
130 # Build the package.
131 #---------------------------------------------------------------------
132 if test x"$silent" = x0
133 then
134 config_com='./configure'
135 else
136 config_com='./configure --silent'
137 fi
138
139 if test -f "${basedir}/configs/${arch}.configure"
140 then
141 while read line
142 do
143 if test -z "`echo $line | awk '/^#/'`"
144 then
145 nline=`echo ${line} | tr -d '\n'`
146 config_com="${config_com} ${nline}"
147 fi
148 done <"${basedir}/configs/${arch}.configure"
149 else
150 printFATAL "Configure options file ${basedir}/configs/${arch}.configure not found."
151 fi
152
153 printINFO "configure command is ${config_com}"
154 if test x"$bd_packed" = x
155 then
156 command="make clean"
157 else
158 command="make CLIENTPASSWD=${bd_packed} samhain-packed"
159 fi
160
161
162 command=`eval echo $command`;
163
164 if test x"$simulate" = x0
165 then
166 if test $silent -lt 2
167 then
168 ssh -x -l "${bd_user}" "${host}" /bin/sh -c \''(PATH="'/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${PATH}:${bd_addpath}'" && export PATH && cd "'${tmpdir}'" && tar -xf "'samhain-${src_version}.tar'" && cd "'samhain-${src_version}'" && eval "'${config_com}'" && eval "'${command}'" && make "'${format}-light'")'\'
169 else
170 ssh -x -l "${bd_user}" "${host}" /bin/sh -c \''(PATH="'/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${PATH}:${bd_addpath}'" && export PATH && cd "'${tmpdir}'" && tar -xf "'samhain-${src_version}.tar'" && cd "'samhain-${src_version}'" && eval "'${config_com}'" && eval "'${command}'" && make "'${format}-light'") >/dev/null'\'
171 fi
172 else
173 if test $silent -lt 2
174 then
175 printINFO "ssh -x -l ${bd_user} ${host} /bin/sh -c '(PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:\${PATH}:${bd_addpath} && export PATH && cd ${tmpdir} && tar -xf samhain-${src_version}.tar && cd samhain-${src_version} && eval ${config_com} && eval ${command} && make ${format}-light)'"
176 else
177 printINFO "ssh -x -l ${bd_user} ${host} /bin/sh -c '(PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:\${PATH}:${bd_addpath} && export PATH && cd ${tmpdir} && tar -xf samhain-${src_version}.tar && cd samhain-${src_version} && eval ${config_com} && eval ${command} && make ${format}-light) >/dev/null'"
178 fi
179 fi
180
181 if test x"$?" != x0
182 then
183 printFATAL "Could not build package on host ${host}."
184 else
185 printINFO "Source compiled."
186 fi
187
188 #---------------------------------------------------------------------
189 # Fetch package and remove temporary build directory on build host.
190 #---------------------------------------------------------------------
191 realformat=`echo $format | sed s,solaris-,,`
192
193 if test x"$simulate" = x0
194 then
195 ssh -x -l "${bd_user}" "${host}" '(cat "'${tmpdir}/samhain-${src_version}/samhain-install.sh'")' >"${basedir}/archpkg/${arch}/install-${src_version}.${realformat}"
196 else
197 printINFO "ssh -x -l ${bd_user} ${host} (cat ${tmpdir}/samhain-${src_version}/samhain-install.sh) >${basedir}/archpkg/${arch}/install-${src_version}.${realformat}"
198 fi
199
200 if test x"$?" != x0
201 then
202 printFATAL "Could not fetch samhain-install.sh script from host ${host}."
203 fi
204 chmod +x "${basedir}/archpkg/${arch}/install-${src_version}.${realformat}"
205
206 if test x"$simulate" = x0
207 then
208 ssh -x -l "${bd_user}" "${host}" '(cat "'${tmpdir}/samhain-${src_version}/samhain-${src_version}.${realformat}'" && rm -rf "'${tmpdir}'")' >"${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}"
209 else
210 printINFO "ssh -x -l ${bd_user} ${host} (cat ${tmpdir}/samhain-${src_version}/samhain-${src_version}.${realformat} && rm -rf ${tmpdir}) >${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}"
211 fi
212 if test x"$?" != x0
213 then
214 printFATAL "Could not fetch package samhain-${src_version}.${realformat} from host ${host}."
215 else
216 printLOG "Build directory ${tmpdir} deleted on host ${host}."
217 fi
218 chmod +x "${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}"
219
220 if test x"$simulate" = x0
221 then
222 pkgsize=`ls -l "${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}" | awk '{print $5}'`
223 if test "x$pkgsize" = "x0"; then
224 printFATAL "Returned package file is empty."
225 fi
226 else
227 printINFO "ls -l ${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat} | awk '{print $5}'"
228 fi
229
230 # >> Save password
231 #
232 if test x"$bd_packed" = x
233 then
234 :
235 else
236 if test x"$simulate" = x0
237 then
238 echo "$bd_packed" >"${basedir}/archpkg/${arch}/PASSWD-${src_version}.${realformat}"
239 fi
240 fi
241
242 # >> Save configure options
243 #
244 if test x"$simulate" = x0
245 then
246 cp "${basedir}/configs/${arch}.configure" "${basedir}/archpkg/${arch}/configure-${src_version}.${realformat}"
247 else
248 printINFO "cp ${basedir}/configs/${arch}.configure ${basedir}/archpkg/${arch}/configure-${src_version}.${realformat}"
249 fi
250
251 printLOG "New package: ${arch}/samhain-${src_version}.${realformat}."
252}
253
Note: See TracBrowser for help on using the repository browser.