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