1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#!/usr/bin/perl
# Gerald Pani
#
#
# installHeader.pl
#
# $Id: hgInstallHeader,v 1.1 1995/11/28 13:18:50 root Exp $
#
# $Log: hgInstallHeader,v $
# Revision 1.1 1995/11/28 13:18:50 root
# Initial revision
#
#
$path = '';
$src = '';
$dst = '';
{
local($arg);
while ($arg = shift) {
if ($arg =~ /^-p$/) {
if (($arg = shift) && (!($arg =~ /^-/))) {
$path = $arg;
next;
}
else {
die &Usage();
}
}
elsif ($arg =~ /^-s$/) {
if (($arg = shift) && (!($arg =~ /^-/))) {
$src = $arg;
next;
}
else {
die &Usage();
}
}
elsif ($arg =~ /^-d$/) {
if (($arg = shift) && (!($arg =~ /^-/))) {
$dst = $arg;
next;
}
else {
die &Usage();
}
}
die &Usage();
}
}
die &Usage() if (!$path || !$dst || !$src);
$stime = (stat($src))[9];
$dtime = (stat($dst))[9];
exit(0) if ($stime <= $dtime);
open(SRC, "< $src") || die "open $src:$!\n";
rename($dst, "$dst.old");
open(DST, "> $dst") || die "create $dst:$!\n";
while(<SRC>) {
/^(\#\s*include\s+)\"([^\/]\S+)\"(.*)/ && (print(DST "$1<$path/$2>$3\n"), next);
print DST;
}
close(SRC);
close(DST);
chmod( 0444, $dst) || die "chmod $dst:$!\n";
exit(0);
|