Ravenports generated: 10 Mar 2019 23:41
[ravenports.git] / bucket_83 / genpatch
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               genpatch
4 VERSION=                1.65
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:{{WRKSRC}}/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:2498: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 realpath 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=$(realpath /usr/obj/raven)
216    else
217       objpath=/usr/obj/raven # let it fail
218    fi
219 fi
220 rvnpath="/construction"
221 fullpath=$(dirname `realpath ${old}`)
222 testpath1=$(echo ${fullpath} | awk -vstd="${objpath}" "${AWKTRUNC}")
223 testpath2=$(echo ${fullpath} | awk -vstd="${rvnpath}" "${AWKTRUNC}")
224
225 if [ -n "${PRINT}" ]; then
226     # send patch to stdout unconditionally
227     diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}"
228 elif [ "${testpath1}" = "${objpath}" -o "${testpath2}" = "${rvnpath}" ]; then
229     # Inside standard work area.  Assume genpatch executed from wrksrc
230     # and generate patch with appropriate name
231
232     fname=patch-$(echo ${new} | sed -e 's|_|__|g' -e 's|/|_|g')
233     diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}" > ${fname}
234     echo "generated ${fname}"
235 else
236     # Not in standard work area, just send patch to stdout
237     diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}"
238 fi
239
240
241 [FILE:1908:files/genpatch.1]
242 .Dd 17 May, 2015
243 .Dt GENPATCH 1      
244 .Os
245 .Sh NAME
246 .Nm genpatch
247 .Nd generate patch quickly in standard Ravenports format
248 .Sh SYNOPSIS             
249 .Nm
250 .Ar newfile
251 .Nm
252 .Ar oldfile
253 .Ar newfile
254 .Sh DESCRIPTION    
255 This utility is always called by
256 .Xr portfix 1 ,
257 but quite often it is useful in its own right.
258
259 It creates patches using the standard Ravenports format, but there are different
260 operational modes. If
261 .Nm
262 is called when the current working directory is a subdirectory of the
263 /usr/obj/raven or /construction, then a patch will be saved in the
264 current directory using the Ravenports naming standard.  Note that the utility
265 assumes that it has been executed in the WRKSRC directory, the standard location
266 for applying Ravenports patches.
267
268 If
269 .Nm
270 is executed outside of those directories, then a patch will not be created.  The 
271 contents of the patch will be send to stdout, so the user will have to direct it to a
272 file manually as desired.
273
274 If only one argument is given,
275 .Nm
276 will search for a file named "<newfile>.intermediate" and if found, it will generated diff
277 output between it and
278 .Op newfile .
279 If that file doesn't exist, it will search for "<newfile>.orig" and attempt to create diff
280 output between it and
281 .Op newfile .
282 .Pp
283 .Sh ERRORS
284 .Nm
285 will abort if no arguments or more than 2 arguments are given.  If only one argument (
286 .Op newfile
287 ) is given, then a regular file called "<newfile>.orig" or "<newfile>.intermediate"
288 must exist otherwise
289 .Nm
290 will abort.  If two arguments are given, both must be existing regular files.
291 .Pp
292 .Sh ENVIRONMENT
293 .Bl -tag -width "PORTEDITOR" -indent 
294 .It Ev WORKHERE
295 Overrides hardcoded /usr/obj/raven and /construction with the current
296 value of pwd.  This also enables patch generation outside of standard working areas.
297 .Pp
298 .It Ev PRINT
299 Always send the contents of the patch to stdout (never generate a file).
300 .Pp
301 .Sh SEE ALSO 
302 .Xr dupe 1 , 
303 .Xr portfix 1 
304
305
306 [FILE:756:files/portfix]
307 #!/bin/sh
308 #
309 # usage: portfix origfile
310 #
311 # This is a wrapper.  It runs consecutively:
312 #   1. dupe XXX
313 #   2. <editor> XXX
314 #   3. genpatch XXX 
315 #
316 # If PORTEDITOR is defined in the environment, that program will be
317 # used instead of the EDITOR env. variable.  If neither are defined
318 # it will fall back to vi.
319
320
321 if [ $# -eq 1 ]; then
322         old=${1}
323         if [ ! -f ${old} ]; then
324                 echo "${0}: '${old}' does not exist! aborting..."
325                 exit 1;
326         fi
327 else
328         echo "${0}: need exactly one argument"
329         echo "${0} <path/to/original/file>"
330         exit 1;
331 fi
332
333 if [ -n "${PORTEDITOR}" ]; then
334         MYPORTEDITOR=${PORTEDITOR}
335 elif [ -n "${EDITOR}" ]; then
336         MYPORTEDITOR=${EDITOR}
337 else
338         MYPORTEDITOR=/usr/bin/vi
339 fi
340
341 dupe ${old}
342 ${MYPORTEDITOR} ${old}
343 if [ $? -eq 0 ]; then
344    genpatch ${old}
345 fi
346
347
348 [FILE:2250:files/portfix.1]
349 .Dd 17 May 2015
350 .Dt PORTFIX 1     
351 .Os 
352 .Sh NAME
353 .Nm portfix
354 .Nd macro to execute three programs to create a ports patch
355 .Sh SYNOPSIS
356 .Nm
357 .Ar original               
358 .Sh DESCRIPTION        
359 .Nm
360 is a wrapper.  It consecutively runs:
361
362 .Bl -enum -compact
363 .It 
364 dupe
365 .Ar original
366 .It
367 <editor>
368 .Ar original
369 .It
370 genpatch
371 .Ar original
372 .El
373
374 If PORTEDITOR is defined in the environment then that program will be used to edit
375 .Op original
376 file.  If PORTEDITOR is not defined but EDITOR is defined, then the EDITOR program
377 will be invoked.  If neither variable is defined in the environment, then
378 .Xr vi 1
379 will be invoked for the edit step.
380
381 .Nm
382 should be launched when the current working directory is equal to the port's WRKSRC, and
383 .Op original
384 should be a relative path to file that needs a patch.  Assuming changes are saved after
385 the editor appears, a patch file will be automatically generated in the proper diff format
386 with the standard "make makepatch" naming convention.  It only needs to be moved to the
387 port's "files" directory to be used.
388
389 If
390 .Nm
391 is launched outside of the port's WRKSRC, then diff output will still be generated, but it
392 will be sent to stdout rather than to a file.  This will also occur when the port is located
393 outside of the standard tree.
394 .Pp
395 .Pp
396 .Sh ERRORS
397 The script will abort if the number of arguments does not equal one, or if the one argument
398 is not an existing regular file.
399
400 If the editor is closed without making changes, no patch will be created.  However, the 
401 duplicated file will exist.  If the script is run again, it will detect the duplicate and
402 create a second duplicate with the .intermediate extension.  See
403 .Xr genpatch 1
404 for more information.
405 .Sh ENVIRONMENT 
406 .Bl -tag -width "PORTEDITOR" -indent 
407 .It Ev PORTEDITOR
408 First priority editor to use for modifying file to be patched
409 .It Ev EDITOR
410 Second priority editor to use for modifying file to be patched
411 .El                      
412 .Sh SEE ALSO 
413 .Xr dupe 1 , 
414 .Xr genpatch 1 
415 .Sh HISTORY     
416 This script was inspired by pkgsrc's pkgdiff suite although it works a bit differently.
417 It was written by 
418 .An John Marino Aq Mt marino@freebsd.org
419 and used for a couple of years on DragonFly's DPorts before being formally imported
420 into FreeBSD Ports Collection.
421