summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorrillig <rillig>2006-08-04 07:04:38 +0000
committerrillig <rillig>2006-08-04 07:04:38 +0000
commitfc2e076438030796205eb1e4c45c30a0f7656b7d (patch)
tree6bfecc2db0a88b476e82ede6b501a36ef86a61cd /mk
parent11ddb2c3dc8d51a76fd9a25071bda0641bcdb91e (diff)
downloadpkgsrc-fc2e076438030796205eb1e4c45c30a0f7656b7d.tar.gz
Moved the bin-install target from bsd.pkg.mk to install/bin-install.mk.
Added documentation. Added locking around the real installation.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.mk36
-rw-r--r--mk/install/bin-install.mk64
2 files changed, 66 insertions, 34 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 0a80248ee1d..a9d9254f81d 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1882 2006/08/04 06:27:27 rillig Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1883 2006/08/04 07:04:38 rillig Exp $
#
# This file is in the public domain.
#
@@ -723,11 +723,6 @@ su-target: .USE
lint:
${_PKG_SILENT}${_PKG_DEBUG}${LOCALBASE}/bin/pkglint
-# List of sites carrying binary pkgs. Variables "rel" and "arch" are
-# replaced with OS release ("1.5", ...) and architecture ("mipsel", ...)
-BINPKG_SITES?= \
- ftp://ftp.NetBSD.org/pub/NetBSD/packages/$${rel}/$${arch}
-
# List of flags to pass to pkg_add(1) for bin-install:
BIN_INSTALL_FLAGS?= # -v
@@ -742,34 +737,7 @@ _BIN_INSTALL_FLAGS+= ${PKG_ARGS_ADD}
_SHORT_UNAME_R= ${:!${UNAME} -r!:C@\.([0-9]*)[_.].*@.\1@} # n.n[_.]anything => n.n
-# Install binary pkg, without strict uptodate-check first
-.PHONY: su-bin-install
-su-bin-install:
- @found="`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`"; \
- if [ "$$found" != "" ]; then \
- ${ERROR_MSG} "$$found is already installed - perhaps an older version?"; \
- ${ERROR_MSG} "If so, you may wish to \`\`pkg_delete $$found'' and install"; \
- ${ERROR_MSG} "this package again by \`\`${MAKE} bin-install'' to upgrade it properly."; \
- exit 1; \
- fi
- @rel=${_SHORT_UNAME_R:Q} ; \
- arch=${MACHINE_ARCH:Q} ; \
- pkgpath=${PKGREPOSITORY:Q} ; \
- for i in ${BINPKG_SITES} ; do pkgpath="$$pkgpath;$$i/All" ; done ; \
- ${ECHO} "Trying $$pkgpath" ; \
- if ${SETENV} PKG_PATH="$$pkgpath" ${PKG_ADD} ${_BIN_INSTALL_FLAGS} ${PKGNAME_REQD:U${PKGNAME}:Q}${PKG_SUFX} ; then \
- ${ECHO} "`${PKG_INFO} -e ${PKGNAME_REQD:U${PKGNAME}:Q}` successfully installed."; \
- else \
- ${SHCOMMENT} Cycle through some FTP server here ;\
- ${ECHO_MSG} "Installing from source" ; \
- ${RECURSIVE_MAKE} ${MAKEFLAGS} package \
- DEPENDS_TARGET=${DEPENDS_TARGET:Q} && \
- ${RECURSIVE_MAKE} ${MAKEFLAGS} clean ; \
- fi
-
-.PHONY: bin-install
-bin-install: su-target
- @${PHASE_MSG} "Binary install for "${PKGNAME_REQD:U${PKGNAME}:Q}
+.include "${PKGSRCDIR}/mk/install/bin-install.mk"
################################################################
# Everything after here are internal targets and really
diff --git a/mk/install/bin-install.mk b/mk/install/bin-install.mk
new file mode 100644
index 00000000000..e047735d64d
--- /dev/null
+++ b/mk/install/bin-install.mk
@@ -0,0 +1,64 @@
+# $NetBSD: bin-install.mk,v 1.1 2006/08/04 07:04:38 rillig Exp $
+#
+
+# The bin-install target tries to install a package from a prebuilt
+# binary package, and if that doesn't work, builds the package from
+# source.
+#
+# The following variables can be set by the pkgsrc user in mk.conf:
+#
+# PACKAGES
+# This directory is searched before BINPKG_SITES when trying to
+# install binary packages.
+#
+# BINPKG_SITES
+# A list of URLs where binary packages can be found.
+# See mk/defaults/mk.conf for details.
+#
+
+# List of sites carrying binary pkgs. Variables "rel" and "arch" are
+# replaced with OS release ("1.5", ...) and architecture ("mipsel", ...)
+BINPKG_SITES?= \
+ ftp://ftp.NetBSD.org/pub/NetBSD/packages/$${rel}/$${arch}
+
+_SU_BIN_INSTALL_TARGETS= acquire-bin-install-lock
+_SU_BIN_INSTALL_TARGETS+= locked-su-bin-install
+_SU_BIN_INSTALL_TARGETS+= release-bin-install-lock
+
+.PHONY: acquire-bin-install-lock release-bin-install-lock
+acquire-bin-install-lock: acquire-lock
+release-bin-install-lock: release-lock
+
+# Install binary pkg, without strict uptodate-check first
+.PHONY: su-bin-install
+su-bin-install: ${_SU_BIN_INSTALL_TARGETS}
+.ORDER: ${_SU_BIN_INSTALL_TARGETS}
+
+locked-su-bin-install:
+ @found=`${PKG_BEST_EXISTS} \"${PKGWILDCARD}\" || ${TRUE}`; \
+ if [ "$$found" != "" ]; then \
+ ${ERROR_MSG} "$$found is already installed - perhaps an older version?"; \
+ ${ERROR_MSG} "If so, you may wish to \`\`pkg_delete $$found'' and install"; \
+ ${ERROR_MSG} "this package again by \`\`${MAKE} bin-install'' to upgrade it properly."; \
+ exit 1; \
+ fi
+ @rel=${_SHORT_UNAME_R:Q}; \
+ arch=${MACHINE_ARCH:Q}; \
+ pkgpath=${PKGREPOSITORY:Q}; \
+ for i in ${BINPKG_SITES}; do \
+ pkgpath="$$pkgpath;$$i/All"; \
+ done; \
+ ${STEP_MSG} "Installing ${PKGNAME} from $$pkgpath"; \
+ if ${SETENV} PKG_PATH="$$pkgpath" ${PKG_ADD} ${_BIN_INSTALL_FLAGS} ${PKGNAME_REQD:U${PKGNAME}:Q}${PKG_SUFX}; then \
+ ${ECHO} "`${PKG_INFO} -e ${PKGNAME_REQD:U${PKGNAME}:Q}` successfully installed."; \
+ else \
+ ${SHCOMMENT} "Cycle through some FTP server here"; \
+ ${STEP_MSG} "No binary package found for ${PKGNAME} -- installing from source"; \
+ ${RECURSIVE_MAKE} ${MAKEFLAGS} package \
+ DEPENDS_TARGET=${DEPENDS_TARGET:Q} \
+ && ${RECURSIVE_MAKE} ${MAKEFLAGS} clean; \
+ fi
+
+.PHONY: bin-install
+bin-install: su-target
+ @${PHASE_MSG} "Binary install for "${PKGNAME_REQD:U${PKGNAME}:Q}