1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
8 SDESC[std]= Single patch generator tool for Ravenports
10 CONTACT= John_Marino[draco@marino.st]
18 OPTIONS_AVAILABLE= none
19 OPTIONS_STANDARD= none
21 LICENSE= BSD2CLAUSE:primary
22 LICENSE_FILE= BSD2CLAUSE:{{FILESDIR}}/LICENSE
25 FPC_EQUIVALENT= ports-mgmt/genpatch
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)
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.
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.
47 Please see the dupe, genpatch, and portfix man pages for details.
50 [FILE:30:manifests/plist.primary]
57 [FILE:47:manifests/plist.man]
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.
70 # Redistribution and use in source and binary forms, with or without
71 # modification, are permitted provided that the following conditions
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.
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.
96 # Usage: dupe origfile
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
103 if [ $# -eq 1 ]; then
105 if [ ! -f ${old} ]; then
106 echo "${0}: '${old}' does not exist! aborting..."
109 if [ -f "${old}.orig" ]; then
110 new="${old}.intermediate"
115 echo "${0}: need exactly one argument"
116 echo "${0} <path/to/original/file>"
123 [FILE:741:files/dupe.1]
129 .Nd duplicate a file quickly
134 This utility is always called by
136 but sometimes it is useful in its own right.
139 takes exactly one argument, a path to a file. It will duplicate the
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.
147 will abort if zero or more than one argument is given, or if
149 is not a path to a valid regular file.
156 [FILE:2565:files/genpatch]
159 # Usage: genpatch newfile
160 # genpatch oldfile newfile
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
171 # Ensure we always use the same timezone to avoid spurious metadata diffs
177 if [ -f "$1.intermediate" ]; then
178 if [ -s "$1.intermediate" ]; then
179 old="$1.intermediate"
182 elif [ -f "$1.orig" ]; then
183 if [ -s "$1.orig" ]; then
188 echo $0: need at least one valid argument >&2
197 echo $0: more than two arguments detected >&2
202 PKGDIFF_FMT="-p --unified=3"
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:.+]*\)*$||'
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)}'
212 if diff -q ${PKGDIFF_FMT} ${old} ${new} > /dev/null
217 if [ -n "${WORKHERE}" ]; then
220 if [ -d /usr/obj/raven ]; then
221 objpath=$(cd /usr/obj/raven && pwd -P)
223 objpath=/usr/obj/raven # let it fail
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}")
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
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}"
243 # Not in standard work area, just send patch to stdout
244 diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}"
248 [FILE:1908:files/genpatch.1]
254 .Nd generate patch quickly in standard Ravenports format
262 This utility is always called by
264 but quite often it is useful in its own right.
266 It creates patches using the standard Ravenports format, but there are different
267 operational modes. If
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.
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.
281 If only one argument is given,
283 will search for a file named "<newfile>.intermediate" and if found, it will generated diff
284 output between it and
286 If that file doesn't exist, it will search for "<newfile>.orig" and attempt to create diff
287 output between it and
292 will abort if no arguments or more than 2 arguments are given. If only one argument (
294 ) is given, then a regular file called "<newfile>.orig" or "<newfile>.intermediate"
297 will abort. If two arguments are given, both must be existing regular files.
300 .Bl -tag -width "PORTEDITOR" -indent
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.
306 Always send the contents of the patch to stdout (never generate a file).
313 [FILE:756:files/portfix]
316 # usage: portfix origfile
318 # This is a wrapper. It runs consecutively:
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.
328 if [ $# -eq 1 ]; then
330 if [ ! -f ${old} ]; then
331 echo "${0}: '${old}' does not exist! aborting..."
335 echo "${0}: need exactly one argument"
336 echo "${0} <path/to/original/file>"
340 if [ -n "${PORTEDITOR}" ]; then
341 MYPORTEDITOR=${PORTEDITOR}
342 elif [ -n "${EDITOR}" ]; then
343 MYPORTEDITOR=${EDITOR}
345 MYPORTEDITOR=/usr/bin/vi
349 ${MYPORTEDITOR} ${old}
350 if [ $? -eq 0 ]; then
355 [FILE:2250:files/portfix.1]
361 .Nd macro to execute three programs to create a ports patch
367 is a wrapper. It consecutively runs:
381 If PORTEDITOR is defined in the environment then that program will be used to edit
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
386 will be invoked for the edit step.
389 should be launched when the current working directory is equal to the port's WRKSRC, and
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.
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.
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.
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
411 for more information.
413 .Bl -tag -width "PORTEDITOR" -indent
415 First priority editor to use for modifying file to be patched
417 Second priority editor to use for modifying file to be patched
423 This script was inspired by pkgsrc's pkgdiff suite although it works a bit differently.
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.