# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= genpatch VERSION= 1.70 KEYWORDS= raven devel VARIANTS= standard SDESC[standard]= Single patch generator tool for Ravenports HOMEPAGE= none CONTACT= John_Marino[draco@marino.st] DOWNLOAD_GROUPS= main SITES[main]= none SPKGS[standard]= single OPTIONS_AVAILABLE= none OPTIONS_STANDARD= none LICENSE= BSD2CLAUSE:single LICENSE_FILE= BSD2CLAUSE:{{FILESDIR}}/LICENSE LICENSE_SCHEME= solo FPC_EQUIVALENT= ports-mgmt/genpatch SKIP_BUILD= yes do-install: ${INSTALL_SCRIPT} ${FILESDIR}/portfix ${STAGEDIR}${PREFIX}/bin ${INSTALL_SCRIPT} ${FILESDIR}/genpatch ${STAGEDIR}${PREFIX}/bin ${INSTALL_SCRIPT} ${FILESDIR}/dupe ${STAGEDIR}${PREFIX}/bin (cd ${FILESDIR} && ${INSTALL_MAN} dupe.1 genpatch.1 portfix.1 \ ${STAGEDIR}${MANPREFIX}/man/man1) [FILE:587:descriptions/desc.single] This is a set of three simple tools written in sh(1) for generating single patches for use in Ravenports. These are ideal for creating patches in the standard convention format. The first tool is "dupe" which is a quick copy utility. The second tool is "genpatch" which creates patches in the standard diff format and using the standard file name conventions. The last tool is "portfix" which runs "dupe", an editor of choice, and "genpatch" serially as a macro as a convenient and quick way to create port patches. Please see the dupe, genpatch, and portfix man pages for details. [FILE:86:manifests/plist.single] bin/ dupe genpatch portfix share/man/man1/ dupe.1.gz genpatch.1.gz portfix.1.gz [FILE:1422:files/LICENSE] # Copyright (c) 2004-2011 The NetBSD Foundation, Inc. # Copyright (c) 2011 by Thomas Klausner # Copyright (c) 2012 by John Marino # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. [FILE:609:files/dupe] #!/bin/sh # # Usage: dupe origfile # # This will make a duplicate of the file indicate by the first argument. # If .orig does not exist, the duplicate will have this name, # otherwise it will be called .intermediate. # This is a complementary tool of genpatch if [ $# -eq 1 ]; then old=${1} if [ ! -f ${old} ]; then echo "${0}: '${old}' does not exist! aborting..." exit 1; fi if [ -f "${old}.orig" ]; then new="${old}.intermediate" else new="${old}.orig" fi else echo "${0}: need exactly one argument" echo "${0} " exit 1; fi cp -p ${old} ${new} [FILE:741:files/dupe.1] .Dd May 17, 2015 .Dt DUPE 1 .Os .Sh NAME .Nm dupe .Nd duplicate a file quickly .Sh SYNOPSIS .Nm .Ar original .Sh DESCRIPTION This utility is always called by .Xr portfix 1 , but sometimes it is useful in its own right. .Nm takes exactly one argument, a path to a file. It will duplicate the .Op original file to ".orig" unless there is already an existing file with this exact name. In that case, the target file name will be ".intermediate" and any existing file of that name will be unconditionally overwritten. .Pp .Sh ERRORS .Nm will abort if zero or more than one argument is given, or if .Op original is not a path to a valid regular file. .Pp .Sh SEE ALSO .Xr genpatch 1 , .Xr portfix 1 [FILE:2565:files/genpatch] #!/bin/sh # # Usage: genpatch newfile # genpatch oldfile newfile # # Will output a patch ready for dports (unified diff). # If only newfile is given, oldfile is assumed as newfile.intermediate (1st) # or newfile.orig (2nd) if such a file exists # If the physical path doesn't start with /usr/obj/raven or /construction, # genpatch sends output to stdout, otherwise, the patch file will be # created in the current directory with a filename on the file's # location relative to worksource. The patch will be generated from # wrksrc location. # Ensure we always use the same timezone to avoid spurious metadata diffs export TZ=UTC if [ $# -le 1 ] then old=/dev/null if [ -f "$1.intermediate" ]; then if [ -s "$1.intermediate" ]; then old="$1.intermediate" fi new="$1" elif [ -f "$1.orig" ]; then if [ -s "$1.orig" ]; then old="$1.orig" fi new="$1" else echo $0: need at least one valid argument >&2 exit 1; fi else if [ $# -eq 2 ] then old="$1" new="$2" else echo $0: more than two arguments detected >&2 exit 1; fi fi PKGDIFF_FMT="-p --unified=3" # Strip out the date on the +++ line to reduce needless # differences in regenerated patches SEDPLUS='/^---/s|\.[0-9]* +0000$| UTC| ; /^+++/s|\([[:blank:]][-0-9:.+]*\)*$||' # Truncate given string to same length as its comparing standard # External variables: std AWKTRUNC='BEGIN {stdlen=length(std)}{print substr($1,1,stdlen)}' if diff -q ${PKGDIFF_FMT} ${old} ${new} > /dev/null then exit 0 fi if [ -n "${WORKHERE}" ]; then objpath=$(pwd) else if [ -d /usr/obj/raven ]; then objpath=$(cd /usr/obj/raven && pwd -P) else objpath=/usr/obj/raven # let it fail fi fi rvnpath="/construction" old_directory=$(dirname "${old}") real_directory=$(cd "${old_directory}" && pwd -P) testpath1=$(echo ${real_directory} | awk -vstd="${objpath}" "${AWKTRUNC}") testpath2=$(echo ${real_directory} | awk -vstd="${rvnpath}" "${AWKTRUNC}") if [ -n "${PRINT}" ]; then # send patch to stdout unconditionally diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}" elif [ "${testpath1}" = "${objpath}" -o "${testpath2}" = "${rvnpath}" ]; then # Inside standard work area. Assume genpatch executed from wrksrc # and generate patch with appropriate name fname=patch-$(echo ${new} | sed -e 's|_|__|g' -e 's|/|_|g') diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}" > ${fname} echo "generated ${fname}" else # Not in standard work area, just send patch to stdout diff ${PKGDIFF_FMT} ${old} ${new} | sed -e "${SEDPLUS}" fi [FILE:1908:files/genpatch.1] .Dd 17 May, 2015 .Dt GENPATCH 1 .Os .Sh NAME .Nm genpatch .Nd generate patch quickly in standard Ravenports format .Sh SYNOPSIS .Nm .Ar newfile .Nm .Ar oldfile .Ar newfile .Sh DESCRIPTION This utility is always called by .Xr portfix 1 , but quite often it is useful in its own right. It creates patches using the standard Ravenports format, but there are different operational modes. If .Nm is called when the current working directory is a subdirectory of the /usr/obj/raven or /construction, then a patch will be saved in the current directory using the Ravenports naming standard. Note that the utility assumes that it has been executed in the WRKSRC directory, the standard location for applying Ravenports patches. If .Nm is executed outside of those directories, then a patch will not be created. The contents of the patch will be send to stdout, so the user will have to direct it to a file manually as desired. If only one argument is given, .Nm will search for a file named ".intermediate" and if found, it will generated diff output between it and .Op newfile . If that file doesn't exist, it will search for ".orig" and attempt to create diff output between it and .Op newfile . .Pp .Sh ERRORS .Nm will abort if no arguments or more than 2 arguments are given. If only one argument ( .Op newfile ) is given, then a regular file called ".orig" or ".intermediate" must exist otherwise .Nm will abort. If two arguments are given, both must be existing regular files. .Pp .Sh ENVIRONMENT .Bl -tag -width "PORTEDITOR" -indent .It Ev WORKHERE Overrides hardcoded /usr/obj/raven and /construction with the current value of pwd. This also enables patch generation outside of standard working areas. .Pp .It Ev PRINT Always send the contents of the patch to stdout (never generate a file). .Pp .Sh SEE ALSO .Xr dupe 1 , .Xr portfix 1 [FILE:756:files/portfix] #!/bin/sh # # usage: portfix origfile # # This is a wrapper. It runs consecutively: # 1. dupe XXX # 2. XXX # 3. genpatch XXX # # If PORTEDITOR is defined in the environment, that program will be # used instead of the EDITOR env. variable. If neither are defined # it will fall back to vi. if [ $# -eq 1 ]; then old=${1} if [ ! -f ${old} ]; then echo "${0}: '${old}' does not exist! aborting..." exit 1; fi else echo "${0}: need exactly one argument" echo "${0} " exit 1; fi if [ -n "${PORTEDITOR}" ]; then MYPORTEDITOR=${PORTEDITOR} elif [ -n "${EDITOR}" ]; then MYPORTEDITOR=${EDITOR} else MYPORTEDITOR=/usr/bin/vi fi dupe ${old} ${MYPORTEDITOR} ${old} if [ $? -eq 0 ]; then genpatch ${old} fi [FILE:2250:files/portfix.1] .Dd 17 May 2015 .Dt PORTFIX 1 .Os .Sh NAME .Nm portfix .Nd macro to execute three programs to create a ports patch .Sh SYNOPSIS .Nm .Ar original .Sh DESCRIPTION .Nm is a wrapper. It consecutively runs: .Bl -enum -compact .It dupe .Ar original .It .Ar original .It genpatch .Ar original .El If PORTEDITOR is defined in the environment then that program will be used to edit .Op original file. If PORTEDITOR is not defined but EDITOR is defined, then the EDITOR program will be invoked. If neither variable is defined in the environment, then .Xr vi 1 will be invoked for the edit step. .Nm should be launched when the current working directory is equal to the port's WRKSRC, and .Op original should be a relative path to file that needs a patch. Assuming changes are saved after the editor appears, a patch file will be automatically generated in the proper diff format with the standard "make makepatch" naming convention. It only needs to be moved to the port's "files" directory to be used. If .Nm is launched outside of the port's WRKSRC, then diff output will still be generated, but it will be sent to stdout rather than to a file. This will also occur when the port is located outside of the standard tree. .Pp .Pp .Sh ERRORS The script will abort if the number of arguments does not equal one, or if the one argument is not an existing regular file. If the editor is closed without making changes, no patch will be created. However, the duplicated file will exist. If the script is run again, it will detect the duplicate and create a second duplicate with the .intermediate extension. See .Xr genpatch 1 for more information. .Sh ENVIRONMENT .Bl -tag -width "PORTEDITOR" -indent .It Ev PORTEDITOR First priority editor to use for modifying file to be patched .It Ev EDITOR Second priority editor to use for modifying file to be patched .El .Sh SEE ALSO .Xr dupe 1 , .Xr genpatch 1 .Sh HISTORY This script was inspired by pkgsrc's pkgdiff suite although it works a bit differently. It was written by .An John Marino Aq Mt marino@freebsd.org and used for a couple of years on DragonFly's DPorts before being formally imported into FreeBSD Ports Collection.