1 # 2 # CDDL HEADER START 3 # 4 # The contents of this file are subject to the terms of the 5 # Common Development and Distribution License (the "License"). 6 # You may not use this file except in compliance with the License. 7 # 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 # or http://www.opensolaris.org/os/licensing. 10 # See the License for the specific language governing permissions 11 # and limitations under the License. 12 # 13 # When distributing Covered Code, include this CDDL HEADER in each 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 # If applicable, add the following below this CDDL HEADER, with the 16 # fields enclosed by brackets "[]" replaced with your own identifying 17 # information: Portions Copyright [yyyy] [name of copyright owner] 18 # 19 # CDDL HEADER END 20 # 21 # Copyright 2007 Sun Microsystems, Inc. All rights reserved. 22 # Use is subject to license terms. 23 # 24 # ident "%Z%%M% %I% %E% SMI" 25 # 26 # 27 # Copy files from SRCDIR to TARGETDIR. The list of files to 28 # be copied are stored in FILELIST in the format: 29 # 30 # <type(f or d)> <permission> <ownership> <filename> 31 # 32 copyfiles() { 33 typeset fl="" 34 35 SRCDIR=$1 36 TARGETDIR=$2 37 FILELIST=$3 38 39 cat "$FILELIST" | while read typ perms own f 40 do 41 fl="$f" 42 43 if [[ "$typ" = "d" ]] 44 then 45 mkdir -m $perms -p "$TARGETDIR/$f" 46 47 elif [[ "$typ" = "f" ]] 48 then 49 /usr/bin/cp -f -p "$SRCDIR/$f" "$TARGETDIR/$f" 50 51 elif [[ "$typ" = "s" ]] 52 then 53 fl=`echo $f | sed 's/=/ /' | cut -d" " -f1` 54 trg=`echo $f | sed 's/=/ /' | cut -d" " -f2` 55 ln -sf $trg "$TARGETDIR/$fl" 56 57 elif [[ "$typ" = "l" ]] 58 then 59 fl=`echo $f | sed 's/=/ /' | cut -d" " -f1` 60 trg=`echo $f | sed 's/=/ /' | cut -d" " -f2` 61 62 dir=`pwd` 63 cd `dirname "$TARGETDIR/$fl"` 64 ln -f $trg `basename "$fl"` 65 cd $dir 66 else 67 continue 68 fi 69 70 if [[ "$typ" != "s" ]] 71 then 72 if [[ "$typ" != "d" ]] 73 then 74 /usr/bin/chmod $perms "$TARGETDIR/$fl" 75 fi 76 /usr/bin/chown $own "$TARGETDIR/$fl" 77 else 78 /usr/bin/chown -h $own "$TARGETDIR/$fl" 79 fi 80 done 81 } 82 # 83 # Given a target base directory and a file containing a list of files, create 84 # any directories in that list with the permissions and ownership as specified 85 # in the list 86 # 87 mkdirs() { 88 typeset fl="" 89 90 TARGETDIR=$1 91 FILELIST=$2 92 93 cat "$FILELIST" | while read typ perms own f 94 do 95 fl="$f" 96 97 if [[ "$typ" = "d" ]] 98 then 99 /usr/bin/mkdir -m $perms -p "$TARGETDIR/$f" 100 /usr/bin/chown $own "$TARGETDIR/$fl" 101 fi 102 done 103 } 104 # 105 # Relocate a list of modules from one directory to another 106 # 107 relocatemodules() { 108 FROMDIR=$1 109 TODIR=$2 110 MODULES=$3 111 112 grep -v "^#" $MODULES | while read mod 113 do 114 fdir=`dirname $TODIR/$mod` 115 mkdir -p $fdir 116 117 cp $FROMDIR/$mod $TODIR/$mod 118 rm -f $FROMDIR/$mod 119 done 120 } 121 122