pkgsrc-Changes-HG archive

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

[pkgsrc/pkg_install-renovation]: pkgsrc/pkgtools/pkg_install/files pkg_instal...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f00d565a086f
branches:  pkg_install-renovation
changeset: 541573:f00d565a086f
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Wed Jul 30 15:38:37 2008 +0000

description:
pkg_install-20080730:
Add destdir installation support for pkg_add and pkg_delete.
This does not chroot install/deinstall scripts, they have to
support it directly (using PKG_DESTDIR) or they have to be disabled.

diffstat:

 pkgtools/pkg_install/files/add/add.h              |   3 +-
 pkgtools/pkg_install/files/add/main.c             |  18 ++++--
 pkgtools/pkg_install/files/add/perform.c          |  62 +++++++++++++++-------
 pkgtools/pkg_install/files/add/pkg_add.1          |  17 +++++-
 pkgtools/pkg_install/files/add/pkg_add.cat1       |  12 +++-
 pkgtools/pkg_install/files/delete/delete.h        |   3 +-
 pkgtools/pkg_install/files/delete/main.c          |  38 ++++++++++---
 pkgtools/pkg_install/files/delete/perform.c       |   8 +-
 pkgtools/pkg_install/files/delete/pkg_delete.1    |  17 +++++-
 pkgtools/pkg_install/files/delete/pkg_delete.cat1 |  13 +++-
 pkgtools/pkg_install/files/lib/lib.h              |   7 +-
 pkgtools/pkg_install/files/lib/plist.c            |  15 +++-
 pkgtools/pkg_install/files/lib/version.h          |   4 +-
 13 files changed, 158 insertions(+), 59 deletions(-)

diffs (truncated from 682 to 300 lines):

diff -r f0fb7247d021 -r f00d565a086f pkgtools/pkg_install/files/add/add.h
--- a/pkgtools/pkg_install/files/add/add.h      Wed Jul 30 15:02:18 2008 +0000
+++ b/pkgtools/pkg_install/files/add/add.h      Wed Jul 30 15:38:37 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: add.h,v 1.10.8.1 2008/04/26 17:44:23 joerg Exp $ */
+/* $NetBSD: add.h,v 1.10.8.2 2008/07/30 15:38:37 joerg Exp $ */
 
 /* from FreeBSD Id: add.h,v 1.8 1997/02/22 16:09:15 peter Exp  */
 
@@ -25,6 +25,7 @@
 #ifndef _INST_ADD_H_INCLUDE
 #define _INST_ADD_H_INCLUDE
 
+extern char *Destdir;
 extern char *OverrideMachine;
 extern char *Prefix;
 extern char *View;
diff -r f0fb7247d021 -r f00d565a086f pkgtools/pkg_install/files/add/main.c
--- a/pkgtools/pkg_install/files/add/main.c     Wed Jul 30 15:02:18 2008 +0000
+++ b/pkgtools/pkg_install/files/add/main.c     Wed Jul 30 15:38:37 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.14.4.4 2008/06/22 22:10:45 joerg Exp $      */
+/*     $NetBSD: main.c,v 1.14.4.5 2008/07/30 15:38:37 joerg Exp $      */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -11,7 +11,7 @@
 #if 0
 static char *rcsid = "from FreeBSD Id: main.c,v 1.16 1997/10/08 07:45:43 charnier Exp";
 #else
-__RCSID("$NetBSD: main.c,v 1.14.4.4 2008/06/22 22:10:45 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.14.4.5 2008/07/30 15:38:37 joerg Exp $");
 #endif
 #endif
 
@@ -48,8 +48,9 @@
 #include "lib.h"
 #include "add.h"
 
-static char Options[] = "AIK:LRVW:fhm:np:t:uvw:";
+static char Options[] = "AIK:LP:RVW:fhm:np:t:uvw:";
 
+char   *Destdir = NULL;
 char   *OverrideMachine = NULL;
 char   *Prefix = NULL;
 char   *View = NULL;
@@ -64,9 +65,10 @@
 static void
 usage(void)
 {
-       (void) fprintf(stderr, "%s\n%s\n%s\n",
-           "usage: pkg_add [-AfhILnRuVv] [-C config] [-K pkg_dbdir] [-m machine] [-p prefix]",
-           "               [-s verification-type] [-W viewbase] [-w view]",
+       (void) fprintf(stderr, "%s\n%s\n%s\n%s\n",
+           "usage: pkg_add [-AfhILnRuVv] [-C config] [-P destdir] [-K pkg_dbdir]",
+           "               [-m machine] [-p prefix] [-s verification-type",
+           "               [-W viewbase] [-w view]\n",
            "               [[ftp|http]://[user[:password]@]host[:port]][/path/]pkg-name ...");
        exit(1);
 }
@@ -87,6 +89,10 @@
                case 'C':
                        config_file = optarg;
 
+               case 'P':
+                       Destdir = optarg;
+                       break;
+
                case 'f':
                        Force = TRUE;
                        break;
diff -r f0fb7247d021 -r f00d565a086f pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Wed Jul 30 15:02:18 2008 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Wed Jul 30 15:38:37 2008 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.70.4.11 2008/07/30 15:02:18 joerg Exp $  */
+/*     $NetBSD: perform.c,v 1.70.4.12 2008/07/30 15:38:37 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.70.4.11 2008/07/30 15:02:18 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.70.4.12 2008/07/30 15:38:37 joerg Exp $");
 
 /*-
  * Copyright (c) 2003 Grant Beattie <grant%NetBSD.org@localhost>
@@ -77,8 +77,10 @@
        char *pkgname;
 
        const char *prefix;
+       char *install_prefix;
 
        char *logdir;
+       char *install_logdir;
        char *other_version;
 
        package_t plist;
@@ -305,6 +307,13 @@
        } else
                pkg->prefix = p->name;
 
+       if (Destdir != NULL) {
+               if (asprintf(&pkg->install_prefix, "%s/%s", Destdir,
+                   pkg->prefix) == -1)
+                       err(EXIT_FAILURE, "asprintf failed");
+       } else if ((pkg->install_prefix = strdup(pkg->prefix)) == NULL)
+               err(EXIT_FAILURE, "strdup failed");
+
        return 0;
 }
 
@@ -523,8 +532,8 @@
        if (Fake)
                return 0;
 
-       if (mkdir_p(pkg->logdir)) {
-               warn("Can't create pkgdb entry: %s", pkg->logdir);
+       if (mkdir_p(pkg->install_logdir)) {
+               warn("Can't create pkgdb entry: %s", pkg->install_logdir);
                return -1;
        }
 
@@ -533,7 +542,7 @@
                    descr->entry_offset);
                if (*target == NULL)
                        continue;
-               if (asprintf(&filename, "%s/%s", pkg->logdir,
+               if (asprintf(&filename, "%s/%s", pkg->install_logdir,
                    descr->entry_filename) == -1) {
                            warn("asprintf failed");
                            return -1;
@@ -619,13 +628,13 @@
        if (Fake)
                return 0;
 
-       if (mkdir_p(pkg->prefix)) {
-               warn("Can't create prefix: %s", pkg->prefix);
+       if (mkdir_p(pkg->install_prefix)) {
+               warn("Can't create prefix: %s", pkg->install_prefix);
                return -1;
        }
 
-       if (chdir(pkg->prefix) == -1) {
-               warn("Can't change into prefix: %s", pkg->prefix);
+       if (chdir(pkg->install_prefix) == -1) {
+               warn("Can't change into prefix: %s", pkg->install_prefix);
                return -1;
        }
 
@@ -868,6 +877,8 @@
        if (pkg->meta_data.meta_install == NULL || NoInstall)
                return 0;
 
+       if (Destdir != NULL)
+               setenv(PKG_DESTDIR_VNAME, Destdir, 1);
        setenv(PKG_PREFIX_VNAME, pkg->prefix, 1);
        setenv(PKG_METADATA_DIR_VNAME, pkg->logdir, 1);
        setenv(PKG_REFCOUNT_DBDIR_VNAME, pkgdb_refcount_dir(), 1);
@@ -882,8 +893,8 @@
 
        ret = 0;
 
-       if (chdir(pkg->logdir) == -1) {
-               warn("Can't change to %s", pkg->logdir);
+       if (chdir(pkg->install_logdir) == -1) {
+               warn("Can't change to %s", pkg->install_logdir);
                ret = -1;
        }
 
@@ -1123,13 +1134,15 @@
                return -1;
 
        if (Verbose || Fake) {
-               printf("%s/pkg_delete -K %s -p %s '%s'\n",
+               printf("%s/pkg_delete -K %s -p %s%s%s '%s'\n",
                        BINDIR, _pkgdb_getPKGDB_DIR(), pkg->prefix,
+                       Destdir ? " -P ": "", Destdir ? Destdir : "",
                        pkg->other_version);
        }
        if (!Fake)
                fexec(BINDIR "/pkg_delete", "-K", _pkgdb_getPKGDB_DIR(),
                    "-p", pkg->prefix,
+                   Destdir ? "-P": "", Destdir ? Destdir : "",
                    pkg->other_version, NULL);
 
        /* XXX Check return value and do what? */
@@ -1245,6 +1258,13 @@
                        err(EXIT_FAILURE, "asprintf failed");
        }
 
+       if (Destdir != NULL) {
+               if (asprintf(&pkg->install_logdir, "%s/%s", Destdir, pkg->logdir) == -1)
+                       err(EXIT_FAILURE, "asprintf failed");
+               _pkgdb_setPKGDB_DIR(dirname_of(pkg->install_logdir));
+       } else if ((pkg->install_logdir = strdup(pkg->logdir)) == NULL)
+               err(EXIT_FAILURE, "strdup failed");
+
        if (NoRecord && !Fake) {
                const char *tmpdir;
 
@@ -1252,11 +1272,11 @@
                if (tmpdir == NULL)
                        tmpdir = "/tmp";
 
-               free(pkg->logdir);
-               if (asprintf(&pkg->logdir, "%s/pkg_install.XXXXXX", tmpdir) == -1)
+               free(pkg->install_logdir);
+               if (asprintf(&pkg->install_logdir, "%s/pkg_install.XXXXXX", tmpdir) == -1)
                        err(EXIT_FAILURE, "asprintf failed");
                /* XXX pkg_add -u... */
-               if (mkdtemp(pkg->logdir) == NULL) {
+               if (mkdtemp(pkg->install_logdir) == NULL) {
                        warn("mkdtemp failed");
                        goto clean_memory;
                }
@@ -1326,7 +1346,7 @@
        pkg_register_depends(pkg);
 
        if (Verbose)
-               printf("Package %s registered in %s\n", pkg->pkgname, pkg->logdir);
+               printf("Package %s registered in %s\n", pkg->pkgname, pkg->install_logdir);
 
        if (pkg->meta_data.meta_display != NULL)
                fputs(pkg->meta_data.meta_display, stdout);
@@ -1343,19 +1363,23 @@
                            pkg->other_version, pkg->pkgname);
                        warnx("Remember to run pkg_admin rebuild-tree after fixing this.");
                }
-               delete_package(FALSE, FALSE, &pkg->plist, FALSE);
+               delete_package(FALSE, FALSE, &pkg->plist, FALSE, Destdir);
        }
 
 nuke_pkgdb:
        if (!Fake) {
-               (void) fexec(REMOVE_CMD, "-fr", pkg->logdir, (void *)NULL);
+               (void) fexec(REMOVE_CMD, "-fr", pkg->install_logdir, (void *)NULL);
+               free(pkg->install_logdir);
                free(pkg->logdir);
+               pkg->install_logdir = NULL;
                pkg->logdir = NULL;
        }
 
 clean_memory:
        if (pkg->logdir != NULL && NoRecord && !Fake)
-               (void) fexec(REMOVE_CMD, "-fr", pkg->logdir, (void *)NULL);
+               (void) fexec(REMOVE_CMD, "-fr", pkg->install_logdir, (void *)NULL);
+       free(pkg->install_prefix);
+       free(pkg->install_logdir);
        free(pkg->logdir);
        free_buildinfo(pkg);
        free_plist(&pkg->plist);
diff -r f0fb7247d021 -r f00d565a086f pkgtools/pkg_install/files/add/pkg_add.1
--- a/pkgtools/pkg_install/files/add/pkg_add.1  Wed Jul 30 15:02:18 2008 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.1  Wed Jul 30 15:38:37 2008 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_add.1,v 1.28.6.7 2008/07/27 22:36:19 joerg Exp $
+.\" $NetBSD: pkg_add.1,v 1.28.6.8 2008/07/30 15:38:37 joerg Exp $
 .\"
 .\" FreeBSD install - a package for the installation and maintenance
 .\" of non-core utilities.
@@ -17,7 +17,7 @@
 .\"
 .\"     @(#)pkg_add.1
 .\"
-.Dd July 28, 2008
+.Dd July 30, 2008
 .Dt PKG_ADD 1
 .Os
 .Sh NAME
@@ -28,6 +28,7 @@
 .Op Fl AfILnRuVv
 .Op Fl K Ar pkg_dbdir
 .Op Fl m Ar machine
+.Op Fl P Ar destdir
 .Op Fl p Ar prefix
 .Op Fl W Ar viewbase
 .Op Fl w Ar view
@@ -141,6 +142,11 @@
 .It Fl n
 Don't actually install a package, just report the steps that
 would be taken if it was.
+.It Fl p Ar destdir
+Prefix all file and directory names with
+.Ar destdir .
+For packages without install scripts this has the same behavior as
+using chroot.
 .It Fl p Ar prefix
 Set
 .Ar prefix
@@ -379,6 +385,13 @@
 .Ev PKG_REFCOUNT_DBDIR
 environment variable set to the location of the package reference counts
 database directory.
+If the
+.Fl P
+flag was given to
+.Nm ,



Home | Main Index | Thread Index | Old Index