1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
7 SDESC[standard]= Single patch generator tool for Ravenports
9 CONTACT= John_Marino[draco@marino.st]
13 SPKGS[standard]= single
15 OPTIONS_AVAILABLE= none
16 OPTIONS_STANDARD= none
18 LICENSE= BSD2CLAUSE:single
19 LICENSE_FILE= BSD2CLAUSE:{{WRKSRC}}/LICENSE
22 FPC_EQUIVALENT= ports-mgmt/genpatch
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)
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.
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.
44 Please see the dupe, genpatch, and portfix man pages for details.
47 [FILE:86:manifests/plist.single]
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.
64 # Redistribution and use in source and binary forms, with or without
65 # modification, are permitted provided that the following conditions
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.
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.
90 # Usage: dupe origfile
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
99 if [ ! -f ${old} ]; then
100 echo "${0}: '${old}' does not exist! aborting..."
103 if [ -f "${old}.orig" ]; then
104 new="${old}.intermediate"
109 echo "${0}: need exactly one argument"
110 echo "${0} <path/to/original/file>"
117 [FILE:741:files/dupe.1]
123 .Nd duplicate a file quickly
128 This utility is always called by
130 but sometimes it is useful in its own right.
133 takes exactly one argument, a path to a file. It will duplicate the
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.
141 will abort if zero or more than one argument is given, or if
143 is not a path to a valid regular file.
150 [FILE:2498:files/genpatch]
153 # Usage: genpatch newfile
154 # genpatch oldfile newfile
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
165 # Ensure we always use the same timezone to avoid spurious metadata diffs
171 if [ -f "$1.intermediate" ]; then
172 if [ -s "$1.intermediate" ]; then
173 old="$1.intermediate"
176 elif [ -f "$1.orig" ]; then
177 if [ -s "$1.orig" ]; then
182 echo $0: need at least one valid argument >&2
191 echo $0: more than two arguments detected >&2
196 PKGDIFF_FMT="-p --unified=3"
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:.+]*\)*$||'
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)}'
206 if diff -q ${PKGDIFF_FMT} ${old} ${new} > /dev/null
211 if [ -n "${WORKHERE}" ]; then
214 if [ -d /usr/obj/raven ]; then
215 objpath=$(realpath /usr/obj/raven)
217 objpath=/usr/obj/raven # let it fail
220 rvnpath="/construction"
221 fullpath=$(dirname `realpath ${old}`)
222 testpath1=$(echo ${fullpath} | awk -vstd="${objpath}" "${AWKTRUNC}")
223 testpath2=$(echo ${fullpath} | awk -vstd="${rvnpath}" "${AWKTRUNC}")
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
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}"
236 # Not in standard work area, just send patch to stdout
237 diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}"
241 [FILE:1908:files/genpatch.1]
247 .Nd generate patch quickly in standard Ravenports format
255 This utility is always called by
257 but quite often it is useful in its own right.
259 It creates patches using the standard Ravenports format, but there are different
260 operational modes. If
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.
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.
274 If only one argument is given,
276 will search for a file named "<newfile>.intermediate" and if found, it will generated diff
277 output between it and
279 If that file doesn't exist, it will search for "<newfile>.orig" and attempt to create diff
280 output between it and
285 will abort if no arguments or more than 2 arguments are given. If only one argument (
287 ) is given, then a regular file called "<newfile>.orig" or "<newfile>.intermediate"
290 will abort. If two arguments are given, both must be existing regular files.
293 .Bl -tag -width "PORTEDITOR" -indent
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.
299 Always send the contents of the patch to stdout (never generate a file).
306 [FILE:756:files/portfix]
309 # usage: portfix origfile
311 # This is a wrapper. It runs consecutively:
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.
321 if [ $# -eq 1 ]; then
323 if [ ! -f ${old} ]; then
324 echo "${0}: '${old}' does not exist! aborting..."
328 echo "${0}: need exactly one argument"
329 echo "${0} <path/to/original/file>"
333 if [ -n "${PORTEDITOR}" ]; then
334 MYPORTEDITOR=${PORTEDITOR}
335 elif [ -n "${EDITOR}" ]; then
336 MYPORTEDITOR=${EDITOR}
338 MYPORTEDITOR=/usr/bin/vi
342 ${MYPORTEDITOR} ${old}
343 if [ $? -eq 0 ]; then
348 [FILE:2250:files/portfix.1]
354 .Nd macro to execute three programs to create a ports patch
360 is a wrapper. It consecutively runs:
374 If PORTEDITOR is defined in the environment then that program will be used to edit
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
379 will be invoked for the edit step.
382 should be launched when the current working directory is equal to the port's WRKSRC, and
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.
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.
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.
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
404 for more information.
406 .Bl -tag -width "PORTEDITOR" -indent
408 First priority editor to use for modifying file to be patched
410 Second priority editor to use for modifying file to be patched
416 This script was inspired by pkgsrc's pkgdiff suite although it works a bit differently.
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.