Subject: Handling of shared directories
To: None <tech-pkg@NetBSD.org>
From: Julio M. Merino Vidal <jmmv@menta.net>
List: tech-pkg
Date: 04/13/2004 19:01:42
Hi all,
after the PRINT_PLIST_AWK addition, I have to find a way to easily use it to
handle PLIST entries for directories created and removed by the -dirs packages
(to know, gnome1-dirs, gnome2-dirs, xdg-dirs and xdg-x11-dirs).
And while at it, I'm thinking of better ways to handle shared directories, as
I think the actual approach (of mtree and -dirs packages is not consistent nor
clean). IMHO, mtree should disappear (which I'll consider in both approaches),
and AFAICT, many other people thinks this, because it causes portability
problems, and its use is mostly useless now.
I see two ways to go, which I'll analyze below:
1) Introduce a USE_DIRS variable, which takes the name of the -dirs packages
needed (and their version). For example:
USE_DIRS= gnome2-1.5
This needs a mk/dirs.mk file, which is automatically included by bsd.pkg.mk
when USE_DIRS is not empty. The file analyzes the contents of this line
and then includes other dirs.mk files, but coming from the package(s)
selected. In this example, it could include misc/gnome2-dirs/dirs.mk.
Then, each */*-dirs/dirs.mk file adds the proper DEPENDS, based on the
highest version specified by the USE_DIRS line. In this case, the package
could get a dependency on gnome2-dirs-1.5. This file also does all the
PRINT_PLIST_AWK magic to get @comment lines for all these shared dirs.
Note that handling of specific version numbers is needed, as there will be
no default dependency (i.e., USE_DIRS=gnome2 won't work). This is because
adding a default version is useless, and bumping it could mean many revision
bumps on packages that don't really need it.
The advantadge of this is clear: it is very similar to what we already have,
so changes are not intrusive (it is a matter of changing an explicit DEPENDS
line in a package Makefile by its corresponding USE_DIRS entry; around 175
packages affected). It can also be extended to support new -dirs packages
(a thing I would like to happen if we go this way; see below).
Furthermore, each directory belongs to exactly one package if we go down the
dependency tree (not that pkg_info -F /some/directory knows nothing about it,
but anyway...). So, doing a "pkg_delete *" should remove _everything_ from
/usr/pkg, and not leave empty directories, which I find very ugly.
And... the need to precreate directories before installing files in them is
solved by this.
The problems of this are:
1) By using -dirs packages, handling of shared directories is not very
consistent across pkgsrc. Some of them are handled in the -dirs
packages, while others are handled in the mtree files.
This could be solved by using -dirs packages for everything. I.e.,
provide a base-dirs package for bin, lib, libexec, and so on; provide a
locale-dirs packages for the bloated share/locale directory, etc.
Not very difficult, and could be done in a quite automated way; for
example, depend on the base-dirs package for everything; depend on
locale-dirs when USE_PKGLOCALEDIR is set, etc.
2) -dirs packages are completely useless in the pkgviews world. This could
be solved by simply setting USE_DIRS to the blank string from bsd.pkg.mk
when pkgviews is enabled... but leads us to yet another difference from
overwrite packages and pkgviews ones.
2) Completely drop -dirs packages and mtree files. We could simply keep a
list of directories in a plain text file (or a Makefile defining a variable
with the entire list, doesn't matter). This file could contain entries like:
bin, sbin, lib, lib/pkgconfig, share/applications, etc. I know, similar to
an mtree file.
Then, during print-PLIST, instead of @dirrm'ing the directories found in that
list (or printing a @comment line for them), print an ${RMDIR} line, to mark
explicitly they are shared.
This could add some bloat to the PLISTs, and needs work on all the packages.
Even though, packages not reviewed could keep working as they do now (i.e.,
leaving the standard directories untouched when beeing removed). But packages
modified (mainly just a new print-PLIST from them is needed) could _try_ to
remove all shared directories they use.
This approach is very similar to how directories are handled by pkgviews, so
could give us consistency across overwrite packages and pkgviews. Also, all
packages could handle directories in the same way.
The pre-creation of directories is not done by this, so packages really
needing it will have to set INSTALLATION_DIRS accordingly (which _must_ be
done anyway to get pkgviews working fine).
I'm undecided about what to do, and I have the feeling that changing the way
shared directories are handled in general (i.e., mtree) won't be very welcome.
2 seems cleaner (because empty dirs are removed ASAP, when they really should
be erased), though it may require more work to get it completely right.
1 is easier (talking about just modifying the existing -dirs packages), but to
get it completely done (base-dirs, locale-dirs, etc) also requires a bit work.
If no one comes up with comments saying that either "full" 1 or 2 are very
good things to have... I think I'll go for doing half of 1 by just modifying
the existing -dirs pkgs and adding dirs.mk files for them.
Comments?
Thanks.
--
Julio M. Merino Vidal <jmmv@menta.net>
The NetBSD Project - http://www.NetBSD.org/