mkcopy revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!/bin/perl -w
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident "%Z%%M% %I% %E% SMI"
#
# This script takes a file mapping CSV file as input (see Flist.csv for an
# example) and outputs a ksh script containing the SCCS and Teamware commands
# necessary to copy the required files from a stock perl 5.6.1 build directory
# into an ON workspace. Note that the 'sleep 1' commands are because Teamware
# can't cope with rapid check-ins of large numbers of files.
#
use strict;
use IO::File;
use POSIX qw(uname);
# SCCS comment
my $comment =
qq('PSARC 2001/145 Update of Perl shipped with Solaris to version 5.6.1');
@ARGV == 3 || die("Usage is $0 <mapping file> <perl build dir> <workspace>\n");
my ($mapfile, $pl, $ws) = @ARGV;
die("$pl is not a perl build dir\n") if (! -f "$pl/config.sh");
die("$ws is not a workspace\n") if (! -d "$ws/Codemgr_wsdata");
my $src = "$ws/usr/src/cmd/perl/5.6.1";
my $arch = ((uname())[4] eq 'i86pc') ? 'i386' : 'sparc';
my $otherarch = $arch eq 'i386' ? 'sparc' : 'i386';
# Read in the mapping file
my $fh = IO::File->new($mapfile) || die("Can't open $mapfile: $!\n");
my ($line, %files);
while (($line = $fh->getline()) && $line !~ /^Path/) {
;
}
while ($line = $fh->getline()) {
$line =~ s/\r$//; chomp($line);
my ($path, $file, $p500503, $s8, $p561, $s9, $new) =
split(/,/, $line, 8);
$files{$path}{$file}{500503} = $p500503 if ($p500503);
$files{$path}{$file}{s8} = $s8 if ($s8);
$files{$path}{$file}{561} = $p561 if ($p561);
$files{$path}{$file}{s9} = $s9 if ($s9);
$files{$path}{$file}{new} = $new if ($new);
}
$fh->close();
# Process the mappings
print("#!/bin/ksh\n\nunalias rm\nset -ex\nexport CODEMGR_WS=$ws\n\n");
foreach my $path (sort(keys(%files))) {
foreach my $file (sort(keys(%{$files{$path}}))) {
my $rec = $files{$path}{$file};
next unless (exists($rec->{s9}));
my ($p, $f) = ($path, $file);
$p =~ s!^\.!!;
my $pf = "$p$f";
# If it is to go into the s9 distrib directory
if ($rec->{s9} eq 'distrib') {
print("mkdir -p $src/distrib$p\n");
print("cp $pl$pf $src/distrib$pf\n");
print("( cd $src/distrib$p && " .
"sccs create $f -y$comment && sleep 1 )\n");
print("rm -f $src/distrib$p,$f\n\n");
# If it is to go into the s9 arch directory
} elsif ($rec->{s9} eq 'arch' && $pf !~ /$otherarch/) {
$p =~ s!$arch/?!!;
$pf =~ s!$arch/?!!;
print("mkdir -p $src/$arch$p\n");
print("cp $pl$pf $src/$arch$pf\n");
print("( cd $src/$arch$p && " .
"sccs create $f -y$comment && sleep 1 )\n");
print("rm -f $src/$arch$p,$f\n\n");
}
}
}
print("echo SUCCESS\n");