mkmerge 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 merge the required files from a stock perl 5.6.1 build directory
# on top of a workspace containing the existing 5.005_03 version. 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";
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};
my ($p, $f) = ($path, $file);
$p =~ s!^\.!!;
my $pf = "$p$f";
# If it was in s8 but isn't in s9, delete it
if (exists($rec->{s8}) &&
((! exists($rec->{s9})) ||
(exists($rec->{s9}) && $rec->{s9} eq 'delete'))) {
if ($rec->{s8} eq 'distrib') {
print("workspace filerm $src/distrib$pf\n\n");
} else {
print("workspace filerm $src$pf\n\n");
}
# If it is to go into the s9 distrib directory
} elsif (exists($rec->{s9}) && $rec->{s9} eq 'distrib') {
# If it already exists in s8, edit & check in
if (exists($rec->{s8})) {
print("( cd $src/distrib$p && " .
"sccs edit $f )\n");
print("cp $pl$pf $src/distrib$pf\n");
print("( cd $src/distrib$p && " .
"sccs delget $f -y$comment )\n\n");
# Otherwise check in
} else {
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 (exists($rec->{s9}) && $rec->{s9} eq 'arch' &&
$pf !~ /$otherarch/) {
$p =~ s!$arch/?!!;
$pf =~ s!$arch/?!!;
if (exists($rec->{s8}) && $rec->{s8} eq $rec->{s9}) {
print("( cd $src/$arch$p && sccs edit $f )\n");
print("cp $pl$pf $src/$arch$pf\n\n");
} else {
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");