source: trunk/dsys/comBUILD@ 22

Last change on this file since 22 was 1, checked in by katerina, 19 years ago

Initial import

File size: 8.5 KB
RevLine 
[1]1#########################################################################
2#
3# Subroutine for the 'build' command
4#
5#########################################################################
6
7commandBUILD() {
8 printINFO "About to run \"$action\""
9
10 if test -d "${basedir}/archpkg/${arch}"
11 then
12 :
13 else
14 if test -d "${basedir}/archpkg"
15 then
16 if test x"$simulate" = x0
17 then
18 mkdir "${basedir}/archpkg/${arch}"
19 else
20 printINFO "mkdir ${basedir}/archpkg/${arch}"
21 fi
22 else
23 if test x"$simulate" = x0
24 then
25 mkdir "${basedir}/archpkg" && mkdir "${basedir}/archpkg/${arch}"
26 else
27 printINFO "mkdir ${basedir}/archpkg && mkdir ${basedir}/archpkg/${arch}"
28 fi
29 fi
30 fi
31
32 if test -f "${basedir}/configs/${arch}.configure"
33 then
34 :
35 else
36 printFATAL "Configure options file ${basedir}/configs/${arch}.configure not found."
37 fi
38
39 local_test=`cat "${basedir}/configs/${arch}.configure" | tr -d '\n' | egrep "^ *'?--with-logserver=FQDN_MISSING"`
40 if test x"${local_test}" = x
41 then
42 :
43 else
44 printFATAL "Your configuration file has a bad --with-logserver option."
45 fi
46
47 if test x"$bd_packed" = x
48 then
49 printINFO "Building version: ${src_version}, host: ${host}, os: ${arch}, format: ${format}"
50 else
51 printINFO "Building version: ${src_version}, host: ${host}, os: ${arch}, format: ${format}, packed: password=${bd_packed}"
52 fi
53
54 tmpdir=`eval echo "/tmp/sh_${src_version}_${arch}_${format}_$$"`
55
56 #---------------------------------------------------------------------
57 # Create temporary build directory on build host.
58 #---------------------------------------------------------------------
59 if test x"$simulate" = x0
60 then
61 ssh -x -l "${bd_user}" "${host}" '(umask 0077; mkdir "'${tmpdir}'")'
62 else
63 printINFO "ssh -x -l ${bd_user} ${host} (umask 0077; mkdir ${tmpdir})"
64 fi
65 if test x"$?" != x0
66 then
67 printFATAL "Could not create temporary build directory on host ${host}."
68 else
69 printLOG "Build directory ${tmpdir} created on host ${host}"
70 fi
71
72 #---------------------------------------------------------------------
73 # Copy source tarball to build host.
74 #---------------------------------------------------------------------
75 if test x"$simulate" = x0
76 then
77 rm -f "${basedir}/tmp/samhain-${src_version}.tar"
78 gunzip -c "${basedir}/source/samhain-${src_version}.tar.gz" > "${basedir}/tmp/samhain-${src_version}.tar"
79 else
80 printINFO "rm -f ${basedir}/tmp/samhain-${src_version}.tar"
81 printINFO "gunzip -c ${basedir}/source/samhain-${src_version}.tar.gz > ${basedir}/tmp/samhain-${src_version}.tar"
82 fi
83 if test x"$?" != x0
84 then
85 printFATAL "Could not gunzip source to ${basedir}/tmp/samhain-${src_version}.tar."
86 fi
87
88 if test x"$simulate" = x0
89 then
90 if test x"$silent" = x0
91 then
92 scp "${basedir}/tmp/samhain-${src_version}.tar" "${bd_user}@${host}:${tmpdir}/"
93 else
94 scp -q "${basedir}/tmp/samhain-${src_version}.tar" "${bd_user}@${host}:${tmpdir}/"
95 fi
96 else
97 if test x"$silent" = x0
98 then
99 printINFO "scp ${basedir}/tmp/samhain-${src_version}.tar ${bd_user}@${host}:${tmpdir}/"
100 else
101 printINFO "scp -q ${basedir}/tmp/samhain-${src_version}.tar ${bd_user}@${host}:${tmpdir}/"
102 fi
103 fi
104 if test x"$?" != x0
105 then
106 printFATAL "Could not copy source to host ${host}."
107 else
108 printINFO "Source copied to host ${host}."
109 fi
110
111 #---------------------------------------------------------------------
112 # Build the package.
113 #---------------------------------------------------------------------
114 if test x"$silent" = x0
115 then
116 config_com='./configure'
117 else
118 config_com='./configure --silent'
119 fi
120
121 if test -f "${basedir}/configs/${arch}.configure"
122 then
123 while read line
124 do
125 if test -z "`echo $line | awk '/^#/'`"
126 then
127 nline=`echo ${line} | tr -d '\n'`
128 config_com="${config_com} ${nline}"
129 fi
130 done <"${basedir}/configs/${arch}.configure"
131 else
132 printFATAL "Configure options file ${basedir}/configs/${arch}.configure not found."
133 fi
134
135 printINFO "configure command is ${config_com}"
136 if test x"$bd_packed" = x
137 then
138 command="make clean"
139 else
140 command="make CLIENTPASSWD=${bd_packed} samhain-packed"
141 fi
142
143
144 command=`eval echo $command`;
145
146 if test x"$simulate" = x0
147 then
148 if test $silent -lt 2
149 then
150 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'")'\'
151 else
152 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'\'
153 fi
154 else
155 if test $silent -lt 2
156 then
157 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)'"
158 else
159 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'"
160 fi
161 fi
162
163 if test x"$?" != x0
164 then
165 printFATAL "Could not build package on host ${host}."
166 else
167 printINFO "Source compiled."
168 fi
169
170 #---------------------------------------------------------------------
171 # Fetch package and remove temporary build directory on build host.
172 #---------------------------------------------------------------------
173 realformat=`echo $format | sed s,solaris-,,`
174
175 if test x"$simulate" = x0
176 then
177 ssh -x -l "${bd_user}" "${host}" '(cat "'${tmpdir}/samhain-${src_version}/samhain-install.sh'")' >"${basedir}/archpkg/${arch}/install-${src_version}.${realformat}"
178 else
179 printINFO "ssh -x -l ${bd_user} ${host} (cat ${tmpdir}/samhain-${src_version}/samhain-install.sh) >${basedir}/archpkg/${arch}/install-${src_version}.${realformat}"
180 fi
181
182 if test x"$?" != x0
183 then
184 printFATAL "Could not fetch samhain-install.sh script from host ${host}."
185 fi
186 chmod +x "${basedir}/archpkg/${arch}/install-${src_version}.${realformat}"
187
188 if test x"$simulate" = x0
189 then
190 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}"
191 else
192 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}"
193 fi
194 if test x"$?" != x0
195 then
196 printFATAL "Could not fetch package samhain-${src_version}.${realformat} from host ${host}."
197 else
198 printLOG "Build directory ${tmpdir} deleted on host ${host}."
199 fi
200 chmod +x "${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}"
201
202 if test x"$simulate" = x0
203 then
204 pkgsize=`ls -l "${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat}" | awk '{print $5}'`
205 if test "x$pkgsize" = "x0"; then
206 printFATAL "Returned package file is empty."
207 fi
208 else
209 printINFO "ls -l ${basedir}/archpkg/${arch}/samhain-${src_version}.${realformat} | awk '{print $5}'"
210 fi
211
212 # >> Save password
213 #
214 if test x"$bd_packed" = x
215 then
216 :
217 else
218 if test x"$simulate" = x0
219 then
220 echo "$bd_packed" >"${basedir}/archpkg/${arch}/PASSWD-${src_version}.${realformat}"
221 fi
222 fi
223
224 # >> Save configure options
225 #
226 if test x"$simulate" = x0
227 then
228 cp "${basedir}/configs/${arch}.configure" "${basedir}/archpkg/${arch}/configure-${src_version}.${realformat}"
229 else
230 printINFO "cp ${basedir}/configs/${arch}.configure ${basedir}/archpkg/${arch}/configure-${src_version}.${realformat}"
231 fi
232
233 printLOG "New package: ${arch}/samhain-${src_version}.${realformat}."
234}
235
Note: See TracBrowser for help on using the repository browser.