diff options
author | jlam <jlam@pkgsrc.org> | 2005-01-28 06:30:58 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2005-01-28 06:30:58 +0000 |
commit | 5aa13ad4ee16dd77a666dd4cf0afc2a1144efcbc (patch) | |
tree | 9cf438e5d9a3ee9483f6b8a2483d71a25e7c5d0a /mk/bsd.pkg.install.mk | |
parent | 83424a7b07031ffbf5ef211705cc519baf36fa76 (diff) | |
download | pkgsrc-5aa13ad4ee16dd77a666dd4cf0afc2a1144efcbc.tar.gz |
Use reference counts to properly account for the creation and removal
of directories needed for the proper functioning of each package.
The +INSTALL script unpacks a +DIRS script that adds and removes
directories. The +DIRS script entirely encapsulates the directory
creation and removal, and completely replaces the code in the
mk/install/install and mk/install/deinstall templates that handled
{MAKE,OWN}_DIRS and {MAKE,OWN}_DIRS_PERMS.
The +DIRS script is meant to be executed from within the package
meta-data directory, e.g. /var/db/pkg/<pkgname>. It's usage is:
./+DIRS ADD|REMOVE|CHECK-ADD|CHECK-REMOVE
The ADD and REMOVE actions cause the necessary directories to be added
or removed from the system. The CHECK-ADD and CHECK-REMOVE actions
print out informative messages prompting the user to either create or
remove some necessary directories.
The behaviour of "ADD" is such that if the directory already exists
on the system and is not already ref-counted, then that directory is
marked as "pre-existing". On "REMOVE", pre-existing directories are
left untouched on the filesystem.
At any time, the root user can sanity-check the directories needed by
packages by invoking all of the +DIRS scripts with the "CHECK-ADD"
action. If there are missing directories, then invoking all of the
+DIRS scripts with the "ADD" action will ensure that any missing
directories are created.
The reference counts database is stored in ${PKG_DBDIR}/.refcount.
The reference counts related to directories managed by the +DIRS script
are stored in ${PKG_DBDIR}/.refcount/dirs. If the directory reference
counts database is removed, then invoking all of the +DIRS scripts
with the "ADD" action will reconstruct the database; however, directories
may be marked as being pre-existing, so they won't be removed at
package de-installation (although a message will be displayed informing
the user that those directories can be removed).
Diffstat (limited to 'mk/bsd.pkg.install.mk')
-rw-r--r-- | mk/bsd.pkg.install.mk | 67 |
1 files changed, 62 insertions, 5 deletions
diff --git a/mk/bsd.pkg.install.mk b/mk/bsd.pkg.install.mk index 4ac0296c508..67cc65f58b7 100644 --- a/mk/bsd.pkg.install.mk +++ b/mk/bsd.pkg.install.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.pkg.install.mk,v 1.72 2005/01/26 23:15:03 jlam Exp $ +# $NetBSD: bsd.pkg.install.mk,v 1.73 2005/01/28 06:30:58 jlam Exp $ # # This Makefile fragment is included by bsd.pkg.mk to use the common # INSTALL/DEINSTALL scripts. To use this Makefile fragment, simply: @@ -78,6 +78,13 @@ FILES_SUBST+= CONF_DEPENDS=${CONF_DEPENDS:C/:.*//:Q} FILES_SUBST+= PKGBASE=${PKGBASE} FILES_SUBST+= PKG_INSTALLATION_TYPE=${PKG_INSTALLATION_TYPE} +# Database directory for reference-counted package objects. Subdirectories +# represent different classes of package objects, e.g. dirs, users, +# group, etc. +# +_PKG_REFCOUNT_DBDIR= ${PKG_DBDIR}/.refcount +FILES_SUBST+= PKG_REFCOUNT_DBDIR=${_PKG_REFCOUNT_DBDIR:Q} + # PKG_USERS represents the users to create for the package. It is a # space-separated list of elements of the form # @@ -208,10 +215,59 @@ MAKE_DIRS?= # empty MAKE_DIRS_PERMS?= # empty OWN_DIRS?= # empty OWN_DIRS_PERMS?= # empty -FILES_SUBST+= MAKE_DIRS=${MAKE_DIRS:Q} -FILES_SUBST+= MAKE_DIRS_PERMS=${MAKE_DIRS_PERMS:Q} -FILES_SUBST+= OWN_DIRS=${OWN_DIRS:Q} -FILES_SUBST+= OWN_DIRS_PERMS=${OWN_DIRS_PERMS:Q} + +INSTALL_DIRS_FILE= ${WRKDIR}/.install-dirs +INSTALL_UNPACK_TMPL+= ${INSTALL_DIRS_FILE} + +${INSTALL_DIRS_FILE}: ../../mk/install/dirs + ${_PKG_SILENT}${_PKG_DEBUG}{ \ + ${ECHO} "# start of install-dirs"; \ + ${ECHO} "#"; \ + ${ECHO} "# Generate a +DIRS script that reference counts directories"; \ + ${ECHO} "# that are required for the proper functioning of the"; \ + ${ECHO} "# package."; \ + ${ECHO} "#"; \ + ${ECHO} "case \$${STAGE} in"; \ + ${ECHO} "PRE-INSTALL)"; \ + ${ECHO} " \$${CAT} > ./+DIRS << 'EOF_DIRS'"; \ + ${SED} ${FILES_SUBST_SED} ../../mk/install/dirs; \ + ${ECHO} ""; \ + case "${CONF_FILES}${CONF_FILES_PERMS}${SUPPORT_FILES}${SUPPORT_FILES_PERMS}" in \ + "") ;; \ + *) ${ECHO} "# DIR: ${PKG_SYSCONFDIR} m" ;; \ + esac; \ + case "${RCD_SCRIPTS}" in \ + "") ;; \ + *) ${ECHO} "# DIR: ${RCD_SCRIPTS_DIR} m" ;; \ + esac; \ + eval set -- ${MAKE_DIRS} ; \ + while ${TEST} $$# -gt 0; do \ + dir="$$1"; shift; \ + ${ECHO} "# DIR: $$dir m"; \ + done; \ + eval set -- ${OWN_DIRS} ; \ + while ${TEST} $$# -gt 0; do \ + dir="$$1"; shift; \ + ${ECHO} "# DIR: $$dir mo"; \ + done; \ + eval set -- ${MAKE_DIRS_PERMS} ; \ + while ${TEST} $$# -gt 0; do \ + dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \ + shift; shift; shift; shift; \ + ${ECHO} "# DIR: $$dir m $$owner $$group $$mode"; \ + done; \ + eval set -- ${OWN_DIRS_PERMS} ; \ + while ${TEST} $$# -gt 0; do \ + dir="$$1"; owner="$$2"; group="$$3"; mode="$$4"; \ + shift; shift; shift; shift; \ + ${ECHO} "# DIR: $$dir mo $$owner $$group $$mode"; \ + done; \ + ${ECHO} "EOF_DIRS"; \ + ${ECHO} " \$${CHMOD} +x ./+DIRS"; \ + ${ECHO} " ;;"; \ + ${ECHO} "esac"; \ + } > ${.TARGET}.tmp; \ + ${MV} -f ${.TARGET}.tmp ${.TARGET} # PKG_CREATE_USERGROUP indicates whether the INSTALL script should # automatically add any needed users/groups to the system using @@ -298,6 +354,7 @@ FILES_SUBST+= XARGS=${XARGS:Q} FILES_SUBST_SED= ${FILES_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/} INSTALL_SCRIPTS_ENV= PKG_PREFIX=${PREFIX} +INSTALL_SCRIPTS_ENV+= PKG_METADATA_DIR=${_PKG_DBDIR}/${PKGNAME} .PHONY: pre-install-script post-install-script |