OpenSolaris_b135/pkgdefs/common_files/checkinstall.initd

#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"%Z%%M%	%I%	%E% SMI"
#
# checkinstall.initd
#
# Before we begin installing new files, we need to save the existing files
# if the administrator has modified them since their original installation.
# To do this, we find 'e' and 'l' entries in the pkgmap, convert their
# relative "etc/" prefix to /etc, and them pipe them into pkgchk.  For
# each file which already exists and whose contents do not match the size or
# checksum saved in the package database, we get (^ = start of line):
#
#	^ERROR: /etc/init.d/somefile
#	^    file size <104780> expected <181> actual
# 	^    file cksum <56515> expected <14331> actual
#
# We grep for ERROR: followed by a single non-whitespace token, then strip
# the leading '^ERROR: ', leaving us a name of a modified file that we
# capture in the MODIFIED_AFTER_INSTALLED variable.  This variable is written
# to the file provided as an argument to the script, in the form of an
# environment variable setting.  Said file later gets sourced by
# the pkgadd command for use in our class action script.

case "$ARCH" in
	sparc.sun4m)	EXT=.m;;
	sparc.sun4u)	EXT=.u;;
	sparc.sun4v)	EXT=.v;;
	i386.i86pc)	EXT=.i;;
	*)		EXT="";;
esac

PKGMAP=$INST_DATADIR/$PKG$EXT/pkgmap
MODIFIED_AFTER_INSTALLED=""

if [ "$UPDATE" = yes ]; then
	MODIFIED_AFTER_INSTALLED=` \
	  awk '($2 == "e" || $2 == "l") && $3 == "initd" {print $4}' $PKGMAP | \
	  sed -e 's:^etc/:/etc/:' -e 's/=.*$//' | \
	  pkgchk -R ${PKG_INSTALL_ROOT:-/} -q -i /dev/stdin $PKG 2>&1 | \
	  grep '^ERROR: [^ 	]*$' | sed 's/^ERROR: //' `
fi

echo MODIFIED_AFTER_INSTALLED=\"${MODIFIED_AFTER_INSTALLED}\" > $1
exit 0