Alt-App-makepatch
view release on metacpan or search on metacpan
script/makepatch view on Meta::CPAN
unless ( -d catfile($old->{root},$dir) ) {
push (@workq, [ 'C', $dir, 0,
(stat(catfile($new->{root},$dir)))[9],
(stat(_))[2] ]);
$dcreated++;
}
$dir_ok{$dir} = 1;
}
}
}
}
my $fh = new IO::File;
$fh->open(">$tmpfile") || die ("$tmpfile: $!\n");
binmode($fh);
foreach ( @opt_descr ) {
print $fh ("# ", $_, "\n");
}
print $fh <<EOD;
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
EOD
if ( $removed || $created ) {
my $cd = "";
my $fd = "";
$cd = "create" if $created;
if ( $removed ) {
$cd .= "/" if $cd;
$cd .= "delete";
}
$fd = "files";
if ( $dcreated || $dremoved ) {
$fd .= "/" if $fd;
$fd .= "directories";
}
print $fh <<EOD;
# If you have a decent Bourne-type shell:
# STEP 2: Run the shell with this file as input.
# If you don't have such a shell, you may need to manually $cd
# the $fd as shown below.
# STEP 3: Run the 'patch' program with this file as input.
#
# These are the commands needed to create/delete files/directories:
#
EOD
foreach ( @workq ) {
my ($op, $file, @args) = @$_;
if ( $op eq 'C' ) {
print $fh ("mkdir ", quotfn($file), "\n");
if ( defined $args[2] && ($args[2] &= 0777) ) {
printf $fh ("chmod 0%o %s\n", $args[2], quotfn($file))
}
}
}
foreach ( @workq ) {
my ($op, $file, @args) = @$_;
if ( $op eq 'r' ) {
print $fh ("rm -f ", quotfn($file), "\n");
}
elsif ( $op eq 'R' ) {
print $fh ("rmdir ", quotfn($file), "\n");
}
elsif ( $op eq 'c' ) {
print $fh ("touch ", quotfn($file), "\n");
if ( defined $args[2] && ($args[2] &= 0777) ) {
printf $fh ("chmod 0%o %s\n", $args[2], quotfn($file))
}
}
}
print $fh <<EOD;
#
# This command terminates the shell and need not be executed manually.
exit
#
EOD
}
else {
print $fh <<EOD;
# STEP 2: Run the 'patch' program with this file as input.
#
EOD
}
print $fh <<EOD;
#### End of Preamble ####
#### Patch data follows ####
EOD
# Copy patch.
$patch->open($thepatch);
binmode($patch);
while ( <$patch> ) {
print $fh $_;
}
$patch->close;
# Print a reassuring "End of Patch" note so people won't
# wonder if their mailer truncated patches.
print $fh ("#### End of Patch data ####\n\n",
"#### ApplyPatch data follows ####\n",
"# Data version : $data_version\n",
"# Date generated : $timestamp\n",
"# Generated by : $my_name $my_version\n");
print $fh ("# Recurse directories : Yes\n") if $opt_recurse;
print $fh ("# Excluded files : ",
join("\n# ", @opt_exclude_regex), "\n")
if @opt_exclude_regex;
foreach ( @workq ) {
my ($op, $file, @args) = @$_;
$file = quotfn ($file);
print $fh ("# ", $op, " ", $file);
if ( defined ($args[2]) && ($op eq 'c' || $op eq 'C' || $op eq 'p') ) {
$args[2] = sprintf ("0%o", $args[2]);
}
print $fh (" ", join(" ", @args)) if @args;
print $fh ("\n");
}
print $fh ("#### End of ApplyPatch data ####\n");
print $fh ("\n#### End of Patch kit [created: $timestamp] ####\n");
$fh->close;
# Checksum calculation.
# Two checksums are calculated: one for the whole file (for compatibilty),
# and one for just the patch data (so the preamble can be modified).
my $lines = 0;
( run in 0.607 second using v1.01-cache-2.11-cpan-39bf76dae61 )