1N/A#!/usr/perl5/5.8.4/bin/perl
1N/A#
1N/A# Copyright 2004 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# This script takes a file mapping CSV file as input (see flist_s10_5-8-4.csv
1N/A# for an example), a perl build directory and an ON workspace and outputs a ksh
1N/A# script containing the SCCS and Teamware commands necessary to copy the
1N/A# required files from the perl build directory into the ON workspace. Note that
1N/A# the 'sleep 1' commands are because Teamware can't cope with rapid check-ins of
1N/A# large numbers of files.
1N/A#
1N/A
1N/Ause strict;
1N/Ause warnings;
1N/Ause POSIX qw(uname);
1N/A
1N/A# SCCS comment, perl versions.
1N/Aour $Comment =
1N/A qq('5040539 Perl 5.8.4 should be integrated into S10');
1N/Aour $Ver = '5.8.4';
1N/Aour $PrevVer = '5.8.3';
1N/A
1N/A# Cache of already-created directories.
1N/Aour %DirsMade;
1N/A
1N/A#
1N/A# Make a directory if it hasn't already been made.
1N/A#
1N/Asub make_dir
1N/A{
1N/A my ($dir) = @_;
1N/A
1N/A if (! exists($DirsMade{$dir})) {
1N/A print("mkdir -p $dir\n");
1N/A $DirsMade{$dir}++;
1N/A }
1N/A}
1N/A
1N/A#
1N/A# Main.
1N/A#
1N/A
1N/A# Basic sanity checks.
1N/A@ARGV == 3 || die("Usage is $0 <mapping file> <perl build dir> <workspace>\n");
1N/Amy ($mapfile, $bld, $ws) = @ARGV;
1N/Adie("$bld is not a perl build dir\n") if (! -f "$bld/config.sh");
1N/Adie("$ws is not a workspace\n") if (! -d "$ws/Codemgr_wsdata");
1N/A
1N/A# Work out directory locations.
1N/Amy $ver_dst = "$ws/usr/src/cmd/perl/$Ver";
1N/Amy $prev_ver_dst = "$ws/usr/src/cmd/perl/$PrevVer";
1N/Amy $arch = ((uname())[4] eq 'i86pc') ? 'i386' : 'sparc';
1N/A
1N/A# Read in the mapping file.
1N/Amy ($fh, $line, %file);
1N/Aopen($fh, '<', $mapfile) || die("Can't open $mapfile: $!\n");
1N/Awhile (defined($line = <$fh>) && $line !~ m{^"Path",}) {
1N/A ;
1N/A}
1N/Awhile (defined($line = <$fh>)) {
1N/A chomp($line);
1N/A my @field;
1N/A push(@field, $+) while $line =~
1N/A m{["']([^"'\\]*(?:\\.[^"'\\]*)*)["'],?|([^,]+),?|,}g;
1N/A push(@field, undef) if (substr($line, -1, 1) eq ',');
1N/A my $p = shift(@field);
1N/A my $f = shift(@field);
1N/A # We just want the s10 column.
1N/A $file{$p}{$f} = defined($field[3]) ? $field[3] : '';
1N/A}
1N/Aclose($fh);
1N/A
1N/A# Process the mappings.
1N/Aprint("#!/bin/ksh\n\nunalias rm\ntypeset -r comment=$Comment\n",
1N/A "set -ex\nexport CODEMGR_WS=$ws\n\n");
1N/Aforeach my $p (sort(keys(%file))) {
1N/A foreach my $f (sort(keys(%{$file{$p}}))) {
1N/A my $d = $file{$p}{$f};
1N/A my $pf = ($p ne '' ? "$p/" : $p) . $f;
1N/A my $cpf = ($p ne '' ? "$p/" : $p) . ",$f";
1N/A
1N/A # If it is to go into the distrib directory.
1N/A if ($d eq 'distrib') {
1N/A make_dir("$ver_dst/distrib/$p");
1N/A print("cp $bld/$pf $ver_dst/distrib/$pf\n");
1N/A print("( cd $ver_dst/distrib/$p && ",
1N/A "sccs create $f -y\"\$comment\" )\n");
1N/A print("rm -f $ver_dst/distrib/$cpf\n");
1N/A print("sleep 1\n");
1N/A
1N/A # If it is to go into the arch directory.
1N/A } elsif ($d eq 'arch') {
1N/A make_dir("$ver_dst/$arch");
1N/A print("cp $bld/$pf $ver_dst/$arch/$f\n");
1N/A print("( cd $ver_dst/$arch/$p && ",
1N/A "sccs create $f -y\"\$comment\" )\n");
1N/A print("rm -f $ver_dst/$arch/$cpf\n");
1N/A print("sleep 1\n");
1N/A
1N/A # If it is to be copied forwards from the last version.
1N/A } elsif ($d eq 'fwd') {
1N/A make_dir("$ver_dst/distrib/$p");
1N/A print("( cd $prev_ver_dst/distrib/$p && ",
1N/A "sccs edit $f && cp $f $ver_dst/distrib/$pf && ",
1N/A "sccs unedit $f )\n");
1N/A print("( cd $ver_dst/distrib/$p && ",
1N/A "sccs create $f -y\"\$comment\" )\n");
1N/A print("rm -f $ver_dst/distrib/$cpf\n");
1N/A print("sleep 1\n");
1N/A }
1N/A }
1N/A}
1N/A
1N/A# Write a fake MANIFEST file, for 'make test'.
1N/Aprint("cat > $ver_dst/distrib/MANIFEST <<EOF\n");
1N/Aforeach my $p (sort(keys(%file))) {
1N/A foreach my $f (sort(keys(%{$file{$p}}))) {
1N/A print(($p ne '' ? "$p/" : $p) . $f . "\n")
1N/A if ($file{$p}{$f} eq 'distrib');
1N/A }
1N/A}
1N/Aprint("EOF\n");
1N/Aprint("( cd $ver_dst/distrib && sccs create MANIFEST -y\"\$comment\" )\n");
1N/Aprint("rm -f $ver_dst/distrib/,MANIFEST\n");
1N/A
1N/Aprint("echo SUCCESS\n");