diff options
author | jschauma <jschauma@pkgsrc.org> | 2003-03-16 19:44:09 +0000 |
---|---|---|
committer | jschauma <jschauma@pkgsrc.org> | 2003-03-16 19:44:09 +0000 |
commit | ef6b1ec5683da8448e89eef5d610d4b7f36ba90c (patch) | |
tree | a4241dec65f768adb89e77723cc2d31dafcff38e /pkgtools | |
parent | a241275f33ac3a1b595d334fc9b225a898ee16af (diff) | |
download | pkgsrc-ef6b1ec5683da8448e89eef5d610d4b7f36ba90c.tar.gz |
Sync with main sources:
Date: Sat Mar 15 20:49:27 UTC 2003
Introduce a pkgdb_dump() function, which dumps the cache file of
(filename, package) pairs.
Modify calling functions to use pkgdb_dump() directly, rather than
sequences of
pkgdb_open
{ pkgdb_iter, pkgdb_retrieve }
pkgdb_close
calls.
Remove the now unnecessary pkgdb_iter function.
Date: Sat Mar 15 20:50:15 UTC 2003
Bump version string for pkgdb_dump changes.
Date: Sat Mar 15 20:54:26 UTC 2003
Catch one more place that could result in Current not being set properly
(and thus in the execution of "rm -fr /") if ^C is pressed at the wrong time.
See also PR 19436.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkg_install/files/admin/main.c | 22 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/info/perform.c | 16 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/lib.h.in | 4 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/pen.c | 8 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/pkgdb.c | 50 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/version.h | 4 |
6 files changed, 35 insertions, 69 deletions
diff --git a/pkgtools/pkg_install/files/admin/main.c b/pkgtools/pkg_install/files/admin/main.c index f006ecf6cef..e64b29bb626 100644 --- a/pkgtools/pkg_install/files/admin/main.c +++ b/pkgtools/pkg_install/files/admin/main.c @@ -1,9 +1,9 @@ -/* $NetBSD: main.c,v 1.5 2003/01/14 15:18:33 jschauma Exp $ */ +/* $NetBSD: main.c,v 1.6 2003/03/16 19:44:09 jschauma Exp $ */ #if 0 #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: main.c,v 1.5 2003/01/14 15:18:33 jschauma Exp $"); +__RCSID("$NetBSD: main.c,v 1.6 2003/03/16 19:44:09 jschauma Exp $"); #endif #endif @@ -539,23 +539,7 @@ main(int argc, char *argv[]) } else if (strcasecmp(argv[1], "list") == 0 || strcasecmp(argv[1], "dump") == 0) { - - char *key, *val; - char cachename[FILENAME_MAX]; - - - printf("Dumping pkgdb %s:\n", _pkgdb_getPKGDB_FILE(cachename, sizeof(cachename))); - - if (!pkgdb_open(ReadOnly)) { - err(EXIT_FAILURE, "cannot open %s", cachename); - } - while ((key = pkgdb_iter())) { - val = pkgdb_retrieve(key); - - printf("file: %-50s pkg: %s\n", key, val); - } - pkgdb_close(); - + pkgdb_dump(); } #ifdef PKGDB_DEBUG else if (strcasecmp(argv[1], "del") == 0 || diff --git a/pkgtools/pkg_install/files/info/perform.c b/pkgtools/pkg_install/files/info/perform.c index 9b34702faba..d3ee38eae6d 100644 --- a/pkgtools/pkg_install/files/info/perform.c +++ b/pkgtools/pkg_install/files/info/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.5 2003/01/14 15:18:34 jschauma Exp $ */ +/* $NetBSD: perform.c,v 1.6 2003/03/16 19:44:09 jschauma Exp $ */ #if 0 #include <sys/cdefs.h> @@ -6,7 +6,7 @@ #if 0 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp"; #else -__RCSID("$NetBSD: perform.c,v 1.5 2003/01/14 15:18:34 jschauma Exp $"); +__RCSID("$NetBSD: perform.c,v 1.6 2003/03/16 19:44:09 jschauma Exp $"); #endif #endif #endif @@ -340,18 +340,10 @@ pkg_perform(lpkg_head_t *pkghead) return 1; if (File2Pkg) { + /* Show all files with the package they belong to */ - char *file, *pkg; + pkgdb_dump(); - /* pkg_info -Fa => Dump pkgdb */ - if (!pkgdb_open(ReadOnly)) { - err(EXIT_FAILURE, "cannot open pkgdb"); - } - while ((file = pkgdb_iter())) { - pkg = pkgdb_retrieve(file); - printf("%-50s %s\n", file, pkg); - } - pkgdb_close(); } else { /* Show all packges with description */ if ((dirp = opendir(tmp)) != (DIR *) NULL) { diff --git a/pkgtools/pkg_install/files/lib/lib.h.in b/pkgtools/pkg_install/files/lib/lib.h.in index 63d6dea3f2b..20118609c40 100644 --- a/pkgtools/pkg_install/files/lib/lib.h.in +++ b/pkgtools/pkg_install/files/lib/lib.h.in @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h.in,v 1.3 2003/01/14 15:18:35 jschauma Exp $ */ +/* $NetBSD: lib.h.in,v 1.4 2003/03/16 19:44:10 jschauma Exp $ */ /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ @@ -430,9 +430,9 @@ int pkgdb_open(int); void pkgdb_close(void); int pkgdb_store(const char *, const char *); char *pkgdb_retrieve(const char *); +void pkgdb_dump(void); int pkgdb_remove(const char *); int pkgdb_remove_pkg(const char *); -char *pkgdb_iter(void); char *_pkgdb_getPKGDB_FILE(char *, unsigned); char *_pkgdb_getPKGDB_DIR(void); diff --git a/pkgtools/pkg_install/files/lib/pen.c b/pkgtools/pkg_install/files/lib/pen.c index 051a5bb4cfa..a40130a4efc 100644 --- a/pkgtools/pkg_install/files/lib/pen.c +++ b/pkgtools/pkg_install/files/lib/pen.c @@ -1,4 +1,4 @@ -/* $NetBSD: pen.c,v 1.3 2003/01/06 04:34:17 jschauma Exp $ */ +/* $NetBSD: pen.c,v 1.4 2003/03/16 19:44:10 jschauma Exp $ */ #if 0 #include <sys/cdefs.h> @@ -6,7 +6,7 @@ #if 0 static const char *rcsid = "from FreeBSD Id: pen.c,v 1.25 1997/10/08 07:48:12 charnier Exp"; #else -__RCSID("$NetBSD: pen.c,v 1.3 2003/01/06 04:34:17 jschauma Exp $"); +__RCSID("$NetBSD: pen.c,v 1.4 2003/03/16 19:44:10 jschauma Exp $"); #endif #endif #endif @@ -187,7 +187,7 @@ make_playpen(char *pen, size_t pensize, size_t sz) cleanup(0); errx(2, "can't chdir to '%s'", pen); } - strcpy(Current, pen); CurrentSet = 1; + CurrentSet = 0; strcpy(Current, pen); CurrentSet = 1; return Previous; } @@ -228,7 +228,7 @@ leave_playpen(char *save) * in libc on 2.7 and 2.8, but not in 2.9) */ #if !defined(HAVE_STATFS) || (defined(HAVE_STATFS) && defined(HAVE_STATVFS) && !defined(__linux__)) -/* $NetBSD: pen.c,v 1.3 2003/01/06 04:34:17 jschauma Exp $ */ +/* $NetBSD: pen.c,v 1.4 2003/03/16 19:44:10 jschauma Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. diff --git a/pkgtools/pkg_install/files/lib/pkgdb.c b/pkgtools/pkg_install/files/lib/pkgdb.c index bfe305ff798..402aeaf84ec 100644 --- a/pkgtools/pkg_install/files/lib/pkgdb.c +++ b/pkgtools/pkg_install/files/lib/pkgdb.c @@ -1,9 +1,9 @@ -/* $NetBSD: pkgdb.c,v 1.7 2003/02/18 15:45:50 grant Exp $ */ +/* $NetBSD: pkgdb.c,v 1.8 2003/03/16 19:44:10 jschauma Exp $ */ #if 0 #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: pkgdb.c,v 1.7 2003/02/18 15:45:50 grant Exp $"); +__RCSID("$NetBSD: pkgdb.c,v 1.8 2003/03/16 19:44:10 jschauma Exp $"); #endif #endif @@ -179,6 +179,24 @@ pkgdb_retrieve(const char *key) #endif /* HAVE_DBOPEN */ } +/* dump contents of the database to stdout */ +void +pkgdb_dump(void) +{ + DBT key; + DBT val; + int type; + + if (pkgdb_open(ReadOnly)) { + for (type = R_FIRST ; (*pkgdbp->seq)(pkgdbp, &key, &val, type) == 0 ; type = R_NEXT) { + printf("file: %.*s pkg: %.*s\n", + (int) key.size, (char *) key.data, + (int) val.size, (char *) val.data); + } + pkgdb_close(); + } +} + /* * Remove data set from pkgdb * Return value as ypdb_delete: @@ -245,34 +263,6 @@ pkgdb_remove_pkg(const char *pkg) #endif /* HAVE_DBOPEN */ } -/* - * Iterate all pkgdb keys (which can then be handled to pkgdb_retrieve()) - * Return value: - * NULL if no more data is available - * !NULL else - */ -char * -pkgdb_iter(void) -{ -#if defined(HAVE_DBOPEN) - DBT key, val; - int type; - - if (pkgdb_iter_flag == 0) { - pkgdb_iter_flag = 1; - type = R_FIRST; - } else - type = R_NEXT; - - if ((*pkgdbp->seq)(pkgdbp, &key, &val, type) != 0) { - key.data = NULL; - } - - return (char *) key.data; -#else - return NULL; -#endif /* HAVE_DBOPEN */ -} /* * Return name of cache file in the buffer that was passed. diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index c490426d427..57b42345fa4 100644 --- a/pkgtools/pkg_install/files/lib/version.h +++ b/pkgtools/pkg_install/files/lib/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.4 2003/02/11 16:42:07 grant Exp $ */ +/* $NetBSD: version.h,v 1.5 2003/03/16 19:44:10 jschauma 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 "20030202" +#define PKGTOOLS_VERSION "20030315" #endif /* _INST_LIB_VERSION_H_ */ |