pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install pkg_install-20080404:
details: https://anonhg.NetBSD.org/pkgsrc/rev/8b7fc99b3bfc
branches: trunk
changeset: 540519:8b7fc99b3bfc
user: joerg <joerg%pkgsrc.org@localhost>
date: Fri Apr 04 15:21:32 2008 +0000
description:
pkg_install-20080404:
Switch pkg_info to use libfetch for remote access.
diffstat:
pkgtools/pkg_install/Makefile | 7 +-
pkgtools/pkg_install/files/info/Makefile.in | 4 +-
pkgtools/pkg_install/files/info/perform.c | 78 +++++----------
pkgtools/pkg_install/files/lib/Makefile.in | 4 +-
pkgtools/pkg_install/files/lib/lib.h | 10 +-
pkgtools/pkg_install/files/lib/pkg_io.c | 139 ++++++++++++++++++++++++++++
pkgtools/pkg_install/files/lib/version.h | 4 +-
7 files changed, 185 insertions(+), 61 deletions(-)
diffs (truncated from 396 to 300 lines):
diff -r 7ac6a952955a -r 8b7fc99b3bfc pkgtools/pkg_install/Makefile
--- a/pkgtools/pkg_install/Makefile Fri Apr 04 15:21:28 2008 +0000
+++ b/pkgtools/pkg_install/Makefile Fri Apr 04 15:21:32 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.149 2008/04/03 14:22:26 jlam Exp $
+# $NetBSD: Makefile,v 1.150 2008/04/04 15:21:32 joerg Exp $
# Notes to package maintainers:
#
@@ -105,6 +105,7 @@
FILESDIR.bzip2?= ${.CURDIR}/../../archivers/bzip2/files
FILESDIR.libarchive?= ${.CURDIR}/../../archivers/libarchive/files
FILESDIR.zlib?= ${.CURDIR}/../../devel/zlib/files
+FILESDIR.libfetch?= ${.CURDIR}/../../net/libfetch/files
.if empty(USE_BUILTIN.bzip2:M[yY][eE][sS])
CPPFLAGS+= -I${WRKDIR}/bzip2
@@ -118,6 +119,8 @@
CPPFLAGS+= -I${WRKDIR}/libarchive/libarchive
LDFLAGS+= -L${WRKDIR}/libarchive/.libs
.endif
+CPPFLAGS+= -I${WRKDIR}/libfetch
+LDFLAGS+= -L${WRKDIR}/libfetch
do-extract:
@${CP} -R ${FILESDIR} ${WRKSRC}
@@ -130,6 +133,7 @@
.if empty(USE_BUILTIN.libarchive:M[yY][eE][sS])
@${CP} -R ${FILESDIR.libarchive} ${WRKDIR}/libarchive
.endif
+ @${CP} -R ${FILESDIR.libfetch} ${WRKDIR}/libfetch
pre-configure:
.if empty(USE_BUILTIN.bzip2:M[yY][eE][sS])
@@ -146,6 +150,7 @@
--disable-dependency-tracking
cd ${WRKDIR}/libarchive && ${BUILD_MAKE_CMD}
.endif
+ cd ${WRKDIR}/libfetch && ${BUILD_MAKE_CMD}
# XXX Reverse the order that update does things since
# XXX we need pkg_delete built before we can deinstall.
diff -r 7ac6a952955a -r 8b7fc99b3bfc pkgtools/pkg_install/files/info/Makefile.in
--- a/pkgtools/pkg_install/files/info/Makefile.in Fri Apr 04 15:21:28 2008 +0000
+++ b/pkgtools/pkg_install/files/info/Makefile.in Fri Apr 04 15:21:32 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.13 2008/03/10 12:14:32 wiz Exp $
+# $NetBSD: Makefile.in,v 1.14 2008/04/04 15:21:32 joerg Exp $
srcdir= @srcdir@
@@ -16,7 +16,7 @@
CC= @CC@
CCLD= $(CC)
.if empty(BOOTSTRAP)
-LIBS= -linstall -larchive -lbz2 -lz @LIBS@
+LIBS= -linstall -larchive -lbz2 -lfetch -lz @LIBS@
CPPFLAGS= @CPPFLAGS@ -I. -I$(srcdir) -I../lib
.else
LIBS= -linstall @LIBS@
diff -r 7ac6a952955a -r 8b7fc99b3bfc pkgtools/pkg_install/files/info/perform.c
--- a/pkgtools/pkg_install/files/info/perform.c Fri Apr 04 15:21:28 2008 +0000
+++ b/pkgtools/pkg_install/files/info/perform.c Fri Apr 04 15:21:32 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perform.c,v 1.45 2008/03/09 18:03:46 joerg Exp $ */
+/* $NetBSD: perform.c,v 1.46 2008/04/04 15:21:32 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -17,7 +17,7 @@
#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.45 2008/03/09 18:03:46 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.46 2008/04/04 15:21:32 joerg Exp $");
#endif
#endif
@@ -172,14 +172,10 @@
free(meta);
}
+#ifndef BOOTSTRAP
static struct pkg_meta *
-read_meta_data_from_fd(int fd)
+read_meta_data_from_archive(struct archive *archive)
{
-#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;
@@ -190,12 +186,6 @@
found_required = 0;
- 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");
@@ -252,8 +242,8 @@
archive_read_finish(archive);
return meta;
+}
#endif
-}
static struct pkg_meta *
read_meta_data_from_pkgdb(const char *pkg)
@@ -304,21 +294,6 @@
static lfile_head_t files;
-static void
-fetch_child(int fd, const char *url)
-{
- close(STDOUT_FILENO);
- if (dup2(fd, STDOUT_FILENO) == -1) {
- static const char err_msg[] =
- "cannot redirect stdout of FTP process\n";
- write(STDERR_FILENO, err_msg, sizeof(err_msg) - 1);
- _exit(255);
- }
- close(fd);
- execlp(FTP_CMD, FTP_CMD, "-V", "-o", "-", url, (char *)NULL);
- _exit(255);
-}
-
static int
pkg_do(const char *pkg)
{
@@ -328,33 +303,30 @@
const char *binpkgfile = NULL;
if (IS_URL(pkg)) {
- pid_t child;
- int fd[2], status;
+#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);
- if (pipe(fd) == -1)
- err(EXIT_FAILURE, "cannot create input pipes");
- if (Verbose)
- fprintf(stderr, "ftp -V -o - %s\n", pkg);
- child = vfork();
- if (child == -1)
- err(EXIT_FAILURE, "cannot fork FTP process");
- if (child == 0) {
- close(fd[0]);
- fetch_child(fd[1], pkg);
- }
- close(fd[1]);
- meta = read_meta_data_from_fd(fd[0]);
- kill(child, SIGTERM);
- close(fd[0]);
- waitpid(child, &status, 0);
+ meta = read_meta_data_from_archive(archive);
+ close_remote_archive(remote_archive_cookie);
+#endif
} else if (fexists(pkg) && isfile(pkg)) {
- int pkg_fd;
+#ifdef BOOTSTRAP
+ errx(2, "Binary packages not supported during bootstrap");
+#else
+ struct archive *archive;
+ void *remote_archive_cookie;
- if ((pkg_fd = open(pkg, O_RDONLY, 0)) == -1)
- err(EXIT_FAILURE, "cannot open package %s", pkg);
- meta = read_meta_data_from_fd(pkg_fd);
- close(pkg_fd);
+ archive = open_local_archive(pkg, &remote_archive_cookie);
+
+ meta = read_meta_data_from_archive(archive);
+ close_local_archive(remote_archive_cookie);
binpkgfile = pkg;
+#endif
} else {
/*
* It's not an uninstalled package, try and find it among the
diff -r 7ac6a952955a -r 8b7fc99b3bfc pkgtools/pkg_install/files/lib/Makefile.in
--- a/pkgtools/pkg_install/files/lib/Makefile.in Fri Apr 04 15:21:28 2008 +0000
+++ b/pkgtools/pkg_install/files/lib/Makefile.in Fri Apr 04 15:21:32 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.19 2008/03/10 12:14:32 wiz Exp $
+# $NetBSD: Makefile.in,v 1.20 2008/04/04 15:21:32 joerg Exp $
srcdir= @srcdir@
@@ -29,7 +29,7 @@
OBJS= automatic.o conflicts.o decompress.o dewey.o fexec.o file.o \
ftpio.o global.o iterate.o lpkg.o opattern.o \
- path.o pen.o pexec.o pkgdb.o plist.o \
+ path.o pen.o pexec.o pkgdb.o pkg_io.o plist.o \
str.o var.o version.o vulnerabilities-file.o
.if !empty(BOOTSTRAP)
diff -r 7ac6a952955a -r 8b7fc99b3bfc pkgtools/pkg_install/files/lib/lib.h
--- a/pkgtools/pkg_install/files/lib/lib.h Fri Apr 04 15:21:28 2008 +0000
+++ b/pkgtools/pkg_install/files/lib/lib.h Fri Apr 04 15:21:32 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.40 2008/02/19 15:16:24 joerg Exp $ */
+/* $NetBSD: lib.h,v 1.41 2008/04/04 15:21:32 joerg Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@@ -385,6 +385,14 @@
int ftp_start(const char *);
void ftp_stop(void);
+/* pkg_io.c: Local and remote archive handling */
+struct archive;
+
+struct archive *open_remote_archive(const char *, void **);
+void close_remote_archive(void *);
+struct archive *open_local_archive(const char *, void **);
+void close_local_archive(void *);
+
/* Packing list */
plist_t *new_plist_entry(void);
plist_t *last_plist(package_t *);
diff -r 7ac6a952955a -r 8b7fc99b3bfc pkgtools/pkg_install/files/lib/pkg_io.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_install/files/lib/pkg_io.c Fri Apr 04 15:21:32 2008 +0000
@@ -0,0 +1,139 @@
+/* $NetBSD: pkg_io.c,v 1.1 2008/04/04 15:21:32 joerg 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <nbcompat.h>
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+
+__RCSID("$NetBSD: pkg_io.c,v 1.1 2008/04/04 15:21:32 joerg Exp $");
+
+#include <archive.h>
+#include <archive_entry.h>
+#if HAVE_ERR_H
+#include <err.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <fetch.h>
+#include <stdlib.h>
+
+#include "lib.h"
+
+struct fetch_archive {
+ const char *url;
+ fetchIO *fetch;
+ char buffer[32768];
+};
+
+static int
Home |
Main Index |
Thread Index |
Old Index