xref: /titanic_44/usr/src/cmd/sgs/packages/common/postinstall (revision ea8dc4b6d2251b437950c0056bc626b311c73c27)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License, Version 1.0 only
6# (the "License").  You may not use this file except in compliance
7# with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23#ident	"%Z%%M%	%I%	%E% SMI"
24#
25# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
26# Use is subject to license terms.
27#
28
29ONLDCPIO=/tmp/SUNWonld.cpio.$$
30LINKERALIAS=linker_install@eng.sun.com
31
32
33#
34# This script handles the installation of the new sgstools on
35# both Solaris10 systems (which libraries moved to '/lib') and
36# pre Solaris10 systems where libraries reside under '/usr/lib'.
37#
38# We test to deterine if '/lib' is a symlink (pre Solaris10) or a
39# directory (Solaris10 & later).  We key off of that for
40# everything below.
41#
42if [ -h ${BASEDIR}/lib ]
43then
44	LIBBASE=usr/lib
45	ETCLIST="etc/lib/ld.so.1 etc/lib/libdl.so.1"
46else
47	LIBBASE=lib
48fi
49export LIBBASE
50
51
52build_liblist ()
53{
54	#
55	# Build '/lib' file list for backing up
56	#
57	cd $BASEDIR/$SGSDIR/lib
58	find . \( -type f -o -type l \) -print | while read file
59	do
60		if [ \( -f $BASEDIR/$LIBBASE/$file \)  -o \
61		    \( -h $BASEDIR/$LIBBASE/$file \) ]; then
62			echo $LIBBASE/$file
63		fi
64	done
65}
66
67build_filelist()
68{
69	#
70	# Build rest of files
71	#
72	cd $BASEDIR/$SGSDIR
73	find usr \( -type f -o -type l \) -print | while read file
74	do
75		if [ \( -f $BASEDIR/$file \)  -o \
76		    \( -h $BASEDIR/$file \) ]; then
77			echo $file
78		fi
79	done
80}
81
82LIBLIST=`build_liblist`
83FILELIST=`build_filelist`
84
85#
86# backup all existing SGStools.
87#
88echo "Backup up existing SGS tools to $SGSBACKUPDIR..."
89cd $BASEDIR
90for file in $LIBLIST $FILELIST $ETCLIST
91do
92	echo $file
93done  | cpio -pdm $BASEDIR/$SGSBACKUPDIR
94
95
96#
97# Overwrite SGSTOOLS onto existing system.  We use CPIO
98# because rm's a file and then installs a new one
99# instead of copying over a existing file.  This is
100# required when updating libraries (and the run-time linker)
101# which are currently being used.
102#
103
104
105#
106# First '/lib' components
107#
108echo "Installing new SGSTOOLS from $BASEDIR/$SGSDIR"
109
110prev_bindnow=$LD_BIND_NOW
111LD_BIND_NOW=1
112export LD_BIND_NOW
113
114cd $BASEDIR/$SGSDIR/lib
115find . -depth -print | cpio -o -O $ONLDCPIO
116cd $BASEDIR/$LIBBASE
117cpio -imdu < $ONLDCPIO
118rm -f $ONLDCPIO
119
120#
121# Then everything else
122#
123cd $BASEDIR/$SGSDIR
124find usr -depth -print | cpio -o -O $ONLDCPIO
125cd $BASEDIR
126cpio -imdu < $ONLDCPIO
127rm -f $ONLDCPIO
128
129
130#
131# Populate '/etc/lib' directories on systems with the
132# run-time linker installed under '/usr/lib/ld.so.1'
133#
134if [ "${ETCLIST}x" != "x" ]; then
135	cp $BASEDIR/usr/lib/ld.so.1 $BASEDIR/etc/lib/ld.so.1.onld
136	cp $BASEDIR/usr/lib/libdl.so.1 $BASEDIR/etc/lib/libdl.so.1.onld
137	cd $BASEDIR/etc/lib
138	mv ld.so.1.onld ld.so.1
139	mv libdl.so.1.onld libdl.so.1
140fi
141
142LD_BIND_NOW=$prev_bindnow
143
144#
145# E-mail sent to track installations of SUNWonld package.
146# purely for statistical purposes.
147#
148if [ -f /usr/lib/sendmail ]
149then
150	HOSTINFO=`uname -a`
151	DATE=`date`
152	ENVLIST=`env`
153	/usr/lib/sendmail $LINKERALIAS << EOF
154To: $LINKERALIAS
155Subject: SUNWonld Linker Package Installation: $PRODVERS
156Content-type: text/plain
157Precedence: junk
158--------
159
160Package Installation
161uname: $HOSTINFO
162date: $DATE
163VERSION: $VERSION
164ENV:
165$ENVLIST
166$ENV
167
168.
169EOF
170fi
171
172