postinstall revision 2352:9cdfed81bb1c
1218885Sdim#
2218885Sdim# CDDL HEADER START
3218885Sdim#
4218885Sdim# The contents of this file are subject to the terms of the
5218885Sdim# Common Development and Distribution License (the "License").
6218885Sdim# You may not use this file except in compliance with the License.
7218885Sdim#
8218885Sdim# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9218885Sdim# or http://www.opensolaris.org/os/licensing.
10218885Sdim# See the License for the specific language governing permissions
11218885Sdim# and limitations under the License.
12218885Sdim#
13218885Sdim# When distributing Covered Code, include this CDDL HEADER in each
14249423Sdim# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15249423Sdim# If applicable, add the following below this CDDL HEADER, with the
16218885Sdim# fields enclosed by brackets "[]" replaced with your own identifying
17218885Sdim# information: Portions Copyright [yyyy] [name of copyright owner]
18251662Sdim#
19263508Sdim# CDDL HEADER END
20251662Sdim#
21251662Sdim#
22263508Sdim#ident	"%Z%%M%	%I%	%E% SMI"
23251662Sdim#
24251662Sdim# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25251662Sdim# Use is subject to license terms.
26251662Sdim#
27218885Sdim
28218885SdimONLDCPIO=/tmp/SUNWonld.cpio.$$
29218885SdimLINKERALIAS=linker_install@eng.sun.com
30218885Sdim
31218885Sdim
32251662Sdim#
33251662Sdim# This script handles the installation of the new sgstools on
34251662Sdim# both Solaris10 systems (which libraries moved to '/lib') and
35251662Sdim# pre Solaris10 systems where libraries reside under '/usr/lib'.
36251662Sdim#
37218885Sdim# We test to deterine if '/lib' is a symlink (pre Solaris10) or a
38251662Sdim# directory (Solaris10 & later).  We key off of that for
39218885Sdim# everything below.
40234353Sdim#
41234353Sdimif [ -h ${BASEDIR}/lib ]
42218885Sdimthen
43218885Sdim	LIBBASE=usr/lib
44218885Sdim	ETCLIST="etc/lib/ld.so.1 etc/lib/libdl.so.1"
45218885Sdimelse
46218885Sdim	LIBBASE=lib
47234353Sdimfi
48218885Sdimexport LIBBASE
49249423Sdim
50249423Sdim
51249423Sdimbuild_liblist ()
52249423Sdim{
53218885Sdim	#
54218885Sdim	# Build '/lib' file list for backing up
55218885Sdim	#
56218885Sdim	cd $BASEDIR/$SGSDIR/lib
57218885Sdim	find . \( -type f -o -type l \) -print | while read file
58218885Sdim	do
59218885Sdim		if [ \( -f $BASEDIR/$LIBBASE/$file \)  -o \
60218885Sdim		    \( -h $BASEDIR/$LIBBASE/$file \) ]; then
61218885Sdim			echo $LIBBASE/$file
62218885Sdim		fi
63218885Sdim	done
64218885Sdim}
65218885Sdim
66218885Sdimbuild_filelist()
67218885Sdim{
68218885Sdim	#
69218885Sdim	# Build rest of files
70218885Sdim	#
71218885Sdim	cd $BASEDIR/$SGSDIR
72218885Sdim	find usr \( -type f -o -type l \) -print | while read file
73218885Sdim	do
74218885Sdim		if [ \( -f $BASEDIR/$file \)  -o \
75		    \( -h $BASEDIR/$file \) ]; then
76			echo $file
77		fi
78	done
79}
80
81LIBLIST=`build_liblist`
82FILELIST=`build_filelist`
83
84#
85# backup all existing SGStools.
86#
87echo "Backup up existing SGS tools to $SGSBACKUPDIR..."
88cd $BASEDIR
89for file in $LIBLIST $FILELIST $ETCLIST
90do
91	echo $file
92done  | cpio -pdm $BASEDIR/$SGSBACKUPDIR
93
94
95#
96# Overwrite SGSTOOLS onto existing system.  We use CPIO
97# because rm's a file and then installs a new one
98# instead of copying over a existing file.  This is
99# required when updating libraries (and the run-time linker)
100# which are currently being used.
101#
102
103
104#
105# First '/lib' components
106#
107echo "Installing new SGSTOOLS from $BASEDIR/$SGSDIR"
108
109prev_bindnow=$LD_BIND_NOW
110LD_BIND_NOW=1
111export LD_BIND_NOW
112
113cd $BASEDIR/$SGSDIR/lib
114find . -depth -print | cpio -o -O $ONLDCPIO
115cd $BASEDIR/$LIBBASE
116cpio -imdu < $ONLDCPIO
117rm -f $ONLDCPIO
118
119#
120# Then everything else
121#
122cd $BASEDIR/$SGSDIR
123find usr -depth -print | cpio -o -O $ONLDCPIO
124cd $BASEDIR
125cpio -imdu < $ONLDCPIO
126rm -f $ONLDCPIO
127
128
129#
130# Populate '/etc/lib' directories on systems with the
131# run-time linker installed under '/usr/lib/ld.so.1'
132#
133if [ "${ETCLIST}x" != "x" ]; then
134	cp $BASEDIR/usr/lib/ld.so.1 $BASEDIR/etc/lib/ld.so.1.onld
135	cp $BASEDIR/usr/lib/libdl.so.1 $BASEDIR/etc/lib/libdl.so.1.onld
136	cd $BASEDIR/etc/lib
137	mv ld.so.1.onld ld.so.1
138	mv libdl.so.1.onld libdl.so.1
139fi
140
141LD_BIND_NOW=$prev_bindnow
142
143####
144#### E-mail sent to track installations of SUNWonld package.
145#### purely for statistical purposes.
146####
147###if [ -f /usr/lib/sendmail ]
148###then
149###	HOSTINFO=`uname -a`
150###	DATE=`date`
151###	ENVLIST=`env`
152###	/usr/lib/sendmail $LINKERALIAS << EOF
153###To: $LINKERALIAS
154###Subject: SUNWonld Linker Package Installation: $PRODVERS
155###Content-type: text/plain
156###Precedence: junk
157###--------
158###
159###Package Installation
160###uname: $HOSTINFO
161###date: $DATE
162###VERSION: $VERSION
163###ENV:
164###$ENVLIST
165###$ENV
166###
167###.
168###EOF
169###fi
170
171