1 #!/bin/sh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License, Version 1.0 only 7 # (the "License"). You may not use this file except in compliance 8 # with the License. 9 # 10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 # or http://www.opensolaris.org/os/licensing. 12 # See the License for the specific language governing permissions 13 # and limitations under the License. 14 # 15 # When distributing Covered Code, include this CDDL HEADER in each 16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 # If applicable, add the following below this CDDL HEADER, with the 18 # fields enclosed by brackets "[]" replaced with your own identifying 19 # information: Portions Copyright [yyyy] [name of copyright owner] 20 # 21 # CDDL HEADER END 22 # 23 # 24 # Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 #ident "%Z%%M% %I% %E% SMI" 28 # 29 # checkinstall.initd 30 # 31 # Before we begin installing new files, we need to save the existing files 32 # if the administrator has modified them since their original installation. 33 # To do this, we find 'e' and 'l' entries in the pkgmap, convert their 34 # relative "etc/" prefix to /etc, and them pipe them into pkgchk. For 35 # each file which already exists and whose contents do not match the size or 36 # checksum saved in the package database, we get (^ = start of line): 37 # 38 # ^ERROR: /etc/init.d/somefile 39 # ^ file size <104780> expected <181> actual 40 # ^ file cksum <56515> expected <14331> actual 41 # 42 # We grep for ERROR: followed by a single non-whitespace token, then strip 43 # the leading '^ERROR: ', leaving us a name of a modified file that we 44 # capture in the MODIFIED_AFTER_INSTALLED variable. This variable is written 45 # to the file provided as an argument to the script, in the form of an 46 # environment variable setting. Said file later gets sourced by 47 # the pkgadd command for use in our class action script. 48 49 case "$ARCH" in 50 sparc.sun4m) EXT=.m;; 51 sparc.sun4u) EXT=.u;; 52 sparc.sun4v) EXT=.v;; 53 i386.i86pc) EXT=.i;; 54 *) EXT="";; 55 esac 56 57 PKGMAP=$INST_DATADIR/$PKG$EXT/pkgmap 58 MODIFIED_AFTER_INSTALLED="" 59 60 if [ "$UPDATE" = yes ]; then 61 MODIFIED_AFTER_INSTALLED=` \ 62 awk '($2 == "e" || $2 == "l") && $3 == "initd" {print $4}' $PKGMAP | \ 63 sed -e 's:^etc/:/etc/:' -e 's/=.*$//' | \ 64 pkgchk -R ${PKG_INSTALL_ROOT:-/} -q -i /dev/stdin $PKG 2>&1 | \ 65 grep '^ERROR: [^ ]*$' | sed 's/^ERROR: //' ` 66 fi 67 68 echo MODIFIED_AFTER_INSTALLED=\"${MODIFIED_AFTER_INSTALLED}\" > $1 69 exit 0 70