Import pkg_install-20070821.

This commit is contained in:
joerg 2007-08-23 15:19:12 +00:00
parent 8b0f2e2191
commit eeb69d2fa6
11 changed files with 277 additions and 227 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: perform.c,v 1.1.1.3 2007/08/14 22:59:50 joerg Exp $ */
/* $NetBSD: perform.c,v 1.1.1.4 2007/08/23 15:19:12 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -14,7 +14,7 @@
#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.1.1.3 2007/08/14 22:59:50 joerg Exp $");
__RCSID("$NetBSD: perform.c,v 1.1.1.4 2007/08/23 15:19:12 joerg Exp $");
#endif
#endif
@ -203,6 +203,173 @@ installprereq(const char *name, int *errc, int doupdate)
return ret;
}
static int
pkg_do_installed(int *replacing, char replace_via[MaxPathSize], char replace_to[MaxPathSize],
Boolean is_depoted_pkg, const char *dbdir)
{
char replace_from[MaxPathSize];
char *s;
char buf[MaxPathSize];
char *best_installed;
if ((s = strrchr(PkgName, '-')) == NULL) {
warnx("Package name %s does not contain a version, bailing out", PkgName);
return -1;
}
/*
* See if the pkg is already installed. If so, we might want to
* upgrade/replace it. Otherwise, just return and let pkg_do work.
*/
(void) snprintf(buf, sizeof(buf), "%.*s[0-9]*",
(int)(s - PkgName) + 1, PkgName);
best_installed = find_best_matching_installed_pkg(buf);
if (best_installed == NULL)
return 0;
if (!Replace || Fake) {
if (is_depoted_pkg) {
free(best_installed);
return 0;
} else {
warnx("other version '%s' already installed", best_installed);
free(best_installed);
return 1; /* close enough for government work */
}
}
/* XXX Should list the steps in Fake mode */
snprintf(replace_from, sizeof(replace_from), "%s/%s/" REQUIRED_BY_FNAME,
dbdir, best_installed);
snprintf(replace_via, sizeof(replace_via), "%s/.%s." REQUIRED_BY_FNAME,
dbdir, best_installed);
snprintf(replace_to, sizeof(replace_to), "%s/%s/" REQUIRED_BY_FNAME,
dbdir, PkgName);
if (Verbose)
printf("Upgrading %s to %s.\n", best_installed, PkgName);
if (fexists(replace_from)) { /* Are there any dependencies? */
/*
* Upgrade step 1/4: Check if the new version is ok with all pkgs
* (from +REQUIRED_BY) that require this pkg
*/
FILE *rb; /* +REQUIRED_BY file */
char pkg2chk[MaxPathSize];
rb = fopen(replace_from, "r");
if (! rb) {
warnx("Cannot open '%s' for reading%s", replace_from,
Force ? " (proceeding anyways)" : "");
if (Force)
goto ignore_replace_depends_check;
else
return -1;
}
while (fgets(pkg2chk, sizeof(pkg2chk), rb)) {
package_t depPlist;
FILE *depf;
plist_t *depp;
char depC[MaxPathSize];
depPlist.head = depPlist.tail = NULL;
s = strrchr(pkg2chk, '\n');
if (s)
*s = '\0'; /* strip trailing '\n' */
/*
* step into pkg2chk, read it's +CONTENTS file and see if
* all @pkgdep lines agree with PkgName (using pkg_match())
*/
snprintf(depC, sizeof(depC), "%s/%s/%s", dbdir, pkg2chk, CONTENTS_FNAME);
depf = fopen(depC , "r");
if (depf == NULL) {
warnx("Cannot check depends in '%s'%s", depC,
Force ? " (proceeding anyways)" : "!" );
if (Force)
goto ignore_replace_depends_check;
else
return -1;
}
read_plist(&depPlist, depf);
fclose(depf);
for (depp = depPlist.head; depp; depp = depp->next) {
char base_new[MaxPathSize];
char base_exist[MaxPathSize];
char *s2;
if (depp->type != PLIST_PKGDEP)
continue;
/*
* Prepare basename (no versions) of both pkgs,
* to see if we want to compare against that
* one at all.
*/
strlcpy(base_new, PkgName, sizeof(base_new));
s2 = strpbrk(base_new, "<>[]?*{"); /* } */
if (s2)
*s2 = '\0';
else {
s2 = strrchr(base_new, '-');
if (s2)
*s2 = '\0';
}
strlcpy(base_exist, depp->name, sizeof(base_exist));
s2 = strpbrk(base_exist, "<>[]?*{"); /* } */
if (s2)
*s2 = '\0';
else {
s2 = strrchr(base_exist, '-');
if (s2)
*s2 = '\0';
}
if (strcmp(base_new, base_exist) == 0) {
/* Same pkg, so do the interesting compare */
if (pkg_match(depp->name, PkgName)) {
if (Verbose)
printf("@pkgdep check: %s is ok for %s (in %s pkg)\n",
PkgName, depp->name, pkg2chk);
} else {
printf("Package %s requires %s, \n\tCannot replace with %s%s\n",
pkg2chk, depp->name, PkgName,
Force? " (proceeding anyways)" : "!");
if (! Force)
return -1;
}
}
}
}
fclose(rb);
ignore_replace_depends_check:
/*
* Upgrade step 2/4: Do the actual update by moving aside
* the +REQUIRED_BY file, deinstalling the old pkg, adding
* the new one and moving the +REQUIRED_BY file back
* into place (finished in step 3/4)
*/
if (Verbose)
printf("mv %s %s\n", replace_from, replace_via);
if (rename(replace_from, replace_via) != 0)
err(EXIT_FAILURE, "rename failed");
*replacing = 1;
}
if (Verbose) {
printf("%s/pkg_delete -K %s '%s'\n",
BINDIR, dbdir, best_installed);
}
fexec(BINDIR "/pkg_delete", "-K", dbdir, best_installed, NULL);
free(best_installed);
return 0;
}
/*
* Install a single package
* Returns 0 if everything is ok, >0 else
@ -211,7 +378,6 @@ static int
pkg_do(const char *pkg, lpkg_head_t *pkgs)
{
char playpen[MaxPathSize];
char replace_from[MaxPathSize];
char replace_via[MaxPathSize];
char replace_to[MaxPathSize];
char *buildinfo[BI_ENUM_COUNT];
@ -423,7 +589,12 @@ pkg_do(const char *pkg, lpkg_head_t *pkgs)
}
/* Protect against old packages with bogus @name fields */
PkgName = (p = find_plist(&Plist, PLIST_NAME)) ? p->name : "anonymous";
p = find_plist(&Plist, PLIST_NAME);
if (p->name == NULL) {
warnx("PLIST contains no @name field");
goto bomb;
}
PkgName = p->name;
if (fexists(VIEWS_FNAME))
is_depoted_pkg = TRUE;
@ -474,158 +645,14 @@ pkg_do(const char *pkg, lpkg_head_t *pkgs)
}
/* See if some other version of us is already installed */
{
char *s;
if ((s = strrchr(PkgName, '-')) != NULL) {
char buf[MaxPathSize];
char *best_installed;
/*
* See if the pkg is already installed. If so, we might
* want to upgrade/replace it.
*/
(void) snprintf(buf, sizeof(buf), "%.*s[0-9]*",
(int)(s - PkgName) + 1, PkgName);
best_installed = find_best_matching_installed_pkg(buf);
if (best_installed) {
if (Replace && !Fake) {
/* XXX Should list the steps in Fake mode */
snprintf(replace_from, sizeof(replace_from), "%s/%s/" REQUIRED_BY_FNAME,
dbdir, best_installed);
snprintf(replace_via, sizeof(replace_via), "%s/.%s." REQUIRED_BY_FNAME,
dbdir, best_installed);
snprintf(replace_to, sizeof(replace_to), "%s/%s/" REQUIRED_BY_FNAME,
dbdir, PkgName);
if (Verbose)
printf("Upgrading %s to %s.\n", best_installed, PkgName);
if (fexists(replace_from)) { /* Are there any dependencies? */
/*
* Upgrade step 1/4: Check if the new version is ok with all pkgs
* (from +REQUIRED_BY) that require this pkg
*/
FILE *rb; /* +REQUIRED_BY file */
char pkg2chk[MaxPathSize];
rb = fopen(replace_from, "r");
if (! rb) {
warnx("Cannot open '%s' for reading%s", replace_from,
Force ? " (proceeding anyways)" : "");
if (Force)
goto ignore_replace_depends_check;
else
goto bomb;
}
while (fgets(pkg2chk, sizeof(pkg2chk), rb)) {
package_t depPlist;
FILE *depf;
plist_t *depp;
char depC[MaxPathSize];
depPlist.head = depPlist.tail = NULL;
s = strrchr(pkg2chk, '\n');
if (s)
*s = '\0'; /* strip trailing '\n' */
/*
* step into pkg2chk, read it's +CONTENTS file and see if
* all @pkgdep lines agree with PkgName (using pkg_match())
*/
snprintf(depC, sizeof(depC), "%s/%s/%s", dbdir, pkg2chk, CONTENTS_FNAME);
depf = fopen(depC , "r");
if (depf == NULL) {
warnx("Cannot check depends in '%s'%s", depC,
Force ? " (proceeding anyways)" : "!" );
if (Force)
goto ignore_replace_depends_check;
else
goto bomb;
}
read_plist(&depPlist, depf);
fclose(depf);
for (depp = depPlist.head; depp; depp = depp->next) {
char base_new[MaxPathSize];
char base_exist[MaxPathSize];
char *s2;
if (depp->type != PLIST_PKGDEP)
continue;
/* Prepare basename (no versions) of both pkgs,
* to see if we want to compare against that
* one at all.
*/
strlcpy(base_new, PkgName, sizeof(base_new));
s2 = strpbrk(base_new, "<>[]?*{"); /* } */
if (s2)
*s2 = '\0';
else {
s2 = strrchr(base_new, '-');
if (s2)
*s2 = '\0';
}
strlcpy(base_exist, depp->name, sizeof(base_exist));
s2 = strpbrk(base_exist, "<>[]?*{"); /* } */
if (s2)
*s2 = '\0';
else {
s2 = strrchr(base_exist, '-');
if (s2)
*s2 = '\0';
}
if (strcmp(base_new, base_exist) == 0) {
/* Same pkg, so do the interesting compare */
if (pkg_match(depp->name, PkgName)) {
if (Verbose)
printf("@pkgdep check: %s is ok for %s (in %s pkg)\n",
PkgName, depp->name, pkg2chk);
} else {
printf("Package %s requires %s, \n\tCannot replace with %s%s\n",
pkg2chk, depp->name, PkgName,
Force? " (proceeding anyways)" : "!");
if (! Force)
goto bomb;
}
}
}
}
fclose(rb);
ignore_replace_depends_check:
/*
* Upgrade step 2/4: Do the actual update by moving aside
* the +REQUIRED_BY file, deinstalling the old pkg, adding
* the new one and moving the +REQUIRED_BY file back
* into place (finished in step 3/4)
*/
if (Verbose)
printf("mv %s %s\n", replace_from, replace_via);
rc = rename(replace_from, replace_via);
assert(rc == 0);
replacing = 1;
}
if (Verbose) {
printf("%s/pkg_delete -K %s '%s'\n",
BINDIR,
dbdir,
best_installed);
}
fexec(BINDIR "/pkg_delete", "-K", dbdir, best_installed, NULL);
} else if (!is_depoted_pkg) {
warnx("other version '%s' already installed", best_installed);
errc = 1;
goto success; /* close enough for government work */
}
free(best_installed);
}
}
switch (pkg_do_installed(&replacing, replace_via, replace_to, is_depoted_pkg, dbdir)) {
case 0:
break;
case 1:
errc = 1;
goto success;
case -1:
goto bomb;
}
/* See if there are conflicting packages installed */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.1.1.3 2007/08/14 22:59:50 joerg Exp $ */
/* $NetBSD: main.c,v 1.1.1.4 2007/08/23 15:19:13 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -8,7 +8,7 @@
#include <sys/cdefs.h>
#endif
#ifndef lint
__RCSID("$NetBSD: main.c,v 1.1.1.3 2007/08/14 22:59:50 joerg Exp $");
__RCSID("$NetBSD: main.c,v 1.1.1.4 2007/08/23 15:19:13 joerg Exp $");
#endif
/*
@ -229,8 +229,9 @@ add1pkg(const char *pkgdir)
FILE *f;
plist_t *p;
package_t Plist;
char contents[MaxPathSize];
char *PkgDBDir, *PkgName, *dirp;
char *contents;
const char *PkgDBDir;
char *PkgName, *dirp;
char file[MaxPathSize];
char dir[MaxPathSize];
int cnt = 0;
@ -239,14 +240,10 @@ add1pkg(const char *pkgdir)
err(EXIT_FAILURE, "cannot open pkgdb");
PkgDBDir = _pkgdb_getPKGDB_DIR();
(void) snprintf(contents, sizeof(contents), "%s/%s", PkgDBDir, pkgdir);
if (!(isdir(contents) || islinktodir(contents)))
errx(EXIT_FAILURE, "`%s' does not exist.", contents);
(void) strlcat(contents, "/", sizeof(contents));
(void) strlcat(contents, CONTENTS_FNAME, sizeof(contents));
contents = pkgdb_pkg_file(pkgdir, CONTENTS_FNAME);
if ((f = fopen(contents, "r")) == NULL)
errx(EXIT_FAILURE, "%s: can't open `%s'", pkgdir, CONTENTS_FNAME);
free(contents);
Plist.head = Plist.tail = NULL;
read_plist(&Plist, f);
@ -323,7 +320,7 @@ rebuild(void)
{
DIR *dp;
struct dirent *de;
char *PkgDBDir;
const char *PkgDBDir;
char cachename[MaxPathSize];
pkgcnt = 0;
@ -455,9 +452,7 @@ remove_required_by(const char *pkgname, void *cookie)
{
char *path;
if (asprintf(&path, "%s/%s/%s", _pkgdb_getPKGDB_DIR(), pkgname,
REQUIRED_BY_FNAME) == -1)
errx(EXIT_FAILURE, "asprintf failed");
path = pkgdb_pkg_file(pkgname, REQUIRED_BY_FNAME);
if (unlink(path) == -1 && errno != ENOENT)
err(EXIT_FAILURE, "Cannot remove %s", path);
@ -480,9 +475,7 @@ add_required_by(const char *pattern, const char *required_by)
return;
}
if (asprintf(&path, "%s/%s/%s", _pkgdb_getPKGDB_DIR(), best_installed,
REQUIRED_BY_FNAME) == -1)
errx(EXIT_FAILURE, "asprintf failed");
path = pkgdb_pkg_file(best_installed, REQUIRED_BY_FNAME);
free(best_installed);
if ((fd = open(path, O_WRONLY | O_APPEND | O_CREAT, 0644)) == -1)
@ -505,9 +498,7 @@ add_depends_of(const char *pkgname, void *cookie)
package_t plist;
char *path;
if (asprintf(&path, "%s/%s/%s", _pkgdb_getPKGDB_DIR(), pkgname,
CONTENTS_FNAME) == -1)
errx(EXIT_FAILURE, "asprintf failed");
path = pkgdb_pkg_file(pkgname, CONTENTS_FNAME);
if ((fp = fopen(path, "r")) == NULL)
errx(EXIT_FAILURE, "Cannot read %s of package %s",
CONTENTS_FNAME, pkgname);
@ -847,9 +838,7 @@ set_installed_info_var(const char *name, void *cookie)
char *filename;
int retval;
if (asprintf(&filename, "%s/%s/%s", _pkgdb_getPKGDB_DIR(), name,
INSTALLED_INFO_FNAME) == -1)
errx(EXIT_FAILURE, "asprintf failed");
filename = pkgdb_pkg_file(name, INSTALLED_INFO_FNAME);
retval = var_set(filename, arg->variable, arg->value);

View File

@ -1,4 +1,4 @@
/* $NetBSD: audit-packages.c,v 1.1.1.3 2007/08/14 22:59:50 joerg Exp $ */
/* $NetBSD: audit-packages.c,v 1.1.1.4 2007/08/23 15:19:13 joerg Exp $ */
/*
* Copyright (c) 2007 Adrian Portelli <adrianp@NetBSD.org>.
@ -126,10 +126,10 @@ int check_sig(char *);
int pv_message(char *[]);
int ap_ignore(char *[]);
void show_info(char *);
void set_pvfile(char *);
void set_pvfile(const char *);
char *clean_conf(char *);
int get_confvalues(void);
char *safe_strdup(char *);
char *safe_strdup(const char *);
/*
* TODO:
@ -574,6 +574,7 @@ char *
clean_conf(char *conf_line)
{
int i = 0;
size_t len = 0;
char *token = NULL;
char *cp;
@ -600,6 +601,13 @@ clean_conf(char *conf_line)
}
}
len = strlen(token);
/* look for entries with no associated value */
if (len == 0) {
token = NULL;
}
return token;
}
@ -611,6 +619,9 @@ get_confvalues(void)
char *line_ptr = NULL;
char *line = NULL;
char *retval = NULL;
Boolean f_ignore = FALSE;
Boolean f_verify_bin = FALSE;
Boolean f_set_pvfile = FALSE;
if ((conf = fopen(conf_file, "r")) == NULL) {
if (verbose >= 2)
@ -629,20 +640,29 @@ get_confvalues(void)
if ((line[0] == '#') || (line[0] == '\n'))
continue;
if (strncmp(line, "IGNORE_URLS", 11) == 0) {
if ((strncmp(line, "IGNORE_URLS", 11) == 0) &&
(f_ignore == FALSE)) {
retval = clean_conf(line);
if (retval != NULL)
if (retval != NULL) {
ignore = safe_strdup(retval);
f_ignore = TRUE;
}
}
else if (strncmp(line, "GPG", 3) == 0) {
else if ((strncmp(line, "GPG", 3) == 0) &&
(f_verify_bin == FALSE)) {
retval = clean_conf(line);
if (retval != NULL)
verify_bin = retval;
if (retval != NULL) {
verify_bin = safe_strdup(retval);
f_verify_bin = TRUE;
}
}
else if (strncmp(line, "PKGVULNDIR", 9) == 0) {
else if ((strncmp(line, "PKGVULNDIR", 9) == 0) &&
(f_set_pvfile == FALSE)) {
retval = clean_conf(line);
if (retval != NULL)
if (retval != NULL) {
set_pvfile(retval);
f_set_pvfile = TRUE;
}
}
retval = NULL;
@ -1035,7 +1055,7 @@ show_info(char *varname)
/* set the location for the pkg-vulnerabilities file */
void
set_pvfile(char *vuln_dir)
set_pvfile(const char *vuln_dir)
{
char *pvloc = NULL;
size_t retval;
@ -1053,7 +1073,7 @@ set_pvfile(char *vuln_dir)
/* duplicate a string and check the return value */
char *
safe_strdup(char *dupe)
safe_strdup(const char *dupe)
{
char *retval;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.1.1.2 2007/08/14 22:59:50 joerg Exp $ */
/* $NetBSD: main.c,v 1.1.1.3 2007/08/23 15:19:13 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -11,7 +11,7 @@
#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.1.1.2 2007/08/14 22:59:50 joerg Exp $");
__RCSID("$NetBSD: main.c,v 1.1.1.3 2007/08/23 15:19:13 joerg Exp $");
#endif
#endif
@ -167,7 +167,7 @@ main(int argc, char **argv)
errx(EXIT_FAILURE, "error expanding '%s' ('%s' nonexistent?)", *argv, _pkgdb_getPKGDB_DIR());
}
} else {
char *dbdir;
const char *dbdir;
dbdir = _pkgdb_getPKGDB_DIR();
if (**argv == '/' && strncmp(*argv, dbdir, strlen(dbdir)) == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.1.1.3 2007/08/14 22:59:51 joerg Exp $ */
/* $NetBSD: main.c,v 1.1.1.4 2007/08/23 15:19:14 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -11,7 +11,7 @@
#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.1.1.3 2007/08/14 22:59:51 joerg Exp $");
__RCSID("$NetBSD: main.c,v 1.1.1.4 2007/08/23 15:19:14 joerg Exp $");
#endif
#endif
@ -315,7 +315,7 @@ main(int argc, char **argv)
errx(EXIT_FAILURE, "Error during search in pkgdb for %s", *argv);
}
} else {
char *dbdir;
const char *dbdir;
dbdir = _pkgdb_getPKGDB_DIR();
if (**argv == '/' && strncmp(*argv, dbdir, strlen(dbdir)) == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: show.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $ */
/* $NetBSD: show.c,v 1.1.1.3 2007/08/23 15:19:14 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -11,7 +11,7 @@
#if 0
static const char *rcsid = "from FreeBSD Id: show.c,v 1.11 1997/10/08 07:47:38 charnier Exp";
#else
__RCSID("$NetBSD: show.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $");
__RCSID("$NetBSD: show.c,v 1.1.1.3 2007/08/23 15:19:14 joerg Exp $");
#endif
#endif
@ -139,16 +139,15 @@ show_file(const char *pkg, const char *title, const char *fname, Boolean separat
void
show_var(const char *pkg, const char *fname, const char *variable)
{
char *value;
char filename[BUFSIZ];
char *filename, *value;
(void)snprintf(filename, sizeof(filename), "%s/%s/%s",
_pkgdb_getPKGDB_DIR(), pkg, fname);
filename = pkgdb_pkg_file(pkg, fname);
if ((value=var_get(fname, variable)) != NULL) {
(void) printf("%s\n", value);
free(value);
if ((value = var_get(filename, variable)) != NULL) {
(void) printf("%s\n", value);
free(value);
}
free(filename);
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: automatic.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $ */
/* $NetBSD: automatic.c,v 1.1.1.3 2007/08/23 15:19:14 joerg Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#endif
#ifndef lint
__RCSID("$NetBSD: automatic.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $");
__RCSID("$NetBSD: automatic.c,v 1.1.1.3 2007/08/23 15:19:14 joerg Exp $");
#endif
#if HAVE_ASSERT_H
@ -69,14 +69,12 @@ __RCSID("$NetBSD: automatic.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $");
Boolean
is_automatic_installed(const char *pkg)
{
char filename[BUFSIZ];
char *value;
char *filename, *value;
Boolean ret;
assert(pkg[0] != '/');
(void)snprintf(filename, sizeof(filename), "%s/%s/%s",
_pkgdb_getPKGDB_DIR(), pkg, INSTALLED_INFO_FNAME);
filename = pkgdb_pkg_file(pkg, INSTALLED_INFO_FNAME);
value = var_get(filename, AUTOMATIC_VARNAME);
@ -86,6 +84,7 @@ is_automatic_installed(const char *pkg)
ret = FALSE;
free(value);
free(filename);
return ret;
}
@ -93,13 +92,16 @@ is_automatic_installed(const char *pkg)
int
mark_as_automatic_installed(const char *pkg, int value)
{
char filename[BUFSIZ];
char *filename;
int retval;
assert(pkg[0] != '/');
(void)snprintf(filename, sizeof(filename), "%s/%s/%s",
_pkgdb_getPKGDB_DIR(), pkg, INSTALLED_INFO_FNAME);
filename = pkgdb_pkg_file(pkg, INSTALLED_INFO_FNAME);
return var_set(filename, AUTOMATIC_VARNAME,
value ? "yes" : NULL);
retval = var_set(filename, AUTOMATIC_VARNAME, value ? "yes" : NULL);
free(filename);
return retval;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: file.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $ */
/* $NetBSD: file.c,v 1.1.1.3 2007/08/23 15:19:14 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -17,7 +17,7 @@
#if 0
static const char *rcsid = "from FreeBSD Id: file.c,v 1.29 1997/10/08 07:47:54 charnier Exp";
#else
__RCSID("$NetBSD: file.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $");
__RCSID("$NetBSD: file.c,v 1.1.1.3 2007/08/23 15:19:14 joerg Exp $");
#endif
#endif
@ -369,7 +369,7 @@ resolvepattern(const char *name)
return cp;
/* add version number wildcard and try */
snprintf(tmp, sizeof(tmp), "%s-[0-9]*.t[bg]z", name);
snprintf(tmp, sizeof(tmp), "%s-[0-9]*", name);
return resolvepattern1(tmp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lib.h,v 1.1.1.3 2007/08/14 22:59:51 joerg Exp $ */
/* $NetBSD: lib.h,v 1.1.1.4 2007/08/23 15:19:15 joerg Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@ -400,9 +400,11 @@ int pkgdb_remove(const char *);
int pkgdb_remove_pkg(const char *);
char *pkgdb_refcount_dir(void);
char *_pkgdb_getPKGDB_FILE(char *, unsigned);
char *_pkgdb_getPKGDB_DIR(void);
const char *_pkgdb_getPKGDB_DIR(void);
void _pkgdb_setPKGDB_DIR(const char *);
char *pkgdb_pkg_file(const char *, const char *);
/* List of packages functions */
lpkg_t *alloc_lpkg(const char *);
lpkg_t *find_on_queue(lpkg_head_t *, const char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pkgdb.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $ */
/* $NetBSD: pkgdb.c,v 1.1.1.3 2007/08/23 15:19:15 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -8,7 +8,7 @@
#include <sys/cdefs.h>
#endif
#ifndef lint
__RCSID("$NetBSD: pkgdb.c,v 1.1.1.2 2007/08/14 22:59:51 joerg Exp $");
__RCSID("$NetBSD: pkgdb.c,v 1.1.1.3 2007/08/23 15:19:15 joerg Exp $");
#endif
/*
@ -314,7 +314,7 @@ _pkgdb_getPKGDB_FILE(char *buf, unsigned size)
/*
* Return directory where pkgdb is stored
*/
char *
const char *
_pkgdb_getPKGDB_DIR(void)
{
char *tmp;
@ -338,3 +338,14 @@ _pkgdb_setPKGDB_DIR(const char *dir)
(void) snprintf(pkgdb_cache, sizeof(pkgdb_cache), "%s", dir);
pkgdb_dir = pkgdb_cache;
}
char *
pkgdb_pkg_file(const char *pkg, const char *file)
{
char *buf;
if (asprintf(&buf, "%s/%s/%s", _pkgdb_getPKGDB_DIR(), pkg, file) == -1)
err(EXIT_FAILURE, "asprintf failed");
return buf;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: version.h,v 1.1.1.4 2007/08/14 22:59:51 joerg Exp $ */
/* $NetBSD: version.h,v 1.1.1.5 2007/08/23 15:19:15 joerg 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 "20070814"
#define PKGTOOLS_VERSION "20070821"
#endif /* _INST_LIB_VERSION_H_ */