tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: OWN_DIRS semantics



On Sun, Sep 17, 2017 at 09:12:45PM +0200, Rhialto wrote:
> On Sat 16 Sep 2017 at 21:32:33 +0000, Johnny C. Lam wrote:
> > Another option is to just refcount the directories and only warn
> > if the refcount is zero but the directory can't be removed because
> > it's not empty.  This is probably the cleanest option, and we get
> > rid of the concept of OWN_DIRS entirely.
> 
> Isn't that what /var/db/pkg.refcount/dirs/  (etc/rc.d/) is doing already?

Almost. For pkginstall, directories are created for both
MAKE_DIRS and OWN_DIRS which both share the same refcounts.
The difference between them is that MAKE_DIRS causes the
+DEINSTALL script to silently attempt to remove the directory
once the refcount is zero, whereas OWN_DIRS causes the script to
attempt to remove the directory and to emit a warning on failure
that "the directory should be removed if no other software is
using it."

My problem with this is that it's hard to know what other
software is using the directory if the refcount is already zero
other than inspecting the contents of the directory and knowing
what software made it.  This is mostly problematic because the
default ${VARBASE} is "/var", so we have packages and system
software mingling together in using directories under /var.

There is also the problem with multiple packages having the same
directory in OWN_DIRS.  This is a bug, but difficult to catch in
the bulk builds.

What I'm proposing is folding MAKE_DIRS into OWN_DIRS and
using the following behavior:

1. If the refcount is NOT zero, then don't try to remove the
   directory and emit no messages.

2. If the refcount is zero, then if the directory was preexisting
   (exists before first package added a reference count), then
   warn that the directory is unused by other packages but was
   preexisting.

3. If the refcount is zero, and the directory was not
   preexisting, then:

   3a. If the directory is empty, then remove the directory and
       emit no messages.

   3b. If the directory is non-empty, then warn that the
       directory can't be removed but that no packages are using
       it.

This should simplify packages because they don't need to
differentiate between MAKE_DIRS and OWN_DIRS, and improves on the
existing behavior by warning about all preexisting directories.

Regards,
-- 
Johnny C. Lam
jlam%NetBSD.org@localhost


Home | Main Index | Thread Index | Old Index