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