David Brownlee <abs%absd.org@localhost> writes: > So, this is all essentially NetBSD specific, as I don't know who else needs > "split brain" handling. Suggest whatever we do is enabled for NetBSD by > default, but disabled for others unless someone sets a build option I really don't follow that. split-brain is an invariant violation; its existence is a symptom of bugs and admin errors, and the only reasonable thing to do is to repair it. Something a future mythical pkg_fsck could address. pkgsrc has long had a notion of PKG_DBDIR set at bootstrap. That's the normal path and the one I think we should continue to be on. We have a mechanism to override PKG_DBDIR in pkg_install.conf. That's a workaround for misconfiguration, and for back compat, which is a misconfiguration introduced by a change in PKG_DBDIR and ended by migrating. This is NetBSD specific because - only NetBSD has ever had /var/db/pkg as PKG_DBDIR, and only for PREFIX=/usr/pkg - the migration from that value to /usr/pkg/pkgdb did not go well because it was far harder than anticipated and did not have a full plan and tool support when it happened > I think the only way to manage this is to have pkgsrc pkg_install make a > runtime decision for PKG_DBDIR I disagree that this is the only way. > - Use any value set in a config file, environment or command-line as now > - Else check for $PREFIX/pkgdb/pkgdb.byfile.db and > /var/db/pkg/pkgdb.byfile.db > a) If only one is found, use it (at some later date start printing a > warning to stderr if using /var/db/pkg) > b) If neither are found use $PREFIX/pkgdb > c) If both are found print an error to stderr and stop - suggest include > detail explaining what is happening, how to fix and include a link to a > netbsd.org page This seems like way too much magic. Everything else just looks for bits where they are supposed to be and errors out if not found. I'd be ok with a) if the db isn't in the right place error out b) if the db is set to /usr/pkg/something, and /var/db/pkg exists, error out c) if the db is set to /var/db/pkg and that exists, and prefix is /usr/pkg, and /usr/pkg/pkgdb exists, error out. with looking for pkgdb.byfile.db when we think it should be there and objecting to even a bare directory when it should not. This is far less magic, and merely asks people doing things that we now say are wrong to edit a tiny config file, in exchange for many people not being unpleasantly surprised. > Enumerating some use cases (All NetBSD, all focussed on binary package > pkg_install & therefore pkgin behaviour) > > 1) Any system with split brain (all others assumed not to be) > - Will get the error and info on how to fix > 2) Any system with PKG_DBDIR set in config files > - Will continue as now am assuming you mean pkg_install.conf > 2) Newer netbsd system, new to pkgsrc, base pkgtools use $PREFIX/pkgdb > - Will use $PREFIX/pkgdb > 3) Older netbsd system, new to pkgsrc, base pkgtools use /var/db/pkgdb > - Will use /var/db/pkgdb > 4) Any netbsd system, existing pkgsrc, with pkgsrc pkg_install using > $PREFIX/pkgdb > - Will continue to use $PREFIX/pkgdb > 5) Any netbsd system, existing pkgsrc, with pkgsrc pkg_install using > /var/db/pkgdb > - Will continue to use /var/db/pkg > > They key points are > - Binary packages will work for existing systems using either $PREFIX/pkgdb > or /var/db/pkgdb > - Recent netbsd systems newly setting up pkgsrc will use $PREFIX/pkgdb > - Anyone can override by setting PKG_DBDIR I really can't tell what you are proposing from what you think was actually implemented in reaction to the default change. I still haven't seen a clear written summary (that we can edit incrementally) of exactly what's going on now, including bulk builds people are using. Looking quickly, I see PKG_DBDIR?= ${LOCALBASE}/pkgdb and a check/warning if PKG_DBDIR is not set explicitly and /var/db/pkg exists. So it seems the trouble is all in - pkg_install - maybe some bulk builds have PKG_DBDIR not equal to /usr/pkg/pkgdb (if so that's a bug and needs to be fixed) At this point, I'm somewhat inclined towards, on NetBSD, pkg_* should refuse to do anything at all unless one of the following: PREFIX is not /usr/pkg (not a case we are having trouble with) PKG_DBDIR is explicitly set in pkg_install.conf (in which case use it) PKG_DBDIR is within /usr/pkg AND /var/db/pkg does not exist which is sort of what I said above, and I'm not sure exactly how they differ and which is right :-) That means - everyone who wants PKG_DBDIR in /var/db/pkg has to set pkg_install.conf - people with a correct setup, i.e. PKG_DBDIR in /usr/pkg/pkgdb, don't have to do anything - people with stray /var/db/pkg who don't understand what's going on will get an error instead of a broken setup - people with NetBSD 8 and 9 who have not updated along the stable branch will need to set PKG_DBDIR in /etc/pkg_install.conf, as they have been advised to do for a really long time by: http://pkgsrc.org/pkgdb-change/ My proposal basically amounts to remove magic from pkg_install (that changes behavior) replace with magic that errors out users, especially those who are on NetBSD 8 and 9 and have not updated to stable after about January 2021, continue to have the responsibility to read the migration page and follow the instructions. As far as I know the instructions do work if followed.
Attachment:
signature.asc
Description: PGP signature