xref: /titanic_44/usr/src/cmd/sgs/packages/common/postinstall (revision 40e5e17b3361b3eea56a9723071c406894a20b78)
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 2006 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
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