2008-06-11 Laszlo (Laca) Peter <
[email protected]>
* README: (new) note on building the CBE from svn
* CBEant.spec: update rev
* CBEautoconf.spec: update rev, gmake dependency
* CBEautomake.spec: update rev, gmake dependency, create aclocal
symlink
* CBEbison.spec: update rev, gmake dependency
* CBEcmake.spec: update rev, gmake depedency, use -norunpath with CC
* CBEcoreutils.spec: update rev, gmake dependency
* CBEcvs.spec: update rev, gmake depedency
* CBEdiff.spec: update rev, gmake depedency
* CBEenv.spec: update version, create symlinks for [Open]Solaris
gnu make, automake, aclocal
* CBEflex.spec: update rev, gmake depedency, use c99flag
* CBEgettext.spec: update rev, gmake dependency
* CBEgnuawk.spec: update rev, gmake dependency
* CBEgnused.spec: update rev, gmake dependency
* CBElibtool.spec: update rev, gmake dependency
* CBElibtool22.spec: update rev, gmake dependency
* CBEm4.spec: update rev, gmake dependency
* CBEmake.spec: update rev
* CBErsync.spec: update rev, gmake dependency
* CBEsubversion.spec: update rev, gmake dependency
* CBEyasm.spec: update rev, gmake dependency, fix _datadir, _mandir
attributes
* cbe-install: major rework for Solaris 10, Nevada and OpenSolaris
* cbe-remove: remove all 'JDS CBE' and 'Desktop CBE' packages
* ext-sources/env.csh: fix unset bug reported by Ben Taylor, where
multi-line values break the script
* ext-sources/env.sh: fix unset bug reported by Ben Taylor
* include/CBE.inc: define c99flag, cxx_optflags, make_dep and change
default cbe prefix to /opt/dtbld
#!/bin/bash
#
# Script for setting up the Desktop Build Environment on Solaris
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
IFS='
'
# this is listed separately because we are using the spec file
# included in the pkgbuild tarball
PKGBUILD_VERSION=1.3.0
# Set to "internal" for sun internal users, "external" for opensolaris
# No big differences really, just slightly different defaults
# and a different README
INT_EXT=@INT_EXT@
if [ "x$INT_EXT" != xinternal -a "x$INT_EXT" != xexternal ]; then
INT_EXT=internal
fi
# Modules needed for building GNOME:
GNOME_MODULES="ant m4 autoconf automake libtool bison coreutils diff flex gettext make subversion"
# Modules needed for building KDE:
KDE_MODULES="ant m4 autoconf automake libtool bison coreutils diff flex gettext subversion gnuawk gnused cmake make yasm"
# Not needed for either GNOME or KDE, but useful to have:
OPT_MODULES="rsync cvs"
# SFE has the same deps as GNOME
SFE_MODULES=$GNOME_MODULES
install_kde=no
install_gnome=no
install_sfe=no
install_opt=no
# Obsolete packages to be pkgrm'd. Mostly renamed packages.
OLD_PKGS="JDSautomake JDSautoconf JDSlibtool JDSm4 JDSgettext JDSfileutils
JDSmake JDSpatch CBEpatch JDSflex JDScvs SUNWpkgbuild"
# default log file. Changed to /tmp/desktop-cbe.install.log.$$ if the user
# installing is not root
LOGFILE=/var/sadm/install/logs/desktop-cbe.install.log.$$
# packages required for building things. cbe-install will check if they
# are installed and install them if not.
# Solaris SVr4 packages:
CBE_SVR4_DEPENDENCIES="SUNWarc SUNWgpch SUNWhea SUNWsfwhea SUNWwgetr
SUNWwgetu SUNWgtar SUNWxcu4 SUNWsprot SUNWxwinc
SUNWxorg-headers SUNWbtool SUNWlibmr SUNWlibm"
# OpenSolaris pkg(5) packages:
CBE_PKG_DEPENDENCIES="SUNWgpch SUNWhea SUNWsfwhea SUNWwget SUNWgtar
SUNWxcu4 SUNWsprot SUNWxwinc SUNWxorg-headers
SUNWbtool SUNWlibm"
# alternatives (SUNW version of tools preferred to CBE version)
# by detault install alternatives when available
install_alt=yes
# by default, install alternatives without asking
ask_alt=no
ALT_make=SUNWgmake
ALT_m4=SUNWgm4
ALT_autoconf=SUNWaconf
ALT_automake="SUNWgnu-automake-110 SUNWgnu-automake-19"
ALT_libtool=SUNWlibtool
ALT_bison=SUNWbison
ALT_coreutils=SUNWgnu-coreutils
ALT_diff=SUNWgnu-diffutils
ALT_flex=SUNWflexlex
# not yet available
#ALT_gettext=SUNWgnu-gettext
ALT_subversion=SUNWsvn
# default cbe install location
cbe_prefix=/opt/dtbld
# this should be set to a reasonable value in install_pkgbuild()
pkgbuild_topdir=/fix/me
# default value for the "who is the build user" question
logname=${LOGNAME:-`logname`}
if [ -x /usr/xpg4/bin/id ]; then
uid=`/usr/xpg4/bin/id -u`
username=`/usr/xpg4/bin/id -un`
else
uid=`/bin/id | cut -f2 -d= | cut -f1 -d'('`
username=`/bin/id |cut -f2 -d'(' | cut -f1 -d')'`
fi
export HOME="$(eval cd ~$username; pwd)"
always_uninstall_existing=
always_skip_existing=
# write a message to the log file
# not visible to the user
log () {
for msg in "${@}"; do
echo "`date`: $msg" >> $LOGFILE
done
}
# print a message to the user and also write it to the log file
msg () {
for msg in "${@}"; do
echo $msg
echo "`date`: $msg" >> $LOGFILE
done
}
# print a message to the user and also write it to the log file
msg_err () {
for msg in "${@}"; do
echo ERROR: $msg 1>&2
echo "`date`: ERROR: $msg" >> $LOGFILE
done
}
# clean up if installation is aborted
tempdirs=
remove_tempdirs () {
IFS=:
for tdir in $tempdirs; do
case "$tdir" in
/tmp/* )
cd /tmp
rm -rf "$tdir"
;;
esac
done
}
trap remove_tempdirs QUIT EXIT
# alternate root directory
rootdir=/
process_cl () {
while [ $# != 0 ]; do
case "$1" in
-R )
shift
if [ $# == 0 ]; then
echo "Option -R requires an argument."
exit 1
fi
rootdir=$1
case "$rootdir" in
/* )
;;
* )
echo "The argument to -R must be an absolute path name"
exit 1
esac
;;
-h|--help)
echo "Usage: $0 [options]"
echo "options:"
echo " -h, --help print this usage info"
echo " -R rootdir install CBE packages in alternate root directory rootdir"
echo " -k, --kde install the packages needed for building KDE"
echo " -g, --gnome install the packages needed for building GNOME"
echo " -s, --sfe install the packages needed for building GNOME"
echo " -o, --optional install the optional packages"
echo " --ask-alt ask for confirmation before installing alternative"
echo " tools ([Open]Solaris tools instead of CBE tools)"
echo " --no-alt do not install alternatives, only CBE tools"
exit 0
;;
--ask-alt)
ask_alt=yes
;;
--no-alt)
install_alt=no
;;
-k|--kde)
install_kde=yes
;;
-g|--gnome)
install_gnome=yes
;;
-s|--sfe)
install_gnome=yes
;;
-o|--optional)
install_opt=yes
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done
}
# create a build environent config file for the given build compiler
make_env () {
echo
}
# look for compilers in known locations
find_compilers () {
# FIXME: if CC = gcc, set CFLAGS to -std=c99
msg "Locating compilers..."
known_compilers="/opt/SUNWspro/bin/cc /usr/bin/cc /opt/SunStudioExpress/bin/cc /usr/sfw/bin/gcc /usr/gnu/bin/gcc"
if [ "x$CC" != x ]; then
if [ ! -x $CC ]; then
unset CC
else
echo " $known_compilers " | grep " $CC " > /dev/null || \
known_compilers="$CC $known_compilers"
fi
fi
for compiler in $known_compilers; do
if [ -x $compiler ]; then
make_env $compiler
fi
done
}
# ask the user for additional compiler locations
ask_compilers () {
:
}
# select the default compiler configuration
select_default_compiler () {
:
}
# verify that the running system is suitable for the Desktop CBE
# and set up some variables
init () {
myos=`uname -s`
if [ "x$myos" != xSunOS ]; then
echo "Run this script on a Solaris system."
exit 1
fi
umask 0022
myos_rel=`uname -r`
if [ "x$myos_rel" = "x5.10" -o "x$myos_rel" = "x5.10.1" -o "x$myos_rel" = "x5.11" ]; then
:
else
echo "Solaris 10, Solaris Nevada or OpenSolaris required."
exit 1
fi
if [ "x$myos_rel" = "x5.10" ]; then
solaris_pkg_dir=/cdrom/cdrom0/Solaris_10/Product
elif [ "x$myos_rel" = "x5.11" ]; then
solaris_pkg_dir=/cdrom/cdrom0/Solaris_11/Product
fi
mydir=$(cd $(dirname $0); pwd);
tardir=${mydir}/tarballs
CBE_VERSION=`cat $mydir/CBE_VERSION`
echo "Desktop Common Build Environment (CBE) Installer version $CBE_VERSION"
my_id=`/usr/xpg4/bin/id -u`
if [ "x$my_id" != x0 ]; then
prof_sw_inst=`/bin/profiles | nl -s: | grep 'Software Installation' | cut -f1 -d:`
prof_pri_adm=`/bin/profiles | nl -s: | grep 'Primary Administrator' | cut -f1 -d:`
prof_basic_usr=`/bin/profiles | nl -s: | grep 'Basic Solaris User' | cut -f1 -d:`
if [ "x$prof_sw_inst" = x -a "x$prof_pri_adm" = x ]; then
echo 'Run this script as root or as a user with the "Software Installation"'
echo 'or "Primary Administrator" profile.'
test -x /usr/bin/users-admin && {
echo
echo 'You can also use the users-admin program (System -> Administration ->'
echo 'Users and Groups in the GNOME menu) to assign profiles.'
echo
}
echo 'See the user_attr(4) and profiles(1) manual pages for further details'
exit 1
else
if [ "x$prof_basic_usr" != x ]; then
if [ "x$prof_sw_inst" != x ]; then
if [ $prof_sw_inst -gt $prof_basic_usr ]; then
echo 'The "Software Installation" profile in /etc/user_attr should appear'
echo 'before Basic Solaris User.'
exit 1
fi
fi
if [ "x$prof_pri_adm" != x ]; then
if [ $prof_pri_adm -gt $prof_basic_usr ]; then
echo 'The "Primary Administrator" profile in /etc/user_attr should appear'
echo 'before Basic Solaris User.'
exit 1
fi
fi
fi
fi
LOGFILE=/tmp/desktop-cbe-${CBE_VERSION}.install.log.$$
else
LOGFILE=/var/sadm/install/logs/desktop-cbe-${CBE_VERSION}.install.log.$$
fi
# svr4 or pkg(5)
check_pkg_system
msg "Using \"$PKG_SYSTEM\" packaging system"
msg "Checking for required packages..."
if [ $PKG_SYSTEM = pkg ]; then
check_cbe_dependencies_pkg $CBE_PKG_DEPENDENCIES
else
check_cbe_dependencies_svr4 $CBE_SVR4_DEPENDENCIES
fi
if [ $DEPS_OK = yes ]; then
msg "All required packages are installed."
else
if [ $DEPS_INSTALLED = yes ]; then
msg "Successfully installed all required packages"
else
msg "WARNING: some required packages are missing. Expect build issues..."
fi
fi
if ! pkginfo -R $rootdir -q 'SUNWgpch.*'; then
echo "ERROR: pkgbuild requires the GNU patch utility (/usr/bin/gpatch)."
echo "ERROR: please install SUNWgpch from your Solaris installation media"
echo "ERROR: before installing the Desktop CBE."
exit 1
fi
if ! pkginfo -R $rootdir -q 'SUNWgtar.*'; then
echo "ERROR: pkgbuild requires the GNU tar utility (/usr/sfw/bin/gtar)."
echo "ERROR: please install SUNWgtar from your Solaris installation media"
echo "ERROR: before installing the Desktop CBE."
exit 1
fi
if [ -f /usr/sfw/include/glib.h ]; then
echo "WARNING: /usr/sfw/include/glib.h is in conflict with the Desktop headers."
echo "WARNING: Please remove this file or SUNWGlib to avoid build problems."
echo
echo "Press Enter to continue"
read dummy
fi
if ! pkginfo -R $rootdir -q 'SUNWwgetu.*'; then
echo "WARNING: pkgbuild requires wget for full functionality."
echo "WARNING: please install SUNWwgetr and SUNWwgetu from your"
echo "WARNING: Solaris installation media"
echo
echo "Press Enter to continue"
read dummy
fi
log "Running on `uname -a`"
log "My directory is $mydir"
ENV_SET=`env | grep '^[a-zA-Z0-9_]*=' | cut -f1 -d=`
for var in $ENV_SET; do
case $var in
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)
;;
*)
val=`eval echo "\\\$$var"`
log "Unsetting $var (=\"$val\")"
unset $var
;;
esac
done
tempdir=`mktemp -d /tmp/cbe-install-XXXX`
tempdirs="$tempdirs:$tempdir"
if [ ! -d $tempdir ]; then
msg_err "Failed to create temporary directory in /tmp"
exit 1
fi
# if binary packages are found in the pkgs/ subdir then this is a
# binary install
if [ -f $mydir/pkgs/CBElibtool/pkginfo ]; then
binary_install=yes
pkg_arch=`grep '^ARCH=' $mydir/pkgs/CBElibtool/pkginfo | cut -f2 -d=`
arch=`uname -p`
if [ "x$arch" != "x$pkg_arch" ]; then
echo "ERROR: wrong architecture"
echo "ERROR: these Desktop CBE packages must be installed on a $pkg_arch system"
exit 1
fi
cbe_prefix=/opt/dtbld
else
binary_install=no
fi
}
# ask "question" variable_name "default answer"
#
# answer is stored in variable variable_name
ask () {
echo -n "$1"
if [ ! -z $3 ]; then
echo -n " [$3]: "
else
echo -n ": "
fi
read -e val
if [ "x$val" = x ]; then
eval "$2=\"$3\""
else
eval "$2=\"$val\""
fi
}
# ask_yes_no "question" variable_name "default answer"
#
# Answer ("yes" or "no") is stored in variable variable_name.
# Keep asking the user until the answer is yes or no.
ask_yes_no () {
yes_no_repeat=yes
while [ $yes_no_repeat = yes ]; do
yes_no_repeat=no
ask "${@}"
eval "the_ans=\"\$$2\""
case "$the_ans" in
[yY]|[yY][eE][sS] )
eval "$2=yes"
;;
[nN]|[nN][oO] )
eval "$2=no"
;;
* )
echo "Please answer yes or no"
yes_no_repeat=yes
esac
done
}
# get_dir "question" "answer_var" "default answer" "owner"
#
# Ask for a directory name and make sure it exists or create it
# for the user
get_dir () {
repeat=yes
while [ $repeat = yes ]; do
repeat=no
ask "$1" new_dir "$3"
case "$new_dir" in
/* )
# absolute path name, nothing to do
;;
~* )
if [ "x$rootdir" != x/ ]; then
msg "The Desktop CBE is being installed to an alternate root directory."
msg "You need to specify the full path to directories within the alternate root."
repeat=yes
continue
fi
d1=`echo "$new_dir" | cut -f1 -d/`
d2=`echo "$new_dir/" | cut -f2- -d/`
d1n=$(eval echo "$d1")
test -d "$d1n" || {
repeat=yes
msg "Directory not found: $d1"
continue
}
d1n=$(cd "$d1n" 2>/dev/null && pwd) || {
repeat=yes
msg "Failed to access directory: $d1"
continue
}
msg "Directory $new_dir expanded to $d1n/$d2"
new_dir="$d1n/$d2"
;;
* )
if [ "x$rootdir" != x/ ]; then
msg "The Desktop CBE is being installed to an alternate root directory."
msg "You need to specify the full path to directories within the alternate root."
repeat=yes
continue
fi
d1=`echo "$new_dir" | cut -f1 -d/`
d2=`echo "$new_dir/" | cut -f2- -d/`
d1n=$(eval echo "$d1")
test -d "$d1n" || {
repeat=yes
msg "Directory not found: $d1"
continue
}
d1n=$(cd "$d1n" 2>/dev/null && pwd) || {
repeat=yes
msg "Failed to access directory: $d1"
continue
}
msg "Directory $new_dir expanded to $d1n/$d2"
new_dir="$d1n/$d2"
;;
esac
done
if [ "x$new_dir" != "x/" ]; then
new_dir=`echo "$new_dir" | sed -e 's%/*$%%'`
fi
eval "$2=\"$new_dir\""
}
# gather info for the installation from the user
ask_defaults () {
if [ $binary_install != yes ]; then
repeat=yes
while [ $repeat = yes ]; do
repeat=no
get_dir "Enter the base directory (prefix) of the cbe" \
cbe_prefix $cbe_prefix root
if [ "$cbe_prefix" = "/" -o "$cbe_prefix" = "/tmp" ]; then
echo "This directory is not allowed."
echo "Please choose a different one as the cbe prefix"
repeat=yes
fi
done
fi
if [ ! -f "$HOME/.pkgbuildmacros" -a ! -d "$HOME/packages" ]; then
# the user probably hasn't used pkgbuild >= 1.1.0 yet
# so let's ask if they want to use a specific topdir
# instead of $HOME/packages
echo "Starting from pkgbuild 1.1.0 (CBE 1.5) there is no system-wide"
echo "build directory (%_topdir), instead, each user has their own."
echo "The default directory is \$HOME/packages."
echo "If you wish to use a different build directory, you can define it"
echo "in \$HOME/.pkgbuildmacros as follows:"
echo
echo " %_topdir /path/to/my/build/area"
echo
if [ "$uid" = 0 ]; then
echo
echo Press Enter to continue
read dummy
else
ask_yes_no "Would you like to do this now?" \
set_topdir no
if [ $set_topdir = no ]; then
log "the user chose not to change the default topdir"
echo "The default topdir ($HOME/packages) will be used"
else
get_dir "Enter your build directory" default_topdir \
"$cbe_prefix/packages" $logname
log "the user selected $default_topdir for topdir"
echo "%_topdir $default_topdir" > $HOME/.pkgbuildmacros
log "created $HOME/.pkgbuildmacros"
fi
fi
else
log "the user already has a .pkgbuildmacros file or ~/packages dir"
fi
the_cpu=`uname -p`
if [ "x$the_cpu" != xsparc ]; then
the_cpu=x86
fi
find_compilers
if [ x$install_gnome = xno -a x$install_kde = xno \
-a x$install_opt = xno -a x$install_sfe = xno ]; then
# no components selected using the CLI (--gnome, etc.)
echo
echo "The Desktop CBE includes tools for building GNOME, KDE and/or SFE packages"
echo "It also includes some optional tools. Please select the tools you wish"
echo "to install."
echo
ask_yes_no "Would you like install the tools for GNOME?" install_gnome yes
ask_yes_no "Would you like install the tools for KDE?" install_kde yes
ask_yes_no "Would you like install the tools for SFE?" install_sfe yes
echo
echo The following tools are optional: $OPTIONAL_MODULES
ask_yes_no "Would you like install the optional tools?" install_opt yes
fi
}
# create an admin file for pkgadd/pkgrm
make_admin_file () {
echo "mail=" > $1
echo "instance=unique" >> $1
echo "conflict=nocheck" >> $1
echo "conflict=quit" >> $1
echo "setuid=nocheck" >> $1
echo "action=nocheck" >> $1
echo "partial=quit" >> $1
echo "space=quit" >> $1
if [ "$2" = "pkgrm" ]; then
echo "idepend=nocheck" >> $1
echo "rdepend=nocheck" >> $1
else
echo "idepend=quit" >> $1
echo "rdepend=quit" >> $1
fi
}
# run a command, redirect the output to a log file and also print it
# on stdout
logrun () {
status_file=/tmp/.command_status.$$
/usr/bin/rm -f $status_file
log "running $*"
log "*** command output follows ***"
( "${@}" 2>&1 ; echo $? > $status_file ) | tee -a $LOGFILE
log "*** command output ends ***"
status=`cat $status_file`
/usr/bin/rm -f $status_file
return $status
}
# run a command, redirect the output to a log file and also print it
# on stdout
logrun_quiet () {
log "running $*"
log "*** command output follows ***"
"${@}" >>$LOGFILE 2>&1
status=$?
log "*** command output ends ***"
return $status
}
# check if a package is installed and if so, offer to uninstall it
check_if_installed () {
for f in $*; do
skip_package=no
pkginfo -R $rootdir -q "$f"'.*' || return 0
if [ x$always_uninstall_existing != xyes -a x$always_skip_existing != xyes ]; then
msg "Package $f is already installed."
ask_yes_no "Would you like uninstall it?" do_uninstall yes
if [ $do_uninstall = yes ]; then
if [ x$always_uninstall_existing != xno ]; then
ask_yes_no "Always uninstall previously installed packages?" \
always_uninstall_existing yes
log "always_uninstall_existing = $always_uninstall_existing"
fi
fi
else
if [ x$always_skip_existing = xyes ]; then
msg "Skipping package $f -- already installed"
skip_package=yes
return 0
else
do_uninstall=yes
fi
fi
if [ $do_uninstall = yes ]; then
log "User chose to uninstall $f"
make_admin_file /tmp/pkgrm.admin.$$ pkgrm || return 1
pkgrm_failed=no
logrun pfexec /usr/sbin/pkgrm -R $rootdir -n -a /tmp/pkgrm.admin.$$ "$f.*" || pkgrm_failed=yes
if [ $pkgrm_failed = yes ]; then
ask_yes_no "pkgrm failed. would you like to continue anyway?" pkgrm_cont no
if [ $pkgrm_cont = yes ]; then
log "User chose to continue anyway"
return 0
fi
return 1
fi
return 0
else
log "User chose not to uninstall $f"
if [ x$always_skip_existing != xyes ]; then
ask_yes_no "Would you like skip to the next package?
(\"no\" means the installer will try to build and install a duplicate package)" skip_package yes
if [ $skip_package = yes ]; then
log "User chose to skip package $f"
if [ x$always_skip_existing != xno ]; then
ask_yes_no "Always skip packages that are already installed?" always_skip_existing yes
log "always_skip_existing = $always_skip_existing"
fi
return 0
fi
else
skip_package=yes
return 0
fi
msg "Not uninstalling $f."
msg "NOTE that this may cause problems later"
ask "Press Enter to continue" dummy ""
return 0
fi
done
return 0
}
# install a list of svr4 packages given its directory, altroot and the
# names of the packages
install_pkgs () {
pdir=$1; shift
rdir=$1; shift
make_admin_file $tempdir/pkgadd.admin.$$ pkgadd
for pkg in $*; do
msg "Installing package $pkg"
logrun pfexec /usr/sbin/pkgadd -R "$rdir" -n -a $tempdir/pkgadd.admin.$$ -d "$pdir" $pkg || \
return 1
done
/usr/bin/rm -f $tempdir/pkgadd.admin.$$
return 0
}
# check if the system is pkg(5) based or SVr4 based
# To identify, we check which system was used to install SUNWcs/SUNWcsu
# Output: set the PKG_SYSTEM variable with either pkg or svr4
check_pkg_system () {
if [ -x /usr/bin/pkg -a -d /var/pkg/catalog ]; then
pkg -R $rootdir list SUNWcs > /dev/null 2>&1 && {
PKG_SYSTEM=pkg
return
}
fi
pkginfo -R $rootdir -q SUNWcsu && {
PKG_SYSTEM=svr4
return
}
msg_err "Could not identify the packaging system"
exit 1
}
pkg_refreshed=no
pkg_refresh () {
if [ $pkg_refreshed = no ]; then
msg "Refeshing the package catalogs..."
logrun_quiet pfexec pkg -R $rootdir refresh
pkg_refreshed=yes
fi
}
pkg_try_install () {
pkg_refresh
pfexec pkg -R $rootdir install -q $1 && {
msg "$1 installed successfully"
return 0
} || {
msg "Failed to install package $1"
msg "Retrying in verbose mode:"
pfexec pkg -R $rootdir install -v $1 && {
msg "$1 installed successfully"
return 0
} || {
msg "Installation of $1 failed again."
ask_yes_no "Would you like to continue? (no means exit)" ans_continue no
if [ $ans_continue = no ]; then
exit 1
fi
DEPS_INSTALLED=no
return 1
}
}
}
install_all_dependencies=
skip_all_dependencies=
check_cbe_dependencies_pkg () {
DEPS_OK=yes
DEPS_INSTALLED=no
for pkg in $*; do
pkg -R $rootdir list $pkg > /dev/null 2>&1 && {
log "$pkg is installed"
} || {
log "$pkg is not installed"
DEPS_OK=no
if [ x$skip_all_dependencies = xyes ]; then
msg " $pkg is not installed (skipping)"
elif [ x$install_all_dependencies = xyes ]; then
pkg_try_install $pkg
elif [ x$install_all_dependencies = x ]; then
msg "Package $pkg is not installed"
ask_yes_no "Would you like the CBE installer to install this package for you?" ans_install_dep "yes"
if [ $ans_install_dep = yes ]; then
ask_yes_no "Would you like the CBE installer to install all required packages?" install_all_dependencies yes
pkg_try_install $pkg && {
DEPS_INSTALLED=yes
}
else
# user chose not to install this dep
DEPS_INSTALLED=no
log "The user chose not to install $pkg"
if [ x$skip_all_dependencies = x ]; then
ask_yes_no "Would you like to skip all missing packages?" skip_all_dependencies no
fi
fi
elif [ x$install_all_dependencies = xno ]; then
msg "Package $pkg is not installed"
ask_yes_no "Install this package?" ans_install_dep "yes"
if [ $ans_install_dep = yes ]; then
pkg_try_install $pkg
fi
fi
}
done
}
install_all_dependencies=
skip_all_dependencies=
# check if the pkgs GNOME or KDE requires are installed; if not install them
check_cbe_dependencies_svr4 () {
DEPS_OK=yes
DEPS_INSTALLED=yes
# we're going to cp solaris pkgs from the media to this dir
tmp_pkg_dir=`mktemp -d /tmp/cbe-pkgs-XXXX`
# schedule this dir for removal if the installation is aborted
tempdirs="$tempdirs:$tmp_pkg_dir"
if [ ! -d $tmp_pkg_dir ]; then
msg_err "Failed to create temporary directory in /tmp"
exit 1
fi
for pkg in $*; do
pkginfo -R $rootdir -q "$pkg."'*' && continue
DEPS_OK=no
if [ x$skip_all_dependencies = xyes ]; then
msg " $pkg is not installed (skipping)"
continue
elif [ x$install_all_dependencies = x ]; then
msg "Package $pkg is not installed"
ask_yes_no "Would you like the CBE installer to install this package for you?" ans_install_dep "yes"
if [ $ans_install_dep = yes ]; then
ask_yes_no "Would you like the CBE installer to install all required packages?" install_all_dependencies yes
while /bin/true; do
ask "Enter the path to the Solaris packages" \
solaris_pkg_dir "$solaris_pkg_dir"
# Copy all packages found in $solaris_pkg_dir to a temporary
# dir so that people installing from CDs don't need to
# swap CDs all the time...
for p0 in $CBE_SVR4_DEPENDENCIES; do
# already copied to the tmp dir
test -d $tmp_pkg_dir/$p0 && continue
# already installed, no need to copy
pkginfo -q $p0 && continue
test -d "$solaris_pkg_dir/$p0" && \
/bin/cp -pr "$solaris_pkg_dir/$p0" $tmp_pkg_dir && \
/bin/chmod -R u+w $tmp_pkg_dir/$p0
done
test -d "$solaris_pkg_dir/$pkg" && break
msg "$solaris_pkg_dir/$pkg not found"
done
else
log "The user chose not to install $pkg"
DEPS_INSTALLED=no
if [ x$skip_all_dependencies = x ]; then
ask_yes_no "Would you like to skip all missing packages?" skip_all_dependencies no
fi
continue
fi
elif [ x$install_all_dependencies = xno ]; then
msg "Package $pkg is not installed"
ask_yes_no "Install this package?" ans_install_dep "yes"
if [ $ans_install_dep = no ]; then
DEPS_INSTALLED=no
continue
fi
fi
while /bin/true; do
msg "Installing package $pkg"
make_admin_file /tmp/pkgadd.admin.$$ pkgadd
if [ -d $tmp_pkg_dir/$pkg ]; then
logrun pfexec /usr/sbin/pkgadd -R $rootdir -n -a /tmp/pkgadd.admin.$$ -d "$tmp_pkg_dir" $pkg
if [ $? != 0 ]; then
msg "WARNING: failed to install required package $pkg"
ask_yes_no "Would you like to retry?" "do_retry" "yes"
if [ $do_retry = no ]; then
DEPS_INSTALLED=no
fi
else
do_retry=no_need_to
fi
else
msg "Package $pkg was not found in $solaris_pkg_dir"
do_retry=yes
/bin/true
fi
if [ $do_retry = yes ]; then
while /bin/true; do
ask "Enter the path to the Solaris packages" \
solaris_pkg_dir "$solaris_pkg_dir"
test -d "$solaris_pkg_dir/$pkg" && break
msg "$solaris_pkg_dir/$pkg not found"
done
# Copy all packages found in $solaris_pkg_dir to a temporary
# dir so that people installing from CDs don't need to
# swap CDs all the time...
for p0 in $CBE_SVR4_DEPENDENCIES; do
test -d "$solaris_pkg_dir/$p0" && \
/bin/cp -pr "$solaris_pkg_dir/$p0" $tmp_pkg_dir && \
/bin/chmod -R u+w $tmp_pkg_dir/$p0
done
elif [ $do_retry = no ]; then
ask_yes_no "Continue installation anyway?" \
do_continue no
if [ $do_continue = no ]; then
/bin/rm -f /tmp/pkgadd.admin.$$
/bin/rm -rf $tmp_pkg_dir
msg "Installation aborted."
exit 1
else
DEPS_INSTALLED=no
break
fi
break
else
/bin/rm -rf $tmp_pkg_dir/$pkg
/bin/rm -f /tmp/pkgadd.admin.$$
break
fi
done
done
/bin/rm -rf $tmp_pkg_dir
}
# install pkgbuild from tarball to a temp location and then build a
# pkgbuild pkg using itself
install_pkgbuild () {
check_if_installed SFpkgbuild || {
pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=`
return 1
}
if [ $skip_package = yes ]; then
return 0
fi
export PATH=/usr/ccs/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/usr/sfw/bin
# we're going to build pkgbuild in this directory
tmp_build_dir=`mktemp -d /tmp/cbe-build-XXXX`
# schedule this dir for removal if the installation is aborted
tempdirs="$tempdirs:$tmp_build_dir"
if [ ! -d $tmp_build_dir ]; then
msg_err "Failed to create temporary directory in /tmp"
exit 1
fi
cd $tmp_build_dir || return 1
logrun mkdir -p src || return 1
cd src || return 1
logrun bash -c "bzcat $tardir/pkgbuild-$PKGBUILD_VERSION.tar.bz2 | tar xf -" || return 1
cd pkgbuild-$PKGBUILD_VERSION || return 1
msg "Building pkgbuild from source..."
# FIXME: delete this when find_compilers is finisheed
export CC=/usr/sfw/bin/gcc
export CFLAGS='-std=c99'
logrun_quiet ./configure --prefix="$tmp_build_dir" || return 1
logrun_quiet make install || return 1
msg "Now rebuilding pkgbuild using itself..."
logrun mkdir -p $tmp_build_dir/packages/SOURCES || return 1
logrun ln -s $tardir/pkgbuild-$PKGBUILD_VERSION.tar.bz2 $tmp_build_dir/packages/SOURCES/ || return 1
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
make_admin_file $tempdir/pkgadd.admin.$$ pkgadd
logrun pfexec /usr/sbin/pkgadd -R $rootdir -n -a $tempdir/pkgadd.admin.$$ -d "$tmp_build_dir/packages/PKGS" SFpkgbuild || return 1
pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=`
logrun mkdir -p "$rootdir/$pkgbuild_topdir/PKGS" "$rootdir/$pkgbuild_topdir/SPKGS"
logrun cp -pr "$tmp_build_dir/packages/SPKGS/SFpkgbuild-src" "$rootdir/$pkgbuild_topdir/SPKGS"
logrun cp -pr "$tmp_build_dir/packages/PKGS/SFpkgbuild" "$rootdir/$pkgbuild_topdir/PKGS"
cd /tmp || return 1
logrun /usr/bin/rm -rf $tmp_build_dir || return 1
return 0
}
# build and install a package
build_pkg () {
install_pkgs "$rootdir$pkgbuild_topdir/PKGS" "$rootdir" "$3" || return 1
}
# older versions of the JDS CBE included packages that were renamed or
# no longer included. These older JDS CBEs only supported SVr4.
uninstall_old_cbe () {
pkg_info=
for pkg in $OLD_PKGS; do
pkginfo -R $rootdir -q "$pkg."'*' && pkg_info="$pkg_info
`pkginfo -R $rootdir $pkg.'*'`"
done
if [ ! -z "$pkg_info" ]; then
echo "The following packages belong to an obsolete version of the JDS CBE."
echo "$pkg_info"
echo
ask_yes_no "Would you like to uninstall them?" do_uninst yes
if [ $do_uninst = yes ]; then
log "User chose to uninstall obsolete CBE pkgs"
make_admin_file $tempdir/pkgrm.admin.$$ pkgrm
pkgrm_failed=no
for pkg in $OLD_PKGS; do
if pkginfo -R $rootdir -q "$pkg."'*'; then
logrun pfexec /usr/sbin/pkgrm -R $rootdir -n -a $tempdir/pkgrm.admin.$$ "$pkg."'*' || \
pkgrm_failed=yes
fi
done
rm -f $tempdir/pkgrm.admin.$$
if [ $pkgrm_failed = yes ]; then
msg "Failed to remove one or more packages"
ask_yes_no "Would you like to continue anyway?" do_cont no
if [ $do_cont = no ]; then
return 1
else
log "User chose to continue anyway"
return 0
fi
fi
fi
fi
return 0
}
main () {
init
uninstall_old_cbe || return 1
ask_defaults
pkginfo -q -R $rootdir CBEenv && {
msg "Uninstalling CBEenv"
make_admin_file /tmp/pkgrm.admin.$$ pkgrm || return 1
logrun pfexec /usr/sbin/pkgrm -R $rootdir -n -a /tmp/pkgrm.admin.$$ "CBEenv.*"
rm -f /tmp/pkgrm.admin.$$
}
ALL_MODULES=
if [ $install_gnome = yes ]; then
ALL_MODULES="$ALL_MODULES $GNOME_MODULES"
fi
if [ $install_kde = yes ]; then
ALL_MODULES="$ALL_MODULES $KDE_MODULES"
fi
if [ $install_sfe = yes ]; then
ALL_MODULES="$ALL_MODULES $SFE_MODULES"
fi
if [ $install_opt = yes ]; then
ALL_MODULES="$ALL_MODULES $OPT_MODULES"
fi
ALL_MODULES=$(echo $ALL_MODULES | sed -e 's/ /\
/g' | sort -u)
if [ $binary_install = no ]; then
install_pkgbuild || return 1
else
check_if_installed SFpkgbuild || return 1
if [ $skip_package != yes ]; then
install_pkgs "$mydir/pkgs" "$rootdir" SFpkgbuild || return 1
fi
fi
pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=`
cd $mydir
# identify the CBE packages to be built/installed
ALL_SPECS=
ALL_CBE_PKGS=
for mod in $ALL_MODULES; do
pkgs=$($cbe_prefix/bin/spectool get_packages CBE${mod}.spec)
check_if_installed $pkgs || return 1
# skip_package is set by check_if_installed
if [ $skip_package = yes ]; then
continue
fi
# On Nevada and OpenSolaris use alternatives if available
if [ $install_alt = yes -a "x$myos_rel" = x5.11 ]; then
eval ALT=\"$(eval echo \$ALT_$mod)\"
if [ "x$ALT" != x ]; then
if [ $ask_alt = yes ]; then
ask_yes_no "Use $ALT ($mod) instead of CBE $mod?" \
use_alt yes
if [ $use_alt = no ]; then
ALL_CBE_PKGS="$ALL_CBE_PKGS $pkgs"
ALL_SPECS="$ALL_SPECS CBE${mod}.spec"
continue
fi
fi
msg "Looking for package $ALT"
check_cbe_dependencies_$PKG_SYSTEM $(eval echo $ALT)
if [ $DEPS_OK = yes ]; then
msg " ... already installed"
continue
elif [ $DEPS_INSTALLED = yes ]; then
msg "Successfully installed $ALT"
continue
else
msg "Using the CBE version of $mod"
ALL_SPECS="$ALL_SPECS CBE${mod}.spec"
ALL_CBE_PKGS="$ALL_CBE_PKGS $pkgs"
fi
fi
else
# alternatives should not be used
ALL_SPECS="$ALL_SPECS CBE${mod}.spec"
ALL_CBE_PKGS="$ALL_CBE_PKGS $pkgs"
fi
done
if [ $binary_install = no ]; then
export "PATH=$rootdir$cbe_prefix/bin:/usr/ccs/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/usr/sfw/bin"
if [ "x$rootdir" != x/ ]; then
export AC_MACRODIR="$rootdir$cbe_prefix/share/autoconf"
sed -e "s%--prepend-include %--prepend-include $rootdir%" "$rootdir$cbe_prefix/share/autoconf/autom4te.cfg" > $tempdir/autom4te.cfg
export AUTOM4TE_CFG="$tempdir/autom4te.cfg"
export autom4te_perllibdir="$rootdir$cbe_prefix/share/autoconf"
export AUTOM4TE="$rootdir$cbe_prefix/bin/autom4te"
fi
ALL_SPECS=$($cbe_prefix/bin/pkgtool -q build-order $ALL_SPECS)
for spec in $ALL_SPECS; do
pkgs=$($cbe_prefix/bin/spectool get_packages $spec)
# build the package
logrun $cbe_prefix/bin/pkgtool --define "cbe_prefix $cbe_prefix" --define "cbe_version $CBE_VERSION" build-only $spec || return 1
for pkg in $pkgs; do
install_pkgs "$rootdir$pkgbuild_topdir/PKGS" "$rootdir" "$pkg" || return 1
done
done
else
# binary install
install_pkgs "$mydir/pkgs" "$rootdir" $ALL_CBE_PKGS || return 1
pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=`
fi
log "Creating env.sh"
logrun mkdir -p $rootdir$pkgbuild_topdir/SOURCES || return 1
build_info="built on `date +%Y-%m-%d` by ${logname}@`hostname`"
logrun_quiet bash -c "sed -e \"s%@CBE_PREFIX@%$cbe_prefix%\" \
-e \"s%@JDS_PREFIX@%$JDS_PREFIX%\" \
-e \"s%@CC32@%$cc32dir/$cc_name%\" \
-e \"s%@CXX32@%$cc32dir/$cxx_name%\" \
-e \"s%@CC64@%$cc64dir/$cc_name%\" \
-e \"s%@CXX64@%$cc64dir/$cxx_name%\" \
-e \"s%@CBE_VERSION@%$CBE_VERSION%\" \
-e \"s%@BUILD_INFO@%$build_info%\" \
$mydir/ext-sources/env.sh > $rootdir$pkgbuild_topdir/SOURCES/env.sh" || \
return 1
log "Creating env.csh"
logrun_quiet bash -c "sed -e \"s%@CBE_PREFIX@%$cbe_prefix%\" \
-e \"s%@JDS_PREFIX@%$JDS_PREFIX%\" \
-e \"s%@CC32@%$cc32dir/$cc_name%\" \
-e \"s%@CXX32@%$cc32dir/$cxx_name%\" \
-e \"s%@CC64@%$cc64dir/$cc_name%\" \
-e \"s%@CXX64@%$cc64dir/$cxx_name%\" \
-e \"s%@CBE_VERSION@%$CBE_VERSION%\" \
-e \"s%@BUILD_INFO@%$build_info%\" \
$mydir/ext-sources/env.csh > $rootdir$pkgbuild_topdir/SOURCES/env.csh" || \
return 1
log "Copying ld-wrapper"
logrun bash -c "cp $mydir/ext-sources/ld-wrapper $rootdir$pkgbuild_topdir/SOURCES" || \
return 1
logrun_quiet $cbe_prefix/bin/pkgbuild --define "cbe_prefix $cbe_prefix" --define "cbe_version $CBE_VERSION" -ba CBEenv.spec || return 1
logrun $cbe_prefix/bin/pkgtool install-pkgs CBEenv.spec || return 1
msg "CBE setup complete"
echo "Run"
echo " . $cbe_prefix/bin/env.sh"
echo "or"
echo " source $cbe_prefix/bin/env.csh"
echo "depending on your shell, to use this build environment."
}
process_cl "${@}"
main || msg "CBE setup FAILED"
echo "Installation log saved in $LOGFILE"