xref: /illumos-gate/usr/src/cmd/svr4pkg/pkgscripts/r.sed.sh (revision 5c51f1241dbbdf2656d0e10011981411ed0c9673)
1*5c51f124SMoriah Waterland#!/bin/sh
2*5c51f124SMoriah Waterland#
3*5c51f124SMoriah Waterland# CDDL HEADER START
4*5c51f124SMoriah Waterland#
5*5c51f124SMoriah Waterland# The contents of this file are subject to the terms of the
6*5c51f124SMoriah Waterland# Common Development and Distribution License (the "License").
7*5c51f124SMoriah Waterland# You may not use this file except in compliance with the License.
8*5c51f124SMoriah Waterland#
9*5c51f124SMoriah Waterland# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*5c51f124SMoriah Waterland# or http://www.opensolaris.org/os/licensing.
11*5c51f124SMoriah Waterland# See the License for the specific language governing permissions
12*5c51f124SMoriah Waterland# and limitations under the License.
13*5c51f124SMoriah Waterland#
14*5c51f124SMoriah Waterland# When distributing Covered Code, include this CDDL HEADER in each
15*5c51f124SMoriah Waterland# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*5c51f124SMoriah Waterland# If applicable, add the following below this CDDL HEADER, with the
17*5c51f124SMoriah Waterland# fields enclosed by brackets "[]" replaced with your own identifying
18*5c51f124SMoriah Waterland# information: Portions Copyright [yyyy] [name of copyright owner]
19*5c51f124SMoriah Waterland#
20*5c51f124SMoriah Waterland# CDDL HEADER END
21*5c51f124SMoriah Waterland#
22*5c51f124SMoriah Waterland
23*5c51f124SMoriah Waterland#
24*5c51f124SMoriah Waterland# Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
25*5c51f124SMoriah Waterland# Use is subject to license terms.
26*5c51f124SMoriah Waterland#
27*5c51f124SMoriah Waterland
28*5c51f124SMoriah Waterlanderror=no
29*5c51f124SMoriah Waterlandwhile read dest
30*5c51f124SMoriah Waterlanddo
31*5c51f124SMoriah Waterland	if [ -d $dest ]
32*5c51f124SMoriah Waterland	then
33*5c51f124SMoriah Waterland		echo "$dest"
34*5c51f124SMoriah Waterland		rmdir $dest || error=yes
35*5c51f124SMoriah Waterland	elif [ -f $dest ]
36*5c51f124SMoriah Waterland	then
37*5c51f124SMoriah Waterland		echo "Modifying $dest"
38*5c51f124SMoriah Waterland
39*5c51f124SMoriah Waterland		# Strip PKG_INSTALL_ROOT from dest if installation is to an
40*5c51f124SMoriah Waterland		# alternate root.
41*5c51f124SMoriah Waterland
42*5c51f124SMoriah Waterland		if [ -n "$PKG_INSTALL_ROOT" -a "$PKG_INSTALL_ROOT" != "/" ]; then
43*5c51f124SMoriah Waterland			client_dest=`echo $dest | \
44*5c51f124SMoriah Waterland				/usr/bin/nawk -v rootdir="$PKG_INSTALL_ROOT" '{
45*5c51f124SMoriah Waterland				    { print substr($0, length(rootdir)+1)} }'`
46*5c51f124SMoriah Waterland			savepath=$PKGSAV/sed${client_dest}
47*5c51f124SMoriah Waterland		else
48*5c51f124SMoriah Waterland			savepath=$PKGSAV/sed${dest}
49*5c51f124SMoriah Waterland		fi
50*5c51f124SMoriah Waterland
51*5c51f124SMoriah Waterland		/usr/sadm/install/scripts/cmdexec /bin/sed remove $savepath $dest ||
52*5c51f124SMoriah Waterland			error=yes
53*5c51f124SMoriah Waterland	else
54*5c51f124SMoriah Waterland		[ -r $dest ] && echo "$dest"
55*5c51f124SMoriah Waterland		rm -f $dest || error=yes
56*5c51f124SMoriah Waterland	fi
57*5c51f124SMoriah Waterlanddone
58*5c51f124SMoriah Waterland[ "$error" = yes ] &&
59*5c51f124SMoriah Waterland	exit 2
60*5c51f124SMoriah Waterlandexit 0
61