Subject: Re: change to makepatchsum
To: Simon Burge <simonb@netbsd.org>
From: Frederick Bruckman <fb@enteract.com>
List: tech-pkg
Date: 10/06/1999 06:42:46
I've changed the test for no patch-* files back to the idiomatic way.
Here's the corrected version.

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.352
diff -c -r1.352 bsd.pkg.mk
*** bsd.pkg.mk	1999/10/05 22:18:05	1.352
--- bsd.pkg.mk	1999/10/06 11:41:34
***************
*** 1808,1832 ****
  
  .if !target(makepatchsum)
  makepatchsum:
! 	${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${FILESDIR}
! 	${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PATCH_SUM_FILE}
! 	${_PKG_SILENT}(${_PKG_DEBUG}					\
  	if [ -d ${PATCHDIR} ]; then					\
  		cd ${PATCHDIR};						\
- 		${ECHO} -n "$$" > ${PATCH_SUM_FILE};			\
- 		${ECHO} -n "NetBSD" >> ${PATCH_SUM_FILE}; 		\
- 		${ECHO} "$$" >> ${PATCH_SUM_FILE};			\
- 		${ECHO} "" >> ${PATCH_SUM_FILE};			\
  		for sumfile in "" patch-*; do				\
  			if [ "X$$sumfile" = X"" ]; then continue; fi;	\
  			case $$sumfile in				\
  			patch-local-*) ;;				\
  			*.orig) continue ;;				\
  			*)						\
! 				${ECHO} "MD5 ($$sumfile) = `${SED} -e '/\$$NetBSD.*/d' $$sumfile | ${MD5}`" >> ${PATCH_SUM_FILE}; \
  			esac;						\
  		done;							\
! 	fi)
  .endif
  
  .if !target(checksum)
--- 1808,1845 ----
  
  .if !target(makepatchsum)
  makepatchsum:
! 	${_PKG_SILENT}${_PKG_DEBUG}					\
! 	(${MKDIR} ${FILESDIR};						\
! 	${ECHO} -n "$$" > ${PATCH_SUM_FILE}.new;			\
! 	${ECHO} -n "NetBSD" >> ${PATCH_SUM_FILE}.new;			\
! 	${ECHO} "$$" >> ${PATCH_SUM_FILE}.new;				\
! 	${ECHO} "" >> ${PATCH_SUM_FILE}.new;				\
  	if [ -d ${PATCHDIR} ]; then					\
  		cd ${PATCHDIR};						\
  		for sumfile in "" patch-*; do				\
  			if [ "X$$sumfile" = X"" ]; then continue; fi;	\
  			case $$sumfile in				\
  			patch-local-*) ;;				\
  			*.orig) continue ;;				\
  			*)						\
! 				${ECHO} "MD5 ($$sumfile) = `${SED} -e '/\$$NetBSD.*/d' $$sumfile | ${MD5}`" >> ${PATCH_SUM_FILE}.new; \
  			esac;						\
  		done;							\
! 	fi;								\
! 	if [ `${AWK} -- '{nlines++} END {print nlines}' < ${PATCH_SUM_FILE}.new` = 2 ]; then \
! 		${ECHO} "This placeholder file is generated by the \`\`makepatchsum'' target" >> ${PATCH_SUM_FILE}.new; \
! 		${ECHO} "whenever the patches directory is empty or missing. Its purpose" >> ${PATCH_SUM_FILE}.new; \
! 		${ECHO} "is to ensure that the presence of any obsolete patches will cause" >> ${PATCH_SUM_FILE}.new; \
! 		${ECHO} "the proper error to be emitted at build time." >> ${PATCH_SUM_FILE}.new; \
! 	fi;								\
! 	if [ -f "${PATCH_SUM_FILE}" ]; then				\
! 		tail +2 ${PATCH_SUM_FILE} > .patchsumold;		\
! 		tail +2 ${PATCH_SUM_FILE}.new > .patchsumnew;		\
! 	fi;								\
! 	((cmp -s .patchsumold .patchsumnew && 				\
! 		${ECHO_MSG} patch-sum file unchanged\!) ||		\
! 		${MV} ${PATCH_SUM_FILE}.new ${PATCH_SUM_FILE});		\
! 	rm -f .patchsumold .patchsumnew ${PATCH_SUM_FILE}.new)
  .endif
  
  .if !target(checksum)