ActivePatch Developer's Guide - Command-Line Utilities - Patch

Create or apply a patch file.

Usage Message
Usage: patch operation files [ <options> ]
Operations:      -h This message (all other arguments ignored)
-a Apply patch
-c Create patch
-i Show patch file information
Files: -r oldfile Reference file
-n newfile Update file
-p patchfile       Patch file
Options: -l level 0-9, default 0
-e expires Number of days from creation that patch may be applied
   0 means no expiration (default)
-w password Password (default none)
-o flags One or more options (no spaces in list):
f Use path rules to find reference file on target system
b      Create a backup of the file on the target system
(default: no backup)
t Ignore filetimes when applying patch
(default: compare file times)
v Ignore versions when applying patch
(default: compare versions)
a Use default file attributes when applying patch
(default: use update's attributes)
r Clear read-only when applying patch
(default: use update's read-only attribute)
s Ignore digital signature when applying patch
(default: use update's signature)
Description

The command-line utility patch can be used to create or apply patches for a single file.

It can also be used to display information about the reference and update files. The reference and update files are two versions of a file. In general, the reference file is older and the update file is newer, although the time distinction is not enforced. The patch file describes the changes that exist from the reference file to the update file.

The parameters for this utility are divided into three categories: operations, files, and options. Each parameter consists of a dashed letter, some of which must be immediately followed by an additional, un-dashed parameter. The dashed parameters may be given in any order.

The operations are:

-c Create patch file
-a Apply patch file
-i Show information
-h      Show usage message

The file parameters are:

-r      Reference file
-n Update file
-p Patch file
  • If –h (show usage message) is specified, then all other parameters will be ignored.
  • -c (create patch file) and –a (apply patch file) may not both be specified.
  • -i (show information) may be specified with either –c or –a, or by itself.
  • If either -c or -a is specified, then all of -r (reference file), -n (update file), and –p (patch file) must be specified.
  • The names of the reference, update, and patch files must be distinct.
  • If -i is specified, then the patch file must be specified.
  • If -c is specified, then the patch file will be created from the reference and update files.
  • If –a is specified, then the update file will be created from the reference file and patch files.

Each of the options has a default value that is used if an option is not explicitly specified. The default values of the options are given in the usage message. The options are:

-l Level of the patching algorithm
-l
is used only with –c. Values between 1 and 9 determine the speed and amount of memory allocated to create the patch. As a general rule, the higher the patch level, the smaller the resulting patch file will be, at the expense of speed and the amount of memory required. A value of 0 specifies a default patch level that is appropriate for most files.
-e Number of days until expiration of the patch file, used only with –c.
-w      Password
If –w is specified when a patch is created, then it must be specified when the patch is applied.
-o Options
These options govern whether certain policy rules will be followed when the patch is applied. They are:
f      Use path rules to find reference file on target system.
If the reference file cannot be found on the target system, attempt to locate it using the standard Windows pathing rules. The current directory, system directory and the directories in the PATH environment variable are searched in that order.
b Create a backup of the file on the target system.
Create a backup of the file on the target system before applying the patch. If this flag is not specified, the file is modified in-place without any backup file being created.
t Ignore filetimes when applying patch.
Compare the time that the target file was last modified against that of the reference file. If the target file has a later modification time than the reference file at the time the patch was created, the patch application will fail with an error. In effect this ensures that the updated file must always have a later modification time than the reference file.
v Ignore versions when applying patch.
Ignore any differences between the version of the file on the target system and the version of the reference file at the time that the patch was created.
a Use default file attributes when applying patch.
Ignore the updated file attributes when the patch is applied on the target system and use default attributes instead.
r Clear read-only when applying patch.
Ignore the read-only file attribute when applying the patch. If the updated file has this attribute set, it will be cleared.
s Ignore digital signature when applying patch.
Ignore any digital signature that may be present. If the updated file has been digitally signed using AuthentiCode, the signature will be authenticated at the time that the patch is applied. If this flag is specified, no attempt is made to authenticate the signature. This flag has no effect on files that are not digitally signed.

Flag options may be specified at either creation time or application time. Flag options that are specified at creation time are retained with the patch. A flag that is specified at creation time will be used at application time, unless it is overridden at application time.

Examples

patch –c –r myfile1.txt –n myfile2.txt –p myfile txt.pat
patch –c –r myfile1.txt –n myfile2.txt –p myfiletxt.pat –l 8 –e 7 –w kilroy –i
patch -i –p myfiletxt.pat
patch –a –r myfile1.txt –n targetfile.txt –p myfiletxt.pat –o ftr