In message <20081213105545.ga40...@titania.njm.me.uk>,
        N.J. Mann (n...@njm.me.uk) wrote:
> In message <20081212102516.gb7...@hades.panopticon>,
>       Dmitry Marakasov (amd...@amdmi3.ru) wrote:
> > * N.J. Mann (n...@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.
-- 

_______________________________________________
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"

Reply via email to