Ravenports generated: 10 Feb 2024 22:55
[ravenports.git] / bucket_83 / genpatch
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               genpatch
4 VERSION=                1.70
5 KEYWORDS=               raven devel
6 VARIANTS=               standard
7 SDESC[standard]=        Single patch generator tool for Ravenports
8 HOMEPAGE=               none
9 CONTACT=                John_Marino[draco@marino.st]
10
11 DOWNLOAD_GROUPS=        main
12 SITES[main]=            none
13 SPKGS[standard]=        single
14
15 OPTIONS_AVAILABLE=      none
16 OPTIONS_STANDARD=       none
17
18 LICENSE=                BSD2CLAUSE:single
19 LICENSE_FILE=           BSD2CLAUSE:{{FILESDIR}}/LICENSE
20 LICENSE_SCHEME=         solo
21
22 FPC_EQUIVALENT=         ports-mgmt/genpatch
23
24 SKIP_BUILD=             yes
25
26 do-install:
27         ${INSTALL_SCRIPT} ${FILESDIR}/portfix  ${STAGEDIR}${PREFIX}/bin
28         ${INSTALL_SCRIPT} ${FILESDIR}/genpatch ${STAGEDIR}${PREFIX}/bin
29         ${INSTALL_SCRIPT} ${FILESDIR}/dupe     ${STAGEDIR}${PREFIX}/bin
30         (cd ${FILESDIR} && ${INSTALL_MAN} dupe.1 genpatch.1 portfix.1 \
31                 ${STAGEDIR}${MANPREFIX}/man/man1)
32
33 [FILE:587:descriptions/desc.single]
34 This is a set of three simple tools written in sh(1) for generating single
35 patches for use in Ravenports.  These are ideal for creating patches in
36 the standard convention format.
37
38 The first tool is "dupe" which is a quick copy utility.  The second tool
39 is "genpatch" which creates patches in the standard diff format and
40 using the standard file name conventions.  The last tool is "portfix"
41 which runs "dupe", an editor of choice, and "genpatch" serially as a
42 macro as a convenient and quick way to create port patches.
43
44 Please see the dupe, genpatch, and portfix man pages for details.
45
46
47 [FILE:86:manifests/plist.single]
48 bin/
49  dupe
50  genpatch
51  portfix
52 share/man/man1/
53  dupe.1.gz
54  genpatch.1.gz
55  portfix.1.gz
56
57
58 [FILE:1422:files/LICENSE]
59 # Copyright (c) 2004-2011 The NetBSD Foundation, Inc.
60 # Copyright (c) 2011 by Thomas Klausner <wiz@NetBSD.org>
61 # Copyright (c) 2012 by John Marino <draco@marino.st>
62 # All rights reserved.
63 #
64 # Redistribution and use in source and binary forms, with or without
65 # modification, are permitted provided that the following conditions
66 # are met:
67 # 1. Redistributions of source code must retain the above copyright
68 #    notice, this list of conditions and the following disclaimer.
69 # 2. Redistributions in binary form must reproduce the above copyright
70 #    notice, this list of conditions and the following disclaimer in the
71 #    documentation and/or other materials provided with the distribution.
72 #
73 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR
74 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
75 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
76 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR
77 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
78 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
79 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
80 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
81 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
82 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
83 # POSSIBILITY OF SUCH DAMAGE.
84
85
86
87 [FILE:609:files/dupe]
88 #!/bin/sh
89 #
90 # Usage: dupe origfile
91 #
92 # This will make a duplicate of the file indicate by the first argument.
93 # If <origfile>.orig does not exist, the duplicate will have this name,
94 # otherwise it will be called <origfile>.intermediate.
95 # This is a complementary tool of genpatch
96
97 if [ $# -eq 1 ]; then
98         old=${1}
99         if [ ! -f ${old} ]; then
100                 echo "${0}: '${old}' does not exist! aborting..."
101                 exit 1;
102         fi
103         if [ -f "${old}.orig" ]; then
104                 new="${old}.intermediate"
105         else
106                 new="${old}.orig"
107         fi
108 else
109         echo "${0}: need exactly one argument"
110         echo "${0} <path/to/original/file>"
111         exit 1;
112 fi
113
114 cp -p ${old} ${new}
115
116
117 [FILE:741:files/dupe.1]
118 .Dd May 17, 2015
119 .Dt DUPE 1
120 .Os
121 .Sh NAME                  
122 .Nm dupe
123 .Nd duplicate a file quickly
124 .Sh SYNOPSIS
125 .Nm
126 .Ar original
127 .Sh DESCRIPTION
128 This utility is always called by
129 .Xr portfix 1 ,
130 but sometimes it is useful in its own right.
131
132 .Nm 
133 takes exactly one argument, a path to a file.  It will duplicate the
134 .Op original 
135 file to "<original>.orig" unless there is already an existing file with
136 this exact name.  In that case, the target file name will be "<original>.intermediate" 
137 and any existing file of that name will be unconditionally overwritten.
138 .Pp
139 .Sh ERRORS
140 .Nm
141 will abort if zero or more than one argument is given, or if
142 .Op original
143 is not a path to a valid regular file.
144 .Pp
145 .Sh SEE ALSO 
146 .Xr genpatch 1 , 
147 .Xr portfix 1 
148
149
150 [FILE:2565:files/genpatch]
151 #!/bin/sh
152 #
153 # Usage: genpatch newfile
154 #        genpatch oldfile newfile
155 #
156 # Will output a patch ready for dports (unified diff).
157 # If only newfile is given, oldfile is assumed as newfile.intermediate (1st)
158 # or newfile.orig (2nd) if such a file exists
159 # If the physical path doesn't start with /usr/obj/raven or /construction,
160 # genpatch sends output to stdout, otherwise, the patch file will be
161 # created in the current directory with a filename on the file's
162 # location relative to worksource.  The patch will be generated from
163 # wrksrc location.
164
165 # Ensure we always use the same timezone to avoid spurious metadata diffs
166 export TZ=UTC
167
168 if [ $# -le 1 ]
169 then
170         old=/dev/null
171         if [ -f "$1.intermediate" ]; then
172                 if [ -s "$1.intermediate" ]; then
173                         old="$1.intermediate"
174                 fi
175                 new="$1"        
176         elif [ -f "$1.orig" ]; then
177                 if [ -s "$1.orig" ]; then
178                         old="$1.orig"
179                 fi
180                 new="$1"
181         else
182                 echo $0: need at least one valid argument >&2
183                 exit 1;
184         fi
185 else
186         if [ $# -eq 2 ]
187         then
188                 old="$1"
189                 new="$2"
190         else
191                 echo $0: more than two arguments detected >&2
192                 exit 1;
193         fi
194 fi
195
196 PKGDIFF_FMT="-p --unified=3"
197
198 # Strip out the date on the +++ line to reduce needless
199 # differences in regenerated patches
200 SEDPLUS='/^---/s|\.[0-9]* +0000$| UTC| ; /^+++/s|\([[:blank:]][-0-9:.+]*\)*$||'
201
202 # Truncate given string to same length as its comparing standard
203 # External variables: std
204 AWKTRUNC='BEGIN {stdlen=length(std)}{print substr($1,1,stdlen)}'
205
206 if diff -q ${PKGDIFF_FMT} ${old} ${new} > /dev/null
207 then
208         exit 0
209 fi
210
211 if [ -n "${WORKHERE}" ]; then
212 objpath=$(pwd)
213 else
214    if [ -d /usr/obj/raven ]; then
215       objpath=$(cd /usr/obj/raven && pwd -P)
216    else
217       objpath=/usr/obj/raven # let it fail
218    fi
219 fi
220 rvnpath="/construction"
221 old_directory=$(dirname "${old}")
222 real_directory=$(cd "${old_directory}" && pwd -P)
223 testpath1=$(echo ${real_directory} | awk -vstd="${objpath}" "${AWKTRUNC}")
224 testpath2=$(echo ${real_directory} | awk -vstd="${rvnpath}" "${AWKTRUNC}")
225
226 if [ -n "${PRINT}" ]; then
227     # send patch to stdout unconditionally
228     diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}"
229 elif [ "${testpath1}" = "${objpath}" -o "${testpath2}" = "${rvnpath}" ]; then
230     # Inside standard work area.  Assume genpatch executed from wrksrc
231     # and generate patch with appropriate name
232
233     fname=patch-$(echo ${new} | sed -e 's|_|__|g' -e 's|/|_|g')
234     diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}" > ${fname}
235     echo "generated ${fname}"
236 else
237     # Not in standard work area, just send patch to stdout
238     diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}"
239 fi
240
241
242 [FILE:1908:files/genpatch.1]
243 .Dd 17 May, 2015
244 .Dt GENPATCH 1      
245 .Os
246 .Sh NAME
247 .Nm genpatch
248 .Nd generate patch quickly in standard Ravenports format
249 .Sh SYNOPSIS             
250 .Nm
251 .Ar newfile
252 .Nm
253 .Ar oldfile
254 .Ar newfile
255 .Sh DESCRIPTION    
256 This utility is always called by
257 .Xr portfix 1 ,
258 but quite often it is useful in its own right.
259
260 It creates patches using the standard Ravenports format, but there are different
261 operational modes. If
262 .Nm
263 is called when the current working directory is a subdirectory of the
264 /usr/obj/raven or /construction, then a patch will be saved in the
265 current directory using the Ravenports naming standard.  Note that the utility
266 assumes that it has been executed in the WRKSRC directory, the standard location
267 for applying Ravenports patches.
268
269 If
270 .Nm
271 is executed outside of those directories, then a patch will not be created.  The 
272 contents of the patch will be send to stdout, so the user will have to direct it to a
273 file manually as desired.
274
275 If only one argument is given,
276 .Nm
277 will search for a file named "<newfile>.intermediate" and if found, it will generated diff
278 output between it and
279 .Op newfile .
280 If that file doesn't exist, it will search for "<newfile>.orig" and attempt to create diff
281 output between it and
282 .Op newfile .
283 .Pp
284 .Sh ERRORS
285 .Nm
286 will abort if no arguments or more than 2 arguments are given.  If only one argument (
287 .Op newfile
288 ) is given, then a regular file called "<newfile>.orig" or "<newfile>.intermediate"
289 must exist otherwise
290 .Nm
291 will abort.  If two arguments are given, both must be existing regular files.
292 .Pp
293 .Sh ENVIRONMENT
294 .Bl -tag -width "PORTEDITOR" -indent 
295 .It Ev WORKHERE
296 Overrides hardcoded /usr/obj/raven and /construction with the current
297 value of pwd.  This also enables patch generation outside of standard working areas.
298 .Pp
299 .It Ev PRINT
300 Always send the contents of the patch to stdout (never generate a file).
301 .Pp
302 .Sh SEE ALSO 
303 .Xr dupe 1 , 
304 .Xr portfix 1 
305
306
307 [FILE:756:files/portfix]
308 #!/bin/sh
309 #
310 # usage: portfix origfile
311 #
312 # This is a wrapper.  It runs consecutively:
313 #   1. dupe XXX
314 #   2. <editor> XXX
315 #   3. genpatch XXX 
316 #
317 # If PORTEDITOR is defined in the environment, that program will be
318 # used instead of the EDITOR env. variable.  If neither are defined
319 # it will fall back to vi.
320
321
322 if [ $# -eq 1 ]; then
323         old=${1}
324         if [ ! -f ${old} ]; then
325                 echo "${0}: '${old}' does not exist! aborting..."
326                 exit 1;
327         fi
328 else
329         echo "${0}: need exactly one argument"
330         echo "${0} <path/to/original/file>"
331         exit 1;
332 fi
333
334 if [ -n "${PORTEDITOR}" ]; then
335         MYPORTEDITOR=${PORTEDITOR}
336 elif [ -n "${EDITOR}" ]; then
337         MYPORTEDITOR=${EDITOR}
338 else
339         MYPORTEDITOR=/usr/bin/vi
340 fi
341
342 dupe ${old}
343 ${MYPORTEDITOR} ${old}
344 if [ $? -eq 0 ]; then
345    genpatch ${old}
346 fi
347
348
349 [FILE:2250:files/portfix.1]
350 .Dd 17 May 2015
351 .Dt PORTFIX 1     
352 .Os 
353 .Sh NAME
354 .Nm portfix
355 .Nd macro to execute three programs to create a ports patch
356 .Sh SYNOPSIS
357 .Nm
358 .Ar original               
359 .Sh DESCRIPTION        
360 .Nm
361 is a wrapper.  It consecutively runs:
362
363 .Bl -enum -compact
364 .It 
365 dupe
366 .Ar original
367 .It
368 <editor>
369 .Ar original
370 .It
371 genpatch
372 .Ar original
373 .El
374
375 If PORTEDITOR is defined in the environment then that program will be used to edit
376 .Op original
377 file.  If PORTEDITOR is not defined but EDITOR is defined, then the EDITOR program
378 will be invoked.  If neither variable is defined in the environment, then
379 .Xr vi 1
380 will be invoked for the edit step.
381
382 .Nm
383 should be launched when the current working directory is equal to the port's WRKSRC, and
384 .Op original
385 should be a relative path to file that needs a patch.  Assuming changes are saved after
386 the editor appears, a patch file will be automatically generated in the proper diff format
387 with the standard "make makepatch" naming convention.  It only needs to be moved to the
388 port's "files" directory to be used.
389
390 If
391 .Nm
392 is launched outside of the port's WRKSRC, then diff output will still be generated, but it
393 will be sent to stdout rather than to a file.  This will also occur when the port is located
394 outside of the standard tree.
395 .Pp
396 .Pp
397 .Sh ERRORS
398 The script will abort if the number of arguments does not equal one, or if the one argument
399 is not an existing regular file.
400
401 If the editor is closed without making changes, no patch will be created.  However, the 
402 duplicated file will exist.  If the script is run again, it will detect the duplicate and
403 create a second duplicate with the .intermediate extension.  See
404 .Xr genpatch 1
405 for more information.
406 .Sh ENVIRONMENT 
407 .Bl -tag -width "PORTEDITOR" -indent 
408 .It Ev PORTEDITOR
409 First priority editor to use for modifying file to be patched
410 .It Ev EDITOR
411 Second priority editor to use for modifying file to be patched
412 .El                      
413 .Sh SEE ALSO 
414 .Xr dupe 1 , 
415 .Xr genpatch 1 
416 .Sh HISTORY     
417 This script was inspired by pkgsrc's pkgdiff suite although it works a bit differently.
418 It was written by 
419 .An John Marino Aq Mt marino@freebsd.org
420 and used for a couple of years on DragonFly's DPorts before being formally imported
421 into FreeBSD Ports Collection.
422