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-20080202:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/933f24f87464
branches:  trunk
changeset: 538225:933f24f87464
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Sat Feb 02 16:21:45 2008 +0000

description:
pkg_install-20080202:
Convert pkg_info to use libarchive instead of tar for binary package
handling. As a side effect pkg_info on remote packages will use
one FTP instance per argument, but will try to fetch only the meta data.
This reduces time for pkg_info -X on a full binary repository from 36.9s
to 18.1s for the cache hot case (PKG_TMPDIR on tmpfs for the old
pkg_info). Thanks to tnn@ for testing.

diffstat:

 pkgtools/pkg_install/files/info/Makefile.in |   11 +-
 pkgtools/pkg_install/files/info/info.h      |   65 +++-
 pkgtools/pkg_install/files/info/perform.c   |  491 ++++++++++++++++++---------
 pkgtools/pkg_install/files/info/show.c      |  125 ++----
 pkgtools/pkg_install/files/lib/lib.h        |    5 +-
 pkgtools/pkg_install/files/lib/plist.c      |  139 ++++++-
 pkgtools/pkg_install/files/lib/var.c        |   81 +++-
 pkgtools/pkg_install/files/lib/version.h    |    4 +-
 8 files changed, 624 insertions(+), 297 deletions(-)

diffs (truncated from 1315 to 300 lines):

diff -r 569a0265966d -r 933f24f87464 pkgtools/pkg_install/files/info/Makefile.in
--- a/pkgtools/pkg_install/files/info/Makefile.in       Sat Feb 02 15:47:52 2008 +0000
+++ b/pkgtools/pkg_install/files/info/Makefile.in       Sat Feb 02 16:21:45 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.11 2007/07/16 09:57:58 joerg Exp $
+# $NetBSD: Makefile.in,v 1.12 2008/02/02 16:21:45 joerg Exp $
 
 srcdir=                @srcdir@
 
@@ -10,10 +10,17 @@
 man1dir=       $(mandir)/man1
 cat1dir=       $(mandir)/cat1
 
+BOOTSTRAP=     @bootstrap@
+
 CC=            @CC@
 CCLD=          $(CC)
+.if empty(BOOTSTRAP)
+LIBS=          -linstall -larchive -lbz2 -lz @LIBS@
+CPPFLAGS=      @CPPFLAGS@ -I. -I$(srcdir) -I../lib
+.else
 LIBS=          -linstall @LIBS@
-CPPFLAGS=      @CPPFLAGS@ -I. -I$(srcdir) -I../lib
+CPPFLAGS=      @CPPFLAGS@ -I. -I$(srcdir) -I../lib -DBOOTSTRAP
+.endif
 DEFS=          @DEFS@
 CFLAGS=                @CFLAGS@
 LDFLAGS=       @LDFLAGS@ -L../lib
diff -r 569a0265966d -r 933f24f87464 pkgtools/pkg_install/files/info/info.h
--- a/pkgtools/pkg_install/files/info/info.h    Sat Feb 02 15:47:52 2008 +0000
+++ b/pkgtools/pkg_install/files/info/info.h    Sat Feb 02 16:21:45 2008 +0000
@@ -1,7 +1,36 @@
-/* $NetBSD: info.h,v 1.16 2007/08/12 22:09:02 joerg Exp $ */
+/* $NetBSD: info.h,v 1.17 2008/02/02 16:21:45 joerg Exp $ */
 
 /* from FreeBSD Id: info.h,v 1.10 1997/02/22 16:09:40 peter Exp */
 
+/*-
+ * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
 /*
  * FreeBSD install - a package for the installation and maintainance
  * of non-core utilities.
@@ -25,6 +54,24 @@
 #ifndef _INST_INFO_H_INCLUDE
 #define _INST_INFO_H_INCLUDE
 
+struct pkg_meta {
+       char *meta_contents;
+       char *meta_comment;
+       char *meta_desc;
+       char *meta_mtree;
+       char *meta_build_version;
+       char *meta_build_info;
+       char *meta_size_pkg;
+       char *meta_size_all;
+       char *meta_required_by;
+       char *meta_display;
+       char *meta_install;
+       char *meta_deinstall;
+       char *meta_preserve;
+       char *meta_views;
+       char *meta_installed_info;
+};
+
 #ifndef MAXINDEXSIZE
 #define MAXINDEXSIZE 60
 #endif
@@ -73,14 +120,14 @@
 int CheckForPkg(const char *);
 int CheckForBestPkg(const char *);
 
-extern void show_file(const char *, const char *, const char *, Boolean);
-extern void show_var(const char *, const char *, const char *);
-extern void show_plist(const char *, package_t *, pl_ent_t);
-extern void show_files(const char *, package_t *);
-extern void show_depends(const char *, package_t *);
-extern void show_bld_depends(const char *, package_t *);
-extern void show_index(const char *, const char *, const char *);
-extern void show_summary(package_t *, const char *);
+void   show_file(const char *, const char *, Boolean);
+void   show_var(const char *, const char *);
+void   show_plist(const char *, package_t *, pl_ent_t);
+void   show_files(const char *, package_t *);
+void   show_depends(const char *, package_t *);
+void   show_bld_depends(const char *, package_t *);
+void   show_index(const char *, const char *);
+void   show_summary(struct pkg_meta *, package_t *, const char *);
 
 int     pkg_perform(lpkg_head_t *);
 
diff -r 569a0265966d -r 933f24f87464 pkgtools/pkg_install/files/info/perform.c
--- a/pkgtools/pkg_install/files/info/perform.c Sat Feb 02 15:47:52 2008 +0000
+++ b/pkgtools/pkg_install/files/info/perform.c Sat Feb 02 16:21:45 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.40 2007/08/12 22:09:02 joerg Exp $       */
+/*     $NetBSD: perform.c,v 1.41 2008/02/02 16:21:45 joerg Exp $       */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -10,14 +10,46 @@
 #if HAVE_SYS_QUEUE_H
 #include <sys/queue.h>
 #endif
+#if HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.40 2007/08/12 22:09:02 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.41 2008/02/02 16:21:45 joerg Exp $");
 #endif
 #endif
 
+/*-
+ * Copyright (c) 2008 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
 /*
  * FreeBSD install - a package for the installation and maintainance
  * of non-core utilities.
@@ -48,9 +80,16 @@
 #include <sys/stat.h>
 #endif
 
+#ifndef BOOTSTRAP
+#include <archive.h>
+#include <archive_entry.h>
+#endif
 #if HAVE_ERR_H
 #include <err.h>
 #endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
 #if HAVE_SIGNAL_H
 #include <signal.h>
 #endif
@@ -60,117 +99,242 @@
 #if HAVE_CTYPE_H
 #include <ctype.h>
 #endif
+#include <stddef.h>
 
-static char *Home;
+#define        LOAD_CONTENTS           (1 << 0)
+#define        LOAD_COMMENT            (1 << 1)
+#define        LOAD_DESC               (1 << 2)
+#define        LOAD_INSTALL            (1 << 3)
+#define        LOAD_DEINSTALL          (1 << 4)
+#define        LOAD_DISPLAY            (1 << 5)
+#define        LOAD_MTREE              (1 << 6)
+#define        LOAD_BUILD_VERSION      (1 << 7)
+#define        LOAD_BUILD_INFO         (1 << 8)
+#define        LOAD_SIZE_PKG           (1 << 9)
+#define        LOAD_SIZE_ALL           (1 << 10)
+#define        LOAD_PRESERVE           (1 << 11)
+#define        LOAD_VIEWS              (1 << 12)
+#define        LOAD_REQUIRED_BY        (1 << 13)
+#define        LOAD_INSTALLED_INFO     (1 << 14)
+
+static const struct pkg_meta_desc {
+       size_t entry_offset;
+       const char *entry_filename;
+       int entry_mask;
+} pkg_meta_descriptors[] = {
+       { offsetof(struct pkg_meta, meta_contents), CONTENTS_FNAME ,
+           LOAD_CONTENTS},
+       { offsetof(struct pkg_meta, meta_comment), COMMENT_FNAME,
+           LOAD_COMMENT },
+       { offsetof(struct pkg_meta, meta_desc), DESC_FNAME,
+           LOAD_DESC },
+       { offsetof(struct pkg_meta, meta_install), INSTALL_FNAME,
+           LOAD_INSTALL },
+       { offsetof(struct pkg_meta, meta_deinstall), DEINSTALL_FNAME,
+           LOAD_DEINSTALL },
+       { offsetof(struct pkg_meta, meta_display), DISPLAY_FNAME,
+           LOAD_DISPLAY },
+       { offsetof(struct pkg_meta, meta_mtree), MTREE_FNAME,
+           LOAD_MTREE },
+       { offsetof(struct pkg_meta, meta_build_version), BUILD_VERSION_FNAME,
+           LOAD_BUILD_VERSION },
+       { offsetof(struct pkg_meta, meta_build_info), BUILD_INFO_FNAME,
+           LOAD_BUILD_INFO },
+       { offsetof(struct pkg_meta, meta_size_pkg), SIZE_PKG_FNAME,
+           LOAD_SIZE_PKG },
+       { offsetof(struct pkg_meta, meta_size_all), SIZE_ALL_FNAME,
+           LOAD_SIZE_ALL },
+       { offsetof(struct pkg_meta, meta_preserve), PRESERVE_FNAME,
+           LOAD_PRESERVE },
+       { offsetof(struct pkg_meta, meta_views), VIEWS_FNAME,
+           LOAD_VIEWS },
+       { offsetof(struct pkg_meta, meta_required_by), REQUIRED_BY_FNAME,
+           LOAD_REQUIRED_BY },
+       { offsetof(struct pkg_meta, meta_installed_info), INSTALLED_INFO_FNAME,
+           LOAD_INSTALLED_INFO },
+       { 0, NULL, 0 },
+};
+
+static int desired_meta_data;
+
+static void
+free_pkg_meta(struct pkg_meta *meta)
+{
+       const struct pkg_meta_desc *descr;
+
+       for (descr = pkg_meta_descriptors; descr->entry_filename; ++descr)
+               free(*(char **)((char *)meta + descr->entry_offset));
+
+       free(meta);
+}
+
+static struct pkg_meta *
+read_meta_data_from_fd(int fd)
+{
+#ifdef BOOTSTRAP
+       err(2, "binary packages not supported during bootstrap");
+       return NULL;
+#else
+       struct archive *archive;
+       struct pkg_meta *meta;
+       struct archive_entry *entry;
+       const char *fname;
+       const struct pkg_meta_desc *descr, *last_descr;
+       char **target;
+       int64_t size;
+       int r;
+
+       archive = archive_read_new();
+       archive_read_support_compression_all(archive);
+       archive_read_support_format_all(archive);
+       if (archive_read_open_fd(archive, fd, 1024))
+               err(2, "cannot open archive: %s", archive_error_string(archive));
+
+       if ((meta = malloc(sizeof(*meta))) == NULL)
+               err(2, "cannot allocate meta data header");
+
+       memset(meta, 0, sizeof(*meta));
+
+       last_descr = 0;
+       while ((r = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) {
+               fname = archive_entry_pathname(entry);
+
+               for (descr = pkg_meta_descriptors; descr->entry_filename;
+                    ++descr) {
+                       if (strcmp(descr->entry_filename, fname) == 0)
+                               break;



Home | Main Index | Thread Index | Old Index