pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files pkg_install-20100220:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/fd6000a7838d
branches:  trunk
changeset: 572112:fd6000a7838d
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Sat Feb 20 04:40:03 2010 +0000

description:
pkg_install-20100220:
Try harder to give the user an idea which file failed.
Addresses PR 42223.

diffstat:

 pkgtools/pkg_install/files/add/perform.c       |  16 +++++++----
 pkgtools/pkg_install/files/admin/main.c        |  11 +++++--
 pkgtools/pkg_install/files/info/perform.c      |  10 +++---
 pkgtools/pkg_install/files/lib/lib.h           |  10 +++---
 pkgtools/pkg_install/files/lib/pkg_io.c        |  23 +++++++++++-----
 pkgtools/pkg_install/files/lib/pkg_signature.c |  35 ++++++++++++++-----------
 pkgtools/pkg_install/files/lib/version.h       |   4 +-
 7 files changed, 63 insertions(+), 46 deletions(-)

diffs (truncated from 406 to 300 lines):

diff -r b3d478d29831 -r fd6000a7838d pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Sat Feb 20 03:57:11 2010 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Sat Feb 20 04:40:03 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.94 2010/02/03 14:20:14 joerg Exp $       */
+/*     $NetBSD: perform.c,v 1.95 2010/02/20 04:40:03 joerg 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.94 2010/02/03 14:20:14 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.95 2010/02/20 04:40:03 joerg Exp $");
 
 /*-
  * Copyright (c) 2003 Grant Beattie <grant%NetBSD.org@localhost>
@@ -729,8 +729,9 @@
 
                r = archive_write_header(writer, pkg->entry);
                if (r != ARCHIVE_OK) {
-                       warnx("Failed to write %s: %s",
+                       warnx("Failed to write %s for %s: %s",
                            archive_entry_pathname(pkg->entry),
+                           pkg->pkgname,
                            archive_error_string(writer));
                        goto out;
                }
@@ -760,7 +761,8 @@
                        continue;
                }
                if (r != ARCHIVE_OK) {
-                       warnx("Failed to read from archive: %s",
+                       warnx("Failed to read from archive for %s: %s",
+                           pkg->pkgname,
                            archive_error_string(pkg->archive));
                        goto out;
                }
@@ -1334,6 +1336,7 @@
 static int
 pkg_do(const char *pkgpath, int mark_automatic, int top_level)
 {
+       char *archive_name;
        int status, invalid_sig;
        struct pkg_task *pkg;
 
@@ -1341,14 +1344,15 @@
 
        status = -1;
 
-       pkg->archive = find_archive(pkgpath, top_level);
+       pkg->archive = find_archive(pkgpath, top_level, &archive_name);
        if (pkg->archive == NULL) {
                warnx("no pkg found for '%s', sorry.", pkgpath);
                goto clean_find_archive;
        }
 
-       invalid_sig = pkg_verify_signature(&pkg->archive, &pkg->entry,
+       invalid_sig = pkg_verify_signature(archive_name, &pkg->archive, &pkg->entry,
            &pkg->pkgname);
+       free(archive_name);
 
        if (pkg->archive == NULL)
                goto clean_memory;
diff -r b3d478d29831 -r fd6000a7838d pkgtools/pkg_install/files/admin/main.c
--- a/pkgtools/pkg_install/files/admin/main.c   Sat Feb 20 03:57:11 2010 +0000
+++ b/pkgtools/pkg_install/files/admin/main.c   Sat Feb 20 04:40:03 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.59 2010/01/22 13:30:41 joerg Exp $  */
+/*     $NetBSD: main.c,v 1.60 2010/02/20 04:40:03 joerg Exp $  */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -7,7 +7,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: main.c,v 1.59 2010/01/22 13:30:41 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.60 2010/02/20 04:40:03 joerg Exp $");
 
 /*-
  * Copyright (c) 1999-2009 The NetBSD Foundation, Inc.
@@ -614,13 +614,16 @@
 
                rc = 0;
                for (--argc, ++argv; argc > 0; --argc, ++argv) {
-                       pkg = open_archive(*argv);
+                       char *archive_name;
+
+                       pkg = open_archive(*argv, &archive_name);
                        if (pkg == NULL) {
                                warnx("%s could not be opened", *argv);
                                continue;
                        }
-                       if (pkg_full_signature_check(&pkg))
+                       if (pkg_full_signature_check(archive_name, &pkg))
                                rc = 1;
+                       free(archive_name);
                        if (!pkg)
                                archive_read_finish(pkg);
                }
diff -r b3d478d29831 -r fd6000a7838d pkgtools/pkg_install/files/info/perform.c
--- a/pkgtools/pkg_install/files/info/perform.c Sat Feb 20 03:57:11 2010 +0000
+++ b/pkgtools/pkg_install/files/info/perform.c Sat Feb 20 04:40:03 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.60 2010/01/22 13:30:42 joerg Exp $       */
+/*     $NetBSD: perform.c,v 1.61 2010/02/20 04:40:03 joerg Exp $       */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -13,7 +13,7 @@
 #if HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif
-__RCSID("$NetBSD: perform.c,v 1.60 2010/01/22 13:30:42 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.61 2010/02/20 04:40:03 joerg Exp $");
 
 /*-
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -346,16 +346,16 @@
 #else
                struct archive *archive;
                struct archive_entry *entry;
-               char *pkgname;
+               char *archive_name, *pkgname;
 
-               archive = open_archive(pkg);
+               archive = open_archive(pkg, &archive_name);
                if (archive == NULL) {
                        warnx("can't find package `%s', skipped", pkg);
                        return -1;
                }
                pkgname = NULL;
                entry = NULL;
-               pkg_verify_signature(&archive, &entry, &pkgname);
+               pkg_verify_signature(archive_name, &archive, &entry, &pkgname);
                if (archive == NULL)
                        return -1;
                free(pkgname);
diff -r b3d478d29831 -r fd6000a7838d pkgtools/pkg_install/files/lib/lib.h
--- a/pkgtools/pkg_install/files/lib/lib.h      Sat Feb 20 03:57:11 2010 +0000
+++ b/pkgtools/pkg_install/files/lib/lib.h      Sat Feb 20 04:40:03 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.61 2010/02/03 19:28:30 joerg Exp $ */
+/* $NetBSD: lib.h,v 1.62 2010/02/20 04:40:03 joerg Exp $ */
 
 /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
 
@@ -322,8 +322,8 @@
 struct archive;
 struct archive_entry;
 
-struct archive *open_archive(const char *);
-struct archive *find_archive(const char *, int);
+struct archive *open_archive(const char *, char **);
+struct archive *find_archive(const char *, int, char **);
 void   process_pkg_path(void);
 struct url *find_best_package(const char *, const char *, int);
 
@@ -391,8 +391,8 @@
 void pkg_install_show_variable(const char *);
 
 /* Package signature creation and validation */
-int pkg_verify_signature(struct archive **, struct archive_entry **, char **);
-int pkg_full_signature_check(struct archive **);
+int pkg_verify_signature(const char *, struct archive **, struct archive_entry **, char **);
+int pkg_full_signature_check(const char *, struct archive **);
 #ifdef HAVE_SSL
 void pkg_sign_x509(const char *, const char *, const char *, const char *);
 #endif
diff -r b3d478d29831 -r fd6000a7838d pkgtools/pkg_install/files/lib/pkg_io.c
--- a/pkgtools/pkg_install/files/lib/pkg_io.c   Sat Feb 20 03:57:11 2010 +0000
+++ b/pkgtools/pkg_install/files/lib/pkg_io.c   Sat Feb 20 04:40:03 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pkg_io.c,v 1.9 2009/08/16 21:10:15 joerg Exp $ */
+/*     $NetBSD: pkg_io.c,v 1.10 2010/02/20 04:40:03 joerg Exp $        */
 /*-
  * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
  * All rights reserved.
@@ -36,7 +36,7 @@
 #include <sys/cdefs.h>
 #endif
 
-__RCSID("$NetBSD: pkg_io.c,v 1.9 2009/08/16 21:10:15 joerg Exp $");
+__RCSID("$NetBSD: pkg_io.c,v 1.10 2010/02/20 04:40:03 joerg Exp $");
 
 #include <archive.h>
 #include <archive_entry.h>
@@ -98,7 +98,7 @@
 }
 
 static struct archive *
-open_archive_by_url(struct url *url)
+open_archive_by_url(struct url *url, char **archive_name)
 {
        struct fetch_archive *f;
        struct archive *a;
@@ -106,11 +106,15 @@
        f = xmalloc(sizeof(*f));
        f->url = url;
 
+       *archive_name = fetchStringifyURL(url);
+
        a = archive_read_new();
        archive_read_support_compression_all(a);
        archive_read_support_format_all(a);
        if (archive_read_open(a, f, fetch_archive_open, fetch_archive_read,
            fetch_archive_close)) {
+               free(*archive_name);
+               *archive_name = NULL;
                archive_read_finish(a);
                return NULL;
        }
@@ -119,11 +123,13 @@
 }
 
 struct archive *
-open_archive(const char *url)
+open_archive(const char *url, char **archive_name)
 {
        struct url *u;
        struct archive *a;
 
+       *archive_name = NULL;
+
        if (!IS_URL(url)) {
                a = archive_read_new();
                archive_read_support_compression_all(a);
@@ -132,13 +138,14 @@
                        archive_read_close(a);
                        return NULL;
                }
+               *archive_name = xstrdup(url);
                return a;
        }
 
        if ((u = fetchParseURL(url)) == NULL)
                return NULL;
 
-       a = open_archive_by_url(u);
+       a = open_archive_by_url(u, archive_name);
 
        fetchFreeURL(u);
        return a;
@@ -291,7 +298,7 @@
 }
 
 struct archive *
-find_archive(const char *fname, int top_level)
+find_archive(const char *fname, int top_level, char **archive_name)
 {
        struct archive *a;
        struct url *best_match;
@@ -315,7 +322,7 @@
                *last_slash = '/';
        }
 
-       a = open_archive(full_fname);
+       a = open_archive(full_fname, archive_name);
        if (a != NULL) {
                free(full_fname);
                return a;
@@ -333,7 +340,7 @@
 
        if (best_match == NULL)
                return NULL;
-       a = open_archive_by_url(best_match);
+       a = open_archive_by_url(best_match, archive_name);
        fetchFreeURL(best_match);
        return a;
 }
diff -r b3d478d29831 -r fd6000a7838d pkgtools/pkg_install/files/lib/pkg_signature.c
--- a/pkgtools/pkg_install/files/lib/pkg_signature.c    Sat Feb 20 03:57:11 2010 +0000
+++ b/pkgtools/pkg_install/files/lib/pkg_signature.c    Sat Feb 20 04:40:03 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pkg_signature.c,v 1.9 2009/08/02 17:56:45 joerg Exp $  */
+/*     $NetBSD: pkg_signature.c,v 1.10 2010/02/20 04:40:03 joerg Exp $ */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -7,7 +7,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: pkg_signature.c,v 1.9 2009/08/02 17:56:45 joerg Exp $");
+__RCSID("$NetBSD: pkg_signature.c,v 1.10 2010/02/20 04:40:03 joerg Exp $");
 
 /*-
  * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
@@ -165,7 +165,8 @@
 }
 
 static int
-read_file_from_archive(struct archive *archive, struct archive_entry **entry,
+read_file_from_archive(const char *archive_name, struct archive *archive,
+    struct archive_entry **entry,
     const char *fname, char **content, size_t *len)
 {
        int r;



Home | Main Index | Thread Index | Old Index