Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Dec 2008 12:05:22 +0000
From:      "N.J. Mann" <njm@njm.me.uk>
To:        Dmitry Marakasov <amdmi3@amdmi3.ru>, freebsd-ports@freebsd.org
Subject:   Re: Proposal: mechanism for local patches
Message-ID:  <20081213120522.GB40560@titania.njm.me.uk>
In-Reply-To: <20081213105545.GA40560@titania.njm.me.uk>
References:  <20081202201610.GA8753@atarininja.org> <gh4d33$a55$1@hairball.ziemba.us> <20081203131234.GD70240@hades.panopticon> <20081211215712.GA72408@titania.njm.me.uk> <20081212102516.GB7422@hades.panopticon> <20081213105545.GA40560@titania.njm.me.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20081213105545.GA40560@titania.njm.me.uk>,
	N.J. Mann (njm@njm.me.uk) wrote:
> In message <20081212102516.GB7422@hades.panopticon>,
> 	Dmitry Marakasov (amdmi3@amdmi3.ru) wrote:
> > * N.J. Mann (njm@njm.me.uk) wrote:
> > 
> > > > I suppose that check was done to help to detect patching failures, so it
> > > > may be removed.
> > > 
> > > I've just been trying out your patch and I think from an organisational
> > > point of view it is very good.  What I mean by this is that with the
> > > patch I am now able to keep my local patches completely separate from
> > > the official, FreeBSD patches.  No more backing up the whole of
> > > /usr/ports just in case I have a private patch in there somewhere.  Now
> > > I just need to backup /usr/ports.localpatchdir (which is what I called
> > > the directory LOCAPATCHDIR points to).
> > 
> > Nice to hear that it's useful :)
> 
> I found that it was not quite enough.  For one port I am developing
> local patches for I found I either needed to modify the ports' FreeBSD
> Makefile or add a post-extract script.  Since I no longer want to have
> locally modified files in /usr/ports I needed to have a local
> post-extract script.  So, I have modified your change to support both
> patch files and script files.

I spoke too soon. :-(

I found I needed LOCALPATCHDIR and LOCALSCRIPTDIR in the environment
passed to the my script and so had to change my patch.  

%%%%%

--- bsd.port.mk.orig
+++ bsd.port.mk
@@ -591,6 +591,13 @@
 #				  Default: ${MASTERDIR}/files
 # PKGDIR		- A directory containing any package creation files.
 #				  Default: ${MASTERDIR}
+# LOCALDIRPREFIX
+#				- Root of local patches and scripts tree.
+# LOCALPATCHDIR	- An optional directory for storing local patches.
+#				  Default: ${LOCALDIRPREFIX}/${CATEGORY}/${PORT}/files
+# LOCALSCRIPTDIR
+#				- An optional directory for storing local scripts.
+#				  Default: ${LOCALDIRPREFIX}/${CATEGORY}/${PORT}/scripts
 #
 # Variables that serve as convenient "aliases" for your *-install targets.
 # Use these like: "${INSTALL_PROGRAM} ${WRKSRC}/prog ${PREFIX}/bin".
@@ -1371,6 +1378,11 @@
 SCRIPTDIR?=		${MASTERDIR}/scripts
 PKGDIR?=		${MASTERDIR}
 
+.if defined(LOCALDIRPREFIX)
+LOCALPATCHDIR?=		${LOCALDIRPREFIX}/${.CURDIR:C/^.*\/([^\/]+\/[^\/]+)$/\\1/}/files
+LOCALSCRIPTDIR?=	${LOCALDIRPREFIX}/${.CURDIR:C/^.*\/([^\/]+\/[^\/]+)$/\\1/}/scripts
+.endif
+
 .if defined(USE_IMAKE) && !defined(USE_X_PREFIX)
 USE_X_PREFIX=	yes
 .endif
@@ -2887,6 +2899,14 @@
 SCRIPTS_ENV+=	BATCH=yes
 .endif
 
+.if defined(LOCALPATCHDIR)
+SCRIPTS_ENV+=	LOCALPATCHDIR=${LOCALPATCHDIR}
+.endif
+
+.if defined(LOCALSCRIPTDIR)
+SCRIPTS_ENV+=	LOCALSCRIPTDIR=${LOCALSCRIPTDIR}
+.endif
+
 .if ${PREFIX} == /usr
 MANPREFIX?=	/usr/share
 .else
@@ -3604,6 +3624,35 @@
 			done; \
 		fi; \
 	fi
+.if defined(LOCALPATCHDIR)
+	@if [ -d ${LOCALPATCHDIR} ]; then \
+		if [ "`${ECHO_CMD} ${LOCALPATCHDIR}/patch-*`" != "${LOCALPATCHDIR}/patch-*" ]; then \
+			${ECHO_MSG} "===>  Applying local patches for ${PKGNAME}" ; \
+			PATCHES_APPLIED="" ; \
+			for i in ${LOCALPATCHDIR}/patch-*; do \
+				case $$i in \
+					*.orig|*.rej|*~|*,v) \
+						${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
+						;; \
+					*) \
+						if [ ${PATCH_DEBUG_TMP} = yes ]; then \
+							${ECHO_MSG} "===>   Applying local patch $$i" ; \
+						fi; \
+						if ${PATCH} ${PATCH_ARGS} < $$i ; then \
+							PATCHES_APPLIED="$$PATCHES_APPLIED $$i" ; \
+						else \
+							${ECHO_MSG} `${ECHO_CMD} "=> Local patch $$i failed to apply cleanly." | ${SED} "s|${LOCALPATCHDIR}/||"` ; \
+							if [ x"$$PATCHES_APPLIED" != x"" ]; then \
+								${ECHO_MSG} `${ECHO_CMD} "=> Local patch(es) $$PATCHES_APPLIED applied cleanly." | ${SED} "s|${LOCALPATCHDIR}/||g"` ; \
+							fi; \
+							${FALSE} ; \
+						fi; \
+						;; \
+				esac; \
+			done; \
+		fi; \
+	fi
+.endif
 .endif
 
 .if !target(run-autotools)
@@ -4248,6 +4297,12 @@
 		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
 			${SCRIPTDIR}/${.TARGET:S/-script$//}; \
 	fi
+.if defined(LOCALSCRIPTDIR)
+	@if [ -f ${LOCALSCRIPTDIR}/${.TARGET:S/-script$//} ]; then \
+		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
+			${LOCALSCRIPTDIR}/${.TARGET:S/-script$//}; \
+	fi
+.endif
 .endif
 
 .endfor

%%%%%


Cheers,
       Nick.
-- 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081213120522.GB40560>