tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
How do I discover the default PKG_DBDIR ?
I'm planning to write a script that needs to know the value of PKG_DBDIR
(where the pkg database is stored).
Of all the pkgsrc related (meta-)data, this is the one that I
currently have no idea how to discover.
The man page for pkg_admin(1) (and several of the other pkg_*(1))
says ...
-K pkg_dbdir
Set pkg_dbdir as the package database directory. If this option
isn't specified, then the package database directory is taken
from the value of the environment variable PKG_DBDIR if it's set,
otherwise it defaults to /var/db/pkg.
which says how the value can be set, which would be fine if that's
what I wanted to do (it isn't) - it would also be fine if it was
true, in general, rather than just true for the system installed
which it isn't (from a quick glance at the sources I didn't look
enough to see if it always says that, or if the part that isn't general
enough for me is in fact altered on other installations to be correct
for them).
The part I can't handle is ...
otherwise it defaults to /var/db/pkg.
which happens to be correct on my system, and probably all NetBSD
systems (or at least the vast majority) but isn't true in general;
what it defaults to is whatever was set with the --with-pkgdbdir
option to pkg_install's configure (which comes from whatever PKG_DBDIR
was set to when pkgtools/pkg_install was built).
That is, I could write a script which would work on my system, by just
believing what the man page tells me, but then it wouldn't work for
someone else where the database is placed somewhere else by default.
Is there some way that I've been unable to find to get thge pkg_* tools
to tell me what value they're uing for PKG_DBDIR (ideally, it should
just tell me what value it will use, taking into account the current
environment, mk.conf, and cmd line options (like -K) - but I'd take it
if it would just tell me the compiled in fallback (all te rest I can
discover in my script if I have to do it that way) ?
If there's no current way to extract this info, could one perhaps be
added in the next version of the pkg tools? (My script can wait until
a new version is released, it isn't all that urgent - or in the meantime
I can just do something that "knows" /var/db/pkg but I wouldn't like to
leave it that way).
Thanks,
kre
[Aside: if a method to do this gets added, rather than already there
and I just cannot find it, I wouldn't object if it also made available
the current values of other pkg related config vars - LOCALBASE,
PKG_SYSCONFDIR, anything else like that - those I can dig out without extra
support, but it would be easier if there was a simpler way than currently.]
[Random gripe: man pages which state things as facts, which are actually
config options are horrid - even if the config option changing also causes
the man page to alter - from the man page I'd like to be able to discover
what I can actually assume to be true, not what just happens to be true
this week ... that is, in the above quoted paragraph, I'd much prefer
if the last line said something more like:
otherwise it defaults to a system dependent database
directory, which is /var/db/pkg for this installation.
Then it's clear that this isn't a constant, but a variable, and gives
its current value. There are of course other equally satisfactory solutions.]
Home |
Main Index |
Thread Index |
Old Index