1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
INTRODUCTION
------------
Patchtool is a tool aimed to simplify common operations with patchfiles. It
was designed using real world's experience with the subject and expected to be
very handy for an active porter.
MODES OF OPERATION
------------------
The tool has the following two basic modes of operation:
o generation/update of patchfiles. In this mode user provides list of working
files for which patchfiles are to be generated and the tool generates or
updates corresponding patches automatically guessing if there is an original
version (.orig file, rcs(1)) or it is a completely new file;
o automatic update of the existing patchfiles. In this mode user provides a
list of patchfiles or directories containing patchfiles and the tool
re-generates specified patches. In this mode the tool tries hard to guess
whether the patchfile in question is already up to date or not and updates
only those patchfiles, which are found to be outdated.
The following options are supported:
-a -- automatically save resulting diff into a patchfile;
-f -- don't ask any question if target patchfile already exists and is to be
replaced;
-u -- run tool in the "update" mode (see above);
-i -- perform requested operation (generate or update) even if the
patchfile seems to be up-to-date based on last modification time of
all files involved.
The tool supports dozen environment variables that can be used to override
default settings. You can find complete list at the top of patchtool.py,
following are the most useful ones:
PT_CVS_ID -- CVS id to be added at the top of each patchfile generated
("FreeBSD");
PT_DIFF_ARGS -- diff(1) args used to generate patchfile ("-du");
PT_DIFF_SUFX -- suffix used to save original version of the file (".orig");
KNOWN BUGS AND LIMITATIONS
--------------------------
o It is assumed that each patchfile contains exactly one diff, so the tool
may remove useful diffs when there are several diffs merged into one
patchfile. Actually I don't think that it is a bug, because Porter's
Handbook clearly demands to follow a "one diff - one patchfile" rule.
Perhaps portlint(1) should be extended to warn about such abuses;
o only '+++' supported as the prefix for the name of target file in the
patchfile. Neither '***' nor 'Index:' are not recognised/supported yet;
o please keep in mind that when you are trying to do automatic update and
some of the patches are for auto-generated/mangled files (e.g. configure
script in the situation when USE_LIBTOOL is used) then you would end up
with some of patchfiles containing bogus hunks;
o by default the tool tries to recognise saved original version on the file
first by probing file with '.orig' suffix added and if it fails then by
probing file with ',v' suffix added. If you use other suffix to save
original version, for example '~', then set PT_DIFF_SUFX environment
variable to match your settings, otherwise the tool will not function
properly.
REPORTING BUGS AND PROPOSING ENHANCEMENTS
-----------------------------------------
The author of the tool is Maxim Sobolev <sobomax@FreeBSD.org>. Any bug
reports, patches, proposals or suggestions are encouraged. You can do it
either contacting author directly at the e-mail above or submitting a FreeBSD
problem report.
EXAMPLES
--------
Following are several sample sessions which show common usage patterns for
this tool.
1. Generation mode (useful when creating new port).
$ cd /somewhere/foo ; make
[compilation blows with error in src/bar/baz.c]
$ cd work/foo-1.0/src/bar
[dig here and there and finally find that the problem in baz.c]
$ cp baz.c baz.c.orig
$ vi baz.c
[fixing it]
$ patchtool baz.c
[reading diff]
$ patchtool -a baz.c
Generating patchfile: patch-src_bar_baz.c...ok
$ cd ../../../../
$ make
[works as expected, wow!]
$ make install clean
$ send-pr
[...]
2. Generation mode when target patchfile already exists (Minor port update).
$ cd /somewhere/foo ; make
[...]
1 out of 4 hunks failed--saving rejects to Makefile.rej
>> Patch patch-aa failed to apply cleanly.
*** Error code 1
$ cd work/foo-1.0
[examining Makefile.rej]
$ vi Makefile
[merging changes by hand]
$ patchtool Makefile
[reading diff]
$ patchtool -a Makefile
Target patchfile "patch-aa" already exists, do you want to replace it? [y/N]: y
Generating patchfile: patch-aa...ok
$ cd ../../
$ make clean
$ make install clean
$ send-pr
[...]
3. "Gross" update mode (Major update, when several existing patches do not apply
cleanly).
$ cd /somewhere/foo
$ vi Makefile
[increase PORTVERSION]
$ make fetch makesum patch
[several patches are failing to apply cleanly]
$ cd work/foo-1.0
[doing merging work, finally all changes are merged]
$ cd ../../ ; make all install
[compile and works like a charm]
$ pwd
/somewhere/foo
$ patchtool -u ./
Updating patchfile: patch-aa
Updating patchfile: patch-as
Updating patchfile: patch-foo.c
Updating patchfile: patch-foo_bar.c
$ make clean
$ send-pr
[...]
|