Generating patch files

Karel Miklav karel at lovetemple.net
Wed Jun 20 03:32:46 UTC 2007


Steffen Beyer wrote:
> Currently, there are several files to patch. Usually I would run "diff
> -r" to create one large patch, but the build system -- and the rules ,)
> -- expect a separate diff for each file to be patched.
> 
> Is there an easy way to create this set of files, i.e. cutting the patch
> into pieces and naming the files accordingly? I looked through the
> handbook and various tools, but couldn't find the right one.

Maybe you could use 'make makepatch':

lama> grep makepatch /usr/ports/Mk/bsd.port.mk -B4 -A12 | sed 's/ /  /g'

# Look for ${WRKSRC}/.../*.orig files, and (re-)create
# ${FILEDIR}/patch-* files from them.

.if !target(makepatch)
makepatch:
   @cd ${.CURDIR} && ${MKDIR} ${FILESDIR}
   @(cd ${WRKSRC}; \
     for i in `find . -type f -name '*.orig'`; do \
       ORG=$$i; \
       NEW=$${i%.orig}; \
       OUT=${FILESDIR}`${ECHO} $${NEW} | \
         ${SED} -e 's|/|__|g' \
           -e 's|^\.__|/patch-|'`; \
       ${ECHO} ${DIFF} -ud $${ORG} $${NEW} '>' $${OUT}; \
       ${DIFF} -ud $${ORG} $${NEW} > $${OUT} || ${TRUE}; \
     done \
   )



More information about the freebsd-ports mailing list