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 52352Sab196087# Common Development and Distribution License (the "License"). 62352Sab196087# 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# 22*8881SAli.Bahrami@Sun.COM# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate# Use is subject to license terms. 240Sstevel@tonic-gate# 250Sstevel@tonic-gate 260Sstevel@tonic-gateONLDCPIO=/tmp/SUNWonld.cpio.$$ 270Sstevel@tonic-gate 280Sstevel@tonic-gate 290Sstevel@tonic-gate# 300Sstevel@tonic-gate# This script handles the installation of the new sgstools on 310Sstevel@tonic-gate# both Solaris10 systems (which libraries moved to '/lib') and 320Sstevel@tonic-gate# pre Solaris10 systems where libraries reside under '/usr/lib'. 330Sstevel@tonic-gate# 340Sstevel@tonic-gate# We test to deterine if '/lib' is a symlink (pre Solaris10) or a 350Sstevel@tonic-gate# directory (Solaris10 & later). We key off of that for 360Sstevel@tonic-gate# everything below. 370Sstevel@tonic-gate# 380Sstevel@tonic-gateif [ -h ${BASEDIR}/lib ] 390Sstevel@tonic-gatethen 400Sstevel@tonic-gate LIBBASE=usr/lib 410Sstevel@tonic-gate ETCLIST="etc/lib/ld.so.1 etc/lib/libdl.so.1" 420Sstevel@tonic-gateelse 430Sstevel@tonic-gate LIBBASE=lib 440Sstevel@tonic-gatefi 450Sstevel@tonic-gateexport LIBBASE 460Sstevel@tonic-gate 470Sstevel@tonic-gate 480Sstevel@tonic-gatebuild_liblist () 490Sstevel@tonic-gate{ 500Sstevel@tonic-gate # 510Sstevel@tonic-gate # Build '/lib' file list for backing up 520Sstevel@tonic-gate # 530Sstevel@tonic-gate cd $BASEDIR/$SGSDIR/lib 54*8881SAli.Bahrami@Sun.COM find . \( -type f -o -type l \) -print | sed 's/^\.\///'g | 55*8881SAli.Bahrami@Sun.COM while read file 560Sstevel@tonic-gate do 570Sstevel@tonic-gate if [ \( -f $BASEDIR/$LIBBASE/$file \) -o \ 580Sstevel@tonic-gate \( -h $BASEDIR/$LIBBASE/$file \) ]; then 590Sstevel@tonic-gate echo $LIBBASE/$file 600Sstevel@tonic-gate fi 610Sstevel@tonic-gate done 620Sstevel@tonic-gate} 630Sstevel@tonic-gate 640Sstevel@tonic-gatebuild_filelist() 650Sstevel@tonic-gate{ 660Sstevel@tonic-gate # 670Sstevel@tonic-gate # Build rest of files 680Sstevel@tonic-gate # 690Sstevel@tonic-gate cd $BASEDIR/$SGSDIR 700Sstevel@tonic-gate find usr \( -type f -o -type l \) -print | while read file 710Sstevel@tonic-gate do 720Sstevel@tonic-gate if [ \( -f $BASEDIR/$file \) -o \ 730Sstevel@tonic-gate \( -h $BASEDIR/$file \) ]; then 740Sstevel@tonic-gate echo $file 750Sstevel@tonic-gate fi 760Sstevel@tonic-gate done 770Sstevel@tonic-gate} 780Sstevel@tonic-gate 794242Sab196087build_newitemsfile () 804242Sab196087{ 814242Sab196087 rm -f ${SGSBACKUPDIR}.newfiles 824242Sab196087 834242Sab196087 # Build a list of files/directories that this package is going 844242Sab196087 # add to the system that do not already exist. 854242Sab196087 cd $BASEDIR/$SGSDIR/lib 86*8881SAli.Bahrami@Sun.COM find . -depth -print | sed 's/^\.\///'g | while read file 874242Sab196087 do 884242Sab196087 # Built in /bin/sh test lacks -e 894242Sab196087 /usr/bin/test \! -e "$BASEDIR/$LIBBASE/$file" 904242Sab196087 if [ $? = 0 ]; then 914242Sab196087 echo $LIBBASE/$file >> ${SGSBACKUPDIR}.newfiles 924242Sab196087 fi 934242Sab196087 done 944242Sab196087 954242Sab196087 cd $BASEDIR/$SGSDIR 964242Sab196087 find usr -depth -print | while read file 974242Sab196087 do 984242Sab196087 /usr/bin/test \! -e "$BASEDIR/$file" 994242Sab196087 if [ $? = 0 ]; then 1004242Sab196087 echo $file >> ${SGSBACKUPDIR}.newfiles 1014242Sab196087 fi 1024242Sab196087 done 1034242Sab196087} 1044242Sab196087 1054242Sab196087# Generate a file containing the names of the files and directories 1064242Sab196087# that are being added (as opposed to being replaced) to the system. 1074242Sab196087# These items will need to be explicitly removed at uninstall. 1084242Sab196087build_newitemsfile 1094242Sab196087 110*8881SAli.Bahrami@Sun.COM# Generate a file containing the names of the original files backed 111*8881SAli.Bahrami@Sun.COM# up from the system. These items will be moved back at uninstall. 112*8881SAli.Bahrami@Sun.COMLIBLIST=`build_liblist` 113*8881SAli.Bahrami@Sun.COMFILELIST=`build_filelist` 114*8881SAli.Bahrami@Sun.COMfor file in $LIBLIST $FILELIST $ETCLIST 115*8881SAli.Bahrami@Sun.COMdo 116*8881SAli.Bahrami@Sun.COM echo $file 117*8881SAli.Bahrami@Sun.COMdone > ${SGSBACKUPDIR}.origfiles 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate# 1200Sstevel@tonic-gate# backup all existing SGStools. 1210Sstevel@tonic-gate# 1220Sstevel@tonic-gateecho "Backup up existing SGS tools to $SGSBACKUPDIR..." 1230Sstevel@tonic-gatecd $BASEDIR 124*8881SAli.Bahrami@Sun.COMcpio -pdm $BASEDIR/$SGSBACKUPDIR < ${SGSBACKUPDIR}.origfiles 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate# 1280Sstevel@tonic-gate# Overwrite SGSTOOLS onto existing system. We use CPIO 129*8881SAli.Bahrami@Sun.COM# because it unlinks a file and then creates a new one 130*8881SAli.Bahrami@Sun.COM# instead of copying over an existing inode. This is 1310Sstevel@tonic-gate# required when updating libraries (and the run-time linker) 1320Sstevel@tonic-gate# which are currently being used. 1330Sstevel@tonic-gate# 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate# 1370Sstevel@tonic-gate# First '/lib' components 1380Sstevel@tonic-gate# 1390Sstevel@tonic-gateecho "Installing new SGSTOOLS from $BASEDIR/$SGSDIR" 1400Sstevel@tonic-gate 1410Sstevel@tonic-gateprev_bindnow=$LD_BIND_NOW 1420Sstevel@tonic-gateLD_BIND_NOW=1 1430Sstevel@tonic-gateexport LD_BIND_NOW 1440Sstevel@tonic-gate 1450Sstevel@tonic-gatecd $BASEDIR/$SGSDIR/lib 1460Sstevel@tonic-gatefind . -depth -print | cpio -o -O $ONLDCPIO 1470Sstevel@tonic-gatecd $BASEDIR/$LIBBASE 1480Sstevel@tonic-gatecpio -imdu < $ONLDCPIO 1490Sstevel@tonic-gaterm -f $ONLDCPIO 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate# 1520Sstevel@tonic-gate# Then everything else 1530Sstevel@tonic-gate# 1540Sstevel@tonic-gatecd $BASEDIR/$SGSDIR 1550Sstevel@tonic-gatefind usr -depth -print | cpio -o -O $ONLDCPIO 1560Sstevel@tonic-gatecd $BASEDIR 1570Sstevel@tonic-gatecpio -imdu < $ONLDCPIO 1580Sstevel@tonic-gaterm -f $ONLDCPIO 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate# 1620Sstevel@tonic-gate# Populate '/etc/lib' directories on systems with the 1630Sstevel@tonic-gate# run-time linker installed under '/usr/lib/ld.so.1' 1640Sstevel@tonic-gate# 1650Sstevel@tonic-gateif [ "${ETCLIST}x" != "x" ]; then 1660Sstevel@tonic-gate cp $BASEDIR/usr/lib/ld.so.1 $BASEDIR/etc/lib/ld.so.1.onld 1670Sstevel@tonic-gate cp $BASEDIR/usr/lib/libdl.so.1 $BASEDIR/etc/lib/libdl.so.1.onld 1680Sstevel@tonic-gate cd $BASEDIR/etc/lib 1690Sstevel@tonic-gate mv ld.so.1.onld ld.so.1 1700Sstevel@tonic-gate mv libdl.so.1.onld libdl.so.1 1710Sstevel@tonic-gatefi 1720Sstevel@tonic-gate 1730Sstevel@tonic-gateLD_BIND_NOW=$prev_bindnow 174