pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg_add: mention PKGNAME in warnings/errors [was Re: When to rebuild pbulk setup and how?]
On Fri, Jan 17, 2025 at 12:36:46PM +0530, Mayuresh wrote:
> I think it would help if pkg_add can tell which package it is raising an
> error about.
>
> openssl-3.4.0: copying /usr/pkg/share/examples/openssl/openssl.cnf to /usr/pkg/etc/openssl/openssl.cnf
> pkg_add: Missing required library: /usr/pkg/lib/libz.so.1
> gettext-lib-0.22.5: copying /usr/pkg/share/examples/gettext/locale.alias to /usr/pkg/share/locale/locale.alias
> xmlcatmgr-2.2nb1: copying /usr/pkg/share/examples/xmlcatmgr/catalog.etc.sgml to /usr/pkg/etc/sgml/catalog
> xmlcatmgr-2.2nb1: copying /usr/pkg/share/examples/xmlcatmgr/catalog.etc.xml to /usr/pkg/etc/xml/catalog
> xmlcatmgr-2.2nb1: copying /usr/pkg/share/examples/xmlcatmgr/catalog.share.sgml to /usr/pkg/share/sgml/catalog
> xmlcatmgr-2.2nb1: copying /usr/pkg/share/examples/xmlcatmgr/catalog.share.xml to /usr/pkg/share/xml/catalog
> pkg_add: 1 package addition failed
>
> This is a bulklog failure log for libimagequant.
>
> From the two pkg_add messages, wonder who is missing libz and whose
> addition failed.
I think that's a good idea.
I went over the warn() and warnx() calls in pkg_add and added a
package name (where available, which was most of the time). Patch
attached, please give it a try.
Thanks,
Thomas
Index: files/add/perform.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
retrieving revision 1.129
diff -u -r1.129 perform.c
--- files/add/perform.c 13 Jan 2025 11:16:19 -0000 1.129
+++ files/add/perform.c 24 Jan 2025 18:59:02 -0000
@@ -604,7 +604,7 @@
return 0;
if (mkdir_p(pkg->install_logdir)) {
- warn("Can't create pkgdb entry: %s", pkg->install_logdir);
+ warn("%s: can't create pkgdb entry: %s", pkg->pkgname, pkg->install_logdir);
return -1;
}
@@ -618,14 +618,14 @@
(void)unlink(filename);
fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, descr->perm);
if (fd == -1) {
- warn("Can't open meta data file: %s", filename);
+ warn("%s: can't open meta data file: %s", pkg->pkgname, filename);
return -1;
}
len = strlen(*target);
do {
ret = write(fd, *target, len);
if (ret == -1) {
- warn("Can't write meta data file: %s",
+ warn("%s: can't write meta data file: %s", pkg->pkgname,
filename);
free(filename);
close(fd);
@@ -634,7 +634,7 @@
len -= ret;
} while (ret > 0);
if (close(fd) == -1) {
- warn("Can't close meta data file: %s", filename);
+ warn("%s: can't close meta data file: %s", pkg->pkgname, filename);
free(filename);
return -1;
}
@@ -699,12 +699,12 @@
return 0;
if (mkdir_p(pkg->install_prefix)) {
- warn("Can't create prefix: %s", pkg->install_prefix);
+ warn("%s: can't create prefix: %s", pkg->pkgname, pkg->install_prefix);
return -1;
}
if (!NoRecord && !pkgdb_open(ReadWrite)) {
- warn("Can't open pkgdb for writing");
+ warn("%s: can't open pkgdb for writing", pkg->pkgname);
return -1;
}
@@ -713,12 +713,12 @@
#endif
workdir = open(".", O_RDONLY|O_CLOEXEC|O_DIRECTORY);
if (workdir == -1) {
- warn("Can't open current working directory");
+ warn("%s: can't open current working directory", pkg->pkgname);
return -1;
}
if (chdir(pkg->install_prefix) == -1) {
- warn("Can't change into prefix: %s", pkg->install_prefix);
+ warn("%s: can't change into prefix: %s", pkg->pkgname, pkg->install_prefix);
return -1;
}
@@ -738,12 +738,13 @@
case PLIST_FILE:
last_file = p->name;
if (pkg->entry == NULL) {
- warnx("PLIST entry not in package (%s)",
- archive_entry_pathname(pkg->entry));
+ warnx("%s: PLIST entry not in package (%s)",
+ pkg->pkgname, archive_entry_pathname(pkg->entry));
goto out;
}
if (strcmp(p->name, archive_entry_pathname(pkg->entry))) {
- warnx("PLIST entry and package don't match (%s vs %s)",
+ warnx("%s: PLIST entry and package don't match (%s "
+ "vs %s)", pkg->pkgname,
p->name, archive_entry_pathname(pkg->entry));
goto out;
}
@@ -766,7 +767,7 @@
return -1;
printf("Executing '%s'\n", cmd);
if (!Fake && system(cmd))
- warnx("command '%s' failed", cmd); /* XXX bail out? */
+ warnx("%s: command '%s' failed", pkg->pkgname, cmd); /* XXX bail out? */
continue;
case PLIST_CHMOD:
@@ -791,9 +792,9 @@
r = archive_write_header(writer, pkg->entry);
if (r != ARCHIVE_OK) {
- warnx("Failed to write %s for %s: %s",
- archive_entry_pathname(pkg->entry),
+ warnx("%s: failed to write %s: %s",
pkg->pkgname,
+ archive_entry_pathname(pkg->entry),
archive_error_string(writer));
goto out;
}
@@ -823,7 +824,7 @@
continue;
}
if (r != ARCHIVE_OK) {
- warnx("Failed to read from archive for %s: %s",
+ warnx("%s: failed to read from archive: %s",
pkg->pkgname,
archive_error_string(pkg->archive));
goto out;
@@ -831,7 +832,8 @@
}
if (pkg->entry != NULL) {
- warnx("Package contains entries not in PLIST: %s",
+ warnx("%s: package contains entries not in PLIST: %s",
+ pkg->pkgname,
archive_entry_pathname(pkg->entry));
goto out;
}
@@ -870,13 +872,13 @@
fd = open(required_by, O_WRONLY | O_APPEND | O_CREAT, 0644);
if (fd == -1) {
- warn("can't open dependency file '%s',"
- "registration is incomplete!", required_by);
+ warn("%s: can't open dependency file '%s',"
+ "registration is incomplete!", pkg->pkgname, required_by);
} else if (write(fd, text, text_len) != (ssize_t)text_len) {
- warn("can't write to dependency file `%s'", required_by);
+ warn("%s: can't write to dependency file `%s'", pkg->pkgname, required_by);
close(fd);
} else if (close(fd) == -1)
- warn("cannot close file %s", required_by);
+ warn("%s: cannot close file %s", pkg->pkgname, required_by);
free(required_by);
}
@@ -916,10 +918,10 @@
} else {
if (uname(&host_uname) < 0) {
if (Force) {
- warnx("uname() failed, continuing.");
+ warnx("%s: uname() failed, continuing", pkg->pkgname);
return 0;
} else {
- warnx("uname() failed, aborting.");
+ warnx("%s: uname() failed, aborting", pkg->pkgname);
return -1;
}
}
@@ -944,8 +946,8 @@
if (fatal ||
compatible_platform(effective_opsys, effective_os_version,
pkg->buildinfo[BI_OS_VERSION]) != 1) {
- warnx("%s: package `%s' was built for a platform:",
- !Force && fatal ? "Error" : "Warning", pkg->pkgname);
+ warnx("%s: %s: was built for a different platform:", pkg->pkgname,
+ !Force && fatal ? "error" : "warning");
warnx("%s/%s %s (pkg) vs. %s/%s %s (this host)",
pkg->buildinfo[BI_OPSYS],
pkg->buildinfo[BI_MACHINE_ARCH],
@@ -966,22 +968,21 @@
int version;
if (val == NULL) {
- warnx("Warning: package `%s' lacks pkg_install version data",
+ warnx("%s: warning: lacks pkg_install version data",
pkg->pkgname);
return 0;
}
if (strlen(val) != 8 || strspn(val, "0123456789") != 8) {
- warnx("%s:"
- " package `%s' contains an invalid pkg_install version",
- Force ? "Warning" : "Error", pkg->pkgname);
+ warnx("%s: %s: contains an invalid pkg_install version",
+ pkg->pkgname, Force ? "warning" : "error");
return Force ? 0 : -1;
}
version = atoi(val);
if (version > PKGTOOLS_VERSION) {
- warnx("%s:"
- " package `%s' was built with a newer pkg_install version",
- Force ? "Warning" : "Error", pkg->pkgname);
+ warnx("%s: %s:"
+ " was built with a newer pkg_install version",
+ pkg->pkgname, Force ? "warning" : "error");
return Force ? 0 : -1;
}
return 0;
@@ -1018,9 +1019,9 @@
if (fcexec(pkg->install_logdir, filename, pkg->pkgname, argument,
(void *)NULL)) {
if (errno != 0)
- warn("exec of install script failed");
+ warn("%s: exec of install script failed", pkg->pkgname);
else
- warnx("install script returned error status");
+ warnx("%s: install script returned error status", pkg->pkgname);
ret = -1;
}
free(filename);
@@ -1042,7 +1043,7 @@
if (data->old_pkg && strcmp(data->old_pkg, cur_pkg) == 0)
return 0;
- warnx("Package `%s' conflicts with `%s', and `%s' is installed.",
+ warnx("%s: conflicts with `%s', and `%s' is installed.",
data->pkg, data->pattern, cur_pkg);
return 1;
@@ -1074,8 +1075,8 @@
if (some_installed_package_conflicts_with(pkg->pkgname,
pkg->other_version, &installed, &installed_pattern)) {
- warnx("Installed package `%s' conflicts with `%s' when trying to install `%s'.",
- installed, installed_pattern, pkg->pkgname);
+ warnx("%s: Installed package `%s' conflicts with `%s' when trying to install `%s'.",
+ pkg->pkgname, installed, installed_pattern);
free(installed);
free(installed_pattern);
status |= -1;
@@ -1093,7 +1094,7 @@
if (!pkgdb_open(ReadOnly)) {
#if notyet /* XXX empty pkgdb without database? */
- warn("Can't open pkgdb for reading");
+ warn("%s: can't open pkgdb for reading", pkg->pkgname);
return -1;
#else
return 0;
@@ -1118,7 +1119,7 @@
strcmp(pkg->other_version, existing) == 0)
continue;
- warnx("Conflicting PLIST with %s: %s", existing, p->name);
+ warnx("%s: conflicting PLIST with %s: %s", pkg->pkgname, existing, p->name);
if (!Force) {
status = -1;
if (!Verbose)
@@ -1165,7 +1166,7 @@
}
if (!found) {
- warnx("Missing required library: %s", libpath);
+ warnx("%s: missing required library: %s", pkg->pkgname, libpath);
#ifdef __NetBSD__
if (strncmp(libpath, "/usr/X11R7", 10) == 0) {
warnx("Please make sure to install the X sets");
@@ -1255,7 +1256,7 @@
best_installed = find_best_matching_installed_pkg(p->name, 0);
if (best_installed == NULL) {
- warnx("Expected dependency %s still missing", p->name);
+ warnx("%s: expected dependency %s still missing", pkg->pkgname, p->name);
return -1;
}
@@ -1293,8 +1294,8 @@
new_file = xasprintf("%s/%s", pkg->install_logdir, name);
rv = 0;
if (rename(old_file, new_file) == -1 && errno != ENOENT) {
- warn("Can't move %s from %s to %s", name, old_file, new_file);
- rv = -1;
+ warn("%s: can't move %s from %s to %s", pkg->pkgname, name, old_file, new_file);
+ rv = -1;
}
free(old_file);
free(new_file);
@@ -1366,7 +1367,7 @@
return 0;
if (strcasecmp(verified_installation, "always") == 0) {
if (invalid_sig)
- warnx("No valid signature found, rejected");
+ warnx("%s: no valid signature found, rejected", pkg->pkgname);
return invalid_sig;
}
if (strcasecmp(verified_installation, "trusted") == 0) {
@@ -1456,22 +1457,22 @@
if ((pkg->buildinfo[BI_LICENSE] == NULL ||
*pkg->buildinfo[BI_LICENSE] == '\0')) {
-
+
if (LicenseCheck == 1)
return 0;
- warnx("No LICENSE set for package `%s'", pkg->pkgname);
+ warnx("%s: no LICENSE set", pkg->pkgname);
return 1;
}
switch (acceptable_license(pkg->buildinfo[BI_LICENSE])) {
case 0:
- warnx("License `%s' of package `%s' is not acceptable",
- pkg->buildinfo[BI_LICENSE], pkg->pkgname);
+ warnx("%s: license `%s' is not acceptable",
+ pkg->pkgname, pkg->buildinfo[BI_LICENSE]);
return 1;
case 1:
return 0;
default:
- warnx("Invalid LICENSE for package `%s'", pkg->pkgname);
+ warnx("%s: invalid LICENSE", pkg->pkgname);
return 1;
}
#endif
@@ -1531,7 +1532,7 @@
goto clean_memory;
if (pkg->meta_data.meta_mtree != NULL)
- warnx("mtree specification in pkg `%s' ignored", pkg->pkgname);
+ warnx("%s: mtree specification ignored", pkg->pkgname);
pkg->logdir = xasprintf("%s/%s", config_pkg_dbdir, pkg->pkgname);
@@ -1551,7 +1552,7 @@
pkg->install_logdir = xasprintf("%s/pkg_install.XXXXXX", tmpdir);
/* XXX pkg_add -u... */
if (mkdtemp(pkg->install_logdir) == NULL) {
- warn("mkdtemp failed");
+ warn("%s: mkdtemp failed", pkg->pkgname);
goto clean_memory;
}
}
@@ -1646,8 +1647,8 @@
nuke_pkg:
if (!Fake) {
if (pkg->other_version) {
- warnx("Updating of %s to %s failed.",
- pkg->other_version, pkg->pkgname);
+ warnx("%s: updating from %s to %s failed.",
+ pkg->pkgname, pkg->other_version, pkg->pkgname);
warnx("Remember to run pkg_admin rebuild-tree after fixing this.");
}
delete_package(FALSE, &pkg->plist, FALSE, Destdir);
@@ -1657,7 +1658,7 @@
if (!Fake) {
(void) remove_files(pkg->install_logdir, "+*");
if (recursive_remove(pkg->install_logdir, 1))
- warn("Couldn't remove %s", pkg->install_logdir);
+ warn("%s: couldn't remove %s", pkg->pkgname, pkg->install_logdir);
free(pkg->install_logdir_real);
free(pkg->install_logdir);
free(pkg->logdir);
@@ -1669,7 +1670,7 @@
clean_memory:
if (pkg->logdir != NULL && NoRecord && !Fake) {
if (recursive_remove(pkg->install_logdir, 1))
- warn("Couldn't remove %s", pkg->install_logdir);
+ warn("%s: couldn't remove %s", pkg->pkgname, pkg->install_logdir);
}
free(pkg->install_prefix);
free(pkg->install_logdir_real);
Home |
Main Index |
Thread Index |
Old Index