pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk Drop the use of _ACQUIRE_LOCK and _RELEASE_LOCK and...
details: https://anonhg.NetBSD.org/pkgsrc/rev/79322738704b
branches: trunk
changeset: 513810:79322738704b
user: jlam <jlam%pkgsrc.org@localhost>
date: Sun Jun 04 04:31:47 2006 +0000
description:
Drop the use of _ACQUIRE_LOCK and _RELEASE_LOCK and replace with
acquire-lock and release-lock macro targets. Take advantage of using
a make target by breaking up the _ACQUIRE_LOCK script into smaller
pieces, and make better use of the *_MSG definitions for printing
messages within the acquire-lock and release-lock targets.
diffstat:
mk/bsd.pkg.extract.mk | 8 +-
mk/bsd.pkg.mk | 125 ++++++++++++++++++---------------------
mk/bsd.pkg.patch.mk | 8 +-
mk/pkginstall/bsd.pkginstall.mk | 8 +-
4 files changed, 68 insertions(+), 81 deletions(-)
diffs (223 lines):
diff -r 2d69b670b3e1 -r 79322738704b mk/bsd.pkg.extract.mk
--- a/mk/bsd.pkg.extract.mk Sun Jun 04 00:39:05 2006 +0000
+++ b/mk/bsd.pkg.extract.mk Sun Jun 04 04:31:47 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.extract.mk,v 1.23 2006/06/03 23:11:42 jlam Exp $
+# $NetBSD: bsd.pkg.extract.mk,v 1.24 2006/06/04 04:31:47 jlam Exp $
#
# This Makefile fragment is included to bsd.pkg.mk and defines the
# relevant variables and targets for the "extract" phase.
@@ -176,10 +176,8 @@
extract: ${_EXTRACT_TARGETS}
.PHONY: acquire-extract-lock release-extract-lock
-acquire-extract-lock:
- ${_ACQUIRE_LOCK}
-release-extract-lock:
- ${_RELEASE_LOCK}
+acquire-extract-lock: acquire-lock
+release-extract-lock: release-lock
${_EXTRACT_COOKIE}:
.if !empty(INTERACTIVE_STAGE:Mextract) && defined(BATCH)
diff -r 2d69b670b3e1 -r 79322738704b mk/bsd.pkg.mk
--- a/mk/bsd.pkg.mk Sun Jun 04 00:39:05 2006 +0000
+++ b/mk/bsd.pkg.mk Sun Jun 04 04:31:47 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1828 2006/06/04 00:39:05 jlam Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1829 2006/06/04 04:31:47 jlam Exp $
#
# This file is in the public domain.
#
@@ -1134,63 +1134,64 @@
# Extract
-# pkgsrc coarse-grained locking definitions and targets
-acquire-lock: .USE
- ${_ACQUIRE_LOCK}
-release-lock: .USE
- ${_RELEASE_LOCK}
-
-.if ${PKGSRC_LOCKTYPE} == "none"
-_ACQUIRE_LOCK= @${DO_NADA}
-_RELEASE_LOCK= @${DO_NADA}
-.else
+# acquire-lock, release-lock are .USE macro targets for acquiring and
+# release coarse-grained locks.
+#
LOCKFILE= ${WRKDIR}/.lockfile
-_ACQUIRE_LOCK= \
- ${_PKG_SILENT}${_PKG_DEBUG} \
- SHLOCK=${SHLOCK:Q}; \
- if ${TEST} ! -f "$$SHLOCK" || ${TEST} ! -x "$$SHLOCK"; then \
- { ${ECHO} "The \"$$SHLOCK\" utility does not exist, and is necessary for locking."; \
- ${ECHO} "Please \""${MAKE:Q}" install\" in ../../pkgtools/shlock."; \
- } 1>&2; \
- ${FALSE}; \
+acquire-lock: .USE
+.if ${PKGSRC_LOCKTYPE} == "none"
+ @${DO_NADA}
+.else
+ @if ${TEST} ! -x ${SHLOCK:Q}""; then \
+ ${ERROR_MSG} "The ${SHLOCK:Q} utility does not exist, and is necessary for locking."; \
+ ${ERROR_MSG} "Please \""${MAKE:Q}" install\" in ../../pkgtools/shlock."; \
+ exit 1; \
+ fi
+. if !defined(OBJHOSTNAME)
+ @${ERROR_MSG} "PKGSRC_LOCKTYPE needs OBJHOSTNAME defined."; \
+ exit 1
+. endif
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ ppid=`${PS} -p $$$$ -o ppid | ${AWK} 'NR == 2 { print $$1 }'`; \
+ if ${TEST} -z "$$ppid"; then \
+ ${ERROR_MSG} "No parent process ID found."; \
+ exit 1; \
fi; \
- if ${TEST} x${OBJHOSTNAME:Ddefined} != x"defined"; then \
- ${ECHO} "PKGSRC_LOCKTYPE needs OBJHOSTNAME defined." 1>&2; \
- ${FALSE}; \
- fi; \
- ppid=`${PS} -p $$$$ -o ppid | ${AWK} 'NR == 2 { print $$1 }'`; \
- if ${TEST} "$$ppid" = ""; then \
- ${ECHO} "No parent process ID found."; \
- ${FALSE}; \
- fi; \
- while true; do \
- : "Remove lock files older than the last reboot"; \
+ while ${TRUE}; do \
if ${TEST} -f /var/run/dmesg.boot -a -f ${LOCKFILE}; then \
rebooted=`${FIND} /var/run/dmesg.boot -newer ${LOCKFILE} -print`; \
- if ${TEST} x"$$rebooted" != x; then \
- ${ECHO} "=> Removing stale ${LOCKFILE}"; \
- ${RM} ${LOCKFILE}; \
+ if ${TEST} -n "$$rebooted"; then \
+ ${STEP_MSG} "Removing stale ${LOCKFILE}"; \
+ ${RM} -f ${LOCKFILE}; \
fi; \
fi; \
- ${SHLOCK} -f ${LOCKFILE} -p $$ppid && break; \
- ${ECHO} "=> Lock is held by pid `cat ${LOCKFILE}`"; \
- case "${PKGSRC_LOCKTYPE}" in \
- once) exit 1 ;; \
- sleep) ${SLEEP} ${PKGSRC_SLEEPSECS} ;; \
- esac \
- done; \
- if [ "${PKG_VERBOSE}" != "" ]; then \
- ${ECHO_MSG} "=> Lock acquired on behalf of process $$ppid"; \
- fi
+ if ${SHLOCK} -f ${LOCKFILE} -p $$ppid; then \
+ break; \
+ fi; \
+ case ${PKGSRC_LOCKTYPE:Q}"" in \
+ once) ${ERROR_MSG} "Lock is held by pid `${CAT} ${LOCKFILE}`"; \
+ exit 1; \
+ ;; \
+ sleep) ${STEP_MSG} "Lock is held by pid `${CAT} ${LOCKFILE}`"; \
+ ${SLEEP} ${PKGSRC_SLEEPSECS}; \
+ ;; \
+ esac; \
+ done
+. if defined(PKG_VERBOSE)
+ @${STEP_MSG} "Lock acquired for ${.TARGET:S/^acquire-//:S/-lock$//} on behalf of process `${CAT} ${LOCKFILE}`"
+. endif
+.endif
-_RELEASE_LOCK= \
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ "${PKG_VERBOSE}" != "" ]; then \
- ${ECHO_MSG} "=> Lock released on behalf of process `${CAT} ${LOCKFILE}`"; \
- fi; \
- ${RM} ${LOCKFILE}
-.endif # PKGSRC_LOCKTYPE
+release-lock: .USE
+.if ${PKGSRC_LOCKTYPE} == "none"
+ @${DO_NADA}
+.else
+. if defined(PKG_VERBOSE)
+ @${STEP_MSG} "Lock released for ${.TARGET:S/^release-//:S/-lock$//} on behalf of process `${CAT} ${LOCKFILE}`"
+. endif
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${LOCKFILE}
+.endif
${WRKDIR}:
.if !defined(KEEP_WRKDIR)
@@ -1525,25 +1526,17 @@
.PHONY: acquire-tools-lock
.PHONY: acquire-wrapper-lock acquire-configure-lock acquire-build-lock
-acquire-tools-lock:
- ${_ACQUIRE_LOCK}
-acquire-wrapper-lock:
- ${_ACQUIRE_LOCK}
-acquire-configure-lock:
- ${_ACQUIRE_LOCK}
-acquire-build-lock:
- ${_ACQUIRE_LOCK}
+acquire-tools-lock: acquire-lock
+acquire-wrapper-lock: acquire-lock
+acquire-configure-lock: acquire-lock
+acquire-build-lock: acquire-lock
.PHONY: release-tools-lock
.PHONY: release-wrapper-lock release-configure-lock release-build-lock
-release-tools-lock:
- ${_RELEASE_LOCK}
-release-wrapper-lock:
- ${_RELEASE_LOCK}
-release-configure-lock:
- ${_RELEASE_LOCK}
-release-build-lock:
- ${_RELEASE_LOCK}
+release-tools-lock: release-lock
+release-wrapper-lock: release-lock
+release-configure-lock: release-lock
+release-build-lock: release-lock
################################################################
# Skeleton targets start here
diff -r 2d69b670b3e1 -r 79322738704b mk/bsd.pkg.patch.mk
--- a/mk/bsd.pkg.patch.mk Sun Jun 04 00:39:05 2006 +0000
+++ b/mk/bsd.pkg.patch.mk Sun Jun 04 04:31:47 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.patch.mk,v 1.21 2006/01/19 20:32:17 jlam Exp $
+# $NetBSD: bsd.pkg.patch.mk,v 1.22 2006/06/04 04:31:47 jlam Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and defines the
# relevant variables and targets for the "patch" phase.
@@ -292,10 +292,8 @@
patch: ${_PATCH_TARGETS}
.PHONY: acquire-patch-lock release-patch-lock
-acquire-patch-lock:
- ${_ACQUIRE_LOCK}
-release-patch-lock:
- ${_RELEASE_LOCK}
+acquire-patch-lock: acquire-lock
+release-patch-lock: release-lock
${_PATCH_COOKIE}:
${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-patch PKG_PHASE=patch
diff -r 2d69b670b3e1 -r 79322738704b mk/pkginstall/bsd.pkginstall.mk
--- a/mk/pkginstall/bsd.pkginstall.mk Sun Jun 04 00:39:05 2006 +0000
+++ b/mk/pkginstall/bsd.pkginstall.mk Sun Jun 04 04:31:47 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkginstall.mk,v 1.3 2006/06/04 00:39:05 jlam Exp $
+# $NetBSD: bsd.pkginstall.mk,v 1.4 2006/06/04 04:31:47 jlam Exp $
#
# This Makefile fragment is included by bsd.pkg.mk and implements the
# common INSTALL/DEINSTALL scripts framework. To use the pkginstall
@@ -1007,10 +1007,8 @@
pkginstall: ${_PKGINSTALL_TARGETS}
.PHONY: acquire-pkginstall-lock release-pkginstall-lock
-acquire-pkginstall-lock:
- ${_ACQUIRE_LOCK}
-release-pkginstall-lock:
- ${_RELEASE_LOCK}
+acquire-pkginstall-lock: acquire-lock
+release-pkginstall-lock: release-lock
.PHONY: real-pkginstall
real-pkginstall: generate-rcd-scripts generate-install-scripts
Home |
Main Index |
Thread Index |
Old Index