Subject: CVS commit: pkgsrc/mk
To: None <pkgsrc-changes@NetBSD.org>
From: Johnny C. Lam <jlam@netbsd.org>
List: pkgsrc-changes
Date: 01/28/2005 06:30:59
Module Name:	pkgsrc
Committed By:	jlam
Date:		Fri Jan 28 06:30:59 UTC 2005

Modified Files:
	pkgsrc/mk: bsd.pkg.install.mk
	pkgsrc/mk/install: deinstall header install
Added Files:
	pkgsrc/mk/install: dirs

Log Message:
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).


To generate a diff of this commit:
cvs rdiff -r1.72 -r1.73 pkgsrc/mk/bsd.pkg.install.mk
cvs rdiff -r1.29 -r1.30 pkgsrc/mk/install/deinstall
cvs rdiff -r0 -r1.1 pkgsrc/mk/install/dirs
cvs rdiff -r1.27 -r1.28 pkgsrc/mk/install/header
cvs rdiff -r1.33 -r1.34 pkgsrc/mk/install/install

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.