Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/pkg_install/add When adding depoted packages into t...



details:   https://anonhg.NetBSD.org/src/rev/4cf57d651a16
branches:  trunk
changeset: 551557:4cf57d651a16
user:      jlam <jlam%NetBSD.org@localhost>
date:      Mon Sep 08 07:00:10 2003 +0000

description:
When adding depoted packages into the depot, manipulate the correct
pkgdb.byfile.db by using the fact that depoted packages have their
dbdir == ${DEPOTBASE}.

diffstat:

 usr.sbin/pkg_install/add/perform.c |  54 +++++++++++++++++++++----------------
 1 files changed, 31 insertions(+), 23 deletions(-)

diffs (113 lines):

diff -r c1610db27102 -r 4cf57d651a16 usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c        Mon Sep 08 06:51:53 2003 +0000
+++ b/usr.sbin/pkg_install/add/perform.c        Mon Sep 08 07:00:10 2003 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.86 2003/09/02 07:34:50 jlam Exp $        */
+/*     $NetBSD: perform.c,v 1.87 2003/09/08 07:00:10 jlam Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.86 2003/09/02 07:34:50 jlam Exp $");
+__RCSID("$NetBSD: perform.c,v 1.87 2003/09/08 07:00:10 jlam Exp $");
 #endif
 #endif
 
@@ -72,8 +72,9 @@
        if (Verbose)
                printf("Loading it from %s.\n", name);
        path_setenv("PKG_PATH");
-       if (vsystem("%s/pkg_add -s %s %s%s%s %s%s %s%s%s %s%s",
+       if (vsystem("%s/pkg_add -K %s -s %s %s%s%s %s%s %s%s%s %s%s",
                        BINDIR,
+                       _pkgdb_getPKGDB_DIR(),
                        get_verification(),
                        NoView ? "-L " : "",
                        View ? "-w " : "",
@@ -110,7 +111,7 @@
        char    replace_to[FILENAME_MAX];
        int     replacing = 0;
        char   *where_to, *extract;
-       char   *dbdir;
+       char   dbdir[FILENAME_MAX];
        const char *exact;
        FILE   *cfile;
        int     errc;
@@ -283,18 +284,17 @@
        if (fexists(VIEWS_FNAME))
                is_depoted_pkg = TRUE;
        
-       dbdir = _pkgdb_getPKGDB_DIR();
-       (void) snprintf(LogDir, sizeof(LogDir), "%s/%s", dbdir, PkgName);
-
-       /* check if the dbdir is wrong because this is a depoted package */
+       /*
+        * Depoted packages' dbdir is the same as DEPOTBASE.  Non-depoted
+        * packages' dbdir comes from the command-line or the environment.
+        */
        if (is_depoted_pkg) {
-               if ((p = find_plist(&Plist, PLIST_CWD))) {
-                       if (strcmp(p->name, LogDir) != 0) {
-                               warnx("%s is not the depot directory for %s.",
-                                       dbdir, PkgName);
-                               goto success;
-                       }
-               }
+               p = find_plist(&Plist, PLIST_CWD);
+               (void) strlcpy(dbdir, dirname_of(p->name), sizeof(dbdir));
+               (void) strlcpy(LogDir, p->name, sizeof(LogDir));
+       } else {
+               (void) strlcpy(dbdir, _pkgdb_getPKGDB_DIR(), sizeof(dbdir));
+               (void) snprintf(LogDir, sizeof(LogDir), "%s/%s", dbdir, PkgName);
        }
 
        /* make sure dbdir actually exists! */
@@ -620,12 +620,18 @@
                }
        }
 
-       /* Now finally extract the entire show if we're not going direct */
-       if (!inPlace && !Fake)
-           if (!extract_plist(".", &Plist)) {
-               errc = 1;
-               goto fail;
-           }
+       /*
+        * Now finally extract the entire show if we're not going direct.
+        * We need to reset the package dbdir so that extract_plist()
+        * updates the correct pkgdb.byfile.db database.
+        */
+       if (!inPlace && !Fake) {
+               _pkgdb_setPKGDB_DIR(dbdir);
+               if (!extract_plist(".", &Plist)) {
+                       errc = 1;
+                       goto fail;
+               }
+       }
 
        if (!Fake && fexists(MTREE_FNAME)) {
                if (Verbose)
@@ -771,8 +777,9 @@
        /* Add the package to a default view. */
        if (!Fake && !NoView && is_depoted_pkg) {
                if (Verbose) {
-                       printf("%s/pkg_view %s%s %s%s %sadd %s\n",
+                       printf("%s/pkg_view -d %s %s%s %s%s %sadd %s\n",
                                BINDIR,
+                               dbdir,
                                View ? "-w " : "",
                                View ? View : "",
                                Viewbase ? "-W " : "",
@@ -780,8 +787,9 @@
                                Verbose ? "-v " : "",
                                PkgName);
                }
-               vsystem("%s/pkg_view %s%s %s%s %sadd %s",
+               vsystem("%s/pkg_view -d %s %s%s %s%s %sadd %s",
                                BINDIR,
+                               dbdir,
                                View ? "-w " : "",
                                View ? View : "",
                                Viewbase ? "-W " : "",



Home | Main Index | Thread Index | Old Index