pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc *: move default database directory from /var/db/pkg to...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/62cd21a38ef7
branches:  trunk
changeset: 442870:62cd21a38ef7
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Wed Dec 02 10:22:39 2020 +0000

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

As discussed in August 2020 and previously on pkgsrcCon 2019.

Ok pkgsrc-pmc@

diffstat:

 mk/pbulk/pbulk.sh                            |   4 ++--
 mk/pkgformat/pkg/depends.mk                  |   6 +++++-
 mk/pkgformat/pkg/pkgformat-vars.mk           |  14 +++++++-------
 mk/pkgformat/pkg/register-dependencies       |   6 +++---
 pkgtools/pkg_install/Makefile                |   4 ++--
 pkgtools/pkg_install/files/admin/check.c     |   6 +++---
 pkgtools/pkg_install/files/admin/pkg_admin.1 |  10 +++++-----
 pkgtools/pkg_install/files/configure         |   4 ++--
 pkgtools/pkg_install/files/configure.ac      |   6 +++---
 pkgtools/pkg_install/files/lib/Makefile.in   |   3 ++-
 pkgtools/pkg_install/files/lib/pkgdb.c       |  24 +++++++++++++++++-------
 pkgtools/pkg_install/files/lib/version.h     |   4 ++--
 12 files changed, 53 insertions(+), 38 deletions(-)

diffs (truncated from 311 to 300 lines):

diff -r 1c8e9bc72449 -r 62cd21a38ef7 mk/pbulk/pbulk.sh
--- a/mk/pbulk/pbulk.sh Wed Dec 02 08:50:24 2020 +0000
+++ b/mk/pbulk/pbulk.sh Wed Dec 02 10:22:39 2020 +0000
@@ -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 @@
 
 # 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:
diff -r 1c8e9bc72449 -r 62cd21a38ef7 mk/pkgformat/pkg/depends.mk
--- a/mk/pkgformat/pkg/depends.mk       Wed Dec 02 08:50:24 2020 +0000
+++ b/mk/pkgformat/pkg/depends.mk       Wed Dec 02 10:22:39 2020 +0000
@@ -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 @@
 # _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                                 \
diff -r 1c8e9bc72449 -r 62cd21a38ef7 mk/pkgformat/pkg/pkgformat-vars.mk
--- a/mk/pkgformat/pkg/pkgformat-vars.mk        Wed Dec 02 08:50:24 2020 +0000
+++ b/mk/pkgformat/pkg/pkgformat-vars.mk        Wed Dec 02 10:22:39 2020 +0000
@@ -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 @@
 .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 @@
 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
 
diff -r 1c8e9bc72449 -r 62cd21a38ef7 mk/pkgformat/pkg/register-dependencies
--- a/mk/pkgformat/pkg/register-dependencies    Wed Dec 02 08:50:24 2020 +0000
+++ b/mk/pkgformat/pkg/register-dependencies    Wed Dec 02 10:22:39 2020 +0000
@@ -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}
diff -r 1c8e9bc72449 -r 62cd21a38ef7 pkgtools/pkg_install/Makefile
--- a/pkgtools/pkg_install/Makefile     Wed Dec 02 08:50:24 2020 +0000
+++ b/pkgtools/pkg_install/Makefile     Wed Dec 02 10:22:39 2020 +0000
@@ -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+=             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}
diff -r 1c8e9bc72449 -r 62cd21a38ef7 pkgtools/pkg_install/files/admin/check.c
--- a/pkgtools/pkg_install/files/admin/check.c  Wed Dec 02 08:50:24 2020 +0000
+++ b/pkgtools/pkg_install/files/admin/check.c  Wed Dec 02 10:22:39 2020 +0000
@@ -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 @@
 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)
diff -r 1c8e9bc72449 -r 62cd21a38ef7 pkgtools/pkg_install/files/admin/pkg_admin.1
--- a/pkgtools/pkg_install/files/admin/pkg_admin.1      Wed Dec 02 08:50:24 2020 +0000
+++ b/pkgtools/pkg_install/files/admin/pkg_admin.1      Wed Dec 02 10:22:39 2020 +0000
@@ -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 @@
 .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 ,
diff -r 1c8e9bc72449 -r 62cd21a38ef7 pkgtools/pkg_install/files/configure
--- a/pkgtools/pkg_install/files/configure      Wed Dec 02 08:50:24 2020 +0000
+++ b/pkgtools/pkg_install/files/configure      Wed Dec 02 10:22:39 2020 +0000
@@ -1344,7 +1344,7 @@
 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 @@
 if test "${with_pkgdbdir+set}" = set; then :
   withval=$with_pkgdbdir;  pkgdbdir="$with_pkgdbdir"
 else
-   pkgdbdir="/var/db/pkg"
+   pkgdbdir="${prefix}/pkgdb"
 fi
 
 
diff -r 1c8e9bc72449 -r 62cd21a38ef7 pkgtools/pkg_install/files/configure.ac
--- a/pkgtools/pkg_install/files/configure.ac   Wed Dec 02 08:50:24 2020 +0000
+++ b/pkgtools/pkg_install/files/configure.ac   Wed Dec 02 10:22:39 2020 +0000
@@ -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@localhost])
@@ -39,9 +39,9 @@
 
 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,
diff -r 1c8e9bc72449 -r 62cd21a38ef7 pkgtools/pkg_install/files/lib/Makefile.in
--- a/pkgtools/pkg_install/files/lib/Makefile.in        Wed Dec 02 08:50:24 2020 +0000
+++ b/pkgtools/pkg_install/files/lib/Makefile.in        Wed Dec 02 10:22:39 2020 +0000
@@ -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 @@
        str.o var.o version.o vulnerabilities-file.o xwrapper.o
 
 CPPFLAGS+=     -DSYSCONFDIR=\"$(sysconfdir)\"
+CPPFLAGS+=     -DPREFIX=\"$(prefix)\"
 
 .if !empty(BOOTSTRAP)
 CPPFLAGS+=     -DBOOTSTRAP
diff -r 1c8e9bc72449 -r 62cd21a38ef7 pkgtools/pkg_install/files/lib/pkgdb.c
--- a/pkgtools/pkg_install/files/lib/pkgdb.c    Wed Dec 02 08:50:24 2020 +0000
+++ b/pkgtools/pkg_install/files/lib/pkgdb.c    Wed Dec 02 10:22:39 2020 +0000
@@ -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 @@
  * 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 @@
 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;
 }
 
 /*
diff -r 1c8e9bc72449 -r 62cd21a38ef7 pkgtools/pkg_install/files/lib/version.h
--- a/pkgtools/pkg_install/files/lib/version.h  Wed Dec 02 08:50:24 2020 +0000
+++ b/pkgtools/pkg_install/files/lib/version.h  Wed Dec 02 10:22:39 2020 +0000
@@ -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 $        */



Home | Main Index | Thread Index | Old Index