pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/pkg_install/files/add



Module Name:    pkgsrc
Committed By:   wiz
Date:           Tue Feb 18 11:26:40 UTC 2025

Modified Files:
        pkgsrc/pkgtools/pkg_install/files/add: perform.c

Log Message:
pkg_install: prefix errors with the PKGNAME

To make it clearer which package caused problems, when recursively
installing more than one.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 pkgsrc/pkgtools/pkg_install/files/add/perform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkg_install/files/add/perform.c
diff -u pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.129 pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.130
--- pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.129       Mon Jan 13 11:16:19 2025
+++ pkgsrc/pkgtools/pkg_install/files/add/perform.c     Tue Feb 18 11:26:40 2025
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.129 2025/01/13 11:16:19 martin Exp $     */
+/*     $NetBSD: perform.c,v 1.130 2025/02/18 11:26:40 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.129 2025/01/13 11:16:19 martin Exp $");
+__RCSID("$NetBSD: perform.c,v 1.130 2025/02/18 11:26:40 wiz Exp $");
 
 /*-
  * Copyright (c) 2003 Grant Beattie <grant%NetBSD.org@localhost>
@@ -604,7 +604,7 @@ write_meta_data(struct pkg_task *pkg)
                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 @@ write_meta_data(struct pkg_task *pkg)
                (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 @@ write_meta_data(struct pkg_task *pkg)
                        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 @@ extract_files(struct pkg_task *pkg)
                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 @@ extract_files(struct pkg_task *pkg)
 #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 @@ extract_files(struct pkg_task *pkg)
                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 @@ extract_files(struct pkg_task *pkg)
                                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 @@ extract_files(struct pkg_task *pkg)
 
                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 @@ extract_files(struct pkg_task *pkg)
                        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 @@ extract_files(struct pkg_task *pkg)
        }
 
        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 @@ pkg_register_depends(struct pkg_task *pk
 
                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 @@ check_platform(struct pkg_task *pkg)
        } 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 @@ check_platform(struct pkg_task *pkg)
        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 @@ check_pkgtools_version(struct pkg_task *
        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 @@ run_install_script(struct pkg_task *pkg,
        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 @@ check_explicit_conflict_iter(const char 
        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 @@ check_explicit_conflict(struct pkg_task 
 
        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 @@ check_implicit_conflict(struct pkg_task 
 
        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 @@ check_implicit_conflict(struct pkg_task 
                    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 @@ check_requires(struct pkg_task *pkg)
                        }
 
                        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 @@ check_dependencies(struct pkg_task *pkg)
 
                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 @@ preserve_meta_data_file(struct pkg_task 
        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 @@ check_signature(struct pkg_task *pkg, in
                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 @@ check_license(struct pkg_task *pkg)
 
        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 @@ pkg_do(const char *pkgpath, int mark_aut
                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_do(const char *pkgpath, int mark_aut
                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 @@ pkg_do(const char *pkgpath, int mark_aut
 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 @@ nuke_pkgdb:
        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 @@ nuke_pkgdb:
 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