*: move default database directory from /var/db/pkg to ${PREFIX}/pkgdb

As discussed in August 2020 and previously on pkgsrcCon 2019.

Ok pkgsrc-pmc@
This commit is contained in:
wiz 2020-12-02 10:22:39 +00:00
parent 6671bc7a58
commit c85d83c09c
12 changed files with 53 additions and 38 deletions

View file

@ -1,5 +1,5 @@
#!/bin/sh
# $NetBSD: pbulk.sh,v 1.8 2018/10/29 02:47:08 sevan Exp $
# $NetBSD: pbulk.sh,v 1.9 2020/12/02 10:22:39 wiz Exp $
set -e
usage="usage: ${0##*/} [-lun] [-c mk.conf.fragment] [-d nodes]"
@ -40,7 +40,7 @@ fi
# setting pkgdb directory:
if [ -n "$unprivileged" -o -n "${PREFIX}" ]; then
: ${PKGDBDIR:=${PREFIX}/var/db/pkg}
: ${PKGDBDIR:=${PREFIX}/pkgdb}
fi
# Do it early since adding it after it fails is problematic:

View file

@ -1,4 +1,4 @@
# $NetBSD: depends.mk,v 1.11 2020/01/14 22:22:34 rillig Exp $
# $NetBSD: depends.mk,v 1.12 2020/12/02 10:22:39 wiz Exp $
# This command prints out the dependency patterns for all full (run-time)
# dependencies of the package.
@ -188,8 +188,12 @@ ${_RRDEPENDS_FILE}: ${_RDEPENDS_FILE}
# _pkgformat-install-dependencies:
# Installs any missing dependencies.
#
# The ${TEST} at the beginning is for the default change for the
# database directory from /var/db/pkg to ${PREFIX}/pkgdb in December 2020.
#
_pkgformat-install-dependencies: .PHONY ${_DEPENDS_FILE}
${RUN} \
${TEST} -n "${PKG_DBDIR_ERROR}" && ${ERROR_MSG} ${PKG_DBDIR_ERROR:Q} && exit 1; \
exec 3<&0; \
${CAT} ${_DEPENDS_FILE} | \
while read type pattern dir; do \

View file

@ -1,4 +1,4 @@
# $NetBSD: pkgformat-vars.mk,v 1.8 2020/01/12 23:38:42 joerg Exp $
# $NetBSD: pkgformat-vars.mk,v 1.9 2020/12/02 10:22:39 wiz Exp $
#
# This Makefile fragment is included indirectly by bsd.prefs.mk and
# defines some variables which must be defined earlier than where
@ -16,7 +16,11 @@ USE_TOOLS+= date
.endif
# This is the package database directory for the default view.
PKG_DBDIR?= /var/db/pkg
PKG_DBDIR?= ${PREFIX}/pkgdb
.if exists(/var/db/pkg) && !exists(${PKG_DBDIR})
PKG_DBDIR_ERROR= The default package database directory has changed. Please run: mv /var/db/pkg ${PKG_DBDIR}
.endif
# _PKG_DBDIR is the actual packages database directory where we register
# packages.
@ -32,11 +36,7 @@ PKG_INFO_CMD?= ${PKG_TOOLS_BIN}/pkg_info
LINKFARM_CMD?= ${PKG_TOOLS_BIN}/linkfarm
# Latest versions of tools required for correct pkgsrc operation.
.if !empty(USE_PKG_ADMIN_DIGEST:M[Yy][Ee][Ss])
PKGTOOLS_REQD= 20191008
.else
PKGTOOLS_REQD= 20100914
.endif
PKGTOOLS_REQD= 20200828
# Latest version of pkg_install required to extract packages
PKGTOOLS_VERSION_REQD= 20091115

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: register-dependencies,v 1.1 2011/10/15 00:23:09 reed Exp $
# $NetBSD: register-dependencies,v 1.2 2020/12/02 10:22:39 wiz Exp $
#
######################################################################
#
@ -18,14 +18,14 @@
# ENVIRONMENT
# PKG_DBDIR
# This is the package meta-data directory in which the
# packages are registered. By default, this is /var/db/pkg.
# packages are registered. By default, this is ${PREFIX}/pkgdb .
#
######################################################################
: ${AWK:=awk}
: ${CP:=cp}
: ${ECHO:=echo}
: ${PKG_DBDIR:=/var/db/pkg}
: ${PKG_DBDIR:=${PREFIX}/pkgdb}
: ${RM:=rm}
: ${TEST:=test}
: ${TOUCH:=touch}

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.231 2020/08/09 21:40:42 rillig Exp $
# $NetBSD: Makefile,v 1.232 2020/12/02 10:22:39 wiz Exp $
# Notes to package maintainers:
#
@ -81,7 +81,7 @@ MAKE_ENV+= OPSYS=${OPSYS}
MAKE_ENV+= CATMAN_SECTION_SUFFIX=${CATMAN_SECTION_SUFFIX:Q}
MAKE_ENV+= MANINSTALL=${MANINSTALL:Q}
PKG_DBDIR?= /var/db/pkg
PKG_DBDIR?= ${PREFIX}/pkgdb
EGDIR= ${PREFIX}/share/examples/pkg_install
PLIST_SUBST+= PKG_DBDIR=${PKG_DBDIR}

View file

@ -1,4 +1,4 @@
/* $NetBSD: check.c,v 1.10 2010/01/22 13:30:41 joerg Exp $ */
/* $NetBSD: check.c,v 1.11 2020/12/02 10:22:39 wiz Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -7,7 +7,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: check.c,v 1.10 2010/01/22 13:30:41 joerg Exp $");
__RCSID("$NetBSD: check.c,v 1.11 2020/12/02 10:22:39 wiz Exp $");
/*-
* Copyright (c) 1999-2008 The NetBSD Foundation, Inc.
@ -77,7 +77,7 @@ __RCSID("$NetBSD: check.c,v 1.10 2010/01/22 13:30:41 joerg Exp $");
static int checkpattern_fn(const char *, void *);
/*
* Assumes CWD is in /var/db/pkg/<pkg>!
* Assumes CWD is in the database directory ($PREFIX/pkgdb/<pkg>)!
*/
static void
check1pkg(const char *pkgdir, int *filecnt, int *pkgcnt)

View file

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_admin.1,v 1.38 2019/10/11 11:57:41 joerg Exp $
.\" $NetBSD: pkg_admin.1,v 1.39 2020/12/02 10:22:39 wiz Exp $
.\"
.\" Copyright (c) 1999-2019 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -28,7 +28,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 8, 2019
.Dd August 22, 2020
.Dt PKG_ADMIN 1
.Os
.Sh NAME
@ -295,9 +295,9 @@ See
.Xr pkg_install.conf 5
for options, that can also be specified using the environment.
.Sh FILES
.Bl -tag -width /var/db/pkg/pkgdb.byfile.db -compact
.It Pa /var/db/pkg/pkgdb.byfile.db
.It Pa /var/db/pkg/\*[Lt]pkg\*[Gt]/+CONTENTS
.Bl -tag -width @PREFIX@/pkgdb/pkgdb.byfile.db -compact
.It Pa @PREFIX@/pkgdb/pkgdb.byfile.db
.It Pa @PREFIX@/pkgdb/\*[Lt]pkg\*[Gt]/+CONTENTS
.El
.Sh SEE ALSO
.Xr pkg_add 1 ,

View file

@ -1344,7 +1344,7 @@ Optional Features:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pkgdbdir=DIR Where to put the pkg database (/var/db/pkg)
--with-pkgdbdir=DIR Where to put the pkg database (PREFIX/pkgdb)
--with-ssl Enable OpenSSL based signature support
Some influential environment variables:
@ -4025,7 +4025,7 @@ AUTOHEADER=${AUTOHEADER-"$srcdir/missing --run autoheader"}
if test "${with_pkgdbdir+set}" = set; then :
withval=$with_pkgdbdir; pkgdbdir="$with_pkgdbdir"
else
pkgdbdir="/var/db/pkg"
pkgdbdir="${prefix}/pkgdb"
fi

View file

@ -1,4 +1,4 @@
dnl $NetBSD: configure.ac,v 1.43 2020/07/01 10:15:20 jperkin Exp $
dnl $NetBSD: configure.ac,v 1.44 2020/12/02 10:22:39 wiz Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.52)
AC_INIT([pkg_install], [20200701], [joerg@NetBSD.org])
@ -39,9 +39,9 @@ AC_SUBST(AUTOHEADER)
dnl Set the default pkg dbdir
AC_ARG_WITH(pkgdbdir,
[ --with-pkgdbdir=DIR Where to put the pkg database (/var/db/pkg)],
[ --with-pkgdbdir=DIR Where to put the pkg database (PREFIX/pkgdb)],
[ pkgdbdir="$with_pkgdbdir" ],
[ pkgdbdir="/var/db/pkg" ])
[ pkgdbdir="${prefix}/pkgdb" ])
AC_SUBST(pkgdbdir)
AC_ARG_WITH(ssl,

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile.in,v 1.36 2017/04/19 21:42:50 joerg Exp $
# $NetBSD: Makefile.in,v 1.37 2020/12/02 10:22:39 wiz Exp $
srcdir= @srcdir@
@ -32,6 +32,7 @@ OBJS= automatic.o conflicts.o dewey.o fexec.o file.o \
str.o var.o version.o vulnerabilities-file.o xwrapper.o
CPPFLAGS+= -DSYSCONFDIR=\"$(sysconfdir)\"
CPPFLAGS+= -DPREFIX=\"$(prefix)\"
.if !empty(BOOTSTRAP)
CPPFLAGS+= -DBOOTSTRAP

View file

@ -1,4 +1,4 @@
/* $NetBSD: pkgdb.c,v 1.39 2010/04/20 21:22:38 joerg Exp $ */
/* $NetBSD: pkgdb.c,v 1.40 2020/12/02 10:22:39 wiz Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -7,7 +7,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: pkgdb.c,v 1.39 2010/04/20 21:22:38 joerg Exp $");
__RCSID("$NetBSD: pkgdb.c,v 1.40 2020/12/02 10:22:39 wiz Exp $");
/*-
* Copyright (c) 1999-2010 The NetBSD Foundation, Inc.
@ -70,12 +70,9 @@ __RCSID("$NetBSD: pkgdb.c,v 1.39 2010/04/20 21:22:38 joerg Exp $");
* Where we put logging information by default if PKG_DBDIR is unset.
*/
#ifndef DEF_LOG_DIR
#define DEF_LOG_DIR "/var/db/pkg"
#define DEF_LOG_DIR PREFIX "/pkgdb"
#endif
/* just in case we change the environment variable name */
#define PKG_DBDIR "PKG_DBDIR"
static DB *pkgdbp;
static char pkgdb_dir_default[] = DEF_LOG_DIR;
static char *pkgdb_dir = pkgdb_dir_default;
@ -303,8 +300,21 @@ pkgdb_refcount_dir(void)
const char *
pkgdb_get_dir(void)
{
/* Except for the return at this end, this code is for
migration from the previous location /var/db/pkg to the new
default (December 2020). */
return pkgdb_dir;
struct stat sb;
if (strcmp(pkgdb_dir, DEF_LOG_DIR) == 0 &&
stat(pkgdb_dir, &sb) == -1 && errno == ENOENT &&
stat("/var/db/pkg", &sb) == 0) {
errx(EXIT_FAILURE,
"The default PKG_DBDIR has changed, but this installation still uses the old one.\n"
"Please move the database and re-run this command:\n"
"\tmv /var/db/pkg " DEF_LOG_DIR);
}
return pkgdb_dir;
}
/*

View file

@ -1,4 +1,4 @@
/* $NetBSD: version.h,v 1.179 2020/07/01 10:15:20 jperkin Exp $ */
/* $NetBSD: version.h,v 1.180 2020/12/02 10:22:39 wiz Exp $ */
/*
* Copyright (c) 2001 Thomas Klausner. All rights reserved.
@ -27,6 +27,6 @@
#ifndef _INST_LIB_VERSION_H_
#define _INST_LIB_VERSION_H_
#define PKGTOOLS_VERSION 20200701
#define PKGTOOLS_VERSION 20200828
#endif /* _INST_LIB_VERSION_H_ */