pkg_install-20100203:

- Restore PKG_PREFIX in pkg_delete (PR 42731)
- Ensure that the current pkg_install version is at least as new as
  the version used to build the package
This commit is contained in:
joerg 2010-02-03 14:23:39 +00:00
parent 181451b104
commit e8182c96d5
5 changed files with 45 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: perform.c,v 1.1.1.13 2010/01/30 21:33:16 joerg Exp $ */
/* $NetBSD: perform.c,v 1.1.1.14 2010/02/03 14:23:39 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
#endif
@ -6,7 +6,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: perform.c,v 1.1.1.13 2010/01/30 21:33:16 joerg Exp $");
__RCSID("$NetBSD: perform.c,v 1.1.1.14 2010/02/03 14:23:39 joerg Exp $");
/*-
* Copyright (c) 2003 Grant Beattie <grant@NetBSD.org>
@ -57,6 +57,7 @@ __RCSID("$NetBSD: perform.c,v 1.1.1.13 2010/01/30 21:33:16 joerg Exp $");
#include "lib.h"
#include "add.h"
#include "version.h"
struct pkg_meta {
char *meta_contents;
@ -500,6 +501,9 @@ read_buildinfo(struct pkg_task *pkg)
eol);
else if (strncmp(data, "LICENSE=", 8) == 0)
pkg->buildinfo[BI_LICENSE] = dup_value(data, eol);
else if (strncmp(data, "PKGTOOLS_VERSION=", 17) == 0)
pkg->buildinfo[BI_PKGTOOLS_VERSION] = dup_value(data,
eol);
}
if (pkg->buildinfo[BI_OPSYS] == NULL ||
pkg->buildinfo[BI_OS_VERSION] == NULL ||
@ -879,6 +883,32 @@ check_platform(struct pkg_task *pkg)
return 0;
}
static int
check_pkgtools_version(struct pkg_task *pkg)
{
const char *val = pkg->buildinfo[BI_PKGTOOLS_VERSION];
int version;
if (val == NULL) {
warnx("Warning: package `%s' lacks pkg_install version data",
pkg->pkgname);
return 0;
}
if (strlen(val) != 8 || strspn(val, "0123456789") != 8) {
warnx("Warning: package `%s' contains an invalid pkg_install version",
pkg->pkgname);
return Force ? 0 : -1;
}
version = atoi(val);
if (version > PKGTOOLS_VERSION) {
warnx("%s: package `%s' was built with a newer pkg_install version",
Force ? "Warning" : "Error", pkg->pkgname);
return Force ? 0 : -1;
}
return 0;
}
/*
* Run the install script.
*/
@ -1336,6 +1366,9 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level)
if (read_buildinfo(pkg))
goto clean_memory;
if (check_pkgtools_version(pkg))
goto clean_memory;
if (check_vulnerable(pkg))
goto clean_memory;

View File

@ -34,7 +34,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: pkg_delete.c,v 1.1.1.6 2010/01/30 21:33:35 joerg Exp $");
__RCSID("$NetBSD: pkg_delete.c,v 1.1.1.7 2010/02/03 14:23:46 joerg Exp $");
#if HAVE_ERR_H
#include <err.h>
@ -683,6 +683,7 @@ remove_pkg(const char *pkg)
fname = pkgdb_pkg_dir(pkg);
setenv(PKG_METADATA_DIR_VNAME, fname, 1);
free(fname);
setenv(PKG_PREFIX_VNAME, p->name, 1);
if (!no_deinstall && !unregister_only) {
if (run_deinstall_script(pkg, 0) && !Force)

View File

@ -1,4 +1,4 @@
/* $NetBSD: lib.h,v 1.1.1.10 2010/01/30 21:33:47 joerg Exp $ */
/* $NetBSD: lib.h,v 1.1.1.11 2010/02/03 14:23:51 joerg Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@ -184,7 +184,8 @@ typedef enum bi_ent_t {
BI_IGNORE_RECOMMENDED, /* 3 */
BI_USE_ABI_DEPENDS, /* 4 */
BI_LICENSE, /* 5 */
BI_ENUM_COUNT /* 6 */
BI_ENUM_COUNT, /* 6 */
BI_PKGTOOLS_VERSION /* 7 */
} bi_ent_t;
/* Types */

View File

@ -1,4 +1,4 @@
/* $NetBSD: version.c,v 1.1.1.2 2009/02/02 20:44:08 joerg Exp $ */
/* $NetBSD: version.c,v 1.1.1.3 2010/02/03 14:24:00 joerg Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@ -7,7 +7,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: version.c,v 1.1.1.2 2009/02/02 20:44:08 joerg Exp $");
__RCSID("$NetBSD: version.c,v 1.1.1.3 2010/02/03 14:24:00 joerg Exp $");
/*
* Copyright (c) 2001 Thomas Klausner. All rights reserved.
@ -43,7 +43,7 @@ __RCSID("$NetBSD: version.c,v 1.1.1.2 2009/02/02 20:44:08 joerg Exp $");
void
show_version(void)
{
printf("%s\n", PKGTOOLS_VERSION);
printf("%d\n", PKGTOOLS_VERSION);
exit (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: version.h,v 1.1.1.24 2010/01/30 21:33:54 joerg Exp $ */
/* $NetBSD: version.h,v 1.1.1.25 2010/02/03 14:23:59 joerg Exp $ */
/*
* Copyright (c) 2001 Thomas Klausner. All rights reserved.
@ -27,6 +27,6 @@
#ifndef _INST_LIB_VERSION_H_
#define _INST_LIB_VERSION_H_
#define PKGTOOLS_VERSION "20100130"
#define PKGTOOLS_VERSION 20100203
#endif /* _INST_LIB_VERSION_H_ */