xref: /onnv-gate/usr/src/cmd/sgs/packages/common/postinstall (revision 2352:9cdfed81bb1c)
10Sstevel@tonic-gate#
20Sstevel@tonic-gate# CDDL HEADER START
30Sstevel@tonic-gate#
40Sstevel@tonic-gate# The contents of this file are subject to the terms of the
5*2352Sab196087# Common Development and Distribution License (the "License").
6*2352Sab196087# You may not use this file except in compliance with the License.
70Sstevel@tonic-gate#
80Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate# See the License for the specific language governing permissions
110Sstevel@tonic-gate# and limitations under the License.
120Sstevel@tonic-gate#
130Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate#
190Sstevel@tonic-gate# CDDL HEADER END
200Sstevel@tonic-gate#
210Sstevel@tonic-gate#
220Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
230Sstevel@tonic-gate#
24*2352Sab196087# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
250Sstevel@tonic-gate# Use is subject to license terms.
260Sstevel@tonic-gate#
270Sstevel@tonic-gate
280Sstevel@tonic-gateONLDCPIO=/tmp/SUNWonld.cpio.$$
290Sstevel@tonic-gateLINKERALIAS=linker_install@eng.sun.com
300Sstevel@tonic-gate
310Sstevel@tonic-gate
320Sstevel@tonic-gate#
330Sstevel@tonic-gate# This script handles the installation of the new sgstools on
340Sstevel@tonic-gate# both Solaris10 systems (which libraries moved to '/lib') and
350Sstevel@tonic-gate# pre Solaris10 systems where libraries reside under '/usr/lib'.
360Sstevel@tonic-gate#
370Sstevel@tonic-gate# We test to deterine if '/lib' is a symlink (pre Solaris10) or a
380Sstevel@tonic-gate# directory (Solaris10 & later).  We key off of that for
390Sstevel@tonic-gate# everything below.
400Sstevel@tonic-gate#
410Sstevel@tonic-gateif [ -h ${BASEDIR}/lib ]
420Sstevel@tonic-gatethen
430Sstevel@tonic-gate	LIBBASE=usr/lib
440Sstevel@tonic-gate	ETCLIST="etc/lib/ld.so.1 etc/lib/libdl.so.1"
450Sstevel@tonic-gateelse
460Sstevel@tonic-gate	LIBBASE=lib
470Sstevel@tonic-gatefi
480Sstevel@tonic-gateexport LIBBASE
490Sstevel@tonic-gate
500Sstevel@tonic-gate
510Sstevel@tonic-gatebuild_liblist ()
520Sstevel@tonic-gate{
530Sstevel@tonic-gate	#
540Sstevel@tonic-gate	# Build '/lib' file list for backing up
550Sstevel@tonic-gate	#
560Sstevel@tonic-gate	cd $BASEDIR/$SGSDIR/lib
570Sstevel@tonic-gate	find . \( -type f -o -type l \) -print | while read file
580Sstevel@tonic-gate	do
590Sstevel@tonic-gate		if [ \( -f $BASEDIR/$LIBBASE/$file \)  -o \
600Sstevel@tonic-gate		    \( -h $BASEDIR/$LIBBASE/$file \) ]; then
610Sstevel@tonic-gate			echo $LIBBASE/$file
620Sstevel@tonic-gate		fi
630Sstevel@tonic-gate	done
640Sstevel@tonic-gate}
650Sstevel@tonic-gate
660Sstevel@tonic-gatebuild_filelist()
670Sstevel@tonic-gate{
680Sstevel@tonic-gate	#
690Sstevel@tonic-gate	# Build rest of files
700Sstevel@tonic-gate	#
710Sstevel@tonic-gate	cd $BASEDIR/$SGSDIR
720Sstevel@tonic-gate	find usr \( -type f -o -type l \) -print | while read file
730Sstevel@tonic-gate	do
740Sstevel@tonic-gate		if [ \( -f $BASEDIR/$file \)  -o \
750Sstevel@tonic-gate		    \( -h $BASEDIR/$file \) ]; then
760Sstevel@tonic-gate			echo $file
770Sstevel@tonic-gate		fi
780Sstevel@tonic-gate	done
790Sstevel@tonic-gate}
800Sstevel@tonic-gate
810Sstevel@tonic-gateLIBLIST=`build_liblist`
820Sstevel@tonic-gateFILELIST=`build_filelist`
830Sstevel@tonic-gate
840Sstevel@tonic-gate#
850Sstevel@tonic-gate# backup all existing SGStools.
860Sstevel@tonic-gate#
870Sstevel@tonic-gateecho "Backup up existing SGS tools to $SGSBACKUPDIR..."
880Sstevel@tonic-gatecd $BASEDIR
890Sstevel@tonic-gatefor file in $LIBLIST $FILELIST $ETCLIST
900Sstevel@tonic-gatedo
910Sstevel@tonic-gate	echo $file
920Sstevel@tonic-gatedone  | cpio -pdm $BASEDIR/$SGSBACKUPDIR
930Sstevel@tonic-gate
940Sstevel@tonic-gate
950Sstevel@tonic-gate#
960Sstevel@tonic-gate# Overwrite SGSTOOLS onto existing system.  We use CPIO
970Sstevel@tonic-gate# because rm's a file and then installs a new one
980Sstevel@tonic-gate# instead of copying over a existing file.  This is
990Sstevel@tonic-gate# required when updating libraries (and the run-time linker)
1000Sstevel@tonic-gate# which are currently being used.
1010Sstevel@tonic-gate#
1020Sstevel@tonic-gate
1030Sstevel@tonic-gate
1040Sstevel@tonic-gate#
1050Sstevel@tonic-gate# First '/lib' components
1060Sstevel@tonic-gate#
1070Sstevel@tonic-gateecho "Installing new SGSTOOLS from $BASEDIR/$SGSDIR"
1080Sstevel@tonic-gate
1090Sstevel@tonic-gateprev_bindnow=$LD_BIND_NOW
1100Sstevel@tonic-gateLD_BIND_NOW=1
1110Sstevel@tonic-gateexport LD_BIND_NOW
1120Sstevel@tonic-gate
1130Sstevel@tonic-gatecd $BASEDIR/$SGSDIR/lib
1140Sstevel@tonic-gatefind . -depth -print | cpio -o -O $ONLDCPIO
1150Sstevel@tonic-gatecd $BASEDIR/$LIBBASE
1160Sstevel@tonic-gatecpio -imdu < $ONLDCPIO
1170Sstevel@tonic-gaterm -f $ONLDCPIO
1180Sstevel@tonic-gate
1190Sstevel@tonic-gate#
1200Sstevel@tonic-gate# Then everything else
1210Sstevel@tonic-gate#
1220Sstevel@tonic-gatecd $BASEDIR/$SGSDIR
1230Sstevel@tonic-gatefind usr -depth -print | cpio -o -O $ONLDCPIO
1240Sstevel@tonic-gatecd $BASEDIR
1250Sstevel@tonic-gatecpio -imdu < $ONLDCPIO
1260Sstevel@tonic-gaterm -f $ONLDCPIO
1270Sstevel@tonic-gate
1280Sstevel@tonic-gate
1290Sstevel@tonic-gate#
1300Sstevel@tonic-gate# Populate '/etc/lib' directories on systems with the
1310Sstevel@tonic-gate# run-time linker installed under '/usr/lib/ld.so.1'
1320Sstevel@tonic-gate#
1330Sstevel@tonic-gateif [ "${ETCLIST}x" != "x" ]; then
1340Sstevel@tonic-gate	cp $BASEDIR/usr/lib/ld.so.1 $BASEDIR/etc/lib/ld.so.1.onld
1350Sstevel@tonic-gate	cp $BASEDIR/usr/lib/libdl.so.1 $BASEDIR/etc/lib/libdl.so.1.onld
1360Sstevel@tonic-gate	cd $BASEDIR/etc/lib
1370Sstevel@tonic-gate	mv ld.so.1.onld ld.so.1
1380Sstevel@tonic-gate	mv libdl.so.1.onld libdl.so.1
1390Sstevel@tonic-gatefi
1400Sstevel@tonic-gate
1410Sstevel@tonic-gateLD_BIND_NOW=$prev_bindnow
1420Sstevel@tonic-gate
143*2352Sab196087####
144*2352Sab196087#### E-mail sent to track installations of SUNWonld package.
145*2352Sab196087#### purely for statistical purposes.
146*2352Sab196087####
147*2352Sab196087###if [ -f /usr/lib/sendmail ]
148*2352Sab196087###then
149*2352Sab196087###	HOSTINFO=`uname -a`
150*2352Sab196087###	DATE=`date`
151*2352Sab196087###	ENVLIST=`env`
152*2352Sab196087###	/usr/lib/sendmail $LINKERALIAS << EOF
153*2352Sab196087###To: $LINKERALIAS
154*2352Sab196087###Subject: SUNWonld Linker Package Installation: $PRODVERS
155*2352Sab196087###Content-type: text/plain
156*2352Sab196087###Precedence: junk
157*2352Sab196087###--------
158*2352Sab196087###
159*2352Sab196087###Package Installation
160*2352Sab196087###uname: $HOSTINFO
161*2352Sab196087###date: $DATE
162*2352Sab196087###VERSION: $VERSION
163*2352Sab196087###ENV:
164*2352Sab196087###$ENVLIST
165*2352Sab196087###$ENV
166*2352Sab196087###
167*2352Sab196087###.
168*2352Sab196087###EOF
169*2352Sab196087###fi
1700Sstevel@tonic-gate
171