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 When expanding wildcards given on the c...



details:   https://anonhg.NetBSD.org/src/rev/ca58f3cbe50f
branches:  trunk
changeset: 486027:ca58f3cbe50f
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Thu May 11 14:13:13 2000 +0000

description:
When expanding wildcards given on the command line, don't include
files (from /var/db/pkg). Only directories can contain pkgs.

Fixed PR 10083 by Dan McMahill <mcmahill%mtl.mit.edu@localhost>

diffstat:

 usr.sbin/pkg_install/delete/main.c |  15 +++++++++++----
 usr.sbin/pkg_install/info/main.c   |  15 +++++++++++----
 2 files changed, 22 insertions(+), 8 deletions(-)

diffs (72 lines):

diff -r b32d2e71b039 -r ca58f3cbe50f usr.sbin/pkg_install/delete/main.c
--- a/usr.sbin/pkg_install/delete/main.c        Thu May 11 14:01:28 2000 +0000
+++ b/usr.sbin/pkg_install/delete/main.c        Thu May 11 14:13:13 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: main.c,v 1.14 1999/09/24 14:39:44 hubertf Exp $        */
+/*     $NetBSD: main.c,v 1.15 2000/05/11 14:13:13 hubertf Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char *rcsid = "from FreeBSD Id: main.c,v 1.11 1997/10/08 07:46:48 charnier Exp";
 #else
-__RCSID("$NetBSD: main.c,v 1.14 1999/09/24 14:39:44 hubertf Exp $");
+__RCSID("$NetBSD: main.c,v 1.15 2000/05/11 14:13:13 hubertf Exp $");
 #endif
 #endif
 
@@ -58,9 +58,16 @@
 find_fn(const char *pkg, char *data)
 {
        lpkg_t *lpp;
+       char *fn;
 
-       lpp = alloc_lpkg(pkg);
-       TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
+       asprintf(&fn, "%s/%s", _pkgdb_getPKGDB_DIR(), pkg);
+       if (fn == NULL)
+               errx(1, "Out of memory while scanning pkgs.");
+       if (!isfile(fn)) {      /* might as well use sanity_check() */
+               lpp = alloc_lpkg(pkg);
+               TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
+       }
+       free(fn);
 
        return 0;
 }
diff -r b32d2e71b039 -r ca58f3cbe50f usr.sbin/pkg_install/info/main.c
--- a/usr.sbin/pkg_install/info/main.c  Thu May 11 14:01:28 2000 +0000
+++ b/usr.sbin/pkg_install/info/main.c  Thu May 11 14:13:13 2000 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: main.c,v 1.20 2000/01/10 14:53:56 hubertf Exp $        */
+/*     $NetBSD: main.c,v 1.21 2000/05/11 14:13:13 hubertf Exp $        */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char *rcsid = "from FreeBSD Id: main.c,v 1.14 1997/10/08 07:47:26 charnier Exp";
 #else
-__RCSID("$NetBSD: main.c,v 1.20 2000/01/10 14:53:56 hubertf Exp $");
+__RCSID("$NetBSD: main.c,v 1.21 2000/05/11 14:13:13 hubertf Exp $");
 #endif
 #endif
 
@@ -65,9 +65,16 @@
 find_fn(const char *pkg, char *data)
 {
        lpkg_t *lpp;
+       char *fn;
 
-       lpp = alloc_lpkg(pkg);
-       TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
+       asprintf(&fn, "%s/%s", _pkgdb_getPKGDB_DIR(), pkg);
+       if (fn == NULL)
+               errx(1, "Out of memory while scanning pkgs.");
+       if (!isfile(fn)) {      /* might as well use sanity_check() */
+               lpp = alloc_lpkg(pkg);
+               TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
+       }
+       free(fn);
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index