aboutsummaryrefslogtreecommitdiff
path: root/ports-mgmt
diff options
context:
space:
mode:
authorJohn Marino <marino@FreeBSD.org>2015-05-17 23:48:01 +0000
committerJohn Marino <marino@FreeBSD.org>2015-05-17 23:48:01 +0000
commita5f84a8ad8a9a4a299600bc37dd52c96a9ca5cc0 (patch)
tree4e0c9250ab633891b696e98b1c8249a93815bcbb /ports-mgmt
parent76df15a96d9b8f93babb1f538af8158b6776a38f (diff)
downloadports-a5f84a8ad8a9a4a299600bc37dd52c96a9ca5cc0.tar.gz
ports-a5f84a8ad8a9a4a299600bc37dd52c96a9ca5cc0.zip
Notes
Diffstat (limited to 'ports-mgmt')
-rw-r--r--ports-mgmt/Makefile1
-rw-r--r--ports-mgmt/genpatch/Makefile46
-rw-r--r--ports-mgmt/genpatch/files/dupe49
-rw-r--r--ports-mgmt/genpatch/files/dupe.130
-rw-r--r--ports-mgmt/genpatch/files/genpatch.187
-rw-r--r--ports-mgmt/genpatch/files/genpatch.in98
-rw-r--r--ports-mgmt/genpatch/files/portfix.172
-rw-r--r--ports-mgmt/genpatch/files/portfix.in39
-rw-r--r--ports-mgmt/genpatch/pkg-descr11
9 files changed, 433 insertions, 0 deletions
diff --git a/ports-mgmt/Makefile b/ports-mgmt/Makefile
index 802d024b7be2..93ae0aa12529 100644
--- a/ports-mgmt/Makefile
+++ b/ports-mgmt/Makefile
@@ -10,6 +10,7 @@
SUBDIR += distilator
SUBDIR += fastest_sites
SUBDIR += fbsdmon
+ SUBDIR += genpatch
SUBDIR += genplist
SUBDIR += gnome-packagekit
SUBDIR += hs-porte
diff --git a/ports-mgmt/genpatch/Makefile b/ports-mgmt/genpatch/Makefile
new file mode 100644
index 000000000000..f2eae79c8edf
--- /dev/null
+++ b/ports-mgmt/genpatch/Makefile
@@ -0,0 +1,46 @@
+# Created by: John Marino <marino@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME= genpatch
+PORTVERSION= 1.40
+CATEGORIES= ports-mgmt
+MASTER_SITES= # none
+DISTFILES= # none
+
+MAINTAINER= marino@FreeBSD.org
+COMMENT= Single patch generator tool compatible with makepatch format
+
+LICENSE= BSD2CLAUSE
+
+NO_BUILD= yes
+SUB_FILES= genpatch portfix
+SUB_LIST= WORKPATH=${PORTWORK}
+PLIST_FILES= bin/dupe \
+ bin/genpatch \
+ bin/portfix \
+ man/man1/dupe.1.gz \
+ man/man1/genpatch.1.gz \
+ man/man1/portfix.1.gz
+
+.if defined(PACKAGE_BUILDING) # use known default values, poudriere overrides
+. if defined(.MAKE.BUILT.BY) # DragonFly!
+PORTWORK= /usr/obj/dports
+. else
+PORTWORK= /usr/ports
+. endif
+.else
+. if defined(WRKDIRPREFIX) && !empty(WRKDIRPREFIX)
+PORTWORK= ${WRKDIRPREFIX}
+. else
+PORTWORK= ${PORTSDIR}
+. endif
+.endif
+
+do-install:
+ ${INSTALL_SCRIPT} ${FILESDIR}/dupe ${STAGEDIR}${PREFIX}/bin
+ ${INSTALL_SCRIPT} ${WRKDIR}/genpatch ${STAGEDIR}${PREFIX}/bin
+ ${INSTALL_SCRIPT} ${WRKDIR}/portfix ${STAGEDIR}${PREFIX}/bin
+ (cd ${FILESDIR} && ${INSTALL_MAN} dupe.1 genpatch.1 portfix.1 \
+ ${STAGEDIR}${MANPREFIX}/man/man1)
+
+.include <bsd.port.mk>
diff --git a/ports-mgmt/genpatch/files/dupe b/ports-mgmt/genpatch/files/dupe
new file mode 100644
index 000000000000..5fdaa49ab421
--- /dev/null
+++ b/ports-mgmt/genpatch/files/dupe
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# Usage: dupe origfile
+#
+# This will make a duplicate of the file indicate by the first argument.
+# If <origfile>.orig does not exist, the duplicate will have this name,
+# otherwise it will be called <origfile>.intermediate.
+# This is a complementary tool of genpatch
+#
+# 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.
+#
+
+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} <path/to/original/file>"
+ exit 1;
+fi
+
+cp -p ${old} ${new}
diff --git a/ports-mgmt/genpatch/files/dupe.1 b/ports-mgmt/genpatch/files/dupe.1
new file mode 100644
index 000000000000..75127514a5e9
--- /dev/null
+++ b/ports-mgmt/genpatch/files/dupe.1
@@ -0,0 +1,30 @@
+.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 "<original>.orig" unless there is already an existing file with
+this exact name. In that case, the target file name will be "<original>.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
diff --git a/ports-mgmt/genpatch/files/genpatch.1 b/ports-mgmt/genpatch/files/genpatch.1
new file mode 100644
index 000000000000..1ba6e857921f
--- /dev/null
+++ b/ports-mgmt/genpatch/files/genpatch.1
@@ -0,0 +1,87 @@
+.Dd 17 May, 2015
+.Dt GENPATCH 1
+.Os
+.Sh NAME
+.Nm genpatch
+.Nd generate patch quickly in standard FreeBSD ports 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 FreeBSD ports format defined by the "make makepatch"
+ports utility, but there are different operational modes.
+
+If
+.Nm
+is called when the current working directory is a subdirectory of WRKDIRPREFIX if defined
+or PORTSDIR if not, then a patch will be saved in the current directory using the naming
+standard used by "make makepatch". Note that the utility assumes that it has been executed
+in the WRKSRC directory, the standard location for applying ports patches.
+
+If
+.Nm
+is executed outside of WRKDIRPREFIX (or PORTSDIR), 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 "<newfile>.intermediate" and if found, it will generated diff
+output between it and
+.Op newfile .
+If that file doesn't exist, it will search for "<newfile>.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 "<newfile>.orig" or "<newfile>.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 WORKTREE
+Overrides hardcoded WRKDIRPREFIX (or PORTSDIR). This is useful for ports outside of the tree
+or when
+.Nm
+was installed via binary packages and WRKDIRPREFIX is defined (or PORTSDIR is non-standard)
+.Pp
+.Sh NOTES
+.Bl -enum -compact
+.It
+FreeBSD does not set WRKDIRPREFIX by default
+.It
+The default PORTSDIR for FreeBSD is
+.Pa /usr/ports
+so on standard FreeBSD systems
+.Nm
+will generate a patch file in the current directory if executed on any subdirectory of
+.Pa /usr/ports .
+.It
+Dragonfly sets WRKDIRPREFIX to
+.Pa /usr/obj/dports
+by default, so on standard systems patch
+files are generated automatically if
+.Nm
+is executed from a subdirectory of
+.Pa /usr/obj/dports .
+.It
+The root directory used for this calculation is permanently set when
+.Nm
+is built, but it can be overridden with the WORKTREE environment variable.
+.El
+.Pp
+.Sh SEE ALSO
+.Xr dupe 1 ,
+.Xr portfix 1
diff --git a/ports-mgmt/genpatch/files/genpatch.in b/ports-mgmt/genpatch/files/genpatch.in
new file mode 100644
index 000000000000..dbf4f322f585
--- /dev/null
+++ b/ports-mgmt/genpatch/files/genpatch.in
@@ -0,0 +1,98 @@
+#!/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 realpath doesn't start with /usr/obj/dports, 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.
+
+#
+# Copyright (c) 2004-2011 The NetBSD Foundation, Inc.
+# Copyright (c) 2011 by Thomas Klausner <wiz@NetBSD.org>
+# Copyright (c) 2012 by John Marino <draco@marino.st>
+# 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.
+#
+# Ensure we always use the same timezone to avoid spurious metadata diffs
+export TZ=UTC
+
+if [ $# -le 1 ]
+then
+ if [ -f "$1.intermediate" ]; then
+ old="$1.intermediate"
+ new="$1"
+ elif [ -f "$1.orig" ]; then
+ old="$1.orig"
+ 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:.+]*\)*$||'
+
+if diff -q ${PKGDIFF_FMT} ${old} ${new} > /dev/null
+then
+ exit 0
+fi
+
+if [ -n "${WORKTREE}" ]; then
+objpath=${WORKTREE}
+else
+objpath=$(realpath %%WORKPATH%%)
+fi
+cnt1=$(echo ${objpath} | wc -c)
+objcount=$(expr $cnt1 - 1)
+fullpath=$(dirname `realpath ${old}`)
+testpath=$(echo ${fullpath} | cut -c "1-${objcount}")
+
+if [ "${testpath}" = "${objpath}" ]; 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
diff --git a/ports-mgmt/genpatch/files/portfix.1 b/ports-mgmt/genpatch/files/portfix.1
new file mode 100644
index 000000000000..90d939702754
--- /dev/null
+++ b/ports-mgmt/genpatch/files/portfix.1
@@ -0,0 +1,72 @@
+.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
+<editor>
+.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.
diff --git a/ports-mgmt/genpatch/files/portfix.in b/ports-mgmt/genpatch/files/portfix.in
new file mode 100644
index 000000000000..06538310c310
--- /dev/null
+++ b/ports-mgmt/genpatch/files/portfix.in
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# usage: portfix origfile
+#
+# This is a wrapper. It runs consecutively:
+# 1. dupe XXX
+# 2. <editor> 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} <path/to/original/file>"
+ exit 1;
+fi
+
+if [ -n "${PORTEDITOR}" ]; then
+ MYPORTEDITOR=${PORTEDITOR}
+elif [ -n "${EDITOR}" ]; then
+ MYPORTEDITOR=${EDITOR}
+else
+ MYPORTEDITOR=/usr/bin/vi
+fi
+
+%%PREFIX%%/bin/dupe ${old}
+${MYPORTEDITOR} ${old}
+if [ $? -eq 0 ]; then
+ %%PREFIX%%/bin/genpatch ${old}
+fi
diff --git a/ports-mgmt/genpatch/pkg-descr b/ports-mgmt/genpatch/pkg-descr
new file mode 100644
index 000000000000..eb37796aa765
--- /dev/null
+++ b/ports-mgmt/genpatch/pkg-descr
@@ -0,0 +1,11 @@
+This is a set of three simple tools written in sh(1) for generating single
+patches for use in Ports. This set is ideal for creating a new patch when
+it is inconvenient or undesirable to use the "make makepatch" utility.
+
+The first tool is "dupe" which is a quick copy utility. The second tool
+is "genpatch" which creates patches in the standards 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.