Subject: [change request] pattern for patch filenames
To: None <>
From: Roland Illig <>
List: tech-pkg
Date: 06/28/2004 18:01:51
This is a multi-part message in MIME format.
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


I would like the pattern for patch filenames to be changed. In general 
it is the shell pattern "patch-*", but there are two occurrences of the 
AWK pattern "patch-[A-Za-z0-9]+". I would like to have the underscore 
("_") included in the allowed letters.

With this change we could name the patch files after the files they 
patch ("patch-src_inode_c"), not with some arbitrarily chosen number 

And -- best of all -- I have invented the "make-patches" target, so you 
can simply say "bmake make-patches", and all the patches in ${PATCHDIR} 
are regenerated from what you changed in the working directory. It uses 
the naming scheme of the second paragraph. As a consequence, it would be 
immediately clear which patch belongs to which file just by looking into 
the patches directory.

There are some files that would be affected by the change of allowed 



Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

# $NetBSD$
# Automatically creates patches for file modified in the working
# directory.
# Authors:
#    Roland Illig <>, 2004.

.if !defined(_BSD_PKG_MAKE_PATCHES_MK)

# This program should be a diff that understands the -u option.
DIFF?=				diff

make-patches: do-make-patches makepatchsum

	@${ECHO} "===> Updating patch files"
	@if ${TEST} -f ${PATCH_COOKIE}; then				\
	if ${TEST} ! -d ${PATCHDIR}; then				\
	  ${ECHO} "=> Creating patches directory.";			\
	  ${MKDIR} ${PATCHDIR};						\
	fi;								\
	cd ${WRKSRC} &&							\
	${FIND} . -type f -name '*.orig' -print				\
	| sort								\
	| while read origname; do					\
	  dirname=`${DIRNAME} $$origname`;				\
	  fname="$$dirname"/`${BASENAME} $$origname .orig`;		\
	  patchid=`${ECHO} $$fname | ${SED} -e 's,^./,,' -e 's,[^A-Za-z0-9],_,g'` \
	  patchbasename="patch-$$patchid";				\
	  patchname="${PATCHDIR}/$$patchbasename";			\
	  { ${ECHO} "\$$""NetBSD""\$$";					\
	    ${ECHO};							\
	    ${DIFF} -u $$origname $$fname && ret=$$? || ret=$$?;	\
	  } > $$patchname.tmp;						\
	  case $$ret in							\
	    0) ${ECHO} "=> no patch necessary for $$fname";		\
	       ${RM} -f $$patchname $$patchname.tmp;;			\
	    1) if ${CMP} -s $$patchname.tmp $$patchname; then		\
	         ${MV} $$patchname.tmp $$patchname;			\
	         ${ECHO} "=> updating patch for $$fname.";		\
	       else							\
	         ${RM} -f $$patchname.tmp;				\
	         ${ECHO} "=> patch for $$fname has not changed.";	\
	       fi;;							\
	    *) ${FALSE};;						\
	  esac;								\
	done								\
	else								\
	  ${ECHO} "Please do a \"${MAKE} patch\" first.";		\
	  ${FALSE};							\