Alt-App-makepatch

 view release on metacpan or  search on metacpan

script/makepatch  view on Meta::CPAN

# Status          : Released

use strict;
use Getopt::Long 2.00;
use IO qw(File);
use File::Basename;
use File::Spec;
use File::Path;

################ Common stuff ################

my $my_package = 'Sciurix';
my $my_name    = "makepatch";
my $my_version = "2.05";
my $data_version = '1.0';

################ Globals ################

## Options and defaults

my $opt_diff = 'diff -c';	# default diff command
my $opt_sort;			# sort entries. Default = 1
my $opt_follow = 0;		# follow symbolic links
my $opt_automanifest = "MANIFEST";
my $opt_oldmanifest;		# list of files of the old tree
my $opt_newmanifest;		# list of files of the new tree
my $opt_nomanifest = 0;		# suppress use of MANIFEST files
my $opt_patchlevel;		# patchlevel.h file
my $opt_prefix = '';		# prefix to be added
my $opt_filelist = 0;		# make file list
my $opt_infocmd;		# info command
my $opt_exclude_standard = 1;	# standard excludes
my $opt_exclude_rcs = 0;	# exclude RCS files
my $opt_exclude_cvs = 0;	# exclude CVS files
my $opt_exclude_sccs = 0;	# exclude SCCS files
my $opt_ignore_rcs_keywords = 0; # exclude CVS/RCS keyword data
my @opt_exclude;		# list of excludes (wildcards)
my @opt_exclude_regex;		# list of excludes (regex)
my $opt_recurse = 1;		# recurse
my @opt_descr = ();		# description
my %opt_extract = ();		# extraction rules

# Development options (not shown with -help).
my $opt_trace = 0;		# trace messages
my $opt_verbose = 0;		# verbose info
my $opt_quiet = 0;		# (almost?) no info
my $opt_debug = 0;		# debugging messages
my $opt_test = 0;		# testing

## Misc

my $exclude_pat;		# regex to exclude
my @workq = ();			# pre/post work

# Try to find a temp location.
my $TMPDIR = (File::Spec->can('tmpdir') && File::Spec->tmpdir)
  || $ENV{TMPDIR}
  || $ENV{TEMP}
  || '/usr/tmp';

my $dot_u = File::Spec::Unix->curdir; # UNIX current dir
my $dot = File::Spec->curdir;	# current dir
my $dotdot = File::Spec->updir;	# parent dir

# Try to find something home-ish.
my $HOME = $ENV{HOME}
  || ( ($^O eq 'MSWin32')
       && ( $ENV{APPDATA}
            || $ENV{USERPROFILE}
            || $ENV{HOMEDRIVE} && $ENV{HOMEPATH}
	       && $ENV{HOMEDRIVE}.$ENV{HOMEPATH}
	  )
     )
  || $dot;

# Try to find something null-ish.
my $DEVNULL = (File::Spec->can('devnull') && File::Spec->devnull)
  || '/dev/null';
my $nulpat = quotemeta($DEVNULL);	# pattern to match nul device

my $timestamp = "".localtime();	# timestamp, in string format
my $unified = 0;		# produce unified diff
my $skipped = 0;		# number of files skipped.
my $excluded = 0;		# number of files excluded.

## Subroutine prototypes

sub app_options ();
sub app_parse_rc ($$$);
sub app_usage ($);
sub app_usage_filelist ($);
sub catfile ($$);
sub check_extract ($);
sub cleanup ();
sub cvs_excludes($$$);
sub cvs_ignore($);
sub debug   (@);
sub dodiff ($$$$);
sub makepatch ();
sub extract ($$);
sub filelist ($);
sub make_filelist ($;$);
sub make_filelist_from_manifest ($);
sub message (@);
sub newfile ($$);
sub quotfn ($);
sub setup_excludes ();
sub showopts ($);
sub trace   (@);
sub verbose (@);
sub wrapup (;$);
sub yesno ($);

################ INI files, program parameters ################

app_options ();

################ Presets ################

if ( $opt_exclude_sccs ) {
    unshift (@opt_exclude, qw(p.* s.* SCCS));

script/makepatch  view on Meta::CPAN

	}
    }

    $arg->{root} = File::Spec->canonpath ($arg->{name});
    my $base = basename ($arg->{root});

    while ( @exctrl > 0 ) {
	my $pat = shift (@exctrl);
	my $cmd = shift (@exctrl);
	if ( $base =~ /^$pat$/is ) {
	    extract ($arg, $cmd);
	    verbose ("Using $arg->{root} for $arg->{name}\n")
	      unless $arg->{root} eq $arg->{name};
	    return;
	}
    }
    $arg->{root} = $arg->{base} = $arg->{name};
}

sub extract ($$) {
    my ($arg, $cmd) = @_;

    my $tmp = catfile ($tmpdir, $arg->{tag});
    message ("Extracting $arg->{name} to $tmp...\n");

    # Create a temp directory.
    mkdir ($tmp, 0777) || die ("Cannot mkdir $tmp [$!]\n");

    # Extract the kit.
    $cmd = "( cd $tmp; $cmd ) < $arg->{name}";
    trace ("+ $cmd\n");
    my $ret = system ("$cmd 1>&2");
    if ( $ret || ($? & 127) ) {
	die ("Not okay 1\n") if $opt_test;
	exit (1);
    }

    # Inspect the directory.
    my $dir = new IO::File;
    opendir ($dir, $tmp) || die ("Cannot read $tmp [$!]\n");
    my @files = grep ($_ !~ /^\.+$/, readdir ($dir));
    closedir ($dir);

    # If we have only one directory, assume it is the root.
    if ( @files == 1 && -d catfile($tmp,$files[0]) ) {
	$arg->{base} = $files[0];
	$arg->{root} = catfile($tmp,$files[0]);
	return;
    }
    # Else, take the temp dir as root.
    $arg->{root} = $tmp;
    $arg->{base} = $arg->{name};
}

sub catfile ($$) {
    File::Spec->canonpath(File::Spec->catfile(@_));
}

sub dot_file_u ($) {
   $_[0] =~ s,\\,/,g if $^O =~ /^MSWin/i;
   File::Spec::Unix->catfile($dot_u, File::Spec::Unix->canonpath(@_));
}

sub dodiff ($$$$) {
    my ($newdir, $new, $olddir, $old) = @_;
    my $fh = new IO::File;
    my $oldfn = catfile ($olddir, $old);
    my $newfn = catfile ($newdir, $new);

    # Check for binary files.
    if ( -s $oldfn && -B _ ) {
	verbose ("WARNING: Binary file $oldfn -- skipped\n");
	$skipped++;
	return 0;
    }
    if ( -s $newfn && -B _ ) {
	verbose ("WARNING: Binary file $newfn -- skipped\n");
	$skipped++;
	return 0;
    }

    # Produce a patch hunk.
    my $cmd = $opt_diff . ' ' . quotfn($oldfn) . ' ' . quotfn($newfn);
    trace ("+ ", $cmd, "\n");

    my $result = system ("$cmd > $tmpfile");
    debug  (sprintf ("+> result = 0x%x\n", $result)) if $result;

    if ( $result && $result < 128 ) {
	wrapup (($result == 2 || $result == 3)
		? "User request" : "System error");
	die ("Not okay 2\n") if $opt_test;
	exit (1);
    }
    return 0 unless $result == 0x100;	# no diffs
    print $patch ($cmd, "\n");

    # Add output from user defined file information command.
    if ( defined $opt_infocmd ) {
	my $cmd = $opt_infocmd;
	$cmd =~ s/\002P/$oldfn/eg;
	$cmd =~ s/\003P/$newfn/eg;
	print $patch (`$cmd`);
    }

    # By prepending $dot to the names, we can use 'patch -p0' as well
    # as 'patch -p1'.
    print $patch ("Index: ", dot_file_u($old), "\n");

    # Try to find a prereq.
    # The RCS code is based on a suggestion by jima@netcom.com, who also
    # pointed out that patch requires blanks around the prereq string.
    if ( $fh->open($oldfn) ) {
	binmode($fh);
	while ( <$fh> ) {
	    next unless (/(\@\(\#\)\@?|\$Header\:|\$Id\:)(.*)$/);
	    next unless $+ =~ /(\s\d+(\.\d+)*\s)/; # e.g. 5.4
	    print $patch ("Prereq: $1\n");
	    last;
	}
	$fh->close;

script/makepatch  view on Meta::CPAN

    my ($reason) = @_;

    if ( defined $reason ) {
	warn ("*** Aborted: $reason ***\n");
	return;
    }

    warn ("WARNING: $skipped file",
	  $skipped == 1 ? " was" : "s were", " skipped!",
	  $opt_verbose ? "" : " Use \"--verbose\" for more details.",
	  "\n") if $skipped;

    # Construct a description, if possible.
    if ( @opt_descr == 0 ) {
	my $old = $old->{base};
	my $new = $new->{base};
	# We can infer a name if the file name does not contain a
	# directory part, and is not equal to . or ..
	if ( $old ne $dot && $old ne $dotdot && basename($old) eq $old &&
	     $new ne $dot && $new ne $dotdot && basename($new) eq $new
	   ) {
	    @opt_descr = ("This is a patch for $old to update it to $new");
	}
    }

    # Get a description, unless provided.
    if ( @opt_descr == 0 ) {
	print STDERR ("Enter patch description, ",
		      "terminated with a single '.':\n>> ");
	while ( <STDIN> ) {
	    chomp;
	    last if $_ eq ".";
	    push (@opt_descr, $_);
	    print STDERR (">> ");
	}
	print STDERR ("\n") unless $_ eq ".";
    }
    push (@opt_descr, "");

    message ("Collecting patches ...\n");

    my $removed = 0;		# files removed
    my $created = 0;		# files added
    my $patched = 0;		# files patched
    my $dremoved = 0;		# directories removed
    my $dcreated = 0;		# directories created

    {	my @goners = ();
	my %dir_gone = ();
	my @newcomers = ();
	my %dir_ok = ();
	foreach ( @workq ) {
	    my ($op, $fn) = @$_;
	    push (@newcomers, $fn) if $op eq 'c';
	    push (@goners, $fn) if $op eq 'r';
	    $patched++ if $op eq 'p';
	}
	$created = @newcomers;
	$removed = @goners;
	foreach ( sort @goners ) {
	    # WARNING: This code assumes you are running some Unix.
	    my @p = split (/\//, $_);
	    pop (@p);
	    foreach my $i ( (1-@p)..0 ) {
		my $dir = join('/',@p[0..-$i]);
		unless ( defined $dir_gone{$dir} ) {
		    unless ( -d catfile($new->{root},$dir) ) {
			$dremoved++;
			$dir_gone{$dir} = 1;
		    }
		}
	    }
	}
	foreach ( reverse sort keys %dir_gone ) {
	    push (@workq, [ 'R', $_ ]);
	}
	foreach ( sort @newcomers ) {
	    # Explicitly create the new files since not all patch versions
	    # can handle creating new files.
	    # Create intermediate directories first.
	    # WARNING: This code assumes you are running some Unix.
	    my @p = split (/\//, $_);
	    pop (@p);
	    foreach my $i ( 0..(@p-1) ) {
		my $dir = join('/',@p[0..$i]);
		unless ( defined $dir_ok{$dir} ) {
		    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

script/makepatch  view on Meta::CPAN

sub app_options () {
    my $opt_manifest;
    my $opt_help = 0;
    my $opt_ident = 0;
    my $opt_rcfile;

    my @o = (
	     "automanifest=s"		=> \$opt_automanifest,
	     "debug!"			=> \$opt_debug,
	     "description=s@"		=> \@opt_descr,
	     "diff=s"			=> \$opt_diff,
	     "exclude-regex=s@"     	=> \@opt_exclude_regex,
	     "exclude-standard!"	=> \$opt_exclude_standard,
	     "exclude-rcs!"		=> \$opt_exclude_rcs,
	     "exclude-sccs!"		=> \$opt_exclude_sccs,
	     "exclude-cvs!"		=> \$opt_exclude_cvs,
	     "exclude-vc!"		=> sub { $opt_exclude_rcs =
						 $opt_exclude_cvs =
						 $opt_exclude_sccs = $_[1] },
	     "exclude=s@"	     	=> \@opt_exclude,
	     "extract=s%"		=> \%opt_extract,
	     "filelist|list!"		=> \$opt_filelist,
	     "follow!"			=> \$opt_follow,
	     "help"                 	=> \$opt_help,
	     "ident!"			=> \$opt_ident,
	     "ignore-cvs-keywords|ignore-rcs-keywords!"
					=> \$opt_ignore_rcs_keywords,
	     "infocmd=s"		=> \$opt_infocmd,
	     "manifest=s"		=> \$opt_manifest,
	     "newmanifest=s"		=> \$opt_newmanifest,
	     "nomanifest!"		=> \$opt_nomanifest,
	     "oldmanifest=s"		=> \$opt_oldmanifest,
	     "patchlevel=s"		=> \$opt_patchlevel,
	     "prefix=s"			=> \$opt_prefix,
	     "quiet!"			=> \$opt_quiet,
	     "sort!"			=> \$opt_sort,
	     "recurse!"			=> \$opt_recurse,
	     "test"			=> \$opt_test,
	     "trace!"			=> \$opt_trace,
	     "verbose!"			=> \$opt_verbose,
	    );

    my $init;

    # Process ENV options.
    if ( defined ($init = $ENV{MAKEPATCHINIT}) ) {
	require Text::ParseWords;
	local (@ARGV) = Text::ParseWords::shellwords ($init);
	unless ( GetOptions (@o, "rcfile=s" => \$opt_rcfile) &&
		 @ARGV == 0 ) {
	    warn ("Error in MAKEPATCHINIT\n");
	    app_usage (1);
	}
	else {
	    trace ("+ INIT: $init\n");
	}
    }

    unless ( $opt_test ) {
	# Process ini file options.
	# First, try system wide file. Unix specific.
	app_parse_rc ("/etc/makepatchrc", 1, \@o);
	my $rcname = ".".$my_name."rc";
	# Then, try HOME .rc.
	app_parse_rc (catfile ($HOME, $rcname), 1, \@o);
	# Then try --rcfile, defaulting to .rc in current dir.
	if ( defined $opt_rcfile ) {
	    app_parse_rc ($opt_rcfile, 0, \@o);
	}
	else {
	    app_parse_rc (catfile ($dot, $rcname), 1, \@o);
	}
    }

    # Process command line options
    if ( !GetOptions (@o) || $opt_help ) {
	app_usage (1);
    }

    # Argument check.
    if ( $opt_filelist ) {
	if ( defined $opt_manifest ) {
	    app_usage (1) if @ARGV;
	    @ARGV = ( $opt_manifest );
	}
	else {
	    app_usage (1) unless @ARGV == 1;
	}
    }
    else {
	app_usage (1) unless @ARGV == 2;
    }

    $opt_trace = 1 if $opt_debug;

    print STDERR ("This is $my_name version $my_version\n")
      if $opt_verbose || $opt_ident;

    if ( $opt_prefix ne '' ) {
	die ("$0: option \"-prefix\" requires \"-filelist\"\n")
	  unless $opt_filelist;
    }

    if ( defined $opt_sort ) {
	die ("$0: option \"-[no]sort\" requires \"-filelist\"\n")
	  unless $opt_filelist;
    }
    else {
	$opt_sort = 1;
    }

    if ( $opt_filelist ) {
	die ("$0: option \"-filelist\" only uses \"-manifest\"\n")
	  if defined $opt_oldmanifest || defined $opt_newmanifest;
    }

    if ( defined $opt_manifest ) {
	die ("$0: do not use \"-manifest\" with \"-oldmanifest\"".
	     " or \"-newmanifest\"\n")
	  if defined $opt_newmanifest || defined $opt_oldmanifest;
	$opt_newmanifest = $opt_oldmanifest = $opt_manifest;

script/makepatch  view on Meta::CPAN

traverses the source directory and runs a B<diff> on each pair of
corresponding files, accumulating the output into a patch kit. It
knows about the conventions for patch kits: if a file named
C<patchlevel.h> exists, it is handled first, so B<patch> can check the
version of the source tree. Also, to deal with the non-perfect
versions of B<patch> that are in use, it supplies "C<Index:>" and
"C<Prereq:>" lines, so B<patch> can correctly locate the files to
patch, and it relocates the patch to the current directory to avoid
problems with creating new files.

The list of files can be specified in a so called B<MANIFEST> file,
but it can also be generated by recursively traversing the source
tree. Files can be excluded using shell style wildcards and Perl regex
patterns.

But that is not it! B<makepatch> also inserts some additional
information in the patch kit for use by the B<applypatch> program.

It is important to emphasize that the generated patch kit is still
valid input for B<patch>. When used with B<patch>, there are no
verifications and problems may arise when new files need to be
created. B<makepatch> prepends a small shell script in front of the
patch kit that creates the necessary files and directories for the
patch process. If you can not run B<applypatch> for some reason, you
can run the patch kit I<as a shell script> to prepare the source
directory for the patching process.

The B<applypatch> program will do the following:

=over 4

=item *

It will extensively verify that the patch kit is complete and not
corrupted during transfer.

=item *

It will apply some heuristics to verify that the directory in
which the patch will be applied does indeed contain the expected
sources.

=item *

It creates files and directories as necessary.

=item *

It applies the patch by running the B<patch> program.

=item *

Upon completion, obsolete files, directories and C<.orig> files are
removed, file modes of new files are set, and the timestamps of
all patched files are adjusted.

=back 

Note that B<applypatch> only requires the B<patch> program. It does not
rely on a shell or shell tools. This makes it possible to apply
patches on non-Unix systems.

=head1 General usage

Suppose you have an archive `C<pkg-1.6.tar.gz>' containing the sources
for package `C<pkg>' version 1.6, and a directory tree `C<pkg-1.7>'
containing the sources for version 1.7. The following command will
generate a patch kit that updates the 1.6 sources into their 1.7
versions:

    makepatch pkg-1.6.tar.gz pkg-1.7 > pkg-1.6-1.7.patch

To apply this script, go to the directory containing the 1.6 sources
and feed the script to B<applypatch>:

    cd old/pkg-1.6
    applypatch pkg-1.6-1.7.patch

B<applypatch> will verify that it is executing in the right place and
make all necessary updates.

By default, B<makepatch> will provide a few lines of progress
information, for example:

    Extracting pkg-1.6.tar.gz to /tmp/mp21575.d/old...
    Manifest MANIFEST for pkg-1.6 contains 1083 files.
    Manifest MANIFEST for pkg-1.7 contains 1292 files.
    Processing the filelists ...
    Collecting patches ...
      266 files need to be patched.
      216 files and 8 directories need to be created.
      7 files need to be removed.

B<applypatch> will provide no feedback information by default.

=head1 Makepatch arguments

B<makepatch> requires two arguments: I<old_src> and I<new_src>.

=over 4

=item I<old-src>

This is the name of either a single file or a directory that contains
copies of the older version of the target files; in other words,
copies of the files I<prior> to any modifications.

Alternatively, it may be the name of an archive that holds the files
to be processed. Allowable archive formats are gzipped tar (name ends
in "C<.tar.gz>" or "C<.tgz>"), bzipped tar (name ends in
"C<.tar.bz2>"), plain tar (name ends in "C<.tar>" and zip (name ends in
"C<.zip>").

=item I<new-src>

This is the name of either a single file or a directory that contains
copies of the newer version of the target files; in other words,
copies of the files I<after> the modifications have been made. 

Alternatively, it may be the name of an archive that holds the files
to be processed.

script/makepatch  view on Meta::CPAN

the first line.

=item *

Empty lines and lines that start with a C<#> are ignored.

=item *

If there are multiple space-separated "words" on a line, the first
word is considered to be the filename.

=back

=head2 Default treatment

By default, B<makepatch> looks for files named "C<MANIFEST>" in the
top level directories of the old and the new source trees. If these
files (or one of them) are found, they are used.
If no manifest file could be found, the package is assumed to consist
of all files in the directory.

The default name of the default manifest file can be modified with the
command line option "C<-automanifest>", see Section L<Command line
options>.

=head2 Explicitly naming of manifest files

Command line options "C<-oldmanifest>" and "C<-newmanifest>" can be
used to explicitly designate old and new manifest files. Option
"C<-manifest>" is a short way to set one manifest file for both the
old and new source trees.

=head2 Suppress manifest file processing

Command line option "C<-nomanifest>" can be used to suppress all
manifest file processing. The package is assumed to consist
of all files in the source directories.

=head1 Makepatch options

B<makepatch> takes several options to control its behaviour. Options
are usually specified on the command line, but B<makepatch> can take
options from three sources in the following order:

=over 4

=item *

Environment variable B<MAKEPATCHINIT>.

When this environment variable is set its contents are considered to
be command line options that are processed upon startup. All normal
options are allowed, plus one: B<-rcfile >I<filename>. Option
B<-rcfile> can be used to specify an alternate option file, see below.

=item *

Options files.

B<makepatch> first tries to process a file named B</etc/makepatchrc>.
(This is a Unix-ism.)
It is okay if this file is missing.

Next, B<makepatch> will process a file named B<.makepatchrc> in
the user's home directory, if it exists.

After processing this file, B<makepatch> will process a file named
B<.makepatchrc> in the current directory, if it exists. An alternative
name for this file can be specified with option B<-rcfile> in
environment variable B<MAKEPATCHINIT>. This is the only way to specify
an alternative options file name.

In all option files, empty lines and lines starting with C<;> or C<#>
are ignored. All other lines are considered to contain options exactly
as if they had been supplied on the command line.

=item *

The command line.

=back

=head1 Command line options

Options are matched case insensitive, and may be abbreviated to uniqueness.

=over 4

=item B<-description> I<text>

Provide a descriptive text for this patch. Multiple B<-description>
options may be supplied.

If no description is provided, the program try to guess one. This is
usually possible if both directories are simple names, e.g.
'C<pkg-1.16>'. If no description can be determined, the program will
ask for one.

=item B<-diff> I<cmd>

If specified, I<cmd> is the command to be used to
generate the differences between the two versions of the files.  If
not specified, this command defaults to "C<diff -c>".

For best results, only use "C<diff -c>" or "C<diff -u>".
In any case, it B<must> produce either context or unified diff output.

=item B<-patchlevel> I<pfile>

If specified, I<pfile> indicates an alternate file that is to be
used in lieu of "B<patchlevel.h>".

=item B<-automanifest> I<mfile>

B<makepatch> will automatically use manifest files of the given name
if they appear in the directories. The default name is "B<MANIFEST>".

=item B<-nomanifest>

Suppress using manifest files.

script/makepatch  view on Meta::CPAN

command line options that are processed upon startup. All normal
options are allowed, plus one: B<-rcfile >I<filename>. If B<-rcfile>
is specified, the file is read and all lines of it are considered to
contain option settings as described in section L<Makepatch options>.

=item TMPDIR

C<TMPDIR> can be used to designate the area where temporary files are
placed. It defaults to C</usr/tmp>.

=item TEMP

C<TEMP> can be used as an alternative to C<TMPDIR>.

=back

=head1 Examples

Suppose you have a directory tree `C<pkg-1.6>' containing the sources
for package `C<pkg>' version 1.6, and a directory tree `C<pkg-1.7>'
containing the sources for version 1.7. The following command will
generate a patch kit that updates the 1.6 sources into their 1.7
versions:

    makepatch pkg-1.6 pkg-1.7 > pkg-1.6-1.7.patch

To apply this script, go to the pkg-1.6 directory and feed the
script to B<applypatch>:

    cd old/pkg-1.6
    applypatch pkg-1.6-1.7.patch

B<applypatch> will verify that it is executing in the right place and
make all necessary updates.

This is one way to generate and use manifest files:

    (cd pkg-1.6; find . -type f -print > OLDMANIFEST)

    (cd pkg-1.7; find . -type f -print > NEWMANIFEST)

    makepatch \
      -oldmanifest pkg-1.6/OLDMANIFEST \
      -newmanifest pkg-1.7/NEWMANIFEST \
      pkg-1.6 pkg-1.7 > pkg-1.6-1.7.diff

=begin comment

The following example transforms the manifest file into a list of
files suitable for GNU tar. Note the trailing C</> in the prefix
string:

  makepatch -filelist -prefix pkg-1.7/ pkg-1.7/MANIFEST | \
    tar -cvf - -T -Op | gzip > pkg-1.7.tar.gz 

=end comment

=head1 Bugs and restrictions

Much of the job of B<makepatch> is processing file names. B<makepatch>
has been tested extensively on Unix systems, but it is not guaranteed
to work on other systems.

B<applypatch> is repeatedly reported to correctly process B<makepatch>
generated patch kits on modern 32-bit Windows systems as well.

B<makepatch> does not know about symbolic links.
These will be treated like plain files.

Wrong results can be generated if the file lists that are used or
generated use different path separators.

=head1 SEE ALSO

B<applypatch>(1),
B<diff>(1),
B<patch>(1),
B<perl>(1),
B<rm>(1).

=head1 AUTHOR AND CREDITS

Johan Vromans (jvromans@squirrel.nl) wrote the program, with a little
help and inspiration from: Jeffery Small, Ulrich Pfeifer, Nigel
Metheringham, Julian Yip, Tim Bunce, Gurusamy Sarathy, Hugo van der
Sanden, Rob Browning, Joshua Pritikin, and others.

=head1 COPYRIGHT AND DISCLAIMER

This program is Copyright 1992,2004,2006 by Squirrel Consultancy. All
rights reserved.

This program is free software; you can redistribute it and/or modify
it under the terms of either: a) the GNU General Public License as
published by the Free Software Foundation; either version 1, or (at
your option) any later version, or b) the "Artistic License" which
comes with Perl.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
GNU General Public License or the Artistic License for more details.

=cut



( run in 0.530 second using v1.01-cache-2.11-cpan-39bf76dae61 )