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

Hi,

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 
("patch-af").

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 
characters:

./wip/gcc-3.4-ada/patches/patch-function_c
./wip/gcc-3.4/patches/patch-function_c
./wip/gtkada/patches/patch-create_layout
./devel/gdb6/patches/patch-corelow_c
./devel/gdb6/patches/patch-tui_interp_c
./devel/gdb6/patches/patch-Makefile_tpl
./devel/gdb6/patches/patch-mi_mi_cmd_file_c
./devel/gdb6/patches/patch-mi_mi_cmd_disas_c
./devel/gdb6/patches/patch-i386_nm_nbsd_h
./devel/gdb6/patches/patch-config_xm_nbsd_h
./devel/gdb6/patches/patch-mi_mi_out_c
./devel/gdb6/patches/patch-readline_rltty_c
./devel/gdb6/patches/patch-ax_gdb_c
./devel/gdb6/patches/patch-inftarg_c
./devel/gdb6/patches/patch-mi_mi_main_c
./devel/gdb6/patches/patch-i386_nbsdelf_mh
./devel/gdb6/patches/patch-mi_mi_cmd_stack_c
./devel/gdb6/patches/patch-nm_nbsd_h
./devel/gdb6/patches/patch-i387_tdep_c
./devel/gdb6/patches/patch-i386nbsd_tdep_c
./devel/gdb6/patches/patch-gdb_configure_in
./devel/gdb6/patches/patch-cli_cli_setshow_c
./devel/gdb6/patches/patch-mi_mi_interp_c
./devel/gdb6/patches/patch-ser_pipe_c
./devel/gdb6/patches/patch-mi_mi_cmd_env_c
./devel/gdb6/patches/patch-i386bsd_nat_c
./devel/gdb6/patches/patch-cli_cli_dump_c
./devel/gdb6/patches/patch-cli_cli_script_c
./devel/gdb6/patches/patch-remote_fileio_c
./devel/gdb6/patches/patch-remote_c
./devel/gdb6/patches/patch-cli_cmds_c
./devel/gdb6/patches/patch-cli_cli_decode_c
./devel/gdb6/patches/patch-mi_mi_cmd_break_c
./devel/gdb6/patches/patch-mi_mi_getopt_c
./devel/gdbada/patches/patch-gdb_defs

Roland

--------------020708020803080801090303
Content-Type: text/plain;
 name="bsd.pkg.make-patches.mk"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="bsd.pkg.make-patches.mk"

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

.if !defined(_BSD_PKG_MAKE_PATCHES_MK)
_BSD_PKG_MAKE_PATCHES_MK=	# defined

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

make-patches: do-make-patches makepatchsum

do-make-patches:
	@${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};							\
	fi

.endif

--------------020708020803080801090303--