GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MAKEPATCH (1)

.ds Aq ’

NAME

makepatch - create script to update a source tree

CONTENTS

SYNOPSIS

<B>makepatchB> [ options ] old-src new-src

Introduction

Traditionally, source trees are updated with the <B>patchB> program, processing patch information that is generated by the <B>diffB> program. Although <B>diffB> and <B>patchB> 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>diffB> and <B>patchB> seem to be able to create files, and very new versions of <B>patchB> 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>makepatchB> package is designed to overcome these limitations.

DESCRIPTION

The <B>makepatchB> package contains two Perl programs: <B>makepatchB> and <B>applypatchB>.

<B>makepatchB> will generate a patch kit from two source trees. It traverses the source directory and runs a <B>diffB> 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 patchlevel.h exists, it is handled first, so <B>patchB> can check the version of the source tree. Also, to deal with the non-perfect versions of <B>patchB> that are in use, it supplies "Index: and Prereq:" lines, so <B>patchB> 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>MANIFESTB> 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>makepatchB> also inserts some additional information in the patch kit for use by the <B>applypatchB> program.

It is important to emphasize that the generated patch kit is still valid input for <B>patchB>. When used with <B>patchB>, there are no verifications and problems may arise when new files need to be created. <B>makepatchB> 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>applypatchB> for some reason, you can run the patch kit as a shell script to prepare the source directory for the patching process.

The <B>applypatchB> program will do the following:
o It will extensively verify that the patch kit is complete and not corrupted during transfer.
o It will apply some heuristics to verify that the directory in which the patch will be applied does indeed contain the expected sources.
o It creates files and directories as necessary.
o It applies the patch by running the <B>patchB> program.
o Upon completion, obsolete files, directories and .orig files are removed, file modes of new files are set, and the timestamps of all patched files are adjusted.
Note that <B>applypatchB> only requires the <B>patchB> program. It does not rely on a shell or shell tools. This makes it possible to apply patches on non-Unix systems.

General usage

Suppose you have an archive ‘pkg-1.6.tar.gz’ containing the sources for package ‘pkgversion 1.6, and a directory tree ‘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>applypatchB>:



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



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

By default, <B>makepatchB> 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>applypatchB> will provide no feedback information by default.

Makepatch arguments

<B>makepatchB> requires two arguments: old_src and new_src.
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 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 ".tar.gz or .tgz), bzipped tar (name ends in .tar.bz2), plain tar (name ends in .tar and zip (name ends in .zip").

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 after the modifications have been made.

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

The patch script generated by <B>makepatchB> will take care of creating new files and directories, update existing files, and remove files and directories that are no longer present in the new-src directory.

MANIFEST files

The purpose of a manifest file is to provide the list of files that constitute a package. Manifest files are traditionally called "MANIFEST" and reside in the top level directory of the package.

Although there is no formal standard for the contents of manifest files, <B>makepatchB> uses the following rules:
o If the second line from the manifest file looks like a separator line (e.g. it is empty, or contains only dashes), it is discarded and so is the first line.
o Empty lines and lines that start with a # are ignored.
o If there are multiple space-separated words on a line, the first word is considered to be the filename.

    Default treatment

By default, <B>makepatchB> looks for files named "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 "-automanifest", see Section Command line options.

    Explicitly naming of manifest files

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

    Suppress manifest file processing

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

Makepatch options

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

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 B>filename. Option <B>-rcfileB> can be used to specify an alternate option file, see below.

o Options files.

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

Next, <B>makepatchB> will process a file named <B>.makepatchrcB> in the user’s home directory, if it exists.

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

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

o The command line.

Command line options

Options are matched case insensitive, and may be abbreviated to uniqueness.
<B>-descriptionB> text Provide a descriptive text for this patch. Multiple <B>-descriptionB> 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. ’pkg-1.16’. If no description can be determined, the program will ask for one.

<B>-diffB> cmd If specified, 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 "diff -c".

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

<B>-patchlevelB> pfile If specified, pfile indicates an alternate file that is to be used in lieu of "<B>patchlevel.hB>".
<B>-automanifestB> mfile <B>makepatchB> will automatically use manifest files of the given name if they appear in the directories. The default name is "<B>MANIFESTB>".
<B>-nomanifestB> Suppress using manifest files.
<B>-manifestB> mfile If specified, mfile indicates the name of the manifest file which consists of a list of the files contained in both the old and the new directories.
<B>-oldmanifestB> omfile If specified, omfile indicates the name of the manifest file which consists of a list of the files contained in the old directory. This option is designed to be used in conjunction with the <B>-newmanifestB> option. Note that the old and new directories must still be indicated.
<B>-newmanifestB> nmfile If specified, nmfile indicates the name of the manifest file which consists of a list of the files contained in the new directory. This option is designed to be used in conjunction with the <B>-oldmanifestB> option. Note that the old and new directories must still be indicated.
<B>-B>[<B>noB>]<B>recurseB> <B>makepatchB> recurses through directories by default. Option <B>-norecurseB> prevents recursion beyond the initial directories.
<B>-B>[<B>noB>]<B>followB> If set, symbolic links to directories are traversed as if they were real directories.
<B>-infocmdB> command If specified, the output of running command will be added before each patch chunk. command will undergo the following substitutions first: %oP will be replaced by the name of the old file, %nP will be replaced by the name of the new file. %% will be replaced by a single %; other % sequences may be added in future versions. When a new file is being created, the name of the new file will be supplied for both %oP and %nP.

Note that %oP and %nP are modeled after the % sequences of <B>find -printfB>.

<B>-excludeB> pattern If specified, files that match the shell pattern pattern will be excluded. Only wildcard characters * and ?, and character classes [...] are handled. Multiple <B>-excludeB> options may be supplied.
<B>-exclude-regexB> pattern If specified, files and directories that match the Perl regular expression pattern pattern will be excluded. Multiple <B>-exclude-regexB> options may be supplied.
<B>-B>[<B>noB>]<B>exclude-standardB> Set by default. If set, a common set of files and directories are ignored.

See also section Standard Exclude Patterns.

<B>-B>[<B>noB>]<B>exclude-cvsB> If set, files and directories that are usually part of version control system CVS are excluded.

Also, .cvsignore files are honoured just like CVS does it.

See also section Standard Exclude Patterns.

<B>-B>[<B>noB>]<B>exclude-rcsB> If set, files and directories that are usually part of version control system RCS are excluded.

See also section Standard Exclude Patterns.

<B>-B>[<B>noB>]<B>exclude-sccsB> If set, files and directories that are usually part of version control system SCCS are excluded.

See also section Standard Exclude Patterns.

<B>-B>[<B>noB>]<B>exclude-vcB> Short for (re)setting <B>-exclude-rcsB>, <B>-exclude-cvsB>, and <B>-exclude-sccsB>.
<B>-B>[<B>noB>]<B>ignore-cvs-keywordsB> Differences in CVS keyword data (e.g. Id, Header, Revision) are ignored, provided there are no other differences in the same hunk. This option passes a very hairy regex to the <B>--ignore-matching-linesB> option of the diff program, and hence requires GNU diff. This restriction may be lifted in a future version.
<B>-B>[<B>noB>]<B>ignore-rcs-keywordsB> Same as <B>-B>[<B>noB>]<B>ignore-cvs-keywordsB>.
<B>-extractB> pattern<B>=B>command Define additional extraction rules for archives. If the name of the source or destination matches the Perl pattern, the command is executed with the archive on standard input and the current directory set to the location where the files must be extracted. Multiple <B>-extractB> options may be supplied. User defined rules override built-in rules.

Builtin rules are:



    .+\.(tar\.gz|tgz)    => "gzip -d | tar xpf -"
    .+\.(tar\.bz2)       => "bzip2 -d | tar xpf -"
    .+\.tar              => "tar xf -"
    .+\.zip              => "unzip -"



The patterns are implicitly anchored to the begin and end of the filename.

<B>-B>[<B>noB>]<B>identB> If set, the program name and version is reported.
<B>-B>[<B>noB>]<B>verboseB> This is set by default, making <B>makepatchB> display information concerning its activity to stderr.
<B>-B>[<B>noB>]<B>quietB> The opposite of <B>-verboseB>. If set, this instructs <B>makepatchB> to suppress the display of activity information.
<B>-B>[<B>noB>]<B>helpB> If set, this causes a short help message to be displayed, after which the program immediately exits.

Standard Exclude Patterns

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-sccsB> adds:



    p.* s.* SCCS



Option <B>-exclude-rcsB> adds:



    ,* *,v RCS RCSLOG



Option <B>-exclude-cvsB> adds .cvsignore patterns, and:



    .#* #* _$* *$ CVS CVS.adm cvslog.*



Please let me know if I missed some.

Environment variables

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 B>filename. If <B>-rcfileB> is specified, the file is read and all lines of it are considered to contain option settings as described in section Makepatch options.
TMPDIR TMPDIR can be used to designate the area where temporary files are placed. It defaults to /usr/tmp.
TEMP TEMP can be used as an alternative to TMPDIR.

Examples

Suppose you have a directory tree ‘pkg-1.6’ containing the sources for package ‘pkgversion 1.6, and a directory tree ‘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>applypatchB>:



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



<B>applypatchB> 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



Bugs and restrictions

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

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

<B>makepatchB> 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.

SEE ALSO

<B>applypatchB>(1), <B>diffB>(1), <B>patchB>(1), <B>perlB>(1), <B>rmB>(1).

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.

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.

Search for    or go to Top of page |  Section 1 |  Main Index


perl v5.20.3 MAKEPATCH (1) 2012-10-26

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.