Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/pkg_install/dist merge pkg_install after import...
details: https://anonhg.NetBSD.org/src/rev/67dc0c0371eb
branches: trunk
changeset: 978768:67dc0c0371eb
user: wiz <wiz%NetBSD.org@localhost>
date: Wed Dec 02 13:53:50 2020 +0000
description:
merge pkg_install after import of 20201202 version
diffstat:
external/bsd/pkg_install/dist/add/perform.c | 104 ++++++----
external/bsd/pkg_install/dist/admin/check.c | 6 +-
external/bsd/pkg_install/dist/admin/main.c | 150 ++++++++++++--
external/bsd/pkg_install/dist/admin/pkg_admin.1 | 10 +-
external/bsd/pkg_install/dist/create/perform.c | 6 +-
external/bsd/pkg_install/dist/create/pl.c | 4 +-
external/bsd/pkg_install/dist/info/perform.c | 8 +-
external/bsd/pkg_install/dist/lib/iterate.c | 141 +++++++++++++-
external/bsd/pkg_install/dist/lib/lib.h | 25 ++-
external/bsd/pkg_install/dist/lib/license.c | 3 +-
external/bsd/pkg_install/dist/lib/pkgdb.c | 24 +-
external/bsd/pkg_install/dist/lib/plist.c | 6 +-
external/bsd/pkg_install/dist/lib/version.h | 4 +-
external/bsd/pkg_install/dist/lib/vulnerabilities-file.c | 6 +-
14 files changed, 393 insertions(+), 104 deletions(-)
diffs (truncated from 914 to 300 lines):
diff -r c3326640d7f6 -r 67dc0c0371eb external/bsd/pkg_install/dist/add/perform.c
--- a/external/bsd/pkg_install/dist/add/perform.c Wed Dec 02 02:21:43 2020 +0000
+++ b/external/bsd/pkg_install/dist/add/perform.c Wed Dec 02 13:53:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perform.c,v 1.6 2018/03/25 04:04:36 sevan Exp $ */
+/* $NetBSD: perform.c,v 1.7 2020/12/02 13:53:50 wiz Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
#endif
@@ -6,7 +6,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-__RCSID("$NetBSD: perform.c,v 1.6 2018/03/25 04:04:36 sevan Exp $");
+__RCSID("$NetBSD: perform.c,v 1.7 2020/12/02 13:53:50 wiz Exp $");
/*-
* Copyright (c) 2003 Grant Beattie <grant%NetBSD.org@localhost>
@@ -450,7 +450,7 @@
return -1;
}
*iter = '\0';
- pkg->other_version = find_best_matching_installed_pkg(pkgbase);
+ pkg->other_version = find_best_matching_installed_pkg(pkgbase, 0);
free(pkgbase);
if (pkg->other_version == NULL)
return 0;
@@ -505,10 +505,12 @@
continue;
if (pkg_match(p->name, pkg->pkgname) == 1)
continue; /* Both match, ok. */
- warnx("Dependency of %s fulfilled by %s, but not by %s",
- iter, pkg->other_version, pkg->pkgname);
- if (!ForceDepending)
+ if (!ForceDepending) {
+ warnx("Dependency of %s fulfilled by %s, "
+ "but not by %s", iter, pkg->other_version,
+ pkg->pkgname);
status = -1;
+ }
break;
}
free_plist(&plist);
@@ -979,7 +981,8 @@
setenv(PKG_REFCOUNT_DBDIR_VNAME, config_pkg_refcount_dbdir, 1);
if (Verbose)
- printf("Running install with PRE-INSTALL for %s.\n", pkg->pkgname);
+ printf("Running install with %s for %s.\n", argument,
+ pkg->pkgname);
if (Fake)
return 0;
@@ -1102,6 +1105,40 @@
return status;
}
+/*
+ * Install a required dependency and verify its installation.
+ */
+static int
+install_depend_pkg(const char *dep)
+{
+ /* XXX check cyclic dependencies? */
+ if (Fake || NoRecord) {
+ if (!Force) {
+ warnx("Missing dependency %s\n", dep);
+ return 1;
+ }
+ warnx("Missing dependency %s, continuing", dep);
+ }
+
+ if (pkg_do(dep, 1, 0)) {
+ if (!ForceDepends) {
+ warnx("Can't install dependency %s", dep);
+ return 1;
+ }
+ warnx("Can't install dependency %s, continuing", dep);
+ }
+
+ if (find_best_matching_installed_pkg(dep, 0) == NULL) {
+ if (!ForceDepends) {
+ warnx("Just installed dependency %s disappeared", dep);
+ return 1;
+ }
+ warnx("Missing dependency %s ignored", dep);
+ }
+
+ return 0;
+}
+
static int
check_dependencies(struct pkg_task *pkg)
{
@@ -1112,6 +1149,9 @@
status = 0;
+ /*
+ * Recursively handle dependencies, installing as required.
+ */
for (p = pkg->plist.head; p != NULL; p = p->next) {
if (p->type == PLIST_IGNORE) {
p = p->next;
@@ -1119,43 +1159,27 @@
} else if (p->type != PLIST_PKGDEP)
continue;
- best_installed = find_best_matching_installed_pkg(p->name);
-
- if (best_installed == NULL) {
- /* XXX check cyclic dependencies? */
- if (Fake || NoRecord) {
- if (!Force) {
- warnx("Missing dependency %s\n",
- p->name);
- status = -1;
- break;
- }
- warnx("Missing dependency %s, continuing",
- p->name);
- continue;
- }
- if (pkg_do(p->name, 1, 0)) {
- if (ForceDepends) {
- warnx("Can't install dependency %s, "
- "continuing", p->name);
- continue;
- } else {
- warnx("Can't install dependency %s",
- p->name);
- status = -1;
- break;
- }
- }
- best_installed = find_best_matching_installed_pkg(p->name);
- if (best_installed == NULL && ForceDepends) {
- warnx("Missing dependency %s ignored", p->name);
- continue;
- } else if (best_installed == NULL) {
- warnx("Just installed dependency %s disappeared", p->name);
+ if (find_best_matching_installed_pkg(p->name, 0) == NULL) {
+ if (install_depend_pkg(p->name) != 0) {
status = -1;
break;
}
}
+ }
+
+ /*
+ * Now that all dependencies have been processed we can find the best
+ * matches for pkg_register_depends() to store in our +REQUIRED_BY.
+ */
+ for (p = pkg->plist.head; p != NULL; p = p->next) {
+ if (p->type == PLIST_IGNORE) {
+ p = p->next;
+ continue;
+ } else if (p->type != PLIST_PKGDEP)
+ continue;
+
+ best_installed = find_best_matching_installed_pkg(p->name, 0);
+
for (i = 0; i < pkg->dep_length; ++i) {
if (strcmp(best_installed, pkg->dependencies[i]) == 0)
break;
diff -r c3326640d7f6 -r 67dc0c0371eb external/bsd/pkg_install/dist/admin/check.c
--- a/external/bsd/pkg_install/dist/admin/check.c Wed Dec 02 02:21:43 2020 +0000
+++ b/external/bsd/pkg_install/dist/admin/check.c Wed Dec 02 13:53:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: check.c,v 1.3 2020/01/12 21:31:03 christos Exp $ */
+/* $NetBSD: check.c,v 1.4 2020/12/02 13:53:50 wiz Exp $ */
#ifdef HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
@@ -11,7 +11,7 @@
#include <sys/cdefs.h>
#endif
#endif
-__RCSID("$NetBSD: check.c,v 1.3 2020/01/12 21:31:03 christos Exp $");
+__RCSID("$NetBSD: check.c,v 1.4 2020/12/02 13:53:50 wiz Exp $");
/*-
* Copyright (c) 1999-2008 The NetBSD Foundation, Inc.
@@ -81,7 +81,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 c3326640d7f6 -r 67dc0c0371eb external/bsd/pkg_install/dist/admin/main.c
--- a/external/bsd/pkg_install/dist/admin/main.c Wed Dec 02 02:21:43 2020 +0000
+++ b/external/bsd/pkg_install/dist/admin/main.c Wed Dec 02 13:53:50 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.5 2020/01/12 21:31:03 christos Exp $ */
+/* $NetBSD: main.c,v 1.6 2020/12/02 13:53:50 wiz Exp $ */
#ifdef HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
@@ -11,7 +11,7 @@
#include <sys/cdefs.h>
#endif
#endif
-__RCSID("$NetBSD: main.c,v 1.5 2020/01/12 21:31:03 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.6 2020/12/02 13:53:50 wiz Exp $");
/*-
* Copyright (c) 1999-2019 The NetBSD Foundation, Inc.
@@ -94,6 +94,25 @@
size_t packages;
};
+/*
+ * A hashed list of +REQUIRED_BY entries.
+ */
+struct reqd_by_entry {
+ char *pkgname;
+ SLIST_ENTRY(reqd_by_entry) entries;
+};
+SLIST_HEAD(reqd_by_entry_head, reqd_by_entry);
+
+/*
+ * A hashed list of packages that contain +REQUIRED_BY entries.
+ */
+struct pkg_reqd_by {
+ char *pkgname;
+ struct reqd_by_entry_head required_by[PKG_HASH_SIZE];
+ SLIST_ENTRY(pkg_reqd_by) entries;
+};
+SLIST_HEAD(pkg_reqd_by_head, pkg_reqd_by);
+
static const char Options[] = "C:K:SVbd:qs:v";
int quiet, verbose;
@@ -284,37 +303,79 @@
}
static void
-add_required_by(const char *pattern, const char *required_by)
+add_required_by(const char *pattern, const char *pkgname, struct pkg_reqd_by_head *hash)
{
- char *best_installed, *path;
- int fd;
- size_t len;
+ struct pkg_reqd_by_head *phead;
+ struct pkg_reqd_by *pkg;
+ struct reqd_by_entry_head *ehead;
+ struct reqd_by_entry *entry;
+ char *best_installed;
+ int i;
- best_installed = find_best_matching_installed_pkg(pattern);
+ best_installed = find_best_matching_installed_pkg(pattern, 1);
if (best_installed == NULL) {
- warnx("Dependency %s of %s unresolved", pattern, required_by);
+ warnx("Dependency %s of %s unresolved", pattern, pkgname);
return;
}
- path = pkgdb_pkg_file(best_installed, REQUIRED_BY_FNAME);
- free(best_installed);
+ /*
+ * Find correct reqd_by head based on hash of best_installed, which is
+ * the package in question that we are adding +REQUIRED_BY entries for.
+ */
+ phead = &hash[PKG_HASH_ENTRY(best_installed)];
+
+ /*
+ * Look for an existing entry in this hash list.
+ */
+ SLIST_FOREACH(pkg, phead, entries) {
+ if (strcmp(pkg->pkgname, best_installed) == 0) {
+
+ /*
+ * Found an entry, now see if it already has a
+ * +REQUIRED_BY entry recorded for this pkgname,
+ * and if not then add it.
+ */
+ ehead = &pkg->required_by[PKG_HASH_ENTRY(pkgname)];
+ SLIST_FOREACH(entry, ehead, entries) {
+ if (strcmp(entry->pkgname, pkgname) == 0)
+ break;
+ }
- if ((fd = open(path, O_WRONLY | O_APPEND | O_CREAT, 0644)) == -1)
- errx(EXIT_FAILURE, "Cannot write to %s", path);
- free(path);
-
- len = strlen(required_by);
- if (write(fd, required_by, len) != (ssize_t)len ||
- write(fd, "\n", 1) != 1 ||
- close(fd) == -1)
- errx(EXIT_FAILURE, "Cannot write to %s", path);
+ if (entry == NULL) {
+ entry = xmalloc(sizeof(*entry));
+ entry->pkgname = xstrdup(pkgname);
+ SLIST_INSERT_HEAD(ehead, entry, entries);
+ }
Home |
Main Index |
Thread Index |
Old Index