xref: /onnv-gate/usr/src/cmd/svr4pkg/pkgscripts/i.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 src dest
30*9781SMoriah.Waterland@Sun.COMdo
31*9781SMoriah.Waterland@Sun.COM	[ "$src" = /dev/null ] && continue
32*9781SMoriah.Waterland@Sun.COM
33*9781SMoriah.Waterland@Sun.COM	echo "Modifying $dest"
34*9781SMoriah.Waterland@Sun.COM
35*9781SMoriah.Waterland@Sun.COM	# Strip PKG_INSTALL_ROOT from dest if installation is to an
36*9781SMoriah.Waterland@Sun.COM	# alternate root.
37*9781SMoriah.Waterland@Sun.COM
38*9781SMoriah.Waterland@Sun.COM	if [ -n "$PKG_INSTALL_ROOT" -a "$PKG_INSTALL_ROOT" != "/" ]; then
39*9781SMoriah.Waterland@Sun.COM		client_dest=`echo $dest | \
40*9781SMoriah.Waterland@Sun.COM			/usr/bin/nawk -v rootdir="$PKG_INSTALL_ROOT" '{
41*9781SMoriah.Waterland@Sun.COM				{ print substr($0, length(rootdir)+1)} }'`
42*9781SMoriah.Waterland@Sun.COM		savepath=$PKGSAV/awk${client_dest}
43*9781SMoriah.Waterland@Sun.COM	else
44*9781SMoriah.Waterland@Sun.COM		savepath=$PKGSAV/awk${dest}
45*9781SMoriah.Waterland@Sun.COM	fi
46*9781SMoriah.Waterland@Sun.COM
47*9781SMoriah.Waterland@Sun.COM	dirname=`dirname $savepath`
48*9781SMoriah.Waterland@Sun.COM	if [ $? -ne 0 ]
49*9781SMoriah.Waterland@Sun.COM	then
50*9781SMoriah.Waterland@Sun.COM		error=yes
51*9781SMoriah.Waterland@Sun.COM		continue
52*9781SMoriah.Waterland@Sun.COM	fi
53*9781SMoriah.Waterland@Sun.COM	if [ ! -d $dirname ]
54*9781SMoriah.Waterland@Sun.COM	then
55*9781SMoriah.Waterland@Sun.COM		# ignore return code since mkdir has bug
56*9781SMoriah.Waterland@Sun.COM		mkdir -p $dirname
57*9781SMoriah.Waterland@Sun.COM	fi
58*9781SMoriah.Waterland@Sun.COM
59*9781SMoriah.Waterland@Sun.COM	cp $src $savepath &&
60*9781SMoriah.Waterland@Sun.COM	/usr/sadm/install/scripts/cmdexec /usr/bin/awk install $savepath $dest
61*9781SMoriah.Waterland@Sun.COM
62*9781SMoriah.Waterland@Sun.COM	if [ $? -ne 0 ]
63*9781SMoriah.Waterland@Sun.COM	then
64*9781SMoriah.Waterland@Sun.COM		error=yes
65*9781SMoriah.Waterland@Sun.COM		continue
66*9781SMoriah.Waterland@Sun.COM	fi
67*9781SMoriah.Waterland@Sun.COMdone
68*9781SMoriah.Waterland@Sun.COM[ "$error" = yes ] &&
69*9781SMoriah.Waterland@Sun.COM	exit 2
70*9781SMoriah.Waterland@Sun.COMexit 0
71