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