summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_install/files/lib/automatic.c
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2007-08-09 23:18:30 +0000
committerjoerg <joerg@pkgsrc.org>2007-08-09 23:18:30 +0000
commit0e11507110f11b3070ae81d8e9d47e2200c6f7c1 (patch)
tree7782693cc7e7672ac62409c95a7db35650ecd3a2 /pkgtools/pkg_install/files/lib/automatic.c
parentf9bda20537f08f4fbf065accbe7411231fb0b256 (diff)
downloadpkgsrc-0e11507110f11b3070ae81d8e9d47e2200c6f7c1.tar.gz
Change interface of is_automatic_installed and
mark_as_automatic_installed to take a package name and not a full path. Add assertions to test for this. Drop a few islinktodir checks. Change pkg_info to use iterate_pkg_db instead of scanning the directory by hand. As a side effect don't try to check for the pkgdb dir first, let pkgdb_dump and iterate_pkg_db handle that. Make pkgdb_dump return failure if it can't open the package db.
Diffstat (limited to 'pkgtools/pkg_install/files/lib/automatic.c')
-rw-r--r--pkgtools/pkg_install/files/lib/automatic.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/pkgtools/pkg_install/files/lib/automatic.c b/pkgtools/pkg_install/files/lib/automatic.c
index 1c39c68adb1..c0ec8a21a2a 100644
--- a/pkgtools/pkg_install/files/lib/automatic.c
+++ b/pkgtools/pkg_install/files/lib/automatic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: automatic.c,v 1.2 2005/11/06 12:37:43 wiz Exp $ */
+/* $NetBSD: automatic.c,v 1.3 2007/08/09 23:18:31 joerg Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -40,9 +40,12 @@
#include <sys/cdefs.h>
#endif
#ifndef lint
-__RCSID("$NetBSD: automatic.c,v 1.2 2005/11/06 12:37:43 wiz Exp $");
+__RCSID("$NetBSD: automatic.c,v 1.3 2007/08/09 23:18:31 joerg Exp $");
#endif
+#if HAVE_ASSERT_H
+#include <assert.h>
+#endif
#if HAVE_ERR_H
#include <err.h>
#endif
@@ -64,14 +67,16 @@ __RCSID("$NetBSD: automatic.c,v 1.2 2005/11/06 12:37:43 wiz Exp $");
#include "lib.h"
Boolean
-is_automatic_installed(const char *path)
+is_automatic_installed(const char *pkg)
{
char filename[BUFSIZ];
char *value;
Boolean ret;
- (void)snprintf(filename, sizeof(filename), "%s/%s", path,
- INSTALLED_INFO_FNAME);
+ assert(pkg[0] != '/');
+
+ (void)snprintf(filename, sizeof(filename), "%s/%s/%s",
+ _pkgdb_getPKGDB_DIR(), pkg, INSTALLED_INFO_FNAME);
value = var_get(filename, AUTOMATIC_VARNAME);
@@ -86,12 +91,14 @@ is_automatic_installed(const char *path)
}
int
-mark_as_automatic_installed(const char *path, int value)
+mark_as_automatic_installed(const char *pkg, int value)
{
char filename[BUFSIZ];
- (void)snprintf(filename, sizeof(filename), "%s/%s", path,
- INSTALLED_INFO_FNAME);
+ assert(pkg[0] != '/');
+
+ (void)snprintf(filename, sizeof(filename), "%s/%s/%s",
+ _pkgdb_getPKGDB_DIR(), pkg, INSTALLED_INFO_FNAME);
return var_set(filename, AUTOMATIC_VARNAME,
value ? "yes" : NULL);