1 #!/bin/ksh -p 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 # 24 # Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 # ident "%Z%%M% %I% %E% SMI" 28 # 29 30 # 31 # Because we build more than one copy of perl at the same time we need each 32 # to have its own copy of the contrib subdirectory so that the concurrent 33 # builds don't interfere with each other. Rather than duplicating the contents 34 # of the contrib directory under each version of perl we copy the clearfiles 35 # from usr/src/cmd/perl/contrib to the appropriate build directory, taking 36 # care only to do the copy if necessary so as not to cause unnecessary rebuilds. 37 # 38 39 function usage 40 { 41 printf 'copy_contrib: usage is <src dir> <dst dir> <module> ...\n' 42 exit 1 43 } 44 45 # Check arguments. 46 typeset -r src=$1 47 typeset -r dst=$2 48 [[ $src = $dst || ! ( -d $src && -d $dst ) ]] && usage 49 shift 2 50 typeset -r modules=$* 51 [[ -z $modules ]] && usage 52 typeset -r pwd=$PWD 53 54 # 55 # Make sure all the modules have the necessary clearfiles fetched, 56 # but only if we have SCCS files (not true for the source product). 57 # 58 for dir in $(cd $src && find $modules -type d -name SCCS); do 59 dir=${dir%/SCCS} 60 cd $src/$dir 61 for file in SCCS/s.*; do 62 file=${file#SCCS/s\.} 63 if [[ ! ( -f $file || -f SCCS/p.$file ) ]]; then 64 set -e 65 printf 'sccs get %s/%s\n' $dir $file 66 sccs get $file 67 set +e 68 fi 69 done 70 cd $pwd 71 done 72 73 # 74 # Now copy all the clearfiles over to the destination directory, but only if 75 # the destination file doesn't exist or is older than the source file. 76 # Note we also ignore the Teamware req.flg and inc.flg files, to prevent 77 # Teamware bringover and putback warning about them not being in SCCS. 78 # 79 80 for obj in $(cd $src && find $modules -name SCCS -prune -o -print); do 81 # Handle directories. 82 if [[ -d $src/$obj ]]; then 83 # Create destination directory if required. 84 if [[ ! -d $dst/$obj ]]; then 85 set -e 86 printf 'mkdir -p %s/%s\n' $dst $obj 87 mkdir -p $dst/$obj 88 set +e 89 fi 90 91 # Handle plain files. 92 elif [[ -f $src/$obj ]]; then 93 if [[ $obj != */@(req|inc).flg && \ 94 $src/$obj -nt $dst/$obj ]]; then 95 set -e 96 rm -f $dst/$obj 97 printf 'cp -p %s/%s %s/%s\n' $src $obj $dst $obj 98 cp -p $src/$obj $dst/$obj 99 set +e 100 fi 101 102 # Anything else isn't handled. 103 else 104 printf 'copy_contrib: ERROR: unable to copy %s/%s' $src $obj 105 exit 1 106 fi 107 done 108 exit 0