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 Revert last change, it was ...
details: https://anonhg.NetBSD.org/pkgsrc/rev/362e5801d3ab
branches: trunk
changeset: 541858:362e5801d3ab
user: joerg <joerg%pkgsrc.org@localhost>
date: Sat Apr 26 17:40:01 2008 +0000
description:
Revert last change, it was not intended to go into HEAD.
diffstat:
pkgtools/pkg_install/files/add/Makefile.in | 8 +-
pkgtools/pkg_install/files/add/add.h | 9 +-
pkgtools/pkg_install/files/add/extract.c | 340 ++++
pkgtools/pkg_install/files/add/futil.c | 151 ++
pkgtools/pkg_install/files/add/main.c | 18 +-
pkgtools/pkg_install/files/add/perform.c | 2029 ++++++++++++--------------
pkgtools/pkg_install/files/add/pkg_add.1 | 38 +-
pkgtools/pkg_install/files/create/perform.c | 36 +-
pkgtools/pkg_install/files/info/Makefile.in | 4 +-
pkgtools/pkg_install/files/info/perform.c | 29 +-
pkgtools/pkg_install/files/lib/Makefile.in | 8 +-
pkgtools/pkg_install/files/lib/conflicts.c | 9 +-
pkgtools/pkg_install/files/lib/file.c | 429 +++++-
pkgtools/pkg_install/files/lib/ftpio.c | 1259 ++++++++++++++++
pkgtools/pkg_install/files/lib/lib.h | 90 +-
pkgtools/pkg_install/files/lib/pen.c | 206 ++
pkgtools/pkg_install/files/lib/pexec.c | 110 +
pkgtools/pkg_install/files/lib/pkg_io.c | 187 +--
pkgtools/pkg_install/files/lib/plist.c | 5 +-
pkgtools/pkg_install/files/lib/str.c | 45 +-
20 files changed, 3654 insertions(+), 1356 deletions(-)
diffs (truncated from 5612 to 300 lines):
diff -r 1b2a91bf08f9 -r 362e5801d3ab pkgtools/pkg_install/files/add/Makefile.in
--- a/pkgtools/pkg_install/files/add/Makefile.in Sat Apr 26 15:37:21 2008 +0000
+++ b/pkgtools/pkg_install/files/add/Makefile.in Sat Apr 26 17:40:01 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.17 2008/04/26 14:56:33 joerg Exp $
+# $NetBSD: Makefile.in,v 1.18 2008/04/26 17:40:01 joerg Exp $
srcdir= @srcdir@
@@ -13,9 +13,9 @@
CC= @CC@
CCLD= $(CC)
-LIBS= -linstall -lfetch -larchive -lbz2 -lz @LIBS@
+LIBS= -linstall @LIBS@
CPPFLAGS= @CPPFLAGS@ -I. -I$(srcdir) -I../lib
-DEFS= @DEFS@ -DOPSYS_NAME=\"$(OPSYS)\" -DMACHINE_ARCH=\"$(MACHINE_ARCH)\" -DBINDIR=\"$(sbindir)\"
+DEFS= @DEFS@ -DOPSYS_NAME=\"$(OPSYS)\" -DMACHINE_ARCH=\"$(MACHINE_ARCH)\" -DBINDIR=\"$(sbindir)\" -DTAR_CMD=\"@tar@\" -DPAX_CMD=\"@pax@\"
CFLAGS= @CFLAGS@
LDFLAGS= @LDFLAGS@ -L../lib
@@ -23,7 +23,7 @@
PROG= pkg_add
-OBJS= main.o perform.o verify.o
+OBJS= main.o perform.o futil.o extract.o verify.o
all: $(PROG)
diff -r 1b2a91bf08f9 -r 362e5801d3ab pkgtools/pkg_install/files/add/add.h
--- a/pkgtools/pkg_install/files/add/add.h Sat Apr 26 15:37:21 2008 +0000
+++ b/pkgtools/pkg_install/files/add/add.h Sat Apr 26 17:40:01 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: add.h,v 1.11 2008/04/26 14:56:33 joerg Exp $ */
+/* $NetBSD: add.h,v 1.12 2008/04/26 17:40:01 joerg Exp $ */
/* from FreeBSD Id: add.h,v 1.8 1997/02/22 16:09:15 peter Exp */
@@ -35,8 +35,15 @@
extern Boolean Force;
extern Boolean Automatic;
extern int Replace;
+extern char *Mode;
+extern char *Owner;
+extern char *Group;
+extern char *Directory;
+extern char *PkgName;
+extern char FirstPen[];
int make_hierarchy(char *);
+int extract_plist(char *, package_t *);
void apply_perms(char *, char **, int);
int pkg_perform(lpkg_head_t *);
diff -r 1b2a91bf08f9 -r 362e5801d3ab pkgtools/pkg_install/files/add/extract.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/pkg_install/files/add/extract.c Sat Apr 26 17:40:01 2008 +0000
@@ -0,0 +1,340 @@
+/* $NetBSD: extract.c,v 1.18 2008/04/26 17:40:01 joerg Exp $ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <nbcompat.h>
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if HAVE_SYS_QUEUE_H
+#include <sys/queue.h>
+#endif
+#ifndef lint
+#if 0
+static const char *rcsid = "FreeBSD - Id: extract.c,v 1.17 1997/10/08 07:45:35 charnier Exp";
+#else
+__RCSID("$NetBSD: extract.c,v 1.18 2008/04/26 17:40:01 joerg Exp $");
+#endif
+#endif
+
+/*
+ * FreeBSD install - a package for the installation and maintainance
+ * of non-core utilities.
+ *
+ * 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.
+ *
+ * Jordan K. Hubbard
+ * 18 July 1993
+ *
+ * This is the package extraction code for the add module.
+ *
+ */
+
+#if HAVE_ERR_H
+#include <err.h>
+#endif
+#include "lib.h"
+#include "add.h"
+
+lfile_head_t files;
+lfile_head_t perms;
+
+/*
+ * Copy files from staging area to todir.
+ * This is only used when the files cannot be directory rename()ed.
+ */
+static void
+pushout(char *todir)
+{
+ pipe_to_system_t *pipe_to;
+ char *file_args[4];
+ char **perm_argv;
+ int perm_argc = 1;
+ lfile_t *lfp;
+ int count;
+
+ /* set up arguments to run "pax -r -w -p e" */
+ file_args[0] = (char *)strrchr(PAX_CMD, '/');
+ if (file_args[0] == NULL)
+ file_args[0] = PAX_CMD;
+ else
+ file_args[0]++;
+ file_args[1] = "-rwpe";
+ file_args[2] = todir;
+ file_args[3] = NULL;
+
+ /* count entries for files */
+ count = 0;
+ TAILQ_FOREACH(lfp, &files, lf_link)
+ count++;
+
+ if (count > 0) {
+ /* open pipe, feed it files, close pipe */
+ pipe_to = pipe_to_system_begin(PAX_CMD, file_args, NULL);
+ while ((lfp = TAILQ_FIRST(&files)) != NULL) {
+ fprintf(pipe_to->fp, "%s\n", lfp->lf_name);
+ TAILQ_REMOVE(&files, lfp, lf_link);
+ free(lfp);
+ }
+ pipe_to_system_end(pipe_to);
+ }
+
+ /* count entries for permissions */
+ count = 0;
+ TAILQ_FOREACH(lfp, &perms, lf_link)
+ count++;
+
+ if (count > 0) {
+ perm_argv = malloc((count + 1) * sizeof(char *));
+ perm_argc = 0;
+ TAILQ_FOREACH(lfp, &perms, lf_link)
+ perm_argv[perm_argc++] = lfp->lf_name;
+ perm_argv[perm_argc] = NULL;
+ apply_perms(todir, perm_argv, perm_argc);
+
+ /* empty the perm list */
+ while ((lfp = TAILQ_FIRST(&perms)) != NULL) {
+ TAILQ_REMOVE(&perms, lfp, lf_link);
+ free(lfp);
+ }
+ free(perm_argv);
+ }
+}
+
+static void
+rollback(char *name, char *home, plist_t *start, plist_t *stop)
+{
+ plist_t *q;
+ char try[MaxPathSize], bup[MaxPathSize], *dir;
+
+ dir = home;
+ for (q = start; q != stop; q = q->next) {
+ if (q->type == PLIST_FILE) {
+ (void) snprintf(try, sizeof(try), "%s/%s", dir, q->name);
+ if (make_preserve_name(bup, sizeof(bup), name, try) && fexists(bup)) {
+#if HAVE_CHFLAGS
+ (void) chflags(try, 0);
+#endif
+ (void) unlink(try);
+ if (rename(bup, try))
+ warnx("rollback: unable to rename %s back to %s", bup, try);
+ }
+ } else if (q->type == PLIST_CWD) {
+ if (strcmp(q->name, "."))
+ dir = q->name;
+ else
+ dir = home;
+ }
+ }
+}
+
+
+/*
+ * Return 0 on error, 1 for success.
+ */
+int
+extract_plist(char *home, package_t *pkg)
+{
+ plist_t *p = pkg->head;
+ char *last_file;
+ char *last_chdir;
+ Boolean preserve;
+ lfile_t *lfp;
+
+ TAILQ_INIT(&files);
+ TAILQ_INIT(&perms);
+
+ last_chdir = 0;
+ preserve = find_plist_option(pkg, "preserve") ? TRUE : FALSE;
+
+ /* Reset the world */
+ Owner = NULL;
+ Group = NULL;
+ Mode = NULL;
+ last_file = NULL;
+ Directory = home;
+
+ if (!NoRecord) {
+ /* Open Package Database for writing */
+ if (!pkgdb_open(ReadWrite)) {
+ cleanup(0);
+ err(EXIT_FAILURE, "can't open pkgdb");
+ }
+ }
+ /* Do it */
+ while (p) {
+ char cmd[MaxPathSize];
+
+ switch (p->type) {
+ case PLIST_NAME:
+ PkgName = p->name;
+ if (Verbose)
+ printf("extract: Package name is %s\n", p->name);
+ break;
+
+ case PLIST_FILE:
+ last_file = p->name;
+ if (Verbose)
+ printf("extract: %s/%s\n", Directory, p->name);
+ if (!Fake) {
+ char try[MaxPathSize];
+
+ if (strrchr(p->name, '\'')) {
+ cleanup(0);
+ errx(2, "Bogus filename \"%s\"", p->name);
+ }
+
+ /* first try to rename it into place */
+ (void) snprintf(try, sizeof(try), "%s/%s", Directory, p->name);
+ if (fexists(try)) {
+#if HAVE_CHFLAGS
+ (void) chflags(try, 0); /* XXX hack - if truly immutable, rename fails */
+#endif
+ if (preserve && PkgName) {
+ char pf[MaxPathSize];
+
+ if (make_preserve_name(pf, sizeof(pf), PkgName, try)) {
+ if (rename(try, pf)) {
+ warnx(
+ "unable to back up %s to %s, aborting pkg_add",
+ try, pf);
+ rollback(PkgName, home, pkg->head, p);
+ return 0;
+ }
+ }
+ }
+ }
+ if (rename(p->name, try) == 0) {
+ if (!NoRecord) {
+ /* note in pkgdb */
+ char *s, t[MaxPathSize];
+ int rc;
+
+ (void) snprintf(t, sizeof(t), "%s/%s", Directory, p->name);
+
+ s = pkgdb_retrieve(t);
+#ifdef PKGDB_DEBUG
+ printf("pkgdb_retrieve(\"%s\")=\"%s\"\n", t, s); /* pkgdb-debug - HF */
+#endif
+ if (s)
+ warnx("Overwriting %s - pkg %s bogus/conflicting?", t, s);
+ else {
+ rc = pkgdb_store(t, PkgName);
+#ifdef PKGDB_DEBUG
+ printf("pkgdb_store(\"%s\", \"%s\") = %d\n", t, PkgName, rc); /* pkgdb-debug - HF */
+#endif
+
+ }
+ }
+
+ /* try to add to list of perms to be changed and run in bulk. */
+ if (p->name[0] == '/')
+ pushout(Directory);
+
Home |
Main Index |
Thread Index |
Old Index