From owner-freebsd-ports@FreeBSD.ORG Sat Dec 13 12:05:25 2008 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF28F1065672 for ; Sat, 13 Dec 2008 12:05:24 +0000 (UTC) (envelope-from njm@njm.me.uk) Received: from smtp004.apm-internet.net (smtp004.apm-internet.net [85.119.248.54]) by mx1.freebsd.org (Postfix) with SMTP id 5006B8FC17 for ; Sat, 13 Dec 2008 12:05:24 +0000 (UTC) (envelope-from njm@njm.me.uk) Received: (qmail 72868 invoked from network); 13 Dec 2008 12:05:23 -0000 Received: from unknown (HELO titania.njm.me.uk) (86.129.204.56) by smtp004.apm-internet.net with SMTP; 13 Dec 2008 12:05:23 -0000 Received: from titania.njm.me.uk (localhost [127.0.0.1]) by titania.njm.me.uk (8.14.3/8.14.3) with ESMTP id mBDC5MtD074977; Sat, 13 Dec 2008 12:05:22 GMT (envelope-from njm@njm.me.uk) Received: (from njm@localhost) by titania.njm.me.uk (8.14.3/8.14.3/Submit) id mBDC5M9h074976; Sat, 13 Dec 2008 12:05:22 GMT (envelope-from njm@njm.me.uk) Date: Sat, 13 Dec 2008 12:05:22 +0000 From: "N.J. Mann" To: Dmitry Marakasov , freebsd-ports@freebsd.org Message-ID: <20081213120522.GB40560@titania.njm.me.uk> Mail-Followup-To: Dmitry Marakasov , freebsd-ports@freebsd.org References: <20081202201610.GA8753@atarininja.org> <20081203131234.GD70240@hades.panopticon> <20081211215712.GA72408@titania.njm.me.uk> <20081212102516.GB7422@hades.panopticon> <20081213105545.GA40560@titania.njm.me.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081213105545.GA40560@titania.njm.me.uk> X-Operating-System: FreeBSD 7.1-PRERELEASE User-Agent: Mutt/1.5.18cvs (2008-07-02) Cc: Subject: Re: Proposal: mechanism for local patches X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Dec 2008 12:05:25 -0000 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. --