Source-Changes-HG archive

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

[src/pkgviews]: src/usr.sbin/pkg_install Only add to the default view if the ...



details:   https://anonhg.NetBSD.org/src/rev/59b30595b3c1
branches:  pkgviews
changeset: 534279:59b30595b3c1
user:      jlam <jlam%NetBSD.org@localhost>
date:      Sat Aug 30 13:29:30 2003 +0000

description:
Only add to the default view if the package addition was truly successful.
Also double-check that the dbdir is set correctly when adding a depoted
package, otherwise output a warning and exit.  This prevents a likely user
error when pkgviews gets integrated and the user has PKG_DBDIR set in the
shell environment -- we'll error out of installing a depoted binary package
instead of mis-installing the whole thing.

Bump the version to 20020823.

diffstat:

 usr.sbin/pkg_install/add/perform.c |  70 ++++++++++++++++++++++---------------
 usr.sbin/pkg_install/lib/version.h |   4 +-
 2 files changed, 44 insertions(+), 30 deletions(-)

diffs (137 lines):

diff -r 3c312da6e48a -r 59b30595b3c1 usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c        Sat Aug 30 12:09:13 2003 +0000
+++ b/usr.sbin/pkg_install/add/perform.c        Sat Aug 30 13:29:30 2003 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.70.2.9 2003/08/27 00:28:16 jlam Exp $    */
+/*     $NetBSD: perform.c,v 1.70.2.10 2003/08/30 13:29:30 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.70.2.9 2003/08/27 00:28:16 jlam Exp $");
+__RCSID("$NetBSD: perform.c,v 1.70.2.10 2003/08/30 13:29:30 jlam Exp $");
 #endif
 #endif
 
@@ -126,16 +126,6 @@
        LogDir[0] = '\0';
        strlcpy(playpen, FirstPen, sizeof(playpen));
        inPlace = 0;
-       dbdir = _pkgdb_getPKGDB_DIR();
-
-       /* make sure dbdir actually exists! */
-       if (!(isdir(dbdir) || islinktodir(dbdir))) {
-               if (fexec("mkdir", "-m", "755", "-p", dbdir, NULL)) {
-                       errx(EXIT_FAILURE,
-                           "Database-dir %s cannot be generated, aborting.",
-                           dbdir);
-               }
-       }
 
        /* Are we coming in for a second pass, everything already extracted?
         * (Slave mode) */
@@ -173,8 +163,7 @@
                                warnx("Package %s will not be extracted", pkg);
                                goto bomb;
                        }
-               }
-               else { /* local */
+               } else { /* local */
                        if (!IS_STDIN(pkg)) {
                                /* not stdin */
                                if (!ispkgpattern(pkg)) {
@@ -292,8 +281,33 @@
        /* Protect against old packages with bogus @name fields */
        PkgName = (p = find_plist(&Plist, PLIST_NAME)) ? p->name : "anonymous";
 
+       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 */
+       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;
+                       }
+               }
+       }
+
+       /* make sure dbdir actually exists! */
+       if (!(isdir(dbdir) || islinktodir(dbdir))) {
+               if (fexec("mkdir", "-m", "755", "-p", dbdir, NULL)) {
+                       errx(EXIT_FAILURE,
+                           "Database-dir %s cannot be generated, aborting.",
+                           dbdir);
+               }
+       }
+
        /* See if this package (exact version) is already registered */
-       (void) snprintf(LogDir, sizeof(LogDir), "%s/%s", dbdir, PkgName);
        if ((isdir(LogDir) || islinktodir(LogDir)) && !Force) {
                warnx("package `%s' already recorded as installed", PkgName);
                goto success;   /* close enough for government work */
@@ -755,20 +769,8 @@
                        warnx("cannot open %s as display file", buf);
        }
 
-       goto success;
-
-bomb:
-       errc = 1;
-       goto success;
-
-fail:
-       /* Nuke the whole (installed) show, XXX but don't clean directories */
-       if (!Fake)
-               delete_package(FALSE, FALSE, &Plist);
-
-success:
        /* Add the package to a default view. */
-       if (!NoView && is_depoted_pkg) {
+       if (!Fake && !NoView && is_depoted_pkg) {
                if (Verbose) {
                        printf("%s/pkg_view %s%s %s%s %sadd %s\n",
                                BINDIR,
@@ -789,6 +791,18 @@
                                PkgName);
        }
 
+       goto success;
+
+bomb:
+       errc = 1;
+       goto success;
+
+fail:
+       /* Nuke the whole (installed) show, XXX but don't clean directories */
+       if (!Fake)
+               delete_package(FALSE, FALSE, &Plist);
+
+success:
        /* delete the packing list contents */
        free_plist(&Plist);
        leave_playpen(Home);
diff -r 3c312da6e48a -r 59b30595b3c1 usr.sbin/pkg_install/lib/version.h
--- a/usr.sbin/pkg_install/lib/version.h        Sat Aug 30 12:09:13 2003 +0000
+++ b/usr.sbin/pkg_install/lib/version.h        Sat Aug 30 13:29:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.13.4.14 2003/08/30 12:09:16 jlam Exp $   */
+/*     $NetBSD: version.h,v 1.13.4.15 2003/08/30 13:29:31 jlam Exp $   */
 
 /*
  * Copyright (c) 2001 Thomas Klausner.  All rights reserved.
@@ -33,6 +33,6 @@
 #ifndef _INST_LIB_VERSION_H_
 #define _INST_LIB_VERSION_H_
 
-#define PKGTOOLS_VERSION "20030822"
+#define PKGTOOLS_VERSION "20030823"
 
 #endif /* _INST_LIB_VERSION_H_ */



Home | Main Index | Thread Index | Old Index