1N/A#!/bin/ksh -p
1N/A#
1N/A# CDDL HEADER START
1N/A#
1N/A# The contents of this file are subject to the terms of the
1N/A# Common Development and Distribution License (the "License").
1N/A# You may not use this file except in compliance with the License.
1N/A#
1N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1N/A# or http://www.opensolaris.org/os/licensing.
1N/A# See the License for the specific language governing permissions
1N/A# and limitations under the License.
1N/A#
1N/A# When distributing Covered Code, include this CDDL HEADER in each
1N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1N/A# If applicable, add the following below this CDDL HEADER, with the
1N/A# fields enclosed by brackets "[]" replaced with your own identifying
1N/A# information: Portions Copyright [yyyy] [name of copyright owner]
1N/A#
1N/A# CDDL HEADER END
1N/A#
1N/A
1N/A#
1N/A# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
1N/A# Use is subject to license terms.
1N/A#
1N/A# ident "%Z%%M% %I% %E% SMI"
1N/A#
1N/A
1N/A#
1N/A# Because we build more than one copy of perl at the same time we need each
1N/A# to have its own copy of the contrib subdirectory so that the concurrent
1N/A# builds don't interfere with each other. Rather than duplicating the contents
1N/A# of the contrib directory under each version of perl we copy the clearfiles
1N/A# from usr/src/cmd/perl/contrib to the appropriate build directory, taking
1N/A# care only to do the copy if necessary so as not to cause unnecessary rebuilds.
1N/A#
1N/A
1N/Afunction usage
1N/A{
1N/A printf 'copy_contrib: usage is <src dir> <dst dir> <module> ...\n'
1N/A exit 1
1N/A}
1N/A
1N/A# Check arguments.
1N/Atypeset -r src=$1
1N/Atypeset -r dst=$2
1N/A[[ $src = $dst || ! ( -d $src && -d $dst ) ]] && usage
1N/Ashift 2
1N/Atypeset -r modules=$*
1N/A[[ -z $modules ]] && usage
1N/Atypeset -r pwd=$PWD
1N/A
1N/A#
1N/A# Make sure all the modules have the necessary clearfiles fetched,
1N/A# but only if we have SCCS files (not true for the source product).
1N/A#
1N/Afor dir in $(cd $src && find $modules -type d -name SCCS); do
1N/A dir=${dir%/SCCS}
1N/A cd $src/$dir
1N/A for file in SCCS/s.*; do
1N/A file=${file#SCCS/s\.}
1N/A if [[ ! ( -f $file || -f SCCS/p.$file ) ]]; then
1N/A set -e
1N/A printf 'sccs get %s/%s\n' $dir $file
1N/A sccs get $file
1N/A set +e
1N/A fi
1N/A done
1N/A cd $pwd
1N/Adone
1N/A
1N/A#
1N/A# Now copy all the clearfiles over to the destination directory, but only if
1N/A# the destination file doesn't exist or is older than the source file.
1N/A# Note we also ignore the Teamware req.flg and inc.flg files, to prevent
1N/A# Teamware bringover and putback warning about them not being in SCCS.
1N/A#
1N/A
1N/Afor obj in $(cd $src && find $modules -name SCCS -prune -o -print); do
1N/A # Handle directories.
1N/A if [[ -d $src/$obj ]]; then
1N/A # Create destination directory if required.
1N/A if [[ ! -d $dst/$obj ]]; then
1N/A set -e
1N/A printf 'mkdir -p %s/%s\n' $dst $obj
1N/A mkdir -p $dst/$obj
1N/A set +e
1N/A fi
1N/A
1N/A # Handle plain files.
1N/A elif [[ -f $src/$obj ]]; then
1N/A if [[ $obj != */@(req|inc).flg && \
1N/A $src/$obj -nt $dst/$obj ]]; then
1N/A set -e
1N/A rm -f $dst/$obj
1N/A printf 'cp -p %s/%s %s/%s\n' $src $obj $dst $obj
1N/A cp -p $src/$obj $dst/$obj
1N/A set +e
1N/A fi
1N/A
1N/A # Anything else isn't handled.
1N/A else
1N/A printf 'copy_contrib: ERROR: unable to copy %s/%s' $src $obj
1N/A exit 1
1N/A fi
1N/Adone
1N/Aexit 0