summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_install/files/info
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2009-02-02 12:34:59 +0000
committerjoerg <joerg@pkgsrc.org>2009-02-02 12:34:59 +0000
commitd7cc6db11bfefd0006364a122a40572d9eb9b739 (patch)
tree4c0fb6728ab9db1b5dc2233bb02e4ef34022a604 /pkgtools/pkg_install/files/info
parentea71974691a75ab2e2b9c62a6fb9dcc136b266de (diff)
downloadpkgsrc-d7cc6db11bfefd0006364a122a40572d9eb9b739.tar.gz
Merge pkg_install-20090201 from pkg_install-renovation branch.
- DB support is always included from libnbcompat if needed - pkg_view and linkfarm are not installed any more; they are not moved into the attic yet, so they can easily be installed as separte package - common configuration file to customise the behavior of various components; this supersedes the old audit-packages.conf - support for PKSC7 signatures (using X509 certs) and GPG signatures for packages in a secure way. See pkg_admin(8) for how to create them and pkg_install.conf(5) for the options to use them - audit-packages and download-vulnerability-list are wrapper scripts around pkg_admin. They try to mimic the classic options if used sanely. "pkg_admin audit" is now an order of magnitude faster than before - pkg_add uses libarchive and libfetch instead of external ftp and tar: - progress bar is currently missing for downloads - "pkg_add -" is no longer supported - no adhoc check for conficts between dependencies and already installed packages - "pkg_add -s" has been replaced with an option in pkg_install.conf, verification of plain detached GPG signatures is no longer supported - optional check for vulnerabilities before adding a package - if /var and /usr/pkg are on different fileystems it is twice as fast now - conflicts due to overlapping plists are checked before installation - pkg_add no longer plays with the process limits - pkg_add and pkg_delete have a new destdir option; scripts have to either be modified to use PKG_DESTDIR or should be disabled - pkg_add -u for now can't be used to update to the exact same version - internal "rm -rf" and "mkdir_p" code - all memory allocation failures are not explicitly fatal - if a file is not removed due to a failed checksum, still remove the entry from pkgdb
Diffstat (limited to 'pkgtools/pkg_install/files/info')
-rw-r--r--pkgtools/pkg_install/files/info/Makefile.in4
-rw-r--r--pkgtools/pkg_install/files/info/main.c16
-rw-r--r--pkgtools/pkg_install/files/info/perform.c94
-rw-r--r--pkgtools/pkg_install/files/info/show.c10
4 files changed, 52 insertions, 72 deletions
diff --git a/pkgtools/pkg_install/files/info/Makefile.in b/pkgtools/pkg_install/files/info/Makefile.in
index 967ead0f550..e2f1d4a4733 100644
--- a/pkgtools/pkg_install/files/info/Makefile.in
+++ b/pkgtools/pkg_install/files/info/Makefile.in
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.16 2008/04/26 17:40:01 joerg Exp $
+# $NetBSD: Makefile.in,v 1.17 2009/02/02 12:35:01 joerg Exp $
srcdir= @srcdir@
@@ -16,7 +16,7 @@ BOOTSTRAP= @bootstrap@
CC= @CC@
CCLD= $(CC)
.if empty(BOOTSTRAP)
-LIBS= -linstall -larchive -lbz2 -lfetch -lz @LIBS@
+LIBS= -linstall -larchive -lfetch -lbz2 -lz @LIBS@
CPPFLAGS= @CPPFLAGS@ -I. -I$(srcdir) -I../lib
.else
LIBS= -linstall @LIBS@
diff --git a/pkgtools/pkg_install/files/info/main.c b/pkgtools/pkg_install/files/info/main.c
index b6a17261a13..88376fa2b54 100644
--- a/pkgtools/pkg_install/files/info/main.c
+++ b/pkgtools/pkg_install/files/info/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.22 2007/11/05 09:39:38 joerg Exp $ */
+/* $NetBSD: main.c,v 1.23 2009/02/02 12:35:01 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -7,13 +7,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-#ifndef lint
-#if 0
-static char *rcsid = "from FreeBSD Id: main.c,v 1.14 1997/10/08 07:47:26 charnier Exp";
-#else
-__RCSID("$NetBSD: main.c,v 1.22 2007/11/05 09:39:38 joerg Exp $");
-#endif
-#endif
+__RCSID("$NetBSD: main.c,v 1.23 2009/02/02 12:35:01 joerg Exp $");
/*
*
@@ -271,11 +265,9 @@ main(int argc, char **argv)
s = pkgdb_retrieve(CheckPkg);
- if (s) {
- CheckPkg = strdup(s);
- } else {
+ if (s == NULL)
errx(EXIT_FAILURE, "No matching pkg for %s.", CheckPkg);
- }
+ CheckPkg = xstrdup(s);
pkgdb_close();
}
diff --git a/pkgtools/pkg_install/files/info/perform.c b/pkgtools/pkg_install/files/info/perform.c
index cdf4b563f6b..a64c3f807b3 100644
--- a/pkgtools/pkg_install/files/info/perform.c
+++ b/pkgtools/pkg_install/files/info/perform.c
@@ -1,4 +1,4 @@
-/* $NetBSD: perform.c,v 1.48 2008/04/26 17:40:01 joerg Exp $ */
+/* $NetBSD: perform.c,v 1.49 2009/02/02 12:35:01 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -13,13 +13,7 @@
#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.48 2008/04/26 17:40:01 joerg Exp $");
-#endif
-#endif
+__RCSID("$NetBSD: perform.c,v 1.49 2009/02/02 12:35:01 joerg Exp $");
/*-
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -126,7 +120,7 @@ static const struct pkg_meta_desc {
int entry_mask;
int required_file;
} pkg_meta_descriptors[] = {
- { offsetof(struct pkg_meta, meta_contents), CONTENTS_FNAME ,
+ { offsetof(struct pkg_meta, meta_contents), CONTENTS_FNAME,
LOAD_CONTENTS, 1},
{ offsetof(struct pkg_meta, meta_comment), COMMENT_FNAME,
LOAD_COMMENT, 1 },
@@ -174,10 +168,10 @@ free_pkg_meta(struct pkg_meta *meta)
#ifndef BOOTSTRAP
static struct pkg_meta *
-read_meta_data_from_archive(struct archive *archive)
+read_meta_data_from_archive(struct archive *archive,
+ struct archive_entry *entry)
{
struct pkg_meta *meta;
- struct archive_entry *entry;
const char *fname;
const struct pkg_meta_desc *descr, *last_descr;
char **target;
@@ -186,13 +180,14 @@ read_meta_data_from_archive(struct archive *archive)
found_required = 0;
- if ((meta = malloc(sizeof(*meta))) == NULL)
- err(2, "cannot allocate meta data header");
-
- memset(meta, 0, sizeof(*meta));
+ meta = xcalloc(1, sizeof(*meta));
last_descr = 0;
+ if (entry != NULL)
+ goto has_entry;
+
while ((r = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) {
+has_entry:
fname = archive_entry_pathname(entry);
for (descr = pkg_meta_descriptors; descr->entry_filename;
@@ -223,8 +218,7 @@ read_meta_data_from_archive(struct archive *archive)
size = archive_entry_size(entry);
if (size > SSIZE_MAX - 1)
errx(2, "package meta data too large to process");
- if ((*target = malloc(size + 1)) == NULL)
- err(2, "cannot allocate meta data");
+ *target = xmalloc(size + 1);
if (archive_read_data(archive, *target, size) != size)
errx(2, "cannot read package meta data");
(*target)[size] = '\0';
@@ -236,7 +230,7 @@ read_meta_data_from_archive(struct archive *archive)
}
if (found_required != 0) {
free_pkg_meta(meta);
- return NULL;
+ meta = NULL;
}
archive_read_finish(archive);
@@ -255,10 +249,7 @@ read_meta_data_from_pkgdb(const char *pkg)
int fd;
struct stat st;
- if ((meta = malloc(sizeof(*meta))) == NULL)
- err(2, "cannot allocate meta data header");
-
- memset(meta, 0, sizeof(*meta));
+ meta = xcalloc(1, sizeof(*meta));
for (descr = pkg_meta_descriptors; descr->entry_filename; ++descr) {
if ((descr->entry_mask & desired_meta_data) == 0)
@@ -281,8 +272,7 @@ read_meta_data_from_pkgdb(const char *pkg)
errx(1, "meta data is not regular file");
if (st.st_size > SSIZE_MAX - 1)
err(2, "meta data file too large to process");
- if ((*target = malloc(st.st_size + 1)) == NULL)
- err(2, "cannot allocate meta data");
+ *target = xmalloc(st.st_size + 1);
if (read(fd, *target, st.st_size) != st.st_size)
err(2, "cannot read meta data");
(*target)[st.st_size] = '\0';
@@ -302,30 +292,38 @@ pkg_do(const char *pkg)
int code = 0;
const char *binpkgfile = NULL;
- if (IS_URL(pkg)) {
-#ifdef BOOTSTRAP
- errx(2, "Remote access not supported during bootstrap");
-#else
- struct archive *archive;
- void *remote_archive_cookie;
-
- archive = open_remote_archive(pkg, &remote_archive_cookie);
-
- meta = read_meta_data_from_archive(archive);
- close_remote_archive(remote_archive_cookie);
-#endif
- } else if (fexists(pkg) && isfile(pkg)) {
+ if (IS_URL(pkg) || (fexists(pkg) && isfile(pkg))) {
#ifdef BOOTSTRAP
errx(2, "Binary packages not supported during bootstrap");
#else
struct archive *archive;
- void *remote_archive_cookie;
-
- archive = open_local_archive(pkg, &remote_archive_cookie);
-
- meta = read_meta_data_from_archive(archive);
- close_local_archive(remote_archive_cookie);
- binpkgfile = pkg;
+ void *archive_cookie;
+# ifdef HAVE_SSL
+ void *signature_cookie;
+# endif
+ struct archive_entry *entry;
+ char *pkgname;
+
+ archive = open_archive(pkg, &archive_cookie);
+ if (archive == NULL) {
+ warnx("can't find package `%s', skipped", pkg);
+ return -1;
+ }
+ pkgname = NULL;
+ entry = NULL;
+# ifdef HAVE_SSL
+ pkg_verify_signature(&archive, &entry, &pkgname,
+ &signature_cookie);
+# endif
+ free(pkgname);
+
+ meta = read_meta_data_from_archive(archive, entry);
+ close_archive(archive_cookie);
+# ifdef HAVE_SSL
+ pkg_free_signature(signature_cookie);
+# endif
+ if (!IS_URL(pkg))
+ binpkgfile = pkg;
#endif
} else {
/*
@@ -373,7 +371,6 @@ pkg_do(const char *pkg)
package_t plist;
/* Read the contents list */
- plist.head = plist.tail = NULL;
parse_plist(&plist, meta->meta_contents);
/* Start showing the package contents */
@@ -500,8 +497,7 @@ CheckForPkg(const char *pkgname)
if (arg.got_match == 0 && !ispkgpattern(pkgname)) {
char *pattern;
- if (asprintf(&pattern, "%s-[0-9]*", pkgname) == -1)
- errx(EXIT_FAILURE, "asprintf failed");
+ pattern = xasprintf("%s-[0-9]*", pkgname);
arg.pattern = pattern;
arg.got_match = 0;
@@ -536,9 +532,7 @@ CheckForBestPkg(const char *pkgname)
if (ispkgpattern(pkgname))
return 1;
- if (asprintf(&pattern, "%s-[0-9]*", pkgname) == -1)
- errx(EXIT_FAILURE, "asprintf failed");
-
+ pattern = xasprintf("%s-[0-9]*", pkgname);
best_match = find_best_matching_installed_pkg(pattern);
free(pattern);
}
diff --git a/pkgtools/pkg_install/files/info/show.c b/pkgtools/pkg_install/files/info/show.c
index c2591554edd..b95cee60b1b 100644
--- a/pkgtools/pkg_install/files/info/show.c
+++ b/pkgtools/pkg_install/files/info/show.c
@@ -1,4 +1,4 @@
-/* $NetBSD: show.c,v 1.22 2008/04/29 05:46:08 martin Exp $ */
+/* $NetBSD: show.c,v 1.23 2009/02/02 12:35:01 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -7,13 +7,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-#ifndef lint
-#if 0
-static const char *rcsid = "from FreeBSD Id: show.c,v 1.11 1997/10/08 07:47:38 charnier Exp";
-#else
-__RCSID("$NetBSD: show.c,v 1.22 2008/04/29 05:46:08 martin Exp $");
-#endif
-#endif
+__RCSID("$NetBSD: show.c,v 1.23 2009/02/02 12:35:01 joerg Exp $");
/*
* FreeBSD install - a package for the installation and maintainance