author | xlucas |
Tue, 28 Apr 2009 09:49:26 +0000 | |
changeset 41 | 31570364d0f1 |
parent 40 | b92f7755aa91 |
child 44 | 9d78700fb711 |
permissions | -rwxr-xr-x |
1 | 1 |
#!/bin/bash |
2 |
# |
|
10 | 3 |
# Script for setting up the Desktop Build Environment on Solaris |
1 | 4 |
# |
5 |
# CDDL HEADER START |
|
6 |
# |
|
7 |
# The contents of this file are subject to the terms of the |
|
8 |
# Common Development and Distribution License, Version 1.0 only |
|
9 |
# (the "License"). You may not use this file except in compliance |
|
10 |
# with the License. |
|
11 |
# |
|
12 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
13 |
# or http://www.opensolaris.org/os/licensing. |
|
14 |
# See the License for the specific language governing permissions |
|
15 |
# and limitations under the License. |
|
16 |
# |
|
17 |
# When distributing Covered Code, include this CDDL HEADER in each |
|
18 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
19 |
# If applicable, add the following below this CDDL HEADER, with the |
|
20 |
# fields enclosed by brackets "[]" replaced with your own identifying |
|
21 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
|
22 |
# |
|
23 |
# CDDL HEADER END |
|
24 |
# |
|
25 |
# |
|
10 | 26 |
# Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
1 | 27 |
# Use is subject to license terms. |
28 |
# |
|
29 |
||
30 |
IFS=' |
|
31 |
' |
|
10 | 32 |
|
33 |
# this is listed separately because we are using the spec file |
|
34 |
# included in the pkgbuild tarball |
|
41
31570364d0f1
2009-03-16 Lukas (Luc) Oboril <[email protected]> * bump pkgbuild to latest version 1.3.98.4 * add Sun Studio Express 03/09 as known compiler
xlucas
parents:
40
diff
changeset
|
35 |
PKGBUILD_VERSION=1.3.98.4 |
1 | 36 |
|
10 | 37 |
# Modules needed for building GNOME: |
38 |
GNOME_MODULES="ant m4 autoconf automake libtool bison coreutils diff flex gettext make subversion" |
|
39 |
# Modules needed for building KDE: |
|
38 | 40 |
KDE_MODULES="ant m4 autoconf automake libtool bison coreutils diff flex gettext subversion gnuawk gnused cmake make yasm" |
10 | 41 |
# Not needed for either GNOME or KDE, but useful to have: |
42 |
OPT_MODULES="rsync cvs" |
|
43 |
# SFE has the same deps as GNOME |
|
44 |
SFE_MODULES=$GNOME_MODULES |
|
45 |
install_kde=no |
|
46 |
install_gnome=no |
|
47 |
install_sfe=no |
|
48 |
install_opt=no |
|
23 | 49 |
interactive_install=yes |
27 | 50 |
quiet_install=no |
23 | 51 |
default_compiler= |
52 |
orig_CC="${CC}" |
|
1 | 53 |
|
54 |
# Obsolete packages to be pkgrm'd. Mostly renamed packages. |
|
55 |
OLD_PKGS="JDSautomake JDSautoconf JDSlibtool JDSm4 JDSgettext JDSfileutils |
|
23 | 56 |
JDSmake JDSpatch CBEpatch JDSflex JDScvs SUNWpkgbuild CBEfileutils" |
1 | 57 |
|
25 | 58 |
# default log file. Changed to /tmp/desktop-cbe-install* if the user |
1 | 59 |
# installing is not root |
29 | 60 |
LOGFILE=/tmp/desktop-cbe-install-`date +%Y-%m-%d-%H:%M`.log |
1 | 61 |
|
10 | 62 |
# packages required for building things. cbe-install will check if they |
1 | 63 |
# are installed and install them if not. |
10 | 64 |
|
65 |
# Solaris SVr4 packages: |
|
66 |
CBE_SVR4_DEPENDENCIES="SUNWarc SUNWgpch SUNWhea SUNWsfwhea SUNWwgetr |
|
67 |
SUNWwgetu SUNWgtar SUNWxcu4 SUNWsprot SUNWxwinc |
|
68 |
SUNWxorg-headers SUNWbtool SUNWlibmr SUNWlibm" |
|
69 |
||
70 |
# OpenSolaris pkg(5) packages: |
|
71 |
CBE_PKG_DEPENDENCIES="SUNWgpch SUNWhea SUNWsfwhea SUNWwget SUNWgtar |
|
72 |
SUNWxcu4 SUNWsprot SUNWxwinc SUNWxorg-headers |
|
73 |
SUNWbtool SUNWlibm" |
|
74 |
||
75 |
# alternatives (SUNW version of tools preferred to CBE version) |
|
1 | 76 |
|
10 | 77 |
# by detault install alternatives when available |
78 |
install_alt=yes |
|
79 |
# by default, install alternatives without asking |
|
80 |
ask_alt=no |
|
81 |
||
82 |
ALT_make=SUNWgmake |
|
83 |
ALT_m4=SUNWgm4 |
|
84 |
ALT_autoconf=SUNWaconf |
|
85 |
ALT_automake="SUNWgnu-automake-110 SUNWgnu-automake-19" |
|
86 |
ALT_libtool=SUNWlibtool |
|
87 |
ALT_bison=SUNWbison |
|
88 |
ALT_coreutils=SUNWgnu-coreutils |
|
89 |
ALT_diff=SUNWgnu-diffutils |
|
90 |
ALT_flex=SUNWflexlex |
|
38 | 91 |
ALT_gettext=SUNWgnu-gettext |
10 | 92 |
ALT_subversion=SUNWsvn |
38 | 93 |
ALT_gnused=SUNWgsed |
94 |
ALT_gnuawk=SUNWgawk |
|
95 |
# Do not use SUNWcmake, because it does not contain fix for Sun Studio optimalization. --luc |
|
96 |
#ALT_cmake=SUNWcmake |
|
39 | 97 |
# In SXCE build107 SUNWant = ant 1.7.1 |
98 |
#ALT_ant=SUNWant |
|
1 | 99 |
|
100 |
# default cbe install location |
|
23 | 101 |
cbe_prefix=${CBE_PREFIX:-/opt/dtbld} |
1 | 102 |
# this should be set to a reasonable value in install_pkgbuild() |
103 |
pkgbuild_topdir=/fix/me |
|
104 |
||
105 |
# default value for the "who is the build user" question |
|
106 |
logname=${LOGNAME:-`logname`} |
|
107 |
if [ -x /usr/xpg4/bin/id ]; then |
|
108 |
uid=`/usr/xpg4/bin/id -u` |
|
109 |
username=`/usr/xpg4/bin/id -un` |
|
110 |
else |
|
111 |
uid=`/bin/id | cut -f2 -d= | cut -f1 -d'('` |
|
112 |
username=`/bin/id |cut -f2 -d'(' | cut -f1 -d')'` |
|
113 |
fi |
|
114 |
export HOME="$(eval cd ~$username; pwd)" |
|
115 |
||
116 |
always_uninstall_existing= |
|
117 |
always_skip_existing= |
|
118 |
||
119 |
# write a message to the log file |
|
120 |
# not visible to the user |
|
121 |
log () { |
|
122 |
for msg in "${@}"; do |
|
123 |
echo "`date`: $msg" >> $LOGFILE |
|
124 |
done |
|
125 |
} |
|
126 |
||
127 |
# print a message to the user and also write it to the log file |
|
128 |
msg () { |
|
129 |
for msg in "${@}"; do |
|
27 | 130 |
if [ $quiet_install = no ]; then |
131 |
echo $msg |
|
132 |
fi |
|
1 | 133 |
echo "`date`: $msg" >> $LOGFILE |
134 |
done |
|
135 |
} |
|
136 |
||
10 | 137 |
# print a message to the user and also write it to the log file |
138 |
msg_err () { |
|
139 |
for msg in "${@}"; do |
|
27 | 140 |
if [ $quiet_install = no ]; then |
141 |
echo ERROR: $msg 1>&2 |
|
142 |
fi |
|
10 | 143 |
echo "`date`: ERROR: $msg" >> $LOGFILE |
144 |
done |
|
145 |
} |
|
146 |
||
147 |
# clean up if installation is aborted |
|
148 |
tempdirs= |
|
149 |
remove_tempdirs () { |
|
150 |
IFS=: |
|
151 |
for tdir in $tempdirs; do |
|
152 |
case "$tdir" in |
|
153 |
/tmp/* ) |
|
154 |
cd /tmp |
|
155 |
rm -rf "$tdir" |
|
156 |
;; |
|
157 |
esac |
|
158 |
done |
|
159 |
} |
|
160 |
trap remove_tempdirs QUIT EXIT |
|
161 |
||
162 |
||
1 | 163 |
# alternate root directory |
164 |
rootdir=/ |
|
165 |
||
166 |
process_cl () { |
|
167 |
while [ $# != 0 ]; do |
|
168 |
case "$1" in |
|
169 |
-R ) |
|
170 |
shift |
|
171 |
if [ $# == 0 ]; then |
|
27 | 172 |
echo "Option -R requires an argument." 1>&2 |
1 | 173 |
exit 1 |
174 |
fi |
|
175 |
rootdir=$1 |
|
176 |
case "$rootdir" in |
|
177 |
/* ) |
|
178 |
;; |
|
179 |
* ) |
|
27 | 180 |
echo "The argument to -R must be an absolute path name" 1>&2 |
1 | 181 |
exit 1 |
182 |
esac |
|
183 |
;; |
|
184 |
-h|--help) |
|
185 |
echo "Usage: $0 [options]" |
|
186 |
echo "options:" |
|
187 |
echo " -h, --help print this usage info" |
|
188 |
echo " -R rootdir install CBE packages in alternate root directory rootdir" |
|
10 | 189 |
echo " -k, --kde install the packages needed for building KDE" |
190 |
echo " -g, --gnome install the packages needed for building GNOME" |
|
191 |
echo " -s, --sfe install the packages needed for building GNOME" |
|
192 |
echo " -o, --optional install the optional packages" |
|
23 | 193 |
echo " -n non-interactive installation -- assumes the default" |
27 | 194 |
echo " -q, --quiet quiet install, messages are printed in the log only" |
23 | 195 |
echo " answers to all questions" |
196 |
echo " -p dir, --prefix dir" |
|
197 |
echo " install the Desktop CBE to dir" |
|
10 | 198 |
echo " --ask-alt ask for confirmation before installing alternative" |
199 |
echo " tools ([Open]Solaris tools instead of CBE tools)" |
|
200 |
echo " --no-alt do not install alternatives, only CBE tools" |
|
1 | 201 |
exit 0 |
202 |
;; |
|
10 | 203 |
--ask-alt) |
204 |
ask_alt=yes |
|
205 |
;; |
|
23 | 206 |
-c|--compiler) |
207 |
shift |
|
208 |
if [ $# == 0 ]; then |
|
27 | 209 |
echo "Option -R requires an argument." 1>&2 |
23 | 210 |
exit 1 |
211 |
fi |
|
212 |
default_compiler=$1 |
|
213 |
test -x $default_compiler || { |
|
27 | 214 |
echo "Compiler $default_compiler not found" 1>&2 |
23 | 215 |
exit 1 |
216 |
} |
|
217 |
;; |
|
27 | 218 |
-q|--quiet) |
219 |
quiet_install=yes |
|
220 |
;; |
|
10 | 221 |
--no-alt) |
222 |
install_alt=no |
|
223 |
;; |
|
224 |
-k|--kde) |
|
225 |
install_kde=yes |
|
226 |
;; |
|
227 |
-g|--gnome) |
|
228 |
install_gnome=yes |
|
229 |
;; |
|
230 |
-s|--sfe) |
|
231 |
install_gnome=yes |
|
232 |
;; |
|
233 |
-o|--optional) |
|
234 |
install_opt=yes |
|
235 |
;; |
|
23 | 236 |
-n) |
237 |
interactive_install=no |
|
238 |
;; |
|
239 |
-p|--prefix) |
|
240 |
shift |
|
241 |
test $# = 0 && { |
|
27 | 242 |
echo "ERROR: argument required after -p or --prefix option" 1>&2 |
23 | 243 |
} |
244 |
cbe_prefix="$1" |
|
245 |
test ${cbe_prefix:0:1} = / || { |
|
27 | 246 |
echo "ERROR: the prefix must be an absolute path" 1>&2 |
23 | 247 |
} |
248 |
;; |
|
1 | 249 |
*) |
27 | 250 |
echo "Unknown option: $1" 1>&2 |
1 | 251 |
exit 1 |
252 |
;; |
|
253 |
esac |
|
254 |
shift |
|
255 |
done |
|
27 | 256 |
|
257 |
if [ $interactive_install = yes ]; then |
|
258 |
quiet_install=no |
|
259 |
fi |
|
1 | 260 |
} |
261 |
||
11 | 262 |
# check the type and name of the compiler |
263 |
# set CXX to match CC |
|
264 |
identify_compiler () { |
|
265 |
id_CC=$1 |
|
266 |
id_CC_name=unknown |
|
267 |
id_CC_release= |
|
268 |
id_CC_version= |
|
269 |
id_CC_rev= |
|
270 |
id_CC_label=unknown |
|
271 |
||
272 |
id_CC_dir=$(dirname $id_CC) |
|
273 |
||
274 |
# check if it's gcc |
|
275 |
cc_version=$($id_CC --version 2>&1) |
|
276 |
echo "$cc_version" | grep 'gcc (GCC)' > /dev/null && { |
|
277 |
id_CC_name='GNU gcc' |
|
278 |
id_CC_version=$(echo "$cc_version" | grep 'gcc (GCC)' | cut -f3 -d' ') |
|
279 |
id_CC_release=$(echo $id_CC_version | cut -f1 -d.) |
|
280 |
id_CC_label=gcc${id_CC_release} |
|
281 |
CXX="$id_CC_dir/g++" |
|
282 |
if [ ! -x "$CXX" ]; then |
|
283 |
msg "WARNING: $CXX not found" |
|
284 |
fi |
|
285 |
log "$id_CC is $id_CC_name release $id_CC_release" |
|
286 |
return |
|
287 |
} |
|
288 |
cc_version=$($id_CC -V 2>&1) |
|
289 |
echo "$cc_version" | grep '^cc: Sun ' > /dev/null && { |
|
290 |
id_CC_name='Sun Studio' |
|
291 |
id_CC_version=$(echo "$cc_version" | grep '^cc: Sun ' | sed -e 's/^cc: Sun.* C \([0-9][0-9.]*\) .*/\1/') |
|
292 |
id_CC_rev=$(echo "$cc_version" | grep '^cc: Sun ' | sed -e 's/^cc: Sun.* C [0-9][0-9.]* \(.\)*/\1/') |
|
293 |
id_CC_rev=$(echo "$id_CC_rev" | grep '^cc: Sun ' | sed -e 's/SunOS_[^ ]* //') |
|
294 |
if [ "x$id_CC_version" = x5.7 ]; then |
|
295 |
id_CC_label='ss10' |
|
296 |
id_CC_release='Vulcan' |
|
297 |
id_CC_name='Sun Studio 10' |
|
298 |
elif [ "x$id_CC_version" = x5.8 ]; then |
|
299 |
id_CC_label='ss11' |
|
300 |
id_CC_release='Venus' |
|
301 |
id_CC_name='Sun Studio 11' |
|
302 |
elif [ "x$id_CC_version" = x5.9 ]; then |
|
303 |
id_CC_label='ss12' |
|
304 |
id_CC_release='Mars' |
|
305 |
id_CC_name='Sun Studio 12' |
|
306 |
elif [ "x$id_CC_version" = x5.10 ]; then |
|
307 |
id_CC_label='sexp' |
|
308 |
id_CC_release='Ceres' |
|
309 |
id_CC_name='Sun Studio Express' |
|
310 |
else |
|
311 |
id_CC_label="Studio_$id_CC_version" |
|
312 |
id_CC_release="$id_CC_version" |
|
313 |
fi |
|
314 |
CXX="$id_CC_dir/CC" |
|
315 |
if [ ! -x "$CXX" ]; then |
|
316 |
msg "WARNING: $CXX not found" |
|
317 |
fi |
|
318 |
log "$id_CC is $id_CC_name release $id_CC_release" |
|
319 |
return |
|
320 |
} |
|
321 |
msg "WARNING: could not identify $id_CC = $cc_version" |
|
322 |
} |
|
323 |
||
10 | 324 |
# create a build environent config file for the given build compiler |
325 |
make_env () { |
|
11 | 326 |
env_compiler=$1 |
327 |
envdir=$tempdir/env |
|
328 |
logrun mkdir -p $envdir |
|
329 |
identify_compiler $env_compiler |
|
330 |
if [ "$id_CC_name" = unknown ]; then |
|
25 | 331 |
log "Compiler $1 is unknown, ignoring" |
23 | 332 |
return 1 |
11 | 333 |
fi |
334 |
# identify_compiler sets CXX to match CC |
|
335 |
# also id_CC_name, id_CC_label, id_CC_version, id_CC_release, id_CC_rev |
|
336 |
env_file="$envdir/$id_CC_label" |
|
12 | 337 |
env_nr=1 |
338 |
while test -f $env_file; do |
|
339 |
env_file="$envdir/${id_CC_label}.${env_nr}" |
|
340 |
env_nr=$(($env_nr + 1)) |
|
341 |
done |
|
25 | 342 |
log "creating env file for compiler $1 ($id_CC_name)" |
11 | 343 |
echo '# Build environment config file for the Desktop CBE' > "$env_file" |
344 |
echo "CC_name='$id_CC_name'" >> "$env_file" |
|
345 |
echo "CC_version='$id_CC_version'" >> "$env_file" |
|
346 |
echo "CC_release='$id_CC_release'" >> "$env_file" |
|
347 |
echo "CC_rev='$id_CC_rev'" >> "$env_file" |
|
348 |
echo "cc_dir='$id_CC_dir'" >> "$env_file" |
|
349 |
echo "CC='$env_compiler'" >> "$env_file" |
|
350 |
echo "CXX='$CXX'" >> "$env_file" |
|
23 | 351 |
return 0 |
10 | 352 |
} |
353 |
||
354 |
# look for compilers in known locations |
|
355 |
find_compilers () { |
|
11 | 356 |
compiler_found=no |
10 | 357 |
# FIXME: if CC = gcc, set CFLAGS to -std=c99 |
358 |
msg "Locating compilers..." |
|
11 | 359 |
arch=$(uname -p) |
41
31570364d0f1
2009-03-16 Lukas (Luc) Oboril <[email protected]> * bump pkgbuild to latest version 1.3.98.4 * add Sun Studio Express 03/09 as known compiler
xlucas
parents:
40
diff
changeset
|
360 |
known_compilers="/sgnome/onnv-tools/$arch/SS12/bin/cc /sgnome/onnv-tools/$arch/SS11/bin/cc /ws/onnv-tools/SUNWspro/SS12/bin/cc /ws/onnv-tools/SUNWspro/SS11/bin/cc /opt/SUNWspro/bin/cc /opt/SS12/SUNWspro/bin/cc /opt/Studio12/bin/cc /opt/SSX0903/bin/cc /usr/bin/cc /opt/SunStudioExpress/bin/cc /usr/bin/gcc /usr/sfw/bin/gcc /usr/gnu/bin/gcc" |
23 | 361 |
if [ "x$orig_CC" != x ]; then |
362 |
if [ -x $orig_CC ]; then |
|
363 |
echo " $known_compilers " | grep " $orig_CC " > /dev/null || \ |
|
364 |
known_compilers="$orig_CC $known_compilers" |
|
10 | 365 |
fi |
366 |
fi |
|
367 |
for compiler in $known_compilers; do |
|
11 | 368 |
if [ -x $compiler -a ! -d $compiler ]; then |
10 | 369 |
make_env $compiler |
11 | 370 |
compiler_found=yes |
371 |
fi |
|
372 |
done |
|
373 |
} |
|
374 |
||
12 | 375 |
# download pkgbuild from sourceforge using wget |
376 |
download_pkgbuild () { |
|
377 |
mkdir -p $tardir |
|
13 | 378 |
/usr/sfw/bin/wget -nd -nH --tries=1 -T 60 -O $tardir/pkgbuild-${PKGBUILD_VERSION}.tar.bz2 http://internode.dl.sourceforge.net/sourceforge/pkgbuild/pkgbuild-${PKGBUILD_VERSION}.tar.bz2 || { |
12 | 379 |
msg "Failed to download pkgbuild, cannot continue." |
380 |
exit 1 |
|
381 |
} |
|
382 |
} |
|
383 |
||
11 | 384 |
ask_compiler () { |
385 |
ask 'Enter the path to the C compiler' ans_compiler |
|
386 |
if [ ! -x $ans_compiler ]; then |
|
387 |
msg "Invalid answer: $ans_compiler is not an executable" |
|
388 |
return 1 |
|
389 |
fi |
|
390 |
if [ -d $ans_compiler ]; then |
|
391 |
msg "Invalid answer: $ans_compiler is a directory" |
|
392 |
return 1 |
|
393 |
fi |
|
394 |
identify_compiler "$ans_compiler" |
|
395 |
if [ x$ans_compiler == xunknown ]; then |
|
396 |
msg "Unknown compiler: $ans_compiler" |
|
397 |
return 1 |
|
398 |
fi |
|
399 |
compiler_found=yes |
|
400 |
make_env "$ans_compiler" |
|
401 |
return 0 |
|
402 |
} |
|
403 |
||
404 |
# ask the user for additional compiler locations |
|
405 |
ask_compilers () { |
|
406 |
first=$1 |
|
407 |
ans_more_compilers=yes |
|
408 |
while [ $ans_more_compilers = yes ]; do |
|
409 |
if [ "x$first" = xfirst ]; then |
|
410 |
msg "You need a C compiler in order to use the Desktop CBE" |
|
411 |
ask_compiler && first=no |
|
412 |
else |
|
413 |
ask_yes_no 'Would you like to configure more compilers for use with the Desktop CBE?' ans_more_compilers no |
|
414 |
if [ $ans_more_compilers = yes ]; then |
|
415 |
ask_compiler |
|
416 |
fi |
|
10 | 417 |
fi |
1 | 418 |
done |
419 |
} |
|
420 |
||
23 | 421 |
# install gcc and/or Sun Studio |
422 |
install_compilers_pkg () { |
|
423 |
# ask if gcc should be installed |
|
424 |
ask_yes_no "Would you like to install gcc (GNU C compiler)?" \ |
|
425 |
ans_install_gcc yes |
|
426 |
test "$ans_install_gcc" = yes && pkg_try_install SUNWgcc |
|
427 |
# ask if sun studio express should be installed |
|
428 |
ask_yes_no "Would you like to install Sun Studio Express (cc 5.10)?" \ |
|
429 |
ans_install_ssexp yes |
|
430 |
test "$ans_install_ssexp" = yes && pkg_try_install sunstudioexpress |
|
431 |
} |
|
432 |
||
433 |
check_compilers_kde () { |
|
434 |
: |
|
435 |
} |
|
436 |
||
11 | 437 |
# print the details of a compiler specified by its env config file |
438 |
display_compiler () { |
|
439 |
. $1 |
|
27 | 440 |
msg "$2 - $CC_name $CC_version ($CC_release) in $cc_dir" |
10 | 441 |
} |
442 |
||
443 |
# select the default compiler configuration |
|
444 |
select_default_compiler () { |
|
23 | 445 |
if [ "x$default_compiler" != x ]; then |
446 |
grep "^CC='$default_compiler'\$" $envdir/* > /dev/null || { |
|
447 |
make_env $default_compiler && compiler_found=yes |
|
448 |
} |
|
449 |
fi |
|
450 |
found_default_compiler= |
|
451 |
found_CC= |
|
11 | 452 |
if [ $compiler_found = yes ]; then |
27 | 453 |
msg "" |
454 |
msg "The following compilers were found on your system:" |
|
11 | 455 |
i=1 |
456 |
for env in $envdir/*; do |
|
457 |
display_compiler $env $i |
|
23 | 458 |
test "x$default_compiler" != x && \ |
459 |
grep "^CC='$default_compiler'\$" $env > /dev/null && \ |
|
460 |
found_default_compiler=$i |
|
461 |
test "x$CC" != x && \ |
|
462 |
grep "^CC='$orig_CC'\$" $env > /dev/null && \ |
|
463 |
found_CC=$i |
|
11 | 464 |
eval env_$i="$env" |
465 |
i=$((i + 1)) |
|
466 |
done |
|
12 | 467 |
i=$(($i - 1)) |
23 | 468 |
if [ "x$1" != xdont_ask -a "x$found_default_compiler" = x ]; then |
11 | 469 |
ask_compilers |
12 | 470 |
# don't ask again if the user whats to configure more compilers |
471 |
select_default_compiler dont_ask |
|
472 |
return |
|
11 | 473 |
fi |
474 |
else |
|
27 | 475 |
msg "No compilers were found on your system." |
11 | 476 |
if [ $PKG_SYSTEM = pkg ]; then |
477 |
ask_yes_no "Would you like the to install compilers now?" \ |
|
478 |
ans_install_compiler yes |
|
479 |
if [ x$ans_install_compiler = yes ]; then |
|
480 |
install_compilers_pkg && { |
|
481 |
find_compilers |
|
12 | 482 |
# don't ask again if the user whats |
483 |
# to configure more compilers |
|
11 | 484 |
select_default_compiler dont_ask |
485 |
return |
|
486 |
} |
|
487 |
fi |
|
488 |
fi |
|
489 |
ask_compilers first |
|
490 |
select_default_compiler dont_ask |
|
491 |
return |
|
492 |
fi |
|
493 |
||
12 | 494 |
if [ $i = 1 ]; then |
495 |
# there's only one compiler no need to ask which one's the default |
|
496 |
ans_default_compiler=1 |
|
23 | 497 |
elif [ "x$found_default_compiler" != x ]; then |
498 |
# found the compiler specified with the --compiler or -c option |
|
499 |
ans_default_compiler=$found_default_compiler |
|
27 | 500 |
msg "Selected #${found_default_compiler} $default_compiler" |
12 | 501 |
else |
23 | 502 |
if [ "x$found_CC" != x ]; then |
503 |
# found the compiler in the CC env var |
|
504 |
default_default_compiler=$found_CC |
|
505 |
else |
|
506 |
default_default_compiler=$i |
|
507 |
fi |
|
12 | 508 |
ans_default_compiler=9999 |
509 |
while [ $ans_default_compiler -gt $i ]; do |
|
23 | 510 |
ask 'Please select the default compiler' ans_default_compiler \ |
511 |
$default_default_compiler |
|
12 | 512 |
is_number "$ans_default_compiler" || { |
27 | 513 |
msg "Please enter a number from 1 to $i" |
12 | 514 |
ans_default_compiler=9999 |
515 |
} |
|
516 |
done |
|
517 |
fi |
|
11 | 518 |
eval default_env="\$env_$ans_default_compiler" |
519 |
if [ ! -f $default_env ]; then |
|
520 |
msg "Internal error in cbe-install, please report to desktop-discuss" |
|
521 |
fi |
|
522 |
. $default_env |
|
523 |
export CC |
|
524 |
export CXX |
|
25 | 525 |
log "Default environment: `basename $default_env` (CC=$CC, CXX=$CXX)" |
10 | 526 |
} |
527 |
||
528 |
# verify that the running system is suitable for the Desktop CBE |
|
529 |
# and set up some variables |
|
1 | 530 |
init () { |
531 |
myos=`uname -s` |
|
532 |
if [ "x$myos" != xSunOS ]; then |
|
27 | 533 |
echo "Run this script on a Solaris system." 1>&2 |
1 | 534 |
exit 1 |
535 |
fi |
|
536 |
||
537 |
umask 0022 |
|
12 | 538 |
the_cpu=`uname -p` |
539 |
if [ "x$the_cpu" != xsparc ]; then |
|
540 |
the_cpu=x86 |
|
541 |
fi |
|
1 | 542 |
|
543 |
myos_rel=`uname -r` |
|
544 |
if [ "x$myos_rel" = "x5.10" -o "x$myos_rel" = "x5.10.1" -o "x$myos_rel" = "x5.11" ]; then |
|
10 | 545 |
: |
1 | 546 |
else |
27 | 547 |
echo "Solaris 10, Solaris Nevada or OpenSolaris required." 1>&2 |
1 | 548 |
exit 1 |
549 |
fi |
|
550 |
||
10 | 551 |
if [ "x$myos_rel" = "x5.10" ]; then |
552 |
solaris_pkg_dir=/cdrom/cdrom0/Solaris_10/Product |
|
553 |
elif [ "x$myos_rel" = "x5.11" ]; then |
|
554 |
solaris_pkg_dir=/cdrom/cdrom0/Solaris_11/Product |
|
555 |
fi |
|
556 |
||
1 | 557 |
mydir=$(cd $(dirname $0); pwd); |
10 | 558 |
tardir=${mydir}/tarballs |
1 | 559 |
|
560 |
CBE_VERSION=`cat $mydir/CBE_VERSION` |
|
27 | 561 |
if [ $quiet_install = no ]; then |
562 |
echo "Desktop Common Build Environment (CBE) Installer version $CBE_VERSION" |
|
563 |
fi |
|
1 | 564 |
|
565 |
my_id=`/usr/xpg4/bin/id -u` |
|
29 | 566 |
prof_sw_inst=`/bin/profiles | nl -s: | grep 'Software Installation' | cut -f1 -d:` |
567 |
prof_pri_adm=`/bin/profiles | nl -s: | grep 'Primary Administrator' | cut -f1 -d:` |
|
568 |
prof_basic_usr=`/bin/profiles | nl -s: | grep 'Basic Solaris User' | cut -f1 -d:` |
|
569 |
if [ "x$prof_sw_inst" = x -a "x$prof_pri_adm" = x -o "x$my_id" = x0 ]; then |
|
570 |
echo 'Run this script as a user with the "Software Installation"' 1>&2 |
|
571 |
echo 'or "Primary Administrator" profile.' 1>&2 |
|
572 |
test -x /usr/bin/users-admin && { |
|
573 |
echo 1>&2 |
|
574 |
echo 'You can also use the users-admin program (System -> Administration ->' 1>&2 |
|
575 |
echo 'Users and Groups in the GNOME menu) to assign profiles.' 1>&2 |
|
576 |
echo 1>&2 |
|
577 |
} |
|
578 |
echo 'See the user_attr(4) and profiles(1) manual pages for further details' 1>&2 |
|
579 |
exit 1 |
|
580 |
else |
|
581 |
if [ "x$prof_basic_usr" != x ]; then |
|
582 |
if [ "x$prof_sw_inst" != x ]; then |
|
583 |
if [ $prof_sw_inst -gt $prof_basic_usr ]; then |
|
584 |
echo 'The "Software Installation" profile in /etc/user_attr should appear' 1>&2 |
|
585 |
echo 'before Basic Solaris User.' 1>&2 |
|
586 |
exit 1 |
|
10 | 587 |
fi |
29 | 588 |
fi |
589 |
if [ "x$prof_pri_adm" != x ]; then |
|
590 |
if [ $prof_pri_adm -gt $prof_basic_usr ]; then |
|
591 |
echo 'The "Primary Administrator" profile in /etc/user_attr should appear' 1>&2 |
|
592 |
echo 'before Basic Solaris User.' 1>&2 |
|
593 |
exit 1 |
|
10 | 594 |
fi |
595 |
fi |
|
1 | 596 |
fi |
597 |
fi |
|
598 |
||
10 | 599 |
# svr4 or pkg(5) |
600 |
check_pkg_system |
|
601 |
msg "Using \"$PKG_SYSTEM\" packaging system" |
|
602 |
||
1 | 603 |
msg "Checking for required packages..." |
10 | 604 |
if [ $PKG_SYSTEM = pkg ]; then |
605 |
check_cbe_dependencies_pkg $CBE_PKG_DEPENDENCIES |
|
606 |
else |
|
607 |
check_cbe_dependencies_svr4 $CBE_SVR4_DEPENDENCIES |
|
608 |
fi |
|
609 |
if [ $DEPS_OK = yes ]; then |
|
610 |
msg "All required packages are installed." |
|
611 |
else |
|
612 |
if [ $DEPS_INSTALLED = yes ]; then |
|
613 |
msg "Successfully installed all required packages" |
|
614 |
else |
|
615 |
msg "WARNING: some required packages are missing. Expect build issues..." |
|
616 |
fi |
|
617 |
fi |
|
1 | 618 |
|
13 | 619 |
need_tarballs=no |
16 | 620 |
if [ ! -f $mydir/pkgs-${the_cpu}/CBElibtool/pkginfo ]; then |
621 |
# no packages found, will need to build from source |
|
622 |
test ! -f $tardir/pkgbuild-${PKGBUILD_VERSION}.tar.bz2 && { |
|
623 |
download_pkgbuild |
|
624 |
need_tarballs=yes |
|
625 |
} |
|
626 |
fi |
|
13 | 627 |
|
1 | 628 |
if [ -f /usr/sfw/include/glib.h ]; then |
27 | 629 |
echo "WARNING: /usr/sfw/include/glib.h is in conflict with the Desktop headers." 1>&2 |
630 |
echo "WARNING: Please remove this file or SUNWGlib to avoid build problems." 1>&2 |
|
631 |
echo 1>&2 |
|
23 | 632 |
if [ $interactive_install = yes ]; then |
633 |
echo "Press Enter to continue" |
|
634 |
read dummy |
|
635 |
else |
|
27 | 636 |
echo "Aborting installation" 1>&2 |
23 | 637 |
exit 1 |
638 |
fi |
|
1 | 639 |
fi |
640 |
||
641 |
log "Running on `uname -a`" |
|
642 |
log "My directory is $mydir" |
|
643 |
||
10 | 644 |
ENV_SET=`env | grep '^[a-zA-Z0-9_]*=' | cut -f1 -d=` |
1 | 645 |
for var in $ENV_SET; do |
646 |
case $var in |
|
647 |
PS1|PS2|HZ|TERM|SHELL|OLDPWD|PATH|MAIL|PWD|TZ|SHLVL|HOME|LOGNAME|PRINTER|HOSTNAME|_|CC|CXX|EDITOR|SSH_*|DISPLAY|LESS*|LS_COLORS|LS_OPTIONS|TERMINFO|PAGER|MANPATH|VISUAL) |
|
648 |
;; |
|
649 |
*) |
|
650 |
val=`eval echo "\\\$$var"` |
|
651 |
log "Unsetting $var (=\"$val\")" |
|
652 |
unset $var |
|
653 |
;; |
|
654 |
esac |
|
655 |
done |
|
656 |
||
10 | 657 |
tempdir=`mktemp -d /tmp/cbe-install-XXXX` |
1 | 658 |
tempdirs="$tempdirs:$tempdir" |
10 | 659 |
if [ ! -d $tempdir ]; then |
660 |
msg_err "Failed to create temporary directory in /tmp" |
|
661 |
exit 1 |
|
662 |
fi |
|
1 | 663 |
|
12 | 664 |
# if binary packages are found in the pkgs-*/ subdir then this is a |
10 | 665 |
# binary install |
12 | 666 |
if [ -f $mydir/pkgs-${the_cpu}/CBElibtool/pkginfo ]; then |
1 | 667 |
binary_install=yes |
12 | 668 |
pkg_arch=`grep '^ARCH=' $mydir/pkgs-${the_cpu}/CBElibtool/pkginfo | cut -f2 -d=` |
1 | 669 |
arch=`uname -p` |
670 |
if [ "x$arch" != "x$pkg_arch" ]; then |
|
27 | 671 |
echo "ERROR: wrong architecture" 1>&2 |
672 |
echo "ERROR: these Desktop CBE packages must be installed on a $pkg_arch system" 1>&2 |
|
1 | 673 |
exit 1 |
674 |
fi |
|
10 | 675 |
cbe_prefix=/opt/dtbld |
1 | 676 |
else |
677 |
binary_install=no |
|
678 |
fi |
|
679 |
} |
|
680 |
||
11 | 681 |
is_number () { |
682 |
if [ "x$1" = xOK ]; then |
|
683 |
return 1 |
|
684 |
fi |
|
685 |
temp=$(echo "$1" | sed -e 's/[1-9][0-9]*/OK/') |
|
686 |
if [ "x$temp" == xOK ]; then |
|
687 |
return 0 |
|
688 |
fi |
|
689 |
return 1 |
|
690 |
} |
|
691 |
||
1 | 692 |
# ask "question" variable_name "default answer" |
693 |
# |
|
694 |
# answer is stored in variable variable_name |
|
695 |
ask () { |
|
27 | 696 |
if [ $quiet_install = no ]; then |
697 |
echo -n "$1" |
|
698 |
fi |
|
25 | 699 |
log "Question: $1" |
23 | 700 |
if [ $interactive_install = no ]; then |
701 |
if [ ! -z $3 ]; then |
|
27 | 702 |
if [ $quiet_install = no ]; then |
703 |
echo ' => '$3 |
|
704 |
fi |
|
23 | 705 |
eval "$2=\"$3\"" |
25 | 706 |
log "Answer (non-interactive): $3" |
23 | 707 |
return |
708 |
else |
|
27 | 709 |
msg "" |
710 |
msg_err "No default answer found for this question" |
|
711 |
msg_err "Cannot continue with non-interactive installation" |
|
25 | 712 |
log "No default answer, aborting" |
23 | 713 |
exit 1 |
714 |
fi |
|
715 |
fi |
|
27 | 716 |
|
1 | 717 |
if [ ! -z $3 ]; then |
718 |
echo -n " [$3]: " |
|
719 |
else |
|
720 |
echo -n ": " |
|
721 |
fi |
|
722 |
||
723 |
read -e val |
|
25 | 724 |
log "Answer: $val" |
1 | 725 |
if [ "x$val" = x ]; then |
726 |
eval "$2=\"$3\"" |
|
727 |
else |
|
728 |
eval "$2=\"$val\"" |
|
729 |
fi |
|
730 |
} |
|
731 |
||
732 |
# ask_yes_no "question" variable_name "default answer" |
|
733 |
# |
|
734 |
# Answer ("yes" or "no") is stored in variable variable_name. |
|
735 |
# Keep asking the user until the answer is yes or no. |
|
736 |
ask_yes_no () { |
|
737 |
yes_no_repeat=yes |
|
738 |
while [ $yes_no_repeat = yes ]; do |
|
739 |
yes_no_repeat=no |
|
740 |
ask "${@}" |
|
741 |
eval "the_ans=\"\$$2\"" |
|
742 |
case "$the_ans" in |
|
743 |
[yY]|[yY][eE][sS] ) |
|
744 |
eval "$2=yes" |
|
745 |
;; |
|
746 |
[nN]|[nN][oO] ) |
|
747 |
eval "$2=no" |
|
748 |
;; |
|
749 |
* ) |
|
750 |
echo "Please answer yes or no" |
|
751 |
yes_no_repeat=yes |
|
752 |
esac |
|
753 |
done |
|
754 |
} |
|
755 |
||
756 |
# get_dir "question" "answer_var" "default answer" "owner" |
|
757 |
# |
|
758 |
# Ask for a directory name and make sure it exists or create it |
|
759 |
# for the user |
|
760 |
get_dir () { |
|
761 |
repeat=yes |
|
762 |
while [ $repeat = yes ]; do |
|
763 |
repeat=no |
|
764 |
ask "$1" new_dir "$3" |
|
765 |
case "$new_dir" in |
|
766 |
/* ) |
|
767 |
# absolute path name, nothing to do |
|
768 |
;; |
|
769 |
~* ) |
|
770 |
if [ "x$rootdir" != x/ ]; then |
|
10 | 771 |
msg "The Desktop CBE is being installed to an alternate root directory." |
1 | 772 |
msg "You need to specify the full path to directories within the alternate root." |
773 |
repeat=yes |
|
774 |
continue |
|
775 |
fi |
|
776 |
d1=`echo "$new_dir" | cut -f1 -d/` |
|
777 |
d2=`echo "$new_dir/" | cut -f2- -d/` |
|
778 |
d1n=$(eval echo "$d1") |
|
779 |
test -d "$d1n" || { |
|
780 |
repeat=yes |
|
781 |
msg "Directory not found: $d1" |
|
782 |
continue |
|
783 |
} |
|
784 |
d1n=$(cd "$d1n" 2>/dev/null && pwd) || { |
|
785 |
repeat=yes |
|
786 |
msg "Failed to access directory: $d1" |
|
787 |
continue |
|
788 |
} |
|
789 |
msg "Directory $new_dir expanded to $d1n/$d2" |
|
790 |
new_dir="$d1n/$d2" |
|
791 |
;; |
|
792 |
* ) |
|
793 |
if [ "x$rootdir" != x/ ]; then |
|
10 | 794 |
msg "The Desktop CBE is being installed to an alternate root directory." |
1 | 795 |
msg "You need to specify the full path to directories within the alternate root." |
796 |
repeat=yes |
|
797 |
continue |
|
798 |
fi |
|
799 |
d1=`echo "$new_dir" | cut -f1 -d/` |
|
800 |
d2=`echo "$new_dir/" | cut -f2- -d/` |
|
801 |
d1n=$(eval echo "$d1") |
|
802 |
test -d "$d1n" || { |
|
803 |
repeat=yes |
|
804 |
msg "Directory not found: $d1" |
|
805 |
continue |
|
806 |
} |
|
807 |
d1n=$(cd "$d1n" 2>/dev/null && pwd) || { |
|
808 |
repeat=yes |
|
809 |
msg "Failed to access directory: $d1" |
|
810 |
continue |
|
811 |
} |
|
812 |
msg "Directory $new_dir expanded to $d1n/$d2" |
|
813 |
new_dir="$d1n/$d2" |
|
814 |
;; |
|
815 |
esac |
|
816 |
done |
|
817 |
if [ "x$new_dir" != "x/" ]; then |
|
818 |
new_dir=`echo "$new_dir" | sed -e 's%/*$%%'` |
|
819 |
fi |
|
820 |
eval "$2=\"$new_dir\"" |
|
821 |
} |
|
822 |
||
823 |
# gather info for the installation from the user |
|
824 |
ask_defaults () { |
|
825 |
if [ $binary_install != yes ]; then |
|
826 |
repeat=yes |
|
827 |
while [ $repeat = yes ]; do |
|
828 |
repeat=no |
|
829 |
get_dir "Enter the base directory (prefix) of the cbe" \ |
|
830 |
cbe_prefix $cbe_prefix root |
|
831 |
if [ "$cbe_prefix" = "/" -o "$cbe_prefix" = "/tmp" ]; then |
|
27 | 832 |
msg "This directory is not allowed." |
833 |
msg "Please choose a different one as the cbe prefix" |
|
1 | 834 |
repeat=yes |
835 |
fi |
|
836 |
done |
|
837 |
fi |
|
838 |
||
839 |
if [ ! -f "$HOME/.pkgbuildmacros" -a ! -d "$HOME/packages" ]; then |
|
840 |
# the user probably hasn't used pkgbuild >= 1.1.0 yet |
|
841 |
# so let's ask if they want to use a specific topdir |
|
842 |
# instead of $HOME/packages |
|
27 | 843 |
msg "Starting from pkgbuild 1.1.0 (CBE 1.5) there is no system-wide" |
844 |
msg "build directory (%_topdir), instead, each user has their own." |
|
845 |
msg "The default directory is \$HOME/packages." |
|
846 |
msg "If you wish to use a different build directory, you can define it" |
|
847 |
msg "in \$HOME/.pkgbuildmacros as follows:" |
|
848 |
msg "" |
|
849 |
msg " %_topdir /path/to/my/build/area" |
|
850 |
msg "" |
|
1 | 851 |
if [ "$uid" = 0 ]; then |
23 | 852 |
if [ $interactive_install = yes ]; then |
853 |
echo |
|
854 |
echo Press Enter to continue |
|
855 |
read dummy |
|
856 |
fi |
|
1 | 857 |
else |
858 |
ask_yes_no "Would you like to do this now?" \ |
|
859 |
set_topdir no |
|
860 |
if [ $set_topdir = no ]; then |
|
861 |
log "the user chose not to change the default topdir" |
|
27 | 862 |
msg "The default topdir ($HOME/packages) will be used" |
1 | 863 |
else |
864 |
get_dir "Enter your build directory" default_topdir \ |
|
865 |
"$cbe_prefix/packages" $logname |
|
866 |
log "the user selected $default_topdir for topdir" |
|
867 |
echo "%_topdir $default_topdir" > $HOME/.pkgbuildmacros |
|
868 |
log "created $HOME/.pkgbuildmacros" |
|
869 |
fi |
|
870 |
fi |
|
871 |
else |
|
872 |
log "the user already has a .pkgbuildmacros file or ~/packages dir" |
|
873 |
fi |
|
874 |
||
10 | 875 |
find_compilers |
11 | 876 |
select_default_compiler |
1 | 877 |
|
10 | 878 |
if [ x$install_gnome = xno -a x$install_kde = xno \ |
879 |
-a x$install_opt = xno -a x$install_sfe = xno ]; then |
|
880 |
# no components selected using the CLI (--gnome, etc.) |
|
1 | 881 |
|
27 | 882 |
msg "" |
883 |
msg "The Desktop CBE includes tools for building GNOME, KDE and/or SFE packages" |
|
884 |
msg "It also includes some optional tools. Please select the tools you wish" |
|
885 |
msg "to install." |
|
886 |
msg "" |
|
10 | 887 |
ask_yes_no "Would you like install the tools for GNOME?" install_gnome yes |
888 |
ask_yes_no "Would you like install the tools for KDE?" install_kde yes |
|
889 |
ask_yes_no "Would you like install the tools for SFE?" install_sfe yes |
|
27 | 890 |
msg "" |
891 |
msg "The following tools are optional: $OPT_MODULES" |
|
10 | 892 |
ask_yes_no "Would you like install the optional tools?" install_opt yes |
25 | 893 |
else |
894 |
log "Install tools for GNOME? $install_gnome" |
|
895 |
log "Install tools for KDE? $install_kde" |
|
896 |
log "Install tools for SFE? $install_sfe" |
|
897 |
log "Install tools for OPTINAL? $install_opt" |
|
1 | 898 |
fi |
899 |
} |
|
900 |
||
901 |
# create an admin file for pkgadd/pkgrm |
|
902 |
make_admin_file () { |
|
903 |
echo "mail=" > $1 |
|
904 |
echo "instance=unique" >> $1 |
|
905 |
echo "conflict=nocheck" >> $1 |
|
906 |
echo "conflict=quit" >> $1 |
|
907 |
echo "setuid=nocheck" >> $1 |
|
908 |
echo "action=nocheck" >> $1 |
|
909 |
echo "partial=quit" >> $1 |
|
910 |
echo "space=quit" >> $1 |
|
911 |
if [ "$2" = "pkgrm" ]; then |
|
912 |
echo "idepend=nocheck" >> $1 |
|
913 |
echo "rdepend=nocheck" >> $1 |
|
914 |
else |
|
915 |
echo "idepend=quit" >> $1 |
|
916 |
echo "rdepend=quit" >> $1 |
|
917 |
fi |
|
918 |
} |
|
919 |
||
920 |
# run a command, redirect the output to a log file and also print it |
|
921 |
# on stdout |
|
922 |
logrun () { |
|
923 |
status_file=/tmp/.command_status.$$ |
|
924 |
/usr/bin/rm -f $status_file |
|
925 |
log "running $*" |
|
926 |
log "*** command output follows ***" |
|
27 | 927 |
if [ $quiet_install = yes ]; then |
928 |
"${@}" >>$LOGFILE 2>&1 |
|
929 |
status=$? |
|
930 |
else |
|
931 |
( "${@}" 2>&1 ; echo $? > $status_file ) | tee -a $LOGFILE |
|
932 |
status=`cat $status_file` |
|
933 |
/usr/bin/rm -f $status_file |
|
934 |
fi |
|
1 | 935 |
log "*** command output ends ***" |
936 |
return $status |
|
937 |
} |
|
938 |
||
10 | 939 |
# run a command, redirect the output to a log file and also print it |
940 |
# on stdout |
|
941 |
logrun_quiet () { |
|
942 |
log "running $*" |
|
943 |
log "*** command output follows ***" |
|
944 |
"${@}" >>$LOGFILE 2>&1 |
|
945 |
status=$? |
|
946 |
log "*** command output ends ***" |
|
947 |
return $status |
|
948 |
} |
|
949 |
||
1 | 950 |
# check if a package is installed and if so, offer to uninstall it |
951 |
check_if_installed () { |
|
10 | 952 |
for f in $*; do |
953 |
skip_package=no |
|
1 | 954 |
|
10 | 955 |
pkginfo -R $rootdir -q "$f"'.*' || return 0 |
1 | 956 |
|
10 | 957 |
if [ x$always_uninstall_existing != xyes -a x$always_skip_existing != xyes ]; then |
958 |
msg "Package $f is already installed." |
|
959 |
ask_yes_no "Would you like uninstall it?" do_uninstall yes |
|
960 |
if [ $do_uninstall = yes ]; then |
|
961 |
if [ x$always_uninstall_existing != xno ]; then |
|
962 |
ask_yes_no "Always uninstall previously installed packages?" \ |
|
963 |
always_uninstall_existing yes |
|
964 |
log "always_uninstall_existing = $always_uninstall_existing" |
|
965 |
fi |
|
966 |
fi |
|
967 |
else |
|
968 |
if [ x$always_skip_existing = xyes ]; then |
|
969 |
msg "Skipping package $f -- already installed" |
|
970 |
skip_package=yes |
|
971 |
return 0 |
|
972 |
else |
|
973 |
do_uninstall=yes |
|
974 |
fi |
|
975 |
fi |
|
976 |
if [ $do_uninstall = yes ]; then |
|
977 |
log "User chose to uninstall $f" |
|
978 |
make_admin_file /tmp/pkgrm.admin.$$ pkgrm || return 1 |
|
979 |
pkgrm_failed=no |
|
980 |
logrun pfexec /usr/sbin/pkgrm -R $rootdir -n -a /tmp/pkgrm.admin.$$ "$f.*" || pkgrm_failed=yes |
|
981 |
if [ $pkgrm_failed = yes ]; then |
|
982 |
ask_yes_no "pkgrm failed. would you like to continue anyway?" pkgrm_cont no |
|
983 |
if [ $pkgrm_cont = yes ]; then |
|
984 |
log "User chose to continue anyway" |
|
985 |
return 0 |
|
986 |
fi |
|
987 |
return 1 |
|
988 |
fi |
|
989 |
return 0 |
|
990 |
else |
|
991 |
log "User chose not to uninstall $f" |
|
992 |
if [ x$always_skip_existing != xyes ]; then |
|
993 |
ask_yes_no "Would you like skip to the next package? |
|
994 |
(\"no\" means the installer will try to build and install a duplicate package)" skip_package yes |
|
995 |
if [ $skip_package = yes ]; then |
|
996 |
log "User chose to skip package $f" |
|
997 |
if [ x$always_skip_existing != xno ]; then |
|
998 |
ask_yes_no "Always skip packages that are already installed?" always_skip_existing yes |
|
999 |
log "always_skip_existing = $always_skip_existing" |
|
1000 |
fi |
|
1001 |
return 0 |
|
1002 |
fi |
|
1003 |
else |
|
1004 |
skip_package=yes |
|
1 | 1005 |
return 0 |
1006 |
fi |
|
10 | 1007 |
msg "Not uninstalling $f." |
1008 |
msg "NOTE that this may cause problems later" |
|
1009 |
ask "Press Enter to continue" dummy "" |
|
1 | 1010 |
return 0 |
1011 |
fi |
|
10 | 1012 |
done |
1 | 1013 |
return 0 |
1014 |
} |
|
1015 |
||
1016 |
# install a list of svr4 packages given its directory, altroot and the |
|
1017 |
# names of the packages |
|
1018 |
install_pkgs () { |
|
1019 |
pdir=$1; shift |
|
1020 |
rdir=$1; shift |
|
1021 |
make_admin_file $tempdir/pkgadd.admin.$$ pkgadd |
|
1022 |
||
1023 |
for pkg in $*; do |
|
1024 |
msg "Installing package $pkg" |
|
1025 |
logrun pfexec /usr/sbin/pkgadd -R "$rdir" -n -a $tempdir/pkgadd.admin.$$ -d "$pdir" $pkg || \ |
|
1026 |
return 1 |
|
1027 |
done |
|
1028 |
/usr/bin/rm -f $tempdir/pkgadd.admin.$$ |
|
1029 |
return 0 |
|
1030 |
} |
|
1031 |
||
10 | 1032 |
# check if the system is pkg(5) based or SVr4 based |
1033 |
# To identify, we check which system was used to install SUNWcs/SUNWcsu |
|
1034 |
# Output: set the PKG_SYSTEM variable with either pkg or svr4 |
|
1035 |
check_pkg_system () { |
|
1036 |
if [ -x /usr/bin/pkg -a -d /var/pkg/catalog ]; then |
|
1037 |
pkg -R $rootdir list SUNWcs > /dev/null 2>&1 && { |
|
1038 |
PKG_SYSTEM=pkg |
|
1039 |
return |
|
1040 |
} |
|
1041 |
fi |
|
1042 |
||
1043 |
pkginfo -R $rootdir -q SUNWcsu && { |
|
1044 |
PKG_SYSTEM=svr4 |
|
1045 |
return |
|
1046 |
} |
|
1047 |
||
1048 |
msg_err "Could not identify the packaging system" |
|
1049 |
exit 1 |
|
1050 |
} |
|
1051 |
||
1052 |
pkg_refreshed=no |
|
1053 |
pkg_refresh () { |
|
1054 |
if [ $pkg_refreshed = no ]; then |
|
1055 |
msg "Refeshing the package catalogs..." |
|
1056 |
logrun_quiet pfexec pkg -R $rootdir refresh |
|
1057 |
pkg_refreshed=yes |
|
1058 |
fi |
|
1059 |
} |
|
1060 |
||
1061 |
pkg_try_install () { |
|
1062 |
pkg_refresh |
|
1063 |
pfexec pkg -R $rootdir install -q $1 && { |
|
1064 |
msg "$1 installed successfully" |
|
1065 |
return 0 |
|
1066 |
} || { |
|
1067 |
msg "Failed to install package $1" |
|
1068 |
msg "Retrying in verbose mode:" |
|
1069 |
pfexec pkg -R $rootdir install -v $1 && { |
|
1070 |
msg "$1 installed successfully" |
|
1071 |
return 0 |
|
1072 |
} || { |
|
1073 |
msg "Installation of $1 failed again." |
|
1074 |
ask_yes_no "Would you like to continue? (no means exit)" ans_continue no |
|
1075 |
if [ $ans_continue = no ]; then |
|
1076 |
exit 1 |
|
1077 |
fi |
|
1078 |
DEPS_INSTALLED=no |
|
1079 |
return 1 |
|
1080 |
} |
|
1081 |
} |
|
1082 |
} |
|
1083 |
||
1 | 1084 |
install_all_dependencies= |
10 | 1085 |
skip_all_dependencies= |
1086 |
check_cbe_dependencies_pkg () { |
|
1087 |
DEPS_OK=yes |
|
1088 |
DEPS_INSTALLED=no |
|
1089 |
for pkg in $*; do |
|
1090 |
pkg -R $rootdir list $pkg > /dev/null 2>&1 && { |
|
1091 |
log "$pkg is installed" |
|
1092 |
} || { |
|
1093 |
log "$pkg is not installed" |
|
1094 |
DEPS_OK=no |
|
1095 |
if [ x$skip_all_dependencies = xyes ]; then |
|
1096 |
msg " $pkg is not installed (skipping)" |
|
1097 |
elif [ x$install_all_dependencies = xyes ]; then |
|
1098 |
pkg_try_install $pkg |
|
1099 |
elif [ x$install_all_dependencies = x ]; then |
|
1100 |
msg "Package $pkg is not installed" |
|
1101 |
ask_yes_no "Would you like the CBE installer to install this package for you?" ans_install_dep "yes" |
|
1102 |
if [ $ans_install_dep = yes ]; then |
|
1103 |
ask_yes_no "Would you like the CBE installer to install all required packages?" install_all_dependencies yes |
|
1104 |
pkg_try_install $pkg && { |
|
1105 |
DEPS_INSTALLED=yes |
|
1106 |
} |
|
1107 |
else |
|
1108 |
# user chose not to install this dep |
|
1109 |
DEPS_INSTALLED=no |
|
1110 |
log "The user chose not to install $pkg" |
|
1111 |
if [ x$skip_all_dependencies = x ]; then |
|
1112 |
ask_yes_no "Would you like to skip all missing packages?" skip_all_dependencies no |
|
1113 |
fi |
|
1114 |
fi |
|
1115 |
elif [ x$install_all_dependencies = xno ]; then |
|
1116 |
msg "Package $pkg is not installed" |
|
1117 |
ask_yes_no "Install this package?" ans_install_dep "yes" |
|
1118 |
if [ $ans_install_dep = yes ]; then |
|
1119 |
pkg_try_install $pkg |
|
1120 |
fi |
|
1121 |
fi |
|
1122 |
} |
|
1123 |
done |
|
1124 |
} |
|
1125 |
||
1126 |
install_all_dependencies= |
|
1127 |
skip_all_dependencies= |
|
1128 |
# check if the pkgs GNOME or KDE requires are installed; if not install them |
|
1129 |
check_cbe_dependencies_svr4 () { |
|
1130 |
DEPS_OK=yes |
|
1131 |
DEPS_INSTALLED=yes |
|
1 | 1132 |
# we're going to cp solaris pkgs from the media to this dir |
1133 |
tmp_pkg_dir=`mktemp -d /tmp/cbe-pkgs-XXXX` |
|
1134 |
# schedule this dir for removal if the installation is aborted |
|
1135 |
tempdirs="$tempdirs:$tmp_pkg_dir" |
|
10 | 1136 |
if [ ! -d $tmp_pkg_dir ]; then |
1137 |
msg_err "Failed to create temporary directory in /tmp" |
|
1138 |
exit 1 |
|
1139 |
fi |
|
1140 |
for pkg in $*; do |
|
1 | 1141 |
pkginfo -R $rootdir -q "$pkg."'*' && continue |
10 | 1142 |
DEPS_OK=no |
1143 |
if [ x$skip_all_dependencies = xyes ]; then |
|
1144 |
msg " $pkg is not installed (skipping)" |
|
1145 |
continue |
|
1146 |
elif [ x$install_all_dependencies = x ]; then |
|
1147 |
msg "Package $pkg is not installed" |
|
1148 |
ask_yes_no "Would you like the CBE installer to install this package for you?" ans_install_dep "yes" |
|
1149 |
if [ $ans_install_dep = yes ]; then |
|
1150 |
ask_yes_no "Would you like the CBE installer to install all required packages?" install_all_dependencies yes |
|
1 | 1151 |
while /bin/true; do |
1152 |
ask "Enter the path to the Solaris packages" \ |
|
1153 |
solaris_pkg_dir "$solaris_pkg_dir" |
|
1154 |
# Copy all packages found in $solaris_pkg_dir to a temporary |
|
1155 |
# dir so that people installing from CDs don't need to |
|
1156 |
# swap CDs all the time... |
|
10 | 1157 |
for p0 in $CBE_SVR4_DEPENDENCIES; do |
1158 |
# already copied to the tmp dir |
|
1 | 1159 |
test -d $tmp_pkg_dir/$p0 && continue |
10 | 1160 |
# already installed, no need to copy |
1161 |
pkginfo -q $p0 && continue |
|
1 | 1162 |
test -d "$solaris_pkg_dir/$p0" && \ |
10 | 1163 |
/bin/cp -pr "$solaris_pkg_dir/$p0" $tmp_pkg_dir && \ |
1 | 1164 |
/bin/chmod -R u+w $tmp_pkg_dir/$p0 |
1165 |
done |
|
1166 |
test -d "$solaris_pkg_dir/$pkg" && break |
|
1167 |
msg "$solaris_pkg_dir/$pkg not found" |
|
1168 |
done |
|
1169 |
else |
|
10 | 1170 |
log "The user chose not to install $pkg" |
1171 |
DEPS_INSTALLED=no |
|
1172 |
if [ x$skip_all_dependencies = x ]; then |
|
1173 |
ask_yes_no "Would you like to skip all missing packages?" skip_all_dependencies no |
|
1174 |
fi |
|
1175 |
continue |
|
1176 |
fi |
|
1177 |
elif [ x$install_all_dependencies = xno ]; then |
|
1178 |
msg "Package $pkg is not installed" |
|
1179 |
ask_yes_no "Install this package?" ans_install_dep "yes" |
|
1180 |
if [ $ans_install_dep = no ]; then |
|
1181 |
DEPS_INSTALLED=no |
|
1 | 1182 |
continue |
1183 |
fi |
|
1184 |
fi |
|
1185 |
while /bin/true; do |
|
1186 |
msg "Installing package $pkg" |
|
1187 |
make_admin_file /tmp/pkgadd.admin.$$ pkgadd |
|
1188 |
if [ -d $tmp_pkg_dir/$pkg ]; then |
|
1189 |
logrun pfexec /usr/sbin/pkgadd -R $rootdir -n -a /tmp/pkgadd.admin.$$ -d "$tmp_pkg_dir" $pkg |
|
1190 |
if [ $? != 0 ]; then |
|
1191 |
msg "WARNING: failed to install required package $pkg" |
|
1192 |
ask_yes_no "Would you like to retry?" "do_retry" "yes" |
|
10 | 1193 |
if [ $do_retry = no ]; then |
1194 |
DEPS_INSTALLED=no |
|
1195 |
fi |
|
1 | 1196 |
else |
1197 |
do_retry=no_need_to |
|
1198 |
fi |
|
1199 |
else |
|
1200 |
msg "Package $pkg was not found in $solaris_pkg_dir" |
|
1201 |
do_retry=yes |
|
1202 |
/bin/true |
|
1203 |
fi |
|
1204 |
if [ $do_retry = yes ]; then |
|
1205 |
while /bin/true; do |
|
1206 |
ask "Enter the path to the Solaris packages" \ |
|
1207 |
solaris_pkg_dir "$solaris_pkg_dir" |
|
1208 |
test -d "$solaris_pkg_dir/$pkg" && break |
|
1209 |
msg "$solaris_pkg_dir/$pkg not found" |
|
1210 |
done |
|
1211 |
# Copy all packages found in $solaris_pkg_dir to a temporary |
|
1212 |
# dir so that people installing from CDs don't need to |
|
1213 |
# swap CDs all the time... |
|
10 | 1214 |
for p0 in $CBE_SVR4_DEPENDENCIES; do |
1 | 1215 |
test -d "$solaris_pkg_dir/$p0" && \ |
10 | 1216 |
/bin/cp -pr "$solaris_pkg_dir/$p0" $tmp_pkg_dir && \ |
1 | 1217 |
/bin/chmod -R u+w $tmp_pkg_dir/$p0 |
1218 |
done |
|
1219 |
elif [ $do_retry = no ]; then |
|
1220 |
ask_yes_no "Continue installation anyway?" \ |
|
1221 |
do_continue no |
|
1222 |
if [ $do_continue = no ]; then |
|
1223 |
/bin/rm -f /tmp/pkgadd.admin.$$ |
|
1224 |
/bin/rm -rf $tmp_pkg_dir |
|
1225 |
msg "Installation aborted." |
|
1226 |
exit 1 |
|
1227 |
else |
|
10 | 1228 |
DEPS_INSTALLED=no |
1 | 1229 |
break |
1230 |
fi |
|
1231 |
break |
|
1232 |
else |
|
1233 |
/bin/rm -rf $tmp_pkg_dir/$pkg |
|
1234 |
/bin/rm -f /tmp/pkgadd.admin.$$ |
|
1235 |
break |
|
1236 |
fi |
|
1237 |
done |
|
1238 |
done |
|
1239 |
/bin/rm -rf $tmp_pkg_dir |
|
1240 |
} |
|
1241 |
||
1242 |
# install pkgbuild from tarball to a temp location and then build a |
|
1243 |
# pkgbuild pkg using itself |
|
1244 |
install_pkgbuild () { |
|
1245 |
check_if_installed SFpkgbuild || { |
|
1246 |
pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=` |
|
1247 |
return 1 |
|
1248 |
} |
|
1249 |
if [ $skip_package = yes ]; then |
|
1250 |
return 0 |
|
1251 |
fi |
|
1252 |
export PATH=/usr/ccs/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/usr/sfw/bin |
|
10 | 1253 |
# we're going to build pkgbuild in this directory |
1254 |
tmp_build_dir=`mktemp -d /tmp/cbe-build-XXXX` |
|
1255 |
# schedule this dir for removal if the installation is aborted |
|
1256 |
tempdirs="$tempdirs:$tmp_build_dir" |
|
1257 |
if [ ! -d $tmp_build_dir ]; then |
|
1258 |
msg_err "Failed to create temporary directory in /tmp" |
|
1259 |
exit 1 |
|
1260 |
fi |
|
1261 |
cd $tmp_build_dir || return 1 |
|
1262 |
logrun mkdir -p src || return 1 |
|
1263 |
cd src || return 1 |
|
1264 |
logrun bash -c "bzcat $tardir/pkgbuild-$PKGBUILD_VERSION.tar.bz2 | tar xf -" || return 1 |
|
1 | 1265 |
cd pkgbuild-$PKGBUILD_VERSION || return 1 |
10 | 1266 |
msg "Building pkgbuild from source..." |
23 | 1267 |
if [ x"`basename $CC`" = xgcc ]; then |
1268 |
export CFLAGS='-std=c99' |
|
1269 |
fi |
|
10 | 1270 |
logrun_quiet ./configure --prefix="$tmp_build_dir" || return 1 |
1271 |
logrun_quiet make install || return 1 |
|
1272 |
msg "Now rebuilding pkgbuild using itself..." |
|
1273 |
logrun mkdir -p $tmp_build_dir/packages/SOURCES || return 1 |
|
1274 |
logrun ln -s $tardir/pkgbuild-$PKGBUILD_VERSION.tar.bz2 $tmp_build_dir/packages/SOURCES/ || return 1 |
|
41
31570364d0f1
2009-03-16 Lukas (Luc) Oboril <[email protected]> * bump pkgbuild to latest version 1.3.98.4 * add Sun Studio Express 03/09 as known compiler
xlucas
parents:
40
diff
changeset
|
1275 |
logrun cp -pr $tmp_build_dir/src/pkgbuild-$PKGBUILD_VERSION/COPYING $tmp_build_dir/packages/SOURCES/gpl-2.0.txt || return 1 |
10 | 1276 |
logrun_quiet bash -c "$tmp_build_dir/bin/pkgbuild --define \"pkgbuild_prefix $cbe_prefix\" --define \"_topdir $tmp_build_dir/packages\" -ba $tmp_build_dir/src/pkgbuild-$PKGBUILD_VERSION/pkgbuild.spec" || return 1 |
1 | 1277 |
make_admin_file $tempdir/pkgadd.admin.$$ pkgadd |
10 | 1278 |
logrun pfexec /usr/sbin/pkgadd -R $rootdir -n -a $tempdir/pkgadd.admin.$$ -d "$tmp_build_dir/packages/PKGS" SFpkgbuild || return 1 |
1 | 1279 |
pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=` |
10 | 1280 |
logrun mkdir -p "$rootdir/$pkgbuild_topdir/PKGS" "$rootdir/$pkgbuild_topdir/SPKGS" |
1281 |
logrun cp -pr "$tmp_build_dir/packages/SPKGS/SFpkgbuild-src" "$rootdir/$pkgbuild_topdir/SPKGS" |
|
1282 |
logrun cp -pr "$tmp_build_dir/packages/PKGS/SFpkgbuild" "$rootdir/$pkgbuild_topdir/PKGS" |
|
1 | 1283 |
cd /tmp || return 1 |
10 | 1284 |
logrun /usr/bin/rm -rf $tmp_build_dir || return 1 |
23 | 1285 |
unset CFLAGS |
1286 |
||
1 | 1287 |
return 0 |
1288 |
} |
|
1289 |
||
1290 |
# build and install a package |
|
1291 |
build_pkg () { |
|
1292 |
install_pkgs "$rootdir$pkgbuild_topdir/PKGS" "$rootdir" "$3" || return 1 |
|
1293 |
} |
|
1294 |
||
10 | 1295 |
# older versions of the JDS CBE included packages that were renamed or |
1296 |
# no longer included. These older JDS CBEs only supported SVr4. |
|
1 | 1297 |
uninstall_old_cbe () { |
1298 |
pkg_info= |
|
1299 |
for pkg in $OLD_PKGS; do |
|
1300 |
pkginfo -R $rootdir -q "$pkg."'*' && pkg_info="$pkg_info |
|
1301 |
`pkginfo -R $rootdir $pkg.'*'`" |
|
1302 |
done |
|
1303 |
if [ ! -z "$pkg_info" ]; then |
|
27 | 1304 |
msg "The following packages belong to an obsolete version of the JDS CBE." |
1305 |
msg "$pkg_info" |
|
1306 |
msg "" |
|
1 | 1307 |
ask_yes_no "Would you like to uninstall them?" do_uninst yes |
1308 |
if [ $do_uninst = yes ]; then |
|
1309 |
log "User chose to uninstall obsolete CBE pkgs" |
|
1310 |
make_admin_file $tempdir/pkgrm.admin.$$ pkgrm |
|
1311 |
pkgrm_failed=no |
|
1312 |
for pkg in $OLD_PKGS; do |
|
1313 |
if pkginfo -R $rootdir -q "$pkg."'*'; then |
|
1314 |
logrun pfexec /usr/sbin/pkgrm -R $rootdir -n -a $tempdir/pkgrm.admin.$$ "$pkg."'*' || \ |
|
1315 |
pkgrm_failed=yes |
|
1316 |
fi |
|
1317 |
done |
|
1318 |
rm -f $tempdir/pkgrm.admin.$$ |
|
1319 |
if [ $pkgrm_failed = yes ]; then |
|
1320 |
msg "Failed to remove one or more packages" |
|
1321 |
ask_yes_no "Would you like to continue anyway?" do_cont no |
|
1322 |
if [ $do_cont = no ]; then |
|
1323 |
return 1 |
|
1324 |
else |
|
1325 |
log "User chose to continue anyway" |
|
1326 |
return 0 |
|
1327 |
fi |
|
1328 |
fi |
|
1329 |
fi |
|
1330 |
fi |
|
1331 |
return 0 |
|
1332 |
} |
|
1333 |
||
1334 |
main () { |
|
1335 |
init |
|
1336 |
uninstall_old_cbe || return 1 |
|
1337 |
ask_defaults |
|
23 | 1338 |
test -d $ |
10 | 1339 |
pkginfo -q -R $rootdir CBEenv && { |
1340 |
msg "Uninstalling CBEenv" |
|
1341 |
make_admin_file /tmp/pkgrm.admin.$$ pkgrm || return 1 |
|
1342 |
logrun pfexec /usr/sbin/pkgrm -R $rootdir -n -a /tmp/pkgrm.admin.$$ "CBEenv.*" |
|
1343 |
rm -f /tmp/pkgrm.admin.$$ |
|
1344 |
} |
|
1345 |
||
1346 |
ALL_MODULES= |
|
1347 |
if [ $install_gnome = yes ]; then |
|
1348 |
ALL_MODULES="$ALL_MODULES $GNOME_MODULES" |
|
1349 |
fi |
|
1350 |
if [ $install_kde = yes ]; then |
|
1351 |
ALL_MODULES="$ALL_MODULES $KDE_MODULES" |
|
1352 |
fi |
|
1353 |
if [ $install_sfe = yes ]; then |
|
1354 |
ALL_MODULES="$ALL_MODULES $SFE_MODULES" |
|
1355 |
fi |
|
1356 |
if [ $install_opt = yes ]; then |
|
1357 |
ALL_MODULES="$ALL_MODULES $OPT_MODULES" |
|
1358 |
fi |
|
1359 |
ALL_MODULES=$(echo $ALL_MODULES | sed -e 's/ /\ |
|
1360 |
/g' | sort -u) |
|
1361 |
||
1 | 1362 |
if [ $binary_install = no ]; then |
1363 |
install_pkgbuild || return 1 |
|
10 | 1364 |
else |
1365 |
check_if_installed SFpkgbuild || return 1 |
|
1366 |
if [ $skip_package != yes ]; then |
|
13 | 1367 |
install_pkgs "$mydir/pkgs-${the_cpu}" "$rootdir" SFpkgbuild || return 1 |
10 | 1368 |
fi |
1369 |
fi |
|
1370 |
pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=` |
|
1371 |
||
1372 |
cd $mydir |
|
1373 |
||
1374 |
# identify the CBE packages to be built/installed |
|
1375 |
ALL_SPECS= |
|
1376 |
ALL_CBE_PKGS= |
|
1377 |
for mod in $ALL_MODULES; do |
|
11 | 1378 |
pkgs=$($cbe_prefix/bin/spectool get_packages CBE${mod}.spec 2>/dev/null) |
10 | 1379 |
check_if_installed $pkgs || return 1 |
1380 |
# skip_package is set by check_if_installed |
|
1381 |
if [ $skip_package = yes ]; then |
|
1382 |
continue |
|
1 | 1383 |
fi |
10 | 1384 |
# On Nevada and OpenSolaris use alternatives if available |
1385 |
if [ $install_alt = yes -a "x$myos_rel" = x5.11 ]; then |
|
1386 |
eval ALT=\"$(eval echo \$ALT_$mod)\" |
|
1387 |
if [ "x$ALT" != x ]; then |
|
1388 |
if [ $ask_alt = yes ]; then |
|
1389 |
ask_yes_no "Use $ALT ($mod) instead of CBE $mod?" \ |
|
1390 |
use_alt yes |
|
1391 |
if [ $use_alt = no ]; then |
|
1392 |
ALL_CBE_PKGS="$ALL_CBE_PKGS $pkgs" |
|
1393 |
ALL_SPECS="$ALL_SPECS CBE${mod}.spec" |
|
1394 |
continue |
|
1395 |
fi |
|
1396 |
fi |
|
1397 |
msg "Looking for package $ALT" |
|
1398 |
check_cbe_dependencies_$PKG_SYSTEM $(eval echo $ALT) |
|
1399 |
if [ $DEPS_OK = yes ]; then |
|
1400 |
msg " ... already installed" |
|
1401 |
continue |
|
1402 |
elif [ $DEPS_INSTALLED = yes ]; then |
|
1403 |
msg "Successfully installed $ALT" |
|
1404 |
continue |
|
1405 |
else |
|
1406 |
msg "Using the CBE version of $mod" |
|
1407 |
ALL_SPECS="$ALL_SPECS CBE${mod}.spec" |
|
1408 |
ALL_CBE_PKGS="$ALL_CBE_PKGS $pkgs" |
|
1409 |
fi |
|
11 | 1410 |
else |
1411 |
# no alternative exists |
|
1412 |
ALL_SPECS="$ALL_SPECS CBE${mod}.spec" |
|
1413 |
ALL_CBE_PKGS="$ALL_CBE_PKGS $pkgs" |
|
10 | 1414 |
fi |
1415 |
else |
|
1416 |
# alternatives should not be used |
|
1417 |
ALL_SPECS="$ALL_SPECS CBE${mod}.spec" |
|
1418 |
ALL_CBE_PKGS="$ALL_CBE_PKGS $pkgs" |
|
1419 |
fi |
|
1420 |
done |
|
1421 |
||
1422 |
if [ $binary_install = no ]; then |
|
1423 |
export "PATH=$rootdir$cbe_prefix/bin:/usr/ccs/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/usr/sfw/bin" |
|
1424 |
if [ "x$rootdir" != x/ ]; then |
|
1425 |
export AC_MACRODIR="$rootdir$cbe_prefix/share/autoconf" |
|
1426 |
sed -e "s%--prepend-include %--prepend-include $rootdir%" "$rootdir$cbe_prefix/share/autoconf/autom4te.cfg" > $tempdir/autom4te.cfg |
|
1427 |
export AUTOM4TE_CFG="$tempdir/autom4te.cfg" |
|
1428 |
export autom4te_perllibdir="$rootdir$cbe_prefix/share/autoconf" |
|
1429 |
export AUTOM4TE="$rootdir$cbe_prefix/bin/autom4te" |
|
1430 |
fi |
|
11 | 1431 |
|
10 | 1432 |
ALL_SPECS=$($cbe_prefix/bin/pkgtool -q build-order $ALL_SPECS) |
1433 |
for spec in $ALL_SPECS; do |
|
11 | 1434 |
pkgs=$($cbe_prefix/bin/spectool get_packages $spec 2>/dev/null) |
12 | 1435 |
if [ $need_tarballs = yes ]; then |
1436 |
msg "Downloading source tarball for $pkgs" |
|
1437 |
$cbe_prefix/bin/pkgtool download --download-to $tardir $spec || return 1 |
|
1438 |
fi |
|
10 | 1439 |
|
1440 |
# build the package |
|
15 | 1441 |
logrun $cbe_prefix/bin/pkgtool --download --download-to "$tardir" --define "cbe_prefix $cbe_prefix" --define "cbe_version $CBE_VERSION" build-only $spec || return 1 |
10 | 1442 |
for pkg in $pkgs; do |
1443 |
install_pkgs "$rootdir$pkgbuild_topdir/PKGS" "$rootdir" "$pkg" || return 1 |
|
1444 |
done |
|
1445 |
done |
|
1 | 1446 |
else |
10 | 1447 |
# binary install |
12 | 1448 |
for pkg in $ALL_CBE_PKGS; do |
1449 |
if [ -d "$mydir/pkgs-${the_cpu}/${myos_rel}/$pkg" ]; then |
|
1450 |
install_pkgs "$mydir/pkgs-${the_cpu}/${myos_rel}" \ |
|
1451 |
"$rootdir" $pkg || return 1 |
|
1452 |
else |
|
1453 |
install_pkgs "$mydir/pkgs-${the_cpu}" \ |
|
1454 |
"$rootdir" $pkg || return 1 |
|
1455 |
fi |
|
1456 |
done |
|
1 | 1457 |
pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=` |
1458 |
fi |
|
1459 |
log "Creating env.sh" |
|
1460 |
logrun mkdir -p $rootdir$pkgbuild_topdir/SOURCES || return 1 |
|
1461 |
build_info="built on `date +%Y-%m-%d` by ${logname}@`hostname`" |
|
10 | 1462 |
logrun_quiet bash -c "sed -e \"s%@CBE_PREFIX@%$cbe_prefix%\" \ |
1 | 1463 |
-e \"s%@JDS_PREFIX@%$JDS_PREFIX%\" \ |
1464 |
-e \"s%@CC32@%$cc32dir/$cc_name%\" \ |
|
1465 |
-e \"s%@CXX32@%$cc32dir/$cxx_name%\" \ |
|
1466 |
-e \"s%@CC64@%$cc64dir/$cc_name%\" \ |
|
1467 |
-e \"s%@CXX64@%$cc64dir/$cxx_name%\" \ |
|
1468 |
-e \"s%@CBE_VERSION@%$CBE_VERSION%\" \ |
|
1469 |
-e \"s%@BUILD_INFO@%$build_info%\" \ |
|
10 | 1470 |
$mydir/ext-sources/env.sh > $rootdir$pkgbuild_topdir/SOURCES/env.sh" || \ |
1 | 1471 |
return 1 |
29 | 1472 |
log "Creating env_include.sh" |
1473 |
build_info="built on `date +%Y-%m-%d` by ${logname}@`hostname`" |
|
1474 |
logrun_quiet bash -c "sed -e \"s%@CBE_PREFIX@%$cbe_prefix%\" \ |
|
1475 |
-e \"s%@JDS_PREFIX@%$JDS_PREFIX%\" \ |
|
1476 |
-e \"s%@CC32@%$cc32dir/$cc_name%\" \ |
|
1477 |
-e \"s%@CXX32@%$cc32dir/$cxx_name%\" \ |
|
1478 |
-e \"s%@CC64@%$cc64dir/$cc_name%\" \ |
|
1479 |
-e \"s%@CXX64@%$cc64dir/$cxx_name%\" \ |
|
1480 |
-e \"s%@CBE_VERSION@%$CBE_VERSION%\" \ |
|
1481 |
-e \"s%@BUILD_INFO@%$build_info%\" \ |
|
1482 |
$mydir/ext-sources/env_include.sh > $rootdir$pkgbuild_topdir/SOURCES/env_include.sh" || \ |
|
1483 |
return 1 |
|
1 | 1484 |
log "Creating env.csh" |
10 | 1485 |
logrun_quiet bash -c "sed -e \"s%@CBE_PREFIX@%$cbe_prefix%\" \ |
1 | 1486 |
-e \"s%@JDS_PREFIX@%$JDS_PREFIX%\" \ |
1487 |
-e \"s%@CC32@%$cc32dir/$cc_name%\" \ |
|
1488 |
-e \"s%@CXX32@%$cc32dir/$cxx_name%\" \ |
|
1489 |
-e \"s%@CC64@%$cc64dir/$cc_name%\" \ |
|
1490 |
-e \"s%@CXX64@%$cc64dir/$cxx_name%\" \ |
|
1491 |
-e \"s%@CBE_VERSION@%$CBE_VERSION%\" \ |
|
1492 |
-e \"s%@BUILD_INFO@%$build_info%\" \ |
|
10 | 1493 |
$mydir/ext-sources/env.csh > $rootdir$pkgbuild_topdir/SOURCES/env.csh" || \ |
1 | 1494 |
return 1 |
21 | 1495 |
log "Copying ld-wrapper, gendiff" |
10 | 1496 |
logrun bash -c "cp $mydir/ext-sources/ld-wrapper $rootdir$pkgbuild_topdir/SOURCES" || \ |
1 | 1497 |
return 1 |
21 | 1498 |
logrun bash -c "cp $mydir/ext-sources/gendiff $rootdir$pkgbuild_topdir/SOURCES" || \ |
1499 |
return 1 |
|
19 | 1500 |
logrun bash -c "mkdir -p $rootdir$pkgbuild_topdir/SPECS" || \ |
1501 |
return 1 |
|
1502 |
logrun bash -c "cp $mydir/include/CBE.inc $rootdir$pkgbuild_topdir/SPECS/" || \ |
|
1503 |
return 1 |
|
23 | 1504 |
logrun bash -c "cp $mydir/include/default-depend.inc $rootdir$pkgbuild_topdir/SPECS/" || \ |
1505 |
return 1 |
|
27 | 1506 |
msg "Building CBEenv" |
11 | 1507 |
logrun_quiet $cbe_prefix/bin/pkgbuild --define "cbe_prefix $cbe_prefix" --define "cbe_version $CBE_VERSION" --define "build_user $logname" -ba CBEenv.spec || return 1 |
1508 |
logrun $cbe_prefix/bin/pkgtool install-pkgs --define "build_user $logname" CBEenv.spec || return 1 |
|
1509 |
logrun cp ${envdir}/* $cbe_prefix/lib/cbe-env/ |
|
1510 |
def_env_name=$(basename $default_env) |
|
1511 |
cd $cbe_prefix/lib/cbe-env; ln -s $def_env_name default |
|
1512 |
cd $mydir |
|
1 | 1513 |
msg "CBE setup complete" |
27 | 1514 |
msg "Run" |
1515 |
msg " . $cbe_prefix/bin/env.sh [environment]" |
|
1516 |
msg "or" |
|
1517 |
msg " source $cbe_prefix/bin/env.csh [environment]" |
|
1518 |
msg "depending on your shell, to use this build environment." |
|
1519 |
msg "You can also run $cbe_prefix/bin/env.sh [environment] to start subshell." |
|
1 | 1520 |
} |
1521 |
||
1522 |
process_cl "${@}" |
|
27 | 1523 |
main || { |
1524 |
msg "CBE setup FAILED" |
|
1525 |
msg "Installation log saved in $LOGFILE" |
|
1526 |
exit 1 |
|
1527 |
} |
|
1528 |
msg "Installation log saved in $LOGFILE" |