Subject: pkg/18560: better pkgsrc work directory consistency checking
To: None <gnats-bugs@gnats.netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 10/06/2002 20:12:26
>Number:         18560
>Category:       pkg
>Synopsis:       better pkgsrc work directory consistency checking
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 06 17:13:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Greg A. Woods
>Release:        pkgsrc-current 2002/10/05
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
System: NetBSD 1.5W
>Description:

	This patch implements a better test to verify the consistency of
	any work directory in a pkgsrc module.  I've been using this for
	quite a few months now and it's helped me several times....

>How-To-Repeat:

>Fix:

	line numbers are off as this is just one hunk of my local diffs,
	but otherwise it should apply as I edited out the two un-related
	changes to the same lines and manual application should be
	pretty obvious too.  I'm pretty sure it's self contained.

Index: bsd.pkg.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1063
diff -c -r1.1063 bsd.pkg.mk
*** bsd.pkg.mk	4 Oct 2002 11:19:26 -0000	1.1063
--- bsd.pkg.mk	6 Oct 2002 21:25:48 -0000
***************
*** 2671,2697 ****
  build-cookie:
  	${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
  
! .ORDER: pre-fetch do-fetch post-fetch
! .ORDER: extract-message install-depends pre-extract do-extract post-extract extract-cookie
! .ORDER: patch-message pre-patch do-patch post-patch patch-cookie
! .ORDER: buildlink-message pre-buildlink do-buildlink post-buildlink buildlink-cookie
! .ORDER: configure-message pre-configure do-configure post-configure configure-cookie
! .ORDER: build-message pre-build do-build post-build build-cookie
  
  # Please note that the order of the following targets is important, and
  # should not be modified (.ORDER is not recognised by make(1) in a serial
  # make i.e. without -j n)
! real-fetch: pre-fetch do-fetch post-fetch
! real-extract: extract-message install-depends pre-extract do-extract post-extract extract-cookie
! real-patch: patch-message pre-patch do-patch post-patch patch-cookie
! real-buildlink: buildlink-message pre-buildlink do-buildlink post-buildlink buildlink-cookie
! real-configure: configure-message pre-configure do-configure post-configure configure-cookie
! real-build: build-message pre-build do-build post-build build-cookie
! real-install: do-su-install
  real-package: do-su-package
  real-replace: do-su-replace
  real-undo-replace: do-su-undo-replace
  
  _SU_TARGET=								\
  	if [ `${ID} -u` = 0 ]; then					\
  		${MAKE} ${MAKEFLAGS} $$realtarget;			\
--- 2822,2864 ----
  build-cookie:
  	${_PKG_SILENT}${_PKG_DEBUG} ${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
  
! .ORDER: pre-fetch do-fetch post-fetch check-extract
! .ORDER: check-extract extract-message install-depends pre-extract do-extract post-extract extract-cookie
! .ORDER: check-extract patch-message pre-patch do-patch post-patch patch-cookie
! .ORDER: check-extract buildlink-message pre-buildlink do-buildlink post-buildlink buildlink-cookie
! .ORDER: check-extract configure-message pre-configure do-configure post-configure configure-cookie
! .ORDER: check-extract build-message pre-build do-build post-build build-cookie
  
  # Please note that the order of the following targets is important, and
  # should not be modified (.ORDER is not recognised by make(1) in a serial
  # make i.e. without -j n)
! real-fetch: pre-fetch do-fetch post-fetch check-extract
! real-extract: check-extract extract-message install-depends pre-extract do-extract post-extract extract-cookie
! real-patch: check-extract patch-message pre-patch do-patch post-patch patch-cookie
! real-buildlink: check-extract buildlink-message pre-buildlink do-buildlink post-buildlink buildlink-cookie
! real-configure: check-extract configure-message pre-configure do-configure post-configure configure-cookie
! real-build: check-extract build-message pre-build do-build post-build build-cookie
! real-install: check-extract do-su-install
  real-package: do-su-package
  real-replace: do-su-replace
  real-undo-replace: do-su-undo-replace
  
+ check-extract:
+ 	${_PKG_SILENT}${_PKG_DEBUG}					\
+ 	extractname=$$(if [ -r ${EXTRACT_COOKIE} ]; then ${CAT} ${EXTRACT_COOKIE}; else echo "_CHECK_EXTRACT_COOKIE"; fi;); \
+ 	case "$$extractname" in						\
+ 	"")	${ECHO_MSG} "*** Warning: ${WRKDIR} may contain an older version of ${PKGBASE}"; \
+ 		${FALSE};						\
+ 		;;							\
+ 	"_CHECK_EXTRACT_COOKIE"|"${PKGNAME}")				\
+ 		: ${DO_NADA} all is well;				\
+ 		;;							\
+ 	*)	${ECHO_MSG} "*** Warning: Package version $$extractname in ${WRKDIR}"; \
+ 		${ECHO_MSG} "*** Current version ${PKGNAME} in pkgsrc directory"; \
+ 		${FALSE};						\
+ 		;;							\
+ 	esac
+ 
  _SU_TARGET=								\
  	if [ `${ID} -u` = 0 ]; then					\
  		${MAKE} ${MAKEFLAGS} $$realtarget;			\
>Release-Note:
>Audit-Trail:
>Unformatted: