cbe-install
author laca
Mon, 14 Apr 2008 10:39:56 +0000
changeset 1 102c9870ef63
child 10 a65a967018ee
permissions -rwxr-xr-x
initial import -- still incomplete
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     1
#!/bin/bash
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     2
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     3
# Script for setting up the common build environment for JDS on Solaris
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     4
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     5
# CDDL HEADER START
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     6
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     7
# The contents of this file are subject to the terms of the
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     8
# Common Development and Distribution License, Version 1.0 only
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
     9
# (the "License").  You may not use this file except in compliance
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    10
# with the License.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    11
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    12
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    13
# or http://www.opensolaris.org/os/licensing.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    14
# See the License for the specific language governing permissions
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    15
# and limitations under the License.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    16
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    17
# When distributing Covered Code, include this CDDL HEADER in each
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    18
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    19
# If applicable, add the following below this CDDL HEADER, with the
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    20
# fields enclosed by brackets "[]" replaced with your own identifying
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    21
# information: Portions Copyright [yyyy] [name of copyright owner]
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    22
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    23
# CDDL HEADER END
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    24
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    25
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    26
# Copyright 2004-2005 Sun Microsystems, Inc.  All rights reserved.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    27
# Use is subject to license terms.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    28
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    29
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    30
IFS=' 	
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    31
'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    32
PKGBUILD_VERSION=1.2.0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    33
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    34
# Set to "internal" for sun internal users, "external" for opensolaris
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    35
# No big differences really, just slightly different defaults
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    36
INT_EXT=@INT_EXT@
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    37
if [ "x$INT_EXT" != xinternal -a "x$INT_EXT" != xexternal ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    38
    INT_EXT=internal
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    39
fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    40
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    41
# all tarballs need a FOO_TARBALL variable here to be included in the
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    42
# CBE dist tarball
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    43
M4_TARBALL=m4-1.4.5.tar.gz
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    44
AUTOMAKE_1_9_TARBALL=automake-1.9.6.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    45
AUTOMAKE_1_10_TARBALL=automake-1.10.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    46
AUTOCONF_TARBALL=autoconf-2.61.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    47
LIBTOOL_TARBALL=libtool-1.5.22.tar.gz
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    48
GETTEXT_TARBALL=gettext-0.14.1.tar.gz
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    49
FILEUTILS_TARBALL=fileutils-4.1.tar.gz
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    50
MAKE_TARBALL=make-3.80.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    51
FLEX_TARBALL=flex-2.5.33.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    52
CVS_TARBALL=cvs-1.12.5.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    53
BISON_TARBALL=bison-2.3.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    54
DIFF_TARBALL=diffutils-2.8.1.tar.gz
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    55
ANT_TARBALL=apache-ant-1.6.5-bin.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    56
SVN_TARBALL=subversion-1.3.2.tar.bz2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    57
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    58
# Extra packages:
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    59
RSYNC_TARBALL=rsync-2.6.8.tar.gz
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    60
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    61
# Obsolete packages to be pkgrm'd.  Mostly renamed packages.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    62
OLD_PKGS="JDSautomake JDSautoconf JDSlibtool JDSm4 JDSgettext JDSfileutils 
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    63
          JDSmake JDSpatch CBEpatch JDSflex JDScvs SUNWpkgbuild"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    64
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    65
# default log file.  Changed to /tmp/jds-cbe.install.log.$$ if the user
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    66
# installing is not root
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    67
LOGFILE=/var/sadm/install/logs/jds-cbe.install.log.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    68
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    69
# packages that the JDS build requires.  cbe-install will check if they
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    70
# are installed and install them if not.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    71
JDS_DEPENDENCIES="SUNWgpch SUNWi2cs SUNWi1cs SUNWi15cs SUNWceuos
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    72
    SUNWcleu SUNWeuluf SUNWdeiso1 SUNWi5cs SUNWi13cs
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    73
    SUNWi9cs SUNWeeuos SUNWi7cs SUNWesiso1 SUNWcleu2
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    74
    SUNWeu8os SUNWfriso1 SUNWale SUNWhkleu SUNWhleu
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    75
    SUNWinleu SUNWitiso1 SUNWjfpu SUNWkleu SUNWmeaos
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    76
    SUNWsmbaS SUNWnafos SUNWnamos SUNWneuos SUNWsamos
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    77
    SUNWseuos SUNWsviso1 SUNWtleu SUNWweuos SUNWgtar
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    78
    SUNWwgetr SUNWwgetu SUNWhea SUNWsfwhea
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    79
    SUNWsprot SUNWxcu4"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    80
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    81
# all non-optional CBE packages
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    82
CBE_PKGS="SFpkgbuild CBEmake CBEcvs CBEm4 CBEautoconf CBEautomake
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    83
    CBElibtool CBEgettext CBEfileutils CBEflex CBEbison CBEdiff
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    84
    CBEant CBEsvn"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    85
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    86
# default cbe install location
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    87
cbe_prefix=/opt/jdsbld
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    88
# this should be set to a reasonable value in install_pkgbuild()
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    89
pkgbuild_topdir=/fix/me
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    90
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    91
# default value for the "who is the build user" question
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    92
logname=${LOGNAME:-`logname`}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    93
if [ -x /usr/xpg4/bin/id ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    94
    uid=`/usr/xpg4/bin/id -u`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    95
    username=`/usr/xpg4/bin/id -un`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    96
else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    97
    uid=`/bin/id | cut -f2 -d= | cut -f1 -d'('`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    98
    username=`/bin/id |cut -f2 -d'(' | cut -f1 -d')'`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
    99
fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   100
export HOME="$(eval cd ~$username; pwd)"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   101
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   102
# compiler to use for Solaris9 builds (cc -V)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   103
fd7_name='Forte Developer 7'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   104
fd7_sgnome_dir='FD7'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   105
fd7_sparc_version_string='cc: Forte Developer 7 C 5.4 2002/03/09'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   106
fd7_i386_version_string='cc: Forte Developer 7 C 5.4 2002/03/09'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   107
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   108
# compiler to use for Solaris10 builds (cc -V)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   109
k2_name='Sun ONE Studio 8 (K2)'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   110
k2_sgnome_dir='SOS8'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   111
k2_sparc_version_string='cc: Sun C 5.5 Patch 112760-08 2004/02/20'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   112
k2_i386_version_string='cc: Sun C 5.5 Patch 112761-06 2004/01/13'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   113
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   114
vulcan_name='Sun Studio 10 (Vulcan)'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   115
vulcan_sgnome_dir='vulcan-0107/opt'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   116
if [ $INT_EXT = internal ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   117
    # compiler to use for amd64 builds + TJDS + SNV + GNOME 2.10 (S10/x86)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   118
    # version string of the compiler in /sgnome
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   119
    vulcan_i386_version_string='cc: Sun C 5.7 Patch 117837-04 2005/05/11'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   120
    vulcan_sparc_version_string='cc: Sun C 5.7 2005/01/07'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   121
else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   122
    # the current (as of 26/Sept/2005) version on opensolaris.org
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   123
    # version string of the compiler available from opensolaris.org
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   124
    vulcan_i386_version_string='cc: Sun C 5.7 Patch 117837-04 2005/05/11'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   125
    vulcan_sparc_version_string='cc: Sun C 5.7 Patch 117836-03 2005/05/11'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   126
fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   127
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   128
# Sun Studio 11 (aka venus) version strings:
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   129
venus_name='Sun Studio 11 (Venus)'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   130
venus_sgnome_dir="ONNV-TOOLS"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   131
venus_alt_dirs="/sgnome/onnv-tools/`uname -p`/SS11/bin /ws/onnv-tools/SUNWspro/SS11/bin"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   132
venus_sparc_version_string="cc: Sun C 5.8 Patch 121015-02 2006/03/29"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   133
venus_i386_version_string="cc: Sun C 5.8 Patch 121016-02 2006/03/31"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   134
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   135
# Sun Studio 11 (aka venus) with the new patches in /ws/onnv-tools
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   136
venus_p05_name='Sun Studio 11 (Venus) + patches'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   137
venus_p05_sgnome_dir="ONNV-TOOLS"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   138
venus_p05_alt_dirs="/sgnome/onnv-tools/`uname -p`/SS11-new/bin /ws/onnv-tools/SUNWspro/SS11-new/bin /sgnome/onnv-tools/`uname -p`/SS11/bin /ws/onnv-tools/SUNWspro/SS11/bin"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   139
venus_p05_sparc_version_string="cc: Sun C 5.8 Patch 121015-04 2007/01/10"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   140
venus_p05_i386_version_string="cc: Sun C 5.8 Patch 121016-05 2007/01/10"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   141
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   142
always_uninstall_existing=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   143
always_skip_existing=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   144
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   145
# write a message to the log file
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   146
# not visible to the user
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   147
log () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   148
    for msg in "${@}"; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   149
	echo "`date`: $msg" >> $LOGFILE
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   150
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   151
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   152
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   153
# print a message to the user and also write it to the log file
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   154
msg () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   155
    for msg in "${@}"; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   156
	echo $msg
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   157
	echo "`date`: $msg" >> $LOGFILE
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   158
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   159
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   160
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   161
# alternate root directory
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   162
rootdir=/
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   163
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   164
process_cl () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   165
    while [ $# != 0 ]; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   166
	case "$1" in
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   167
	    -R )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   168
		shift
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   169
		if [ $# == 0 ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   170
		    echo "Option -R requires an argument."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   171
		    exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   172
		fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   173
		rootdir=$1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   174
		case "$rootdir" in
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   175
		    /* )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   176
			;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   177
		    * )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   178
			echo "The argument to -R must be an absolute path name"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   179
			exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   180
		esac
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   181
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   182
	    -h|--help)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   183
		echo "Usage: $0 [options]"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   184
		echo "options:"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   185
		echo "   -h, --help        print this usage info"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   186
		echo "   -R rootdir        install CBE packages in alternate root directory rootdir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   187
		exit 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   188
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   189
	    *)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   190
		echo "Unknown option: $1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   191
		exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   192
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   193
	esac
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   194
	shift
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   195
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   196
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   197
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   198
# clean up if installation is aborted
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   199
tempdirs=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   200
remove_tempdirs () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   201
    IFS=:
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   202
    for tdir in $tempdirs; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   203
	case "$tdir" in
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   204
	    /tmp/* )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   205
                cd /tmp
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   206
		rm -rf "$tdir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   207
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   208
	esac
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   209
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   210
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   211
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   212
init () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   213
    myos=`uname -s`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   214
    if [ "x$myos" != xSunOS ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   215
	echo "Run this script on a Solaris system."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   216
	exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   217
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   218
    
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   219
    umask 0022
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   220
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   221
    myos_rel=`uname -r`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   222
    if [ "x$myos_rel" = "x5.10" -o "x$myos_rel" = "x5.10.1" -o "x$myos_rel" = "x5.11" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   223
	if [ $INT_EXT = external ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   224
	    cc32_versions='venus_p05 venus vulcan'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   225
	    cc64_versions='venus_p05 venus vulcan'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   226
	else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   227
	    cc32_versions='venus venus_p05'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   228
	    cc64_versions='venus venus_p05'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   229
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   230
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   231
	echo "Solaris 10 or Solaris 11 required."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   232
	exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   233
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   234
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   235
    mydir=$(cd $(dirname $0); pwd);
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   236
    tardir=$mydir/tarballs
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   237
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   238
    CBE_VERSION=`cat $mydir/CBE_VERSION`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   239
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   240
    my_id=`/usr/xpg4/bin/id -u`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   241
    if [ "x$my_id" != x0 ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   242
	profiles | grep 'Software Installation' > /dev/null
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   243
	if [ $? != 0 ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   244
	    echo 'Run this script as root or a user with the "Software Installation" profile'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   245
	    echo 'See the user_attr(4) and profiles(1) manual pages for details'
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   246
	    exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   247
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   248
	LOGFILE=/tmp/jds-cbe-${CBE_VERSION}.install.log.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   249
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   250
	LOGFILE=/var/sadm/install/logs/jds-cbe-${CBE_VERSION}.install.log.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   251
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   252
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   253
    msg "Checking for required packages..."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   254
    check_jds_dependencies
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   255
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   256
    if ! pkginfo -R $rootdir -q 'SUNWgpch.*'; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   257
	echo "ERROR: pkgbuild requires the GNU patch utility (/usr/bin/gpatch)."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   258
	echo "ERROR: please install SUNWgpch from your Solaris installation media"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   259
	echo "ERROR: before installing the JDS CBE."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   260
	exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   261
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   262
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   263
    if ! pkginfo -R $rootdir -q 'SUNWgtar.*'; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   264
	echo "ERROR: pkgbuild requires the GNU tar utility (/usr/sfw/bin/gtar)."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   265
	echo "ERROR: please install SUNWgtar from your Solaris installation media"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   266
	echo "ERROR: before installing the JDS CBE."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   267
	exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   268
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   269
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   270
    if [ -f /usr/sfw/include/glib.h ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   271
	echo "WARNING: /usr/sfw/include/glib.h is in conflict with the JDS headers."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   272
	echo "WARNING: Please remove this file or SUNWGlib to avoid build problems."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   273
	echo
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   274
	echo "Press Enter to continue"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   275
	read dummy
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   276
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   277
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   278
    if ! pkginfo -R $rootdir -q 'SUNWwgetu.*'; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   279
	echo "WARNING: pkgbuild requires wget for full functionality."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   280
	echo "WARNING: please install SUNWwgetr and SUNWwgetu from your"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   281
	echo "WARNING: Solaris installation media"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   282
	echo
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   283
	echo "Press Enter to continue"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   284
	read dummy
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   285
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   286
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   287
    log "Running on `uname -a`"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   288
    log "My directory is $mydir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   289
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   290
    ENV_SET=`env | cut -f1 -d=`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   291
    for var in $ENV_SET; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   292
	case $var in
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   293
	    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)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   294
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   295
	    *)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   296
		val=`eval echo "\\\$$var"`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   297
		log "Unsetting $var (=\"$val\")"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   298
		unset $var
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   299
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   300
	esac
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   301
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   302
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   303
    tempdir=/tmp/cbe-install.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   304
    tempdirs="$tempdirs:$tempdir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   305
    trap remove_tempdirs QUIT EXIT
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   306
    logrun mkdir -p $tempdir
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   307
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   308
    if [ -f $mydir/pkgs/CBElibtool/pkginfo ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   309
	binary_install=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   310
	pkg_arch=`grep '^ARCH=' $mydir/pkgs/CBElibtool/pkginfo | cut -f2 -d=`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   311
	arch=`uname -p`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   312
	if [ "x$arch" != "x$pkg_arch" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   313
	    echo "ERROR: wrong architecture"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   314
	    echo "ERROR: these JDS CBE packages must be installed on a $pkg_arch system"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   315
	    exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   316
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   317
	cbe_prefix=/opt/jdsbld
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   318
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   319
	binary_install=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   320
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   321
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   322
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   323
# ask "question" variable_name "default answer"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   324
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   325
# answer is stored in variable variable_name
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   326
ask () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   327
    echo -n "$1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   328
    if [ ! -z $3 ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   329
	echo -n " [$3]: "
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   330
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   331
	echo -n ": "
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   332
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   333
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   334
    read -e val
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   335
    if [ "x$val" = x ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   336
	eval "$2=\"$3\""
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   337
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   338
	eval "$2=\"$val\""
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   339
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   340
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   341
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   342
# ask_yes_no "question" variable_name "default answer"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   343
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   344
# Answer ("yes" or "no") is stored in variable variable_name.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   345
# Keep asking the user until the answer is yes or no.
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   346
ask_yes_no () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   347
    yes_no_repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   348
    while [ $yes_no_repeat = yes ]; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   349
	yes_no_repeat=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   350
	ask "${@}"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   351
	eval "the_ans=\"\$$2\""
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   352
	case "$the_ans" in
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   353
	    [yY]|[yY][eE][sS] )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   354
                eval "$2=yes"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   355
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   356
 	    [nN]|[nN][oO] )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   357
		eval "$2=no"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   358
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   359
	    * )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   360
	        echo "Please answer yes or no"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   361
		yes_no_repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   362
	esac
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   363
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   364
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   365
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   366
# get_dir "question" "answer_var" "default answer" "owner"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   367
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   368
# Ask for a directory name and make sure it exists or create it
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   369
# for the user
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   370
get_dir () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   371
    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   372
    while [ $repeat = yes ]; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   373
	repeat=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   374
	ask "$1" new_dir "$3"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   375
	case "$new_dir" in
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   376
	    /* )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   377
                # absolute path name, nothing to do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   378
                ;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   379
	    ~* )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   380
	        if [ "x$rootdir" != x/ ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   381
		    msg "The JDS CBE is being installed to an alternate root directory."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   382
		    msg "You need to specify the full path to directories within the alternate root."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   383
		    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   384
		    continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   385
	        fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   386
		d1=`echo "$new_dir" | cut -f1 -d/`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   387
		d2=`echo "$new_dir/" | cut -f2- -d/`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   388
		d1n=$(eval echo "$d1")
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   389
		test -d "$d1n" || {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   390
		    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   391
		    msg "Directory not found: $d1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   392
		    continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   393
                }
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   394
		d1n=$(cd "$d1n" 2>/dev/null && pwd) || {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   395
		    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   396
		    msg "Failed to access directory: $d1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   397
		    continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   398
		}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   399
		msg "Directory $new_dir expanded to $d1n/$d2"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   400
		new_dir="$d1n/$d2"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   401
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   402
	    * )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   403
	        if [ "x$rootdir" != x/ ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   404
		    msg "The JDS CBE is being installed to an alternate root directory."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   405
		    msg "You need to specify the full path to directories within the alternate root."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   406
		    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   407
		    continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   408
	        fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   409
		d1=`echo "$new_dir" | cut -f1 -d/`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   410
		d2=`echo "$new_dir/" | cut -f2- -d/`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   411
		d1n=$(eval echo "$d1")
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   412
		test -d "$d1n" || {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   413
		    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   414
		    msg "Directory not found: $d1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   415
		    continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   416
                }
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   417
		d1n=$(cd "$d1n" 2>/dev/null && pwd) || {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   418
		    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   419
		    msg "Failed to access directory: $d1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   420
		    continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   421
		}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   422
		msg "Directory $new_dir expanded to $d1n/$d2"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   423
		new_dir="$d1n/$d2"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   424
		;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   425
	esac
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   426
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   427
    if [ "x$new_dir" != "x/" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   428
	new_dir=`echo "$new_dir" | sed -e 's%/*$%%'`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   429
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   430
    eval "$2=\"$new_dir\""
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   431
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   432
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   433
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   434
# ask_ccdir
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   435
#
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   436
# result in new_ccdir and cc_name and cxx_name
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   437
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   438
# The args are:
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   439
#   <cc_version>:  expected compiler version to be displayed to the user,
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   440
#               e.g. "Sun Studio 10"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   441
#   <cc_version_string>:  expected output of cc -V
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   442
#   <sgnome_cc_version>:  compiler subdir in /sgnome (for .ireland users)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   443
#   <ccn>:      default answer (full path to cc)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   444
ask_ccdir () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   445
    if [ $INT_EXT = internal ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   446
	REC="required"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   447
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   448
	REC="recommended"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   449
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   450
    echo "The $REC C compiler(s) for this version of the JDS CBE is/are:"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   451
    for compiler in $cc32_versions; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   452
	echo "        `eval echo \\\$${compiler}_name` (`eval echo \\\$${compiler}_$(uname -p)_version_string`)"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   453
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   454
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   455
    sgnome_cc32dirs=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   456
    for compiler in $cc32_versions; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   457
	sgnome_cc32dirs="$sgnome_cc32dirs /sgnome/tools/${the_cpu}-solaris/forte/`eval echo \\\$${compiler}_sgnome_dir`/SUNWspro/bin"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   458
	sgnome_cc32dirs="$sgnome_cc32dirs `eval echo \\\$${compiler}_alt_dirs`"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   459
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   460
    for cc32dir in $sgnome_cc32dirs; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   461
	cc32name="$cc32dir/cc"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   462
	test -x $cc32name && break
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   463
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   464
    if [ ! -d "$cc32dir" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   465
	CC=${CC:-`which cc`}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   466
	if [ -x "$CC" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   467
	    cc32dir=$(dirname $CC)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   468
	    cc32name=$cc32dir/cc
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   469
	else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   470
	    cc32dir=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   471
	    cc32name=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   472
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   473
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   474
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   475
    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   476
    while [ $repeat = yes ]; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   477
	repeat=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   478
	ask "Enter the path to the C compiler" "new_ccn" "$cc32name"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   479
	new_ccdir=$(dirname $new_ccn)
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   480
	if [ ! -e "$new_ccn" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   481
	    echo $new_ccn not found
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   482
	    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   483
	elif [ ! -f "$new_ccn" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   484
	    echo $new_ccn is not a file
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   485
	    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   486
	elif [ ! -x "$new_ccn" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   487
	    echo $new_ccn is not executable
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   488
	    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   489
	else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   490
	    cc_name=`basename "$new_ccn"`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   491
	    if [ "x$cc_name" = xgcc ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   492
		echo
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   493
		echo "You chose gcc as your C compiler.  Note that building JDS using gcc may be"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   494
		echo "possible but is not tested or supported."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   495
		echo
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   496
		echo "Press Enter to continue"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   497
		read dummy
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   498
		cxx_name=g++
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   499
	    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   500
		cxx_name=CC
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   501
		version_ok=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   502
		for compiler in $cc32_versions; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   503
		    "$new_ccn" -V 2>&1 | egrep -s "`eval echo \\\$${compiler}_$(uname -p)_version_string`" && {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   504
			version_ok=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   505
			break
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   506
		    }
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   507
		done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   508
		if [ $version_ok = no ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   509
		    echo "$new_ccn is not the $REC compiler"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   510
		    echo "\"cc -V\" should print one of the following:"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   511
		    for compiler in $cc32_versions; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   512
			echo "       `eval echo \\\$${compiler}_$(uname -p)_version_string`"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   513
		    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   514
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   515
		    ask_yes_no "Would you like to use this compiler anyway?" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   516
			use_different_cc no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   517
		    if [ $use_different_cc = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   518
			log "User chose to use a non-standard C compiler:"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   519
			log "`$new_ccn -V 1>&1`"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   520
			repeat=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   521
		    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   522
			repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   523
		    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   524
		else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   525
		    ccls=$( cd $new_ccdir; ls -l cc )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   526
		    case "$ccls" in
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   527
			*"cc -> ../prod/bin/cc" )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   528
			    ;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   529
			* )
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   530
			    echo "cc is expected to be a symlink to ../prod/bin/cc"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   531
			    if [ $INT_EXT = internal ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   532
				echo "See the README file for information about installing the C compiler"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   533
				echo "or using it via NFS on SWAN"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   534
			    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   535
			    repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   536
			    ;;
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   537
		    esac
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   538
		fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   539
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   540
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   541
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   542
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   543
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   544
# gather info for the installation from the user
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   545
ask_defaults () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   546
    if [ $binary_install != yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   547
	repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   548
	while [ $repeat = yes ]; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   549
	    repeat=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   550
	    get_dir "Enter the base directory (prefix) of the cbe" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   551
		cbe_prefix $cbe_prefix root
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   552
	    if [ "$cbe_prefix" = "/" -o "$cbe_prefix" = "/tmp" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   553
		echo "This directory is not allowed."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   554
		echo "Please choose a different one as the cbe prefix"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   555
		repeat=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   556
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   557
	done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   558
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   559
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   560
    if [ ! -f "$HOME/.pkgbuildmacros" -a ! -d "$HOME/packages" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   561
	# the user probably hasn't used pkgbuild >= 1.1.0 yet
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   562
	# so let's ask if they want to use a specific topdir
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   563
	# instead of $HOME/packages
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   564
	echo "Starting from pkgbuild 1.1.0 (JDS CBE 1.5) there is no system-wide"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   565
        echo "build directory (%_topdir), instead, each user has their own."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   566
	echo "The default directory is \$HOME/packages."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   567
	echo "If you wish to use a different build directory, you can define it"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   568
	echo "in \$HOME/.pkgbuildmacros as follows:"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   569
	echo
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   570
	echo "       %_topdir    /path/to/my/build/area"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   571
	echo
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   572
	if [ "$uid" = 0 ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   573
	    echo
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   574
	    echo Press Enter to continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   575
	    read dummy
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   576
	else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   577
	    ask_yes_no "Would you like to do this now?" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   578
		set_topdir no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   579
	    if [ $set_topdir = no ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   580
		log "the user chose not to change the default topdir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   581
		echo "The default topdir ($HOME/packages) will be used"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   582
	    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   583
		get_dir "Enter your build directory" default_topdir \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   584
		    "$cbe_prefix/packages" $logname
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   585
		log "the user selected $default_topdir for topdir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   586
		echo "%_topdir $default_topdir" > $HOME/.pkgbuildmacros
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   587
		log "created $HOME/.pkgbuildmacros"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   588
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   589
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   590
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   591
	log "the user already has a .pkgbuildmacros file or ~/packages dir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   592
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   593
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   594
    the_cpu=`uname -p`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   595
    if [ "x$the_cpu" != xsparc ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   596
	the_cpu=x86
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   597
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   598
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   599
    ask_ccdir
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   600
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   601
    cc32dir="$new_ccdir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   602
    log "32-bit C compiler:   $cc32dir/$cc_name"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   603
    log "32-bit C++ compiler: $cc32dir/$cxx_name"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   604
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   605
    cc64dir="$cc32dir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   606
    log "64-bit C compiler:   $cc64dir/$cc_name"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   607
    log "64-bit C++ compiler: $cc64dir/$cxx_name"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   608
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   609
    msg "This version of the CBE comes with some optional utilities."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   610
    msg "These are not required for building the JDS code, nevertheless"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   611
    msg "they are useful to have on your system."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   612
    msg "Please see the README file for the list of optional utilities."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   613
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   614
    ask_yes_no "Would you like to install the optional packages?" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   615
	cbe_opt yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   616
    if [ $cbe_opt = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   617
	log "User chose to install optional packages"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   618
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   619
	log "User chose not to install optional pkgs"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   620
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   621
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   622
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   623
# create an admin file for pkgadd/pkgrm
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   624
make_admin_file () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   625
    echo "mail="                 > $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   626
    echo "instance=unique" 	>> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   627
    echo "conflict=nocheck"     >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   628
    echo "conflict=quit"        >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   629
    echo "setuid=nocheck"       >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   630
    echo "action=nocheck"       >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   631
    echo "partial=quit"         >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   632
    echo "space=quit"           >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   633
    if [ "$2" = "pkgrm" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   634
	echo "idepend=nocheck"      >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   635
	echo "rdepend=nocheck"      >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   636
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   637
	echo "idepend=quit"         >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   638
	echo "rdepend=quit"         >> $1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   639
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   640
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   641
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   642
# run a command, redirect the output to a log file and also print it
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   643
# on stdout
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   644
logrun () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   645
    status_file=/tmp/.command_status.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   646
    /usr/bin/rm -f $status_file
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   647
    log "running $*"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   648
    log "*** command output follows ***"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   649
    ( "${@}" 2>&1 ; echo $? > $status_file ) | tee -a $LOGFILE
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   650
    log "*** command output ends ***"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   651
    status=`cat $status_file`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   652
    /usr/bin/rm -f $status_file
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   653
    return $status
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   654
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   655
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   656
# check if a package is installed and if so, offer to uninstall it
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   657
check_if_installed () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   658
    skip_package=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   659
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   660
    pkginfo -R $rootdir -q "$1"'.*' || return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   661
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   662
    if [ x$always_uninstall_existing != xyes -a x$always_skip_existing != xyes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   663
      msg "Package $1 is already installed."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   664
      ask_yes_no "Would you like uninstall it?" do_uninstall yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   665
      if [ $do_uninstall = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   666
	  if [ x$always_uninstall_existing != xno ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   667
	      ask_yes_no "Always uninstall previously installed packages?" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   668
		  always_uninstall_existing yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   669
	      log "always_uninstall_existing = $always_uninstall_existing"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   670
	  fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   671
      fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   672
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   673
      if [ x$always_skip_existing = xyes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   674
	  msg "Skipping package $1 -- already installed"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   675
	  skip_package=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   676
	  return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   677
      else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   678
	  do_uninstall=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   679
      fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   680
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   681
    if [ $do_uninstall = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   682
	log "User chose to uninstall $1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   683
	make_admin_file /tmp/pkgrm.admin.$$ pkgrm || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   684
	pkgrm_failed=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   685
	logrun pfexec /usr/sbin/pkgrm -R $rootdir -n -a /tmp/pkgrm.admin.$$ "$1.*" || pkgrm_failed=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   686
	if [ $pkgrm_failed = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   687
	    ask_yes_no "pkgrm failed. would you like to continue anyway?" pkgrm_cont no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   688
	    if [ $pkgrm_cont = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   689
		log "User chose to continue anyway"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   690
		return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   691
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   692
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   693
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   694
	return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   695
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   696
	log "User chose not to uninstall $1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   697
	if [ x$always_skip_existing != xyes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   698
	    ask_yes_no "Would you like skip to the next package?" skip_package yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   699
	    if [ $skip_package = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   700
		log "User chose to skip package $1"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   701
		if [ x$always_skip_existing != xno ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   702
		    ask_yes_no "Always skip packages that are already installed?" always_skip_existing yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   703
		    log "always_skip_existing = $always_skip_existing"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   704
		fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   705
		return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   706
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   707
	else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   708
	    skip_package=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   709
	    return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   710
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   711
	msg "Not uninstalling $1."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   712
	msg "NOTE that this may cause problems later"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   713
	ask "Press Enter to continue" dummy ""
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   714
	return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   715
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   716
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   717
    return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   718
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   719
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   720
# install a list of svr4 packages given its directory, altroot and the
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   721
# names of the packages
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   722
install_pkgs () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   723
    pdir=$1; shift
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   724
    rdir=$1; shift
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   725
    make_admin_file $tempdir/pkgadd.admin.$$ pkgadd
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   726
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   727
    for pkg in $*; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   728
	msg "Installing package $pkg"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   729
	logrun pfexec /usr/sbin/pkgadd -R "$rdir" -n -a $tempdir/pkgadd.admin.$$ -d "$pdir" $pkg || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   730
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   731
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   732
    /usr/bin/rm -f $tempdir/pkgadd.admin.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   733
    return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   734
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   735
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   736
install_all_dependencies=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   737
solaris_pkg_dir=/cdrom/cdrom0/Solaris_11/Product
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   738
# check if the pkgs JDS requires are installed; if not install them
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   739
check_jds_dependencies () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   740
    retval=0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   741
    # we're going to cp solaris pkgs from the media to this dir
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   742
    tmp_pkg_dir=`mktemp -d /tmp/cbe-pkgs-XXXX`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   743
    # schedule this dir for removal if the installation is aborted
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   744
    tempdirs="$tempdirs:$tmp_pkg_dir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   745
    for pkg in $JDS_DEPENDENCIES; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   746
	pkginfo -R $rootdir -q "$pkg."'*' && continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   747
	if [ "x$install_all_dependencies" != xyes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   748
	    msg "Package $pkg is required for building JDS"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   749
	    ask_yes_no "Would you like to install it now?" do_inst "yes"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   750
	    if [ $do_inst = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   751
		if [ "x$install_all_dependencies" != xno ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   752
		    ask_yes_no \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   753
			"Install all required packages?" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   754
			install_all_dependencies "yes"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   755
		fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   756
		while /bin/true; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   757
		    ask "Enter the path to the Solaris packages" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   758
			solaris_pkg_dir "$solaris_pkg_dir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   759
		    # Copy all packages found in $solaris_pkg_dir to a temporary
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   760
		    # dir so that people installing from CDs don't need to
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   761
		    # swap CDs all the time...
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   762
		    for p0 in $JDS_DEPENDENCIES; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   763
			pkginfo -q $p0 && continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   764
			test -d $tmp_pkg_dir/$p0 && continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   765
			test -d "$solaris_pkg_dir/$p0" && \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   766
			    /bin/cp -r "$solaris_pkg_dir/$p0" $tmp_pkg_dir && \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   767
			    /bin/chmod -R u+w $tmp_pkg_dir/$p0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   768
		    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   769
		    test -d "$solaris_pkg_dir/$pkg" && break
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   770
		    msg "$solaris_pkg_dir/$pkg not found"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   771
		done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   772
	    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   773
		log "user chose not to install required package $pkg"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   774
		continue
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   775
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   776
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   777
	while /bin/true; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   778
	    msg "Installing package $pkg"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   779
	    make_admin_file /tmp/pkgadd.admin.$$ pkgadd
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   780
	    if [ -d $tmp_pkg_dir/$pkg ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   781
		logrun pfexec /usr/sbin/pkgadd -R $rootdir -n -a /tmp/pkgadd.admin.$$ -d "$tmp_pkg_dir" $pkg
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   782
		if [ $? != 0 ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   783
		    msg "WARNING: failed to install required package $pkg"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   784
		    ask_yes_no "Would you like to retry?" "do_retry" "yes"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   785
		else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   786
		    do_retry=no_need_to
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   787
		fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   788
	    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   789
		msg "Package $pkg was not found in $solaris_pkg_dir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   790
		do_retry=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   791
		/bin/true
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   792
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   793
	    if [ $do_retry = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   794
		while /bin/true; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   795
		    ask "Enter the path to the Solaris packages" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   796
			solaris_pkg_dir "$solaris_pkg_dir"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   797
		    test -d "$solaris_pkg_dir/$pkg" && break
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   798
		    msg "$solaris_pkg_dir/$pkg not found"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   799
		done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   800
		# Copy all packages found in $solaris_pkg_dir to a temporary
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   801
		# dir so that people installing from CDs don't need to
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   802
		# swap CDs all the time...
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   803
		for p0 in $JDS_DEPENDENCIES; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   804
		    test -d "$solaris_pkg_dir/$p0" && \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   805
			/bin/cp -r "$solaris_pkg_dir/$p0" $tmp_pkg_dir && \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   806
			/bin/chmod -R u+w $tmp_pkg_dir/$p0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   807
		done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   808
	    elif [ $do_retry = no ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   809
		ask_yes_no "Continue installation anyway?" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   810
		    do_continue no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   811
		if [ $do_continue = no ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   812
		    /bin/rm -f /tmp/pkgadd.admin.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   813
		    /bin/rm -rf $tmp_pkg_dir
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   814
		    msg "Installation aborted."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   815
		    exit 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   816
		else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   817
		    break
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   818
		fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   819
		break
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   820
	    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   821
		/bin/rm -rf $tmp_pkg_dir/$pkg
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   822
		/bin/rm -f /tmp/pkgadd.admin.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   823
		break
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   824
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   825
	done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   826
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   827
    /bin/rm -rf $tmp_pkg_dir
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   828
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   829
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   830
# install pkgbuild from tarball to a temp location and then build a
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   831
# pkgbuild pkg using itself
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   832
install_pkgbuild () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   833
    check_if_installed SFpkgbuild || {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   834
	pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   835
	return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   836
    }
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   837
    if [ $skip_package = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   838
	return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   839
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   840
    export PATH=/usr/ccs/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/usr/sfw/bin
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   841
    cd $tempdir || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   842
    logrun mkdir -p pkgbuild.tmp.$$/src || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   843
    cd pkgbuild.tmp.$$/src || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   844
    logrun bash -c "bzcat $tardir/pkgbuild-$PKGBUILD_VERSION.tar.bz2 | tar xvf -" || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   845
    cd pkgbuild-$PKGBUILD_VERSION || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   846
    logrun ./configure --prefix="$tempdir/pkgbuild.tmp.$$" || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   847
    logrun make install || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   848
    msg "Now rebuilding pkgbuild using itself"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   849
    logrun mkdir -p $tempdir/pkgbuild.tmp.$$/packages/SOURCES || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   850
    logrun cp $tardir/pkgbuild-$PKGBUILD_VERSION.tar.bz2 $tempdir/pkgbuild.tmp.$$/packages/SOURCES/ || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   851
    logrun bash -c "$tempdir/pkgbuild.tmp.$$/bin/pkgbuild --define \"pkgbuild_prefix $cbe_prefix\" --define \"_topdir $tempdir/pkgbuild.tmp.$$/packages\" -ba $tempdir/pkgbuild.tmp.$$/src/pkgbuild-$PKGBUILD_VERSION/pkgbuild.spec" || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   852
    make_admin_file $tempdir/pkgadd.admin.$$ pkgadd
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   853
    logrun pfexec /usr/sbin/pkgadd -R $rootdir -n -a $tempdir/pkgadd.admin.$$ -d "$tempdir/pkgbuild.tmp.$$/packages/PKGS" SFpkgbuild || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   854
    pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   855
    logrun mkdir -p "$rootdir/$pkgbuild_topdir/PKGS"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   856
    logrun mkdir -p "$rootdir/$pkgbuild_topdir/SPKGS"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   857
    logrun cp -rf "$tempdir/pkgbuild.tmp.$$/packages/SPKGS/SFpkgbuild-src" "$rootdir/$pkgbuild_topdir/SPKGS"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   858
    logrun cp -rf "$tempdir/pkgbuild.tmp.$$/packages/PKGS/SFpkgbuild" "$rootdir/$pkgbuild_topdir/PKGS"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   859
    cd /tmp || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   860
    logrun /usr/bin/rm -rf $tempdir/pkgbuild.tmp.$$ $tempdir/pkgbuild-$PKGBUILD_VERSION || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   861
    
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   862
    return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   863
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   864
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   865
# build and install a package
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   866
build_pkg () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   867
    check_if_installed $3 || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   868
    if [ $skip_package = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   869
	return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   870
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   871
    logrun mkdir -p "$rootdir/$pkgbuild_topdir/SOURCES"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   872
    if [ "x$2" != x ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   873
	log "copying tarball $2 to $rootdir$pkgbuild_topdir/SOURCES"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   874
	fname=`basename $2`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   875
	logrun rm -f "$rootdir$pkgbuild_topdir/SOURCES/$fname"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   876
	logrun cp $2 "$rootdir$pkgbuild_topdir/SOURCES" 2>&1 || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   877
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   878
    export "PATH=$rootdir$cbe_prefix/bin:/usr/ccs/bin:/usr/gnu/bin:/usr/bin:/usr/sbin:/usr/sfw/bin"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   879
    export CC="$cc32dir/$cc_name"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   880
    export CXX="$cc32dir/$cxx_name"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   881
    if [ "x$rootdir" != x/ ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   882
       export AC_MACRODIR="$rootdir$cbe_prefix/share/autoconf"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   883
       sed -e "s%--prepend-include %--prepend-include $rootdir%" "$rootdir$cbe_prefix/share/autoconf/autom4te.cfg" > $tempdir/autom4te.cfg
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   884
       export AUTOM4TE_CFG="$tempdir/autom4te.cfg"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   885
       export autom4te_perllibdir="$rootdir$cbe_prefix/share/autoconf"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   886
       export AUTOM4TE="$rootdir$cbe_prefix/bin/autom4te"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   887
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   888
    msg "Building package $3"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   889
    logrun pkgbuild --define "_topdir $rootdir$pkgbuild_topdir" --define "cbe_prefix $cbe_prefix" -ba $1 || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   890
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   891
    install_pkgs "$rootdir$pkgbuild_topdir/PKGS" "$rootdir" "$3" || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   892
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   893
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   894
uninstall_old_cbe () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   895
    pkg_info=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   896
    for pkg in $OLD_PKGS; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   897
	pkginfo -R $rootdir -q "$pkg."'*' && pkg_info="$pkg_info
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   898
`pkginfo -R $rootdir $pkg.'*'`"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   899
    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   900
    if [ ! -z "$pkg_info" ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   901
	echo "The following packages belong to an obsolete version of the JDS CBE."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   902
	echo "$pkg_info"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   903
	echo 
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   904
	ask_yes_no "Would you like to uninstall them?" do_uninst yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   905
	if [ $do_uninst = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   906
	    log "User chose to uninstall obsolete CBE pkgs"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   907
	    make_admin_file $tempdir/pkgrm.admin.$$ pkgrm
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   908
	    pkgrm_failed=no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   909
	    for pkg in $OLD_PKGS; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   910
		if pkginfo -R $rootdir -q "$pkg."'*'; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   911
		    logrun pfexec /usr/sbin/pkgrm -R $rootdir -n -a $tempdir/pkgrm.admin.$$ "$pkg."'*' || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   912
			pkgrm_failed=yes
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   913
		fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   914
	    done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   915
	    rm -f $tempdir/pkgrm.admin.$$
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   916
	    if [ $pkgrm_failed = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   917
		msg "Failed to remove one or more packages"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   918
		ask_yes_no "Would you like to continue anyway?" do_cont no
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   919
		if [ $do_cont = no ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   920
		    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   921
		else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   922
		    log "User chose to continue anyway"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   923
		    return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   924
		fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   925
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   926
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   927
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   928
    return 0
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   929
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   930
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   931
main () {
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   932
    init
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   933
    uninstall_old_cbe || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   934
    msg "Installing the JDS Common Build Environment (CBE) version $CBE_VERSION"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   935
    ask_defaults
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   936
    if [ $binary_install = no ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   937
	install_pkgbuild || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   938
	pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   939
	build_pkg $mydir/make.spec "$tardir/$MAKE_TARBALL" CBEmake  || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   940
	build_pkg $mydir/cvs.spec "$tardir/$CVS_TARBALL" CBEcvs  || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   941
	if [ $cbe_opt = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   942
	    build_pkg $mydir/rsync.spec "$tardir/$RSYNC_TARBALL" CBErsync  || msg "WARNING: Failed to install rsync.  Note: this is an optional CBE component."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   943
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   944
	build_pkg $mydir/m4.spec "$tardir/$M4_TARBALL" CBEm4 || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   945
	build_pkg $mydir/autoconf.spec "$tardir/$AUTOCONF_TARBALL" CBEautoconf || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   946
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   947
	logrun rm -f "$rootdir$pkgbuild_topdir/SOURCES/$AUTOMAKE_1_9_TARBALL"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   948
	logrun cp "$tardir/$AUTOMAKE_1_9_TARBALL" $rootdir$pkgbuild_topdir/SOURCES/ || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   949
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   950
	build_pkg $mydir/automake.spec "$tardir/$AUTOMAKE_1_10_TARBALL" CBEautomake || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   951
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   952
	logrun cp $mydir/libtool-allextract.diff $rootdir$pkgbuild_topdir/SOURCES/ || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   953
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   954
	build_pkg $mydir/libtool.spec "$tardir/$LIBTOOL_TARBALL" CBElibtool || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   955
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   956
	logrun cp $mydir/gettext.diff $rootdir$pkgbuild_topdir/SOURCES/ || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   957
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   958
	build_pkg $mydir/gettext.spec "$tardir/$GETTEXT_TARBALL" CBEgettext || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   959
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   960
	build_pkg $mydir/fileutils.spec "$tardir/$FILEUTILS_TARBALL" CBEfileutils||\
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   961
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   962
	build_pkg $mydir/flex.spec "$tardir/$FLEX_TARBALL" CBEflex  || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   963
	build_pkg $mydir/bison.spec "$tardir/$BISON_TARBALL" CBEbison  || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   964
	logrun cp $mydir/gendiff $rootdir$pkgbuild_topdir/SOURCES/ || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   965
	    return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   966
	build_pkg $mydir/diff.spec "$tardir/$DIFF_TARBALL" CBEdiff  || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   967
	build_pkg $mydir/ant.spec "$tardir/$ANT_TARBALL" CBEant  || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   968
	build_pkg $mydir/subversion.spec "$tardir/$SVN_TARBALL" CBEsvn  || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   969
	return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   970
    else
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   971
	INSTALL_CBE_PKGS=
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   972
	for pkg in $CBE_PKGS; do
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   973
	    check_if_installed $pkg || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   974
	    if [ $skip_package = no ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   975
		INSTALL_CBE_PKGS="$INSTALL_CBE_PKGS $pkg"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   976
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   977
	done
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   978
	install_pkgs "$mydir/pkgs" "$rootdir" $INSTALL_CBE_PKGS || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   979
	if [ $cbe_opt = yes ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   980
	    check_if_installed CBErsync || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   981
	    if [ $skip_package = no ]; then
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   982
		install_pkgs "$mydir/pkgs" "$rootdir" CBErsync || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   983
	    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   984
	fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   985
	pkgbuild_topdir=`$cbe_prefix/bin/pkgbuild -bp $cbe_prefix/lib/pkgbuild-$PKGBUILD_VERSION/get_rpm_topdir 2>&1 | grep '^TOPDIR=' | cut -f2- -d=`
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   986
    fi
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   987
    log "Creating env.sh"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   988
    logrun mkdir -p $rootdir$pkgbuild_topdir/SOURCES || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   989
    build_info="built on `date +%Y-%m-%d` by ${logname}@`hostname`"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   990
    logrun bash -c "sed -e \"s%@CBE_PREFIX@%$cbe_prefix%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   991
        -e \"s%@JDS_PREFIX@%$JDS_PREFIX%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   992
	-e \"s%@CC32@%$cc32dir/$cc_name%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   993
	-e \"s%@CXX32@%$cc32dir/$cxx_name%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   994
	-e \"s%@CC64@%$cc64dir/$cc_name%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   995
	-e \"s%@CXX64@%$cc64dir/$cxx_name%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   996
	-e \"s%@CBE_VERSION@%$CBE_VERSION%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   997
        -e \"s%@BUILD_INFO@%$build_info%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   998
	$mydir/env.sh > $rootdir$pkgbuild_topdir/SOURCES/env.sh" || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
   999
	return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1000
    log "Creating env.csh"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1001
    logrun bash -c "sed -e \"s%@CBE_PREFIX@%$cbe_prefix%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1002
        -e \"s%@JDS_PREFIX@%$JDS_PREFIX%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1003
	-e \"s%@CC32@%$cc32dir/$cc_name%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1004
	-e \"s%@CXX32@%$cc32dir/$cxx_name%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1005
	-e \"s%@CC64@%$cc64dir/$cc_name%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1006
	-e \"s%@CXX64@%$cc64dir/$cxx_name%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1007
	-e \"s%@CBE_VERSION@%$CBE_VERSION%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1008
        -e \"s%@BUILD_INFO@%$build_info%\" \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1009
	$mydir/env.csh > $rootdir$pkgbuild_topdir/SOURCES/env.csh" || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1010
	return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1011
    log "Copying ld-wrapper"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1012
    logrun bash -c "cp $mydir/ld-wrapper $rootdir$pkgbuild_topdir/SOURCES" || \
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1013
	return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1014
    build_pkg $mydir/CBEenv.spec "" CBEenv  || return 1
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1015
    msg "CBE setup complete"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1016
    echo "Run"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1017
    echo "  . $cbe_prefix/bin/env.sh"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1018
    echo "or"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1019
    echo "  source $cbe_prefix/bin/env.csh"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1020
    echo "depending on your shell, to use this build environment."
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1021
}
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1022
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1023
process_cl "${@}"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1024
main || msg "CBE setup FAILED"
102c9870ef63 initial import -- still incomplete
laca
parents:
diff changeset
  1025
echo "Installation log saved in $LOGFILE"