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 (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 # ident "%Z%%M% %I% %E% SMI" 24 # 25 # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 26 # Use is subject to license terms. 27 # 28 # This is similar to i.preserve, except we also check if there is a file with 29 # the same name in the parent directory. 30 # 31 32 CLEANUP_FILE=/tmp/CLEANUP 33 REMOVEF=removef 34 errmsg1="Could not remove file, referenced by another package" 35 errmsg2="in.ftpd will use both %s and %s" 36 37 while read src dest; do 38 if [ ! -f $dest ]; then 39 # If the destination file does not exit, check the parent 40 # directory to see if it is there. 41 destfile=`basename $dest` 42 destdir=`dirname $dest` 43 parentfile=`dirname $destdir`/$destfile 44 if [ ! -f $parentfile ]; then 45 # If there is no parent file as well, we can use the 46 # file contained in the package. 47 cp $src $dest 48 else 49 # If there is a parent file, then we copy the contents 50 # to the destination, and then try to remove it from 51 # a previous package instance. 52 cp $parentfile $dest 53 $REMOVEF $PKGINST $parentfile 2> /dev/null \ 54 | xargs rm -f 55 if [ -f $parentfile ]; then 56 # If the parent file still exists, we need 57 # to log messages for the user. 58 printf "%s: $errmsg1\n" $parentfile \ 59 >> $CLEANUP_FILE 60 printf "%s: $errmsg2\n" $parentfile $dest \ 61 $parentfile >> $CLEANUP_FILE 62 fi 63 fi 64 fi 65 for user in dladm smmsp gdm webservd mysql 66 do 67 egrep "^$user$|^#[ ]*$user$" $dest >/dev/null 2>&1 || \ 68 echo $user >> $dest 69 done 70 done 71 72 $REMOVEF -f $PKGINST > /dev/null 2>&1 73 exit 0 74