Subject: pkg/7989: bsd.pkg.mk: cleanup of README.html generation code
To: None <gnats-bugs@gnats.netbsd.org>
From: Jaromir Dolecek <dolecek@ics.muni.cz>
List: netbsd-bugs
Date: 07/14/1999 12:32:55
>Number:         7989
>Category:       pkg
>Synopsis:       bsd.pkg.mk: cleanup of README.html generation code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager (NetBSD software packages system bug manager)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 14 12:05:01 1999
>Last-Modified:
>Originator:     Jaromir Dolecek
>Organization:
	ICS MU, Brno, Czech Republic
>Release:        NetBSD-1.4D
>Environment:
	
System: NetBSD jdolecek.per4mance.cz 1.4D NetBSD 1.4D (JDOLECEK) #3: Wed Jul 7 15:21:47 MEST 1999 dolecek@jdolecek.per4mance.cz:/usr/src/sys/arch/i386/compile/JDOLECEK i386


>Description:
	While supping from sup.de.netbsd.org, I noticed that README.html's
	are always all changed every night. I'd though it's problem
	with bsd.pkg.mk accidentaly creating/touching the files
	for every run of `make readme'. I found bsd.pkg.mk is OK
	with regard to this (the file is just moved around a bit, but
	otherwise not touched if not changed). Anyway, the code
	for readme, cdrom-readme & README.html targets can be cleaned-up
	a bit to make the function more clear.
>How-To-Repeat:
>Fix:
	With the patch, README.html is not moved at all, just the
	new version is generated and the files are compared.
	It saves two ${MV}'s in typical case and ${MV} & ${RM}
	when the new README.html is different from the old one.
	Not that it would make any big differense in speed, but
	it simplifies the logic somewhat :)

--- bsd.pkg.mk.orig	Wed Jul 14 19:56:25 1999
+++ bsd.pkg.mk	Wed Jul 14 20:42:41 1999
@@ -2035,7 +2035,6 @@ FTP_PKG_URL_HOST?=	ftp://ftp.netbsd.org
 FTP_PKG_URL_DIR?=	/pub/NetBSD/packages
 
 readme:
-	@if [ -f README.html ]; then ${MV} -f README.html README.html.BAK ; fi
 	@cd ${.CURDIR} && ${MAKE} README.html PKG_URL=${FTP_PKG_URL_HOST}${FTP_PKG_URL_DIR}
 .endif
 
@@ -2046,7 +2045,6 @@ CDROM_PKG_URL_HOST?=	file://localhost
 CDROM_PKG_URL_DIR?=	/usr/pkgsrc/packages
 
 cdrom-readme:
-	@if [ -f README.html ]; then ${MV} -f README.html README.html.BAK ; fi
 	@cd ${.CURDIR} && ${MAKE} README.html PKG_URL=${CDROM_PKG_URL_HOST}${CDROM_PKG_URL_DIR}
 .endif
 
@@ -2072,6 +2070,7 @@ SED_HOMEPAGE_EXPR=       -e 's|%%HOMEPAG
 SED_HOMEPAGE_EXPR=       -e 's|%%HOMEPAGE%%||'
 .endif
 
+.PHONY: README.html
 README.html:
 	@${MAKE} depends-list PACKAGE_NAME_TYPE=html | sort -u >> $@.tmp1
 	@[ -s $@.tmp1 ] || ${ECHO} "<I>(none)</I>" >> $@.tmp1
@@ -2094,15 +2093,11 @@ README.html:
 		-e '/%%BIN_PKGS%%/r$@.tmp4'				\
 		-e '/%%BIN_PKGS%%/d'					\
 		${README_NAME} >> $@.tmp
-	@if cmp -s $@.tmp $@.BAK; then					\
-		${MV} $@.BAK $@;					\
-		${RM} $@.tmp;						\
-	else								\
+	@if ! cmp -s $@.tmp $@; then					\
 		${ECHO_MSG} "===>  Creating README.html for ${_THISDIR_}${PKGNAME}"; \
-		${MV} $@.tmp $@;					\
-		${RM} -f $@.BAK;					\
+		${MV} -f $@.tmp $@;					\
 	fi
-	@${RM} -f $@.tmp1 $@.tmp2 $@.tmp3 $@.tmp4 $@.tmp5
+	@${RM} -f $@.tmp $@.tmp1 $@.tmp2 $@.tmp3 $@.tmp4 $@.tmp5
 
 .if !target(show-pkgtools-version)
 show-pkgtools-version:
>Audit-Trail:
>Unformatted: