Alt-App-makepatch
view release on metacpan or search on metacpan
script/makepatch view on Meta::CPAN
EoU
die ("Not okay 99\n") if $opt_test;
exit $exit if defined $exit && $exit != 0;
}
sub app_usage_filelist ($) {
my ($exit) = @_;
print STDERR <<EoU;
This is $my_name version $my_version
Usage: $0 -filelist [ options ] [ -manifest ] file
Filelist options:
-[file]list extract filenames from manifest file
-prefix XXX add a prefix to these filenames
-nosort do not sort manifest entries
-man[ifest] file list of files
-exclude pat exclude files according to wildcard pattern
-exclude-regex pat exclude files and dirs matching regex pattern
-exclude-vc exclude version control files (RCS, CVS, SCCS)
-exclude-rcs exclude version control files for RCS
-exclude-cvs exclude version control files for CVS
-exclude-sccs exclude version control files for SCCS
-verbose verbose output (default)
-quiet no verbose output
-help this message
EoU
die ("Not okay 99\n") if $opt_test;
exit $exit if defined $exit && $exit != 0;
}
1;
__END__
################ Documentation ################
=head1 NAME
makepatch - create script to update a source tree
=head1 SYNOPSIS
B<makepatch> [ I<options> ] I<old-src> I<new-src>
=for comment
B<makepatch> B<-filelist> [ I<options> ] I<manifest>
=head1 Introduction
Traditionally, source trees are updated with the B<patch> program,
processing patch information that is generated by the B<diff> program.
Although B<diff> and B<patch> do a very good job at patching file
contents, most versions do not handle creating and deleting files and
directories, and adjusting of file modes and time stamps. Newer
versions of B<diff> and B<patch> seem to be able to create files, and
very new versions of B<patch> can remove files. But that's about it.
Another typical problem is that patch kits are typically downloaded
from the Internet, or transmitted via electronic mail. It is often
desirable to verify the correctness of a patch kit before even
attempting to apply it.
The B<makepatch> package is designed to overcome these limitations.
=head1 DESCRIPTION
The B<makepatch> package contains two Perl programs:
B<makepatch> and B<applypatch>.
B<makepatch> will generate a patch kit from two source trees. It
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.
=back
The patch script generated by B<makepatch> will take care of creating
new files and directories, update existing files, and remove files and
directories that are no longer present in the I<new-src> directory.
=head1 MANIFEST files
The purpose of a manifest file is to provide the list of files that
constitute a package. Manifest files are traditionally called
"C<MANIFEST>" and reside in the top level directory of the package.
Although there is no formal standard for the contents of manifest
files, B<makepatch> uses the following rules:
=over 4
script/makepatch view on Meta::CPAN
The following file patterns are always excluded:
*~ *.a *.bak *.BAK *.elc *.exe *.gz *.ln *.o *.obj
*.olb *.old *.orig *.rej *.so *.Z
.del-* .make.state .nse_depinfo core
tags TAGS
Option B<-exclude-sccs> adds:
p.* s.* SCCS
Option B<-exclude-rcs> adds:
,* *,v RCS RCSLOG
Option B<-exclude-cvs> adds C<.cvsignore> patterns, and:
.#* #* _$* *$ CVS CVS.adm cvslog.*
Please let me know if I missed some.
=head1 Environment variables
=over
=item MAKEPATCHINIT
When this environment variable is set its contents is considered to be
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
( run in 0.675 second using v1.01-cache-2.11-cpan-39bf76dae61 )