Subject: local patches
To: tech-pkg@netbsd.org, Stefah `sec` Zehl <sec@42.org>
From: Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de>
List: tech-pkg
Date: 08/20/2001 04:40:08
I was asked how to store local patches outside of pkgsrc. The code below
does so by allowing a variable LOCALPATCHES to point to a tree of such
patches, e.g. a patch for png could be in
$LOCALPATCHES/graphics/png/my.patch. Local patches are applied after
pkgsrc patches.

Any comments?


 - Hubert

Index: Packages.txt
===================================================================
RCS file: /cvsroot/pkgsrc/Packages.txt,v
retrieving revision 1.177
diff -u -r1.177 Packages.txt
--- Packages.txt	2001/08/13 18:09:06	1.177
+++ Packages.txt	2001/08/20 02:32:09
@@ -711,7 +711,17 @@
 for the patch files by using the "make makepatchsum" command, see
 section 4.2.
 
+If it is desired to store any patches that should not be committed into
+pkgsrc, they can be kept outside the pkgsrc tree in the $LOCALPATCHES
+directory. The directory tree there is expected to have the same
+"category/package" structure as pkgsrc, and patches are expected to be
+stored inside these dirs (also known as $LOCALPATCHES/$PKGPATH). For
+example if you want to keep a private patch for pkgsrc/graphics/png, keep
+it in $LOCALPATCHES/graphics/png/mypatch. All files in the named directory
+are expected to be patch files, and they are applied after the "normal"
+pkgsrc patches are applied. 
 
+
  4.4 pkg/*
  =========
 
@@ -1237,12 +1247,13 @@
    EXTRACT_AFTER_ARGS. 
 
  * patch:
-   After extraction, all the patches named by the PATCHFILES and those
-   present in the patches subdirectory of the package are applied. 
-   Patchfiles ending in .Z or .gz are uncompressed before they are
-   applied, files ending in .orig or .rej are ignored.  Any special
-   options to patch(1) can be handed in PATCH_DIST_ARGS.  See section
-   4.3 for more details.
+   After extraction, all the patches named by the PATCHFILES, those present
+   in the patches subdirectory of the package as well as in
+   $LOCALPATCHES/$PKGPATH (e.g. /usr/local/patches/graphics/png) are
+   applied. Patchfiles ending in .Z or .gz are uncompressed before they are
+   applied, files ending in .orig or .rej are ignored. Any special options
+   to patch(1) can be handed in PATCH_DIST_ARGS. See section 4.3 for more
+   details.
    
    By default patch is given special args to make it fail if the
    patches with some lines of fuzz. Please fix (regen) the patches
Index: mk/mk.conf.example
===================================================================
RCS file: /cvsroot/pkgsrc/mk/mk.conf.example,v
retrieving revision 1.238
diff -u -r1.238 mk.conf.example
--- mk/mk.conf.example	2001/08/19 08:47:57	1.238
+++ mk/mk.conf.example	2001/08/20 02:32:10
@@ -347,6 +347,10 @@
 # Possible: -v, -u, etc. See pkg_add(8)
 # Default: (no option)
 
+#LOCALPATCHES=...
+# Directory where local patches are stored. See pkgsrc/Packages.txt.
+# Possible: Any local directory
+# Default: none
 
 #
 #	Definitions used only in the packages collection
Index: mk/bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.797
diff -u -r1.797 bsd.pkg.mk
--- mk/bsd.pkg.mk	2001/08/16 01:49:09	1.797
+++ mk/bsd.pkg.mk	2001/08/20 02:32:12
@@ -1433,7 +1433,15 @@
 		else							\
 			${ECHO_MSG} "${_PKGSRC_IN}> Applying ${OPSYS} patches for ${PKGNAME}" ; \
 			fail="";					\
-			for i in ${PATCHDIR}/patch-*; do		\
+			for i in ${PATCHDIR}/patch-* ${LOCALPATCHES}/${PKGPATH}/* ; do		\
+				if [ "$$i" = "${LOCALPATCHES}/${PKGPATH}/*" ]; then \
+ echo "HF: no local patches" ; \
+					continue ; 			\
+				fi ; 					\
+				if [ ! -f "$$i" ]; then			\
+					${ECHO_MSG} "${_PKGSRC_IN}> $$i is not a valid patch file - skipping" ; \
+					continue ; 			\
+				fi ; 					\
 				case $$i in				\
 				*.orig|*.rej|*~)			\
 					${ECHO_MSG} "${_PKGSRC_IN}> Ignoring patchfile $$i" ; \
@@ -1441,6 +1449,8 @@
 					;;				\
 				${PATCHDIR}/patch-local-*) 		\
 					;;				\
+				${LOCALPATCHES}/${PKGPATH}/*) 		\
+					;;				\
 				*)					\
 					if [ -f ${DISTINFO_FILE} ]; then \
 						filename=`expr $$i : '.*/\(.*\)'`; \
@@ -3116,14 +3126,15 @@
 	 | ${SED}							\
 		-e  's@${PREFIX}/./@@' 					\
 		-e  's@${OPSYS}@\$${OPSYS}@' 				\
-		-e  's@${OS_VERSION:S/./\./}@\$${OS_VERSION}@'	\
+		-e  's@${OS_VERSION:S/./\./}@\$${OS_VERSION}@'		\
 		-e  's@${MACHINE_ARCH}@\$${MACHINE_ARCH}@' 		\
 		-e  's@${MACHINE_GNU_ARCH}@\$${MACHINE_GNU_ARCH}@'	\
 		-e  's@${MACHINE_GNU_PLATFORM}@\$${MACHINE_GNU_PLATFORM}@' \
 		-e  's@${LOWER_VENDOR}@\$${LOWER_VENDOR}@' 		\
 		-e  's@${LOWER_OPSYS}@\$${LOWER_OPSYS}@' 		\
 		-e  's@${PKGNAME}@\$${PKGNAME}@' 			\
-	 | ${SORT} \
+	 | ${SORT}							\
+	 | ${GREP} -v emul/linux/proc					\
 	 | ${AWK} '							\
 		/^@/ { print $$0; next }				\
 		/.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { 	\
@@ -3172,7 +3183,8 @@
 		-e  s@${MACHINE_GNU_PLATFORM}@\$${MACHINE_GNU_PLATFORM}@ \
 		-e  s@${LOWER_VENDOR}@\$${LOWER_VENDOR}@ 		\
 		-e  s@${LOWER_OPSYS}@\$${LOWER_OPSYS}@ 			\
-		-e  s@${PKGNAME}@\$${PKGNAME}@ 
+		-e  s@${PKGNAME}@\$${PKGNAME}@ 				\
+	 | ${GREP} -v emul/linux/proc
 .endif # target(print-PLIST)
 
 
Index: share/man/man7/packages.7
===================================================================
RCS file: /cvsroot/sharesrc/share/man/man7/packages.7,v
retrieving revision 1.54
diff -u -r1.54 packages.7
--- share/man/man7/packages.7	2001/08/14 06:00:15	1.54
+++ share/man/man7/packages.7	2001/08/20 02:32:24
@@ -4,7 +4,7 @@
 .\"
 .\"	This file is in the public domain.
 .\"
-.Dd May 3, 2001
+.Dd Aug 20, 2001
 .Dt PACKAGES 7
 .Os
 .Sh NAME
@@ -98,6 +98,9 @@
 GLX (hardware-accelerated) version of the Mesa library.
 .It BINPKG_SITES
 List of sites carrying binary pkgs. Variables
+.It LOCALPATCHES
+Directory for local patches that aren't part of pkgsrc. See
+pkgsrc/Packages.txt for more information.
 .Dq rel
 and
 .Dq arch

-- 
Want to get a clue on IPv6 but don't know where to start? Try this:
* Basics -> http://www.onlamp.com/pub/a/onlamp/2001/05/24/ipv6_tutorial.html
* Setup  -> http://www.onlamp.com/pub/a/onlamp/2001/06/01/ipv6_tutorial.html 
Of course with your #1 IPv6 ready operating system -> http://www.NetBSD.org/