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:{{FILESDIR}}/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:2565: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 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
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=$(cd /usr/obj/raven && pwd -P)
217 objpath=/usr/obj/raven # let it fail
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}")
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
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}"
237 # Not in standard work area, just send patch to stdout
238 diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}"
242 [FILE:1908:files/genpatch.1]
248 .Nd generate patch quickly in standard Ravenports format
256 This utility is always called by
258 but quite often it is useful in its own right.
260 It creates patches using the standard Ravenports format, but there are different
261 operational modes. If
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.
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.
275 If only one argument is given,
277 will search for a file named "<newfile>.intermediate" and if found, it will generated diff
278 output between it and
280 If that file doesn't exist, it will search for "<newfile>.orig" and attempt to create diff
281 output between it and
286 will abort if no arguments or more than 2 arguments are given. If only one argument (
288 ) is given, then a regular file called "<newfile>.orig" or "<newfile>.intermediate"
291 will abort. If two arguments are given, both must be existing regular files.
294 .Bl -tag -width "PORTEDITOR" -indent
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.
300 Always send the contents of the patch to stdout (never generate a file).
307 [FILE:756:files/portfix]
310 # usage: portfix origfile
312 # This is a wrapper. It runs consecutively:
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.
322 if [ $# -eq 1 ]; then
324 if [ ! -f ${old} ]; then
325 echo "${0}: '${old}' does not exist! aborting..."
329 echo "${0}: need exactly one argument"
330 echo "${0} <path/to/original/file>"
334 if [ -n "${PORTEDITOR}" ]; then
335 MYPORTEDITOR=${PORTEDITOR}
336 elif [ -n "${EDITOR}" ]; then
337 MYPORTEDITOR=${EDITOR}
339 MYPORTEDITOR=/usr/bin/vi
343 ${MYPORTEDITOR} ${old}
344 if [ $? -eq 0 ]; then
349 [FILE:2250:files/portfix.1]
355 .Nd macro to execute three programs to create a ports patch
361 is a wrapper. It consecutively runs:
375 If PORTEDITOR is defined in the environment then that program will be used to edit
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
380 will be invoked for the edit step.
383 should be launched when the current working directory is equal to the port's WRKSRC, and
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.
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.
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.
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
405 for more information.
407 .Bl -tag -width "PORTEDITOR" -indent
409 First priority editor to use for modifying file to be patched
411 Second priority editor to use for modifying file to be patched
417 This script was inspired by pkgsrc's pkgdiff suite although it works a bit differently.
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.