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