diff options
author | jlam <jlam@pkgsrc.org> | 2005-02-04 09:10:13 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2005-02-04 09:10:13 +0000 |
commit | 21f238d2ab10dea987cd356cf988f57692483425 (patch) | |
tree | df2d36a484c7d28e736c190735e7552bd6610240 /pkgtools | |
parent | 9f3d69e32e5a104ffab295d8448b2abdf6a1eb22 (diff) | |
download | pkgsrc-21f238d2ab10dea987cd356cf988f57692483425.tar.gz |
Update pkgtools/pkg_install to 20050204 (latest release from the HEAD
branch of src). Changes from version 20050106:
Teach pkg_add(1) and pkg_delete(1) to pass PKG_METADATA_DIR and
PKG_REFCOUNT_DBDIR in the environment when running the +* scripts.
PKG_METADATA_DIR is the location of the +* files after the package is
registered. PKG_REFCOUNT_DBDIR is the location of the reference counts
database directory. If PKG_REFCOUNT_DBDIR is left unset, then it
defaults the the location of the package database directory with
".refcount" appended to the path, e.g. /var/db/pkg.refcount.
pkgviews users should explicitly set PKG_REFCOUNT_DBDIR in the shell
environment to ensure that all packages will use the same refcount
database.
These changes allow the +INSTALL and +DEINSTALL script to keep state
in +* files within ${PKG_METADATA_DIR}, and to store reference counts
in ${PKG_REFCOUNT_DBDIR} to handle usage of resources outside of
${LOCALBASE}.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkg_install/files/add/perform.c | 39 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/add/pkg_add.1 | 18 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/add/pkg_add.cat1 | 14 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/delete/perform.c | 6 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/delete/pkg_delete.1 | 29 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/delete/pkg_delete.cat1 | 17 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/file.c | 40 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/lib.h | 16 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/pkgdb.c | 23 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/version.h | 4 |
10 files changed, 163 insertions, 43 deletions
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c index a85d9f42a79..f7f3e4eaa3f 100644 --- a/pkgtools/pkg_install/files/add/perform.c +++ b/pkgtools/pkg_install/files/add/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.27 2004/12/29 12:16:56 agc Exp $ */ +/* $NetBSD: perform.c,v 1.28 2005/02/04 09:10:13 jlam Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -11,7 +11,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.27 2004/12/29 12:16:56 agc Exp $"); +__RCSID("$NetBSD: perform.c,v 1.28 2005/02/04 09:10:13 jlam Exp $"); #endif #endif @@ -444,7 +444,6 @@ pkg_do(const char *pkg, lpkg_head_t *pkgs) add_plist_top(&Plist, PLIST_CWD, Prefix); } - setenv(PKG_PREFIX_VNAME, (p = find_plist(&Plist, PLIST_CWD)) ? p->name : ".", 1); /* Protect against old packages with bogus @name fields */ PkgName = (p = find_plist(&Plist, PLIST_NAME)) ? p->name : "anonymous"; @@ -464,6 +463,11 @@ pkg_do(const char *pkg, lpkg_head_t *pkgs) (void) snprintf(LogDir, sizeof(LogDir), "%s/%s", dbdir, PkgName); } + /* Set environment variables expected by the +INSTALL script. */ + setenv(PKG_PREFIX_VNAME, (p = find_plist(&Plist, PLIST_CWD)) ? p->name : ".", 1); + setenv(PKG_METADATA_DIR_VNAME, LogDir, 1); + setenv(PKG_REFCOUNT_DBDIR_VNAME, pkgdb_refcount_dir(), 1); + /* make sure dbdir actually exists! */ if (!(isdir(dbdir) || islinktodir(dbdir))) { if (fexec("mkdir", "-p", dbdir, NULL)) { @@ -866,16 +870,11 @@ ignore_replace_depends_check: } /* Make sure pkg_info can read the entry */ (void) fexec(CHMOD_CMD, "a+rx", LogDir, NULL); - if (fexists(INSTALL_FNAME)) - move_file(".", INSTALL_FNAME, LogDir); - if (fexists(DEINSTALL_FNAME)) - move_file(".", DEINSTALL_FNAME, LogDir); - if (fexists(REQUIRE_FNAME)) - move_file(".", REQUIRE_FNAME, LogDir); - if (fexists(SIZE_PKG_FNAME)) - move_file(".", SIZE_PKG_FNAME, LogDir); - if (fexists(SIZE_ALL_FNAME)) - move_file(".", SIZE_ALL_FNAME, LogDir); + + /* Move all of the +-files into place */ + move_files(".", "+*", LogDir); + + /* Generate the +CONTENTS file in-place from the Plist */ (void) snprintf(contents, sizeof(contents), "%s/%s", LogDir, CONTENTS_FNAME); cfile = fopen(contents, "w"); if (!cfile) { @@ -885,20 +884,6 @@ ignore_replace_depends_check: } write_plist(&Plist, cfile, NULL); fclose(cfile); - move_file(".", DESC_FNAME, LogDir); - move_file(".", COMMENT_FNAME, LogDir); - if (fexists(BUILD_VERSION_FNAME)) - move_file(".", BUILD_VERSION_FNAME, LogDir); - if (fexists(BUILD_INFO_FNAME)) - move_file(".", BUILD_INFO_FNAME, LogDir); - if (fexists(DISPLAY_FNAME)) - move_file(".", DISPLAY_FNAME, LogDir); - if (fexists(PRESERVE_FNAME)) - move_file(".", PRESERVE_FNAME, LogDir); - if (fexists(VIEWS_FNAME)) { - is_depoted_pkg = TRUE; - move_file(".", VIEWS_FNAME, LogDir); - } /* register dependencies */ /* we could save some cycles here if we remembered what we diff --git a/pkgtools/pkg_install/files/add/pkg_add.1 b/pkgtools/pkg_install/files/add/pkg_add.1 index 82d412ce6e4..1a204acee75 100644 --- a/pkgtools/pkg_install/files/add/pkg_add.1 +++ b/pkgtools/pkg_install/files/add/pkg_add.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: pkg_add.1,v 1.11 2005/02/04 01:19:03 jlam Exp $ +.\" $NetBSD: pkg_add.1,v 1.12 2005/02/04 09:10:13 jlam Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -17,7 +17,7 @@ .\" .\" @(#)pkg_add.1 .\" -.Dd December 10, 2004 +.Dd February 4, 2005 .Dt PKG_ADD 1 .Os .Sh NAME @@ -514,6 +514,14 @@ is installed, even if the user might change it with the .Fl p flag to .Cm pkg_add . +The scripts are also called with the +.Ev PKG_METADATA_DIR +environment variable set to the location of the +.Ar +* +meta-data files, and with the +.Ev PKG_REFCOUNT_DBDIR +environment variable set to the location of the package reference counts +database directory. .Sh ENVIRONMENT .Bl -tag -width PKG_TMPDIR .It Ev LOCALBASE @@ -543,6 +551,12 @@ Each entry consists of a directory name or URL. The current directory may be indicated implicitly by an empty directory name, or explicitly by a single period. FTP URLs may not end with a slash. +.It Ev PKG_REFCOUNT_DBDIR +Location of the package reference counts database directory. +The default location is the path to the package database directory with +.Do .refcount Dc +appended to the path, e.g. +.Pa /var/db/pkg.refcount . .It Ev PKG_TMPDIR Staging directory for installing packages, defaults to /var/tmp. Set to directory with lots of free disk if you run out of diff --git a/pkgtools/pkg_install/files/add/pkg_add.cat1 b/pkgtools/pkg_install/files/add/pkg_add.cat1 index 82520bcd95e..e7325ccf26b 100644 --- a/pkgtools/pkg_install/files/add/pkg_add.cat1 +++ b/pkgtools/pkg_install/files/add/pkg_add.cat1 @@ -285,7 +285,11 @@ TTEECCHHNNIICCAALL DDEETTAAIILLSS PKG_PREFIX set to the installation prefix (see the --pp option above). This allows a package author to write a script that reliably performs some action on the directory where the package is installed, even if the - user might change it with the --pp flag to ppkkgg__aadddd. + user might change it with the --pp flag to ppkkgg__aadddd. The scripts are also + called with the PKG_METADATA_DIR environment variable set to the location + of the _+_* meta-data files, and with the PKG_REFCOUNT_DBDIR environment + variable set to the location of the package reference counts database + directory. EENNVVIIRROONNMMEENNTT LOCALBASE This is the location of the _v_i_e_w_b_a_s_e directory in which all @@ -304,6 +308,12 @@ EENNVVIIRROONNMMEENNTT empty directory name, or explicitly by a single period. FTP URLs may not end with a slash. + PKG_REFCOUNT_DBDIR + Location of the package reference counts database directory. + The default location is the path to the package database + directory with ``.refcount'' appended to the path, e.g. + _/_v_a_r_/_d_b_/_p_k_g_._r_e_f_c_o_u_n_t. + PKG_TMPDIR Staging directory for installing packages, defaults to /var/tmp. Set to directory with lots of free disk if you run out of space when installing a binary package. @@ -359,4 +369,4 @@ BBUUGGSS Sure to be others. -NetBSD 2.0 December 10, 2004 NetBSD 2.0 +NetBSD 2.0 February 4, 2005 NetBSD 2.0 diff --git a/pkgtools/pkg_install/files/delete/perform.c b/pkgtools/pkg_install/files/delete/perform.c index 14c5fb9f3ea..314415cc205 100644 --- a/pkgtools/pkg_install/files/delete/perform.c +++ b/pkgtools/pkg_install/files/delete/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.13 2004/12/29 12:16:56 agc Exp $ */ +/* $NetBSD: perform.c,v 1.14 2005/02/04 09:10:13 jlam Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -11,7 +11,7 @@ #if 0 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp"; #else -__RCSID("$NetBSD: perform.c,v 1.13 2004/12/29 12:16:56 agc Exp $"); +__RCSID("$NetBSD: perform.c,v 1.14 2005/02/04 09:10:13 jlam Exp $"); #endif #endif @@ -657,6 +657,7 @@ pkg_do(char *pkg) return 0; } + setenv(PKG_REFCOUNT_DBDIR_VNAME, pkgdb_refcount_dir(), 1); if (!getcwd(home, MaxPathSize)) { cleanup(0); errx(2, "unable to get current working directory!"); @@ -738,6 +739,7 @@ pkg_do(char *pkg) return 1; } setenv(PKG_PREFIX_VNAME, p->name, 1); + setenv(PKG_METADATA_DIR_VNAME, LogDir, 1); if (fexists(REQUIRE_FNAME)) { if (Verbose) printf("Executing 'require' script.\n"); diff --git a/pkgtools/pkg_install/files/delete/pkg_delete.1 b/pkgtools/pkg_install/files/delete/pkg_delete.1 index 11d1018d6ea..c6fad81be23 100644 --- a/pkgtools/pkg_install/files/delete/pkg_delete.1 +++ b/pkgtools/pkg_install/files/delete/pkg_delete.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: pkg_delete.1,v 1.9 2005/02/04 01:19:03 jlam Exp $ +.\" $NetBSD: pkg_delete.1,v 1.10 2005/02/04 09:10:13 jlam Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -17,7 +17,7 @@ .\" .\" from FreeBSD: @(#)pkg_delete.1 .\" -.Dd November 2, 2004 +.Dd February 4, 2005 .Dt PKG_DELETE 1 .Os .Sh NAME @@ -263,6 +263,31 @@ option when running .Nm or .Xr pkg_add 1 . +The scripts are also called with the +.Ev PKG_METADATA_DIR +environment variable set to the location of the +.Ar +* +meta-data files, and with the +.Ev PKG_REFCOUNT_DBDIR +environment variable set to the location of the package reference counts +database directory. +.Sh ENVIRONMENT +.Bl -tag -width PKG_DBDIR +.It Ev PKG_DBDIR +If the +.Fl K +flag isn't given, then +.Ev PKG_DBDIR +is the location of the package database directory. +The default package database directory is +.Pa /var/db/pkg . +.It Ev PKG_REFCOUNT_DBDIR +Location of the package reference counts database directory. +The default location is the path to the package database directory with +.Do .refcount Dc +appended to the path, e.g. +.Pa /var/db/pkg.refcount . +.El .Sh SEE ALSO .Xr pkg_add 1 , .Xr pkg_admin 1 , diff --git a/pkgtools/pkg_install/files/delete/pkg_delete.cat1 b/pkgtools/pkg_install/files/delete/pkg_delete.cat1 index f0f28546d98..36defe12d24 100644 --- a/pkgtools/pkg_install/files/delete/pkg_delete.cat1 +++ b/pkgtools/pkg_install/files/delete/pkg_delete.cat1 @@ -139,6 +139,21 @@ TTEECCHHNNIICCAALL DDEETTAAIILLSS author to write a script that reliably performs some action on the direc- tory where the package is installed, even if the user might have changed it by specifying the --pp option when running ppkkgg__ddeelleettee or pkg_add(1). + The scripts are also called with the PKG_METADATA_DIR environment vari- + able set to the location of the _+_* meta-data files, and with the + PKG_REFCOUNT_DBDIR environment variable set to the location of the pack- + age reference counts database directory. + +EENNVVIIRROONNMMEENNTT + PKG_DBDIR If the --KK flag isn't given, then PKG_DBDIR is the location of + the package database directory. The default package database + directory is _/_v_a_r_/_d_b_/_p_k_g. + + PKG_REFCOUNT_DBDIR + Location of the package reference counts database directory. + The default location is the path to the package database + directory with ``.refcount'' appended to the path, e.g. + _/_v_a_r_/_d_b_/_p_k_g_._r_e_f_c_o_u_n_t. SSEEEE AALLSSOO pkg_add(1), pkg_admin(1), pkg_create(1), pkg_info(1), mktemp(3), @@ -153,4 +168,4 @@ AAUUTTHHOORRSS NetBSD wildcard dependency processing, pkgdb, recursive "down" delete, etc. -NetBSD 2.0 November 2, 2004 NetBSD 2.0 +NetBSD 2.0 February 4, 2005 NetBSD 2.0 diff --git a/pkgtools/pkg_install/files/lib/file.c b/pkgtools/pkg_install/files/lib/file.c index b335fbc495d..5b97fbacf2a 100644 --- a/pkgtools/pkg_install/files/lib/file.c +++ b/pkgtools/pkg_install/files/lib/file.c @@ -1,4 +1,4 @@ -/* $NetBSD: file.c,v 1.13 2004/12/29 12:16:56 agc Exp $ */ +/* $NetBSD: file.c,v 1.14 2005/02/04 09:10:13 jlam Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -11,7 +11,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.13 2004/12/29 12:16:56 agc Exp $"); +__RCSID("$NetBSD: file.c,v 1.14 2005/02/04 09:10:13 jlam Exp $"); #endif #endif @@ -543,6 +543,42 @@ move_file(char *dir, char *fname, char *to) } void +move_files(const char *dir, const char *pattern, const char *to) +{ + char fpath[MaxPathSize]; + glob_t globbed; + int i; + + (void) snprintf(fpath, sizeof(fpath), "%s/%s", dir, pattern); + if ((i=glob(fpath, GLOB_NOSORT, NULL, &globbed)) != 0) { + switch(i) { + case GLOB_NOMATCH: + warn("no files matching ``%s'' found", fpath); + break; + case GLOB_ABORTED: + warn("globbing aborted"); + break; + case GLOB_NOSPACE: + warn("out-of-memory during globbing"); + break; + default: + warn("unknown error during globbing"); + break; + } + return; + } + + /* Moving globbed files -- we just use mv(1) to do the job */ + for (i=0; i<globbed.gl_pathc; i++) + if (fexec("mv", globbed.gl_pathv[i], to, NULL)) { + cleanup(0); + errx(2, "could not perform 'mv %s %s'", globbed.gl_pathv[i], to); + } + + return; +} + +void remove_files(const char *path, const char *pattern) { char fpath[MaxPathSize]; diff --git a/pkgtools/pkg_install/files/lib/lib.h b/pkgtools/pkg_install/files/lib/lib.h index eb4debb13eb..5e52701c6b2 100644 --- a/pkgtools/pkg_install/files/lib/lib.h +++ b/pkgtools/pkg_install/files/lib/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.15 2004/12/29 12:16:56 agc Exp $ */ +/* $NetBSD: lib.h,v 1.16 2005/02/04 09:10:13 jlam Exp $ */ /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ @@ -169,6 +169,18 @@ enum { /* The name of the "prefix" environment variable given to scripts */ #define PKG_PREFIX_VNAME "PKG_PREFIX" +/* + * The name of the "metadatadir" environment variable given to scripts. + * This variable holds the location of the +-files for this package. + */ +#define PKG_METADATA_DIR_VNAME "PKG_METADATA_DIR" + +/* + * The name of the environment variable holding the location to the + * reference-counts database directory. + */ +#define PKG_REFCOUNT_DBDIR_VNAME "PKG_REFCOUNT_DBDIR" + #define PKG_PATTERN_MAX MaxPathSize /* max length of pattern, including nul */ #define PKG_SUFFIX_MAX 10 /* max length of suffix, including nul */ @@ -308,6 +320,7 @@ Boolean make_preserve_name(char *, size_t, char *, char *); void write_file(char *, char *); void copy_file(char *, char *, char *); void move_file(char *, char *, char *); +void move_files(const char *, const char *, const char *); void remove_files(const char *, const char *); int delete_hierarchy(char *, Boolean, Boolean); int unpack(const char *, const char *); @@ -345,6 +358,7 @@ char *pkgdb_retrieve(const char *); void pkgdb_dump(void); 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); void _pkgdb_setPKGDB_DIR(const char *); diff --git a/pkgtools/pkg_install/files/lib/pkgdb.c b/pkgtools/pkg_install/files/lib/pkgdb.c index 2d48d344c75..ae88f0465e4 100644 --- a/pkgtools/pkg_install/files/lib/pkgdb.c +++ b/pkgtools/pkg_install/files/lib/pkgdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkgdb.c,v 1.22 2004/12/29 12:16:56 agc Exp $ */ +/* $NetBSD: pkgdb.c,v 1.23 2005/02/04 09:10:13 jlam 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.22 2004/12/29 12:16:56 agc Exp $"); +__RCSID("$NetBSD: pkgdb.c,v 1.23 2005/02/04 09:10:13 jlam Exp $"); #endif /* @@ -61,6 +61,9 @@ __RCSID("$NetBSD: pkgdb.c,v 1.22 2004/12/29 12:16:56 agc Exp $"); #if HAVE_STDIO_H #include <stdio.h> #endif +#if HAVE_STRING_H +#include <string.h> +#endif #include "lib.h" @@ -275,6 +278,22 @@ int pkgdb_remove_pkg(const char *pkg) { return 1; } #endif /* HAVE_DBOPEN */ /* + * Return the location of the package reference counts database directory. + */ +char * +pkgdb_refcount_dir(void) +{ + static char buf[MaxPathSize]; + char *tmp; + + if (tmp = getenv(PKG_REFCOUNT_DBDIR_VNAME)) + strlcpy(buf, tmp, sizeof(buf)); + else + snprintf(buf, sizeof(buf), "%s.refcount", _pkgdb_getPKGDB_DIR()); + return buf; +} + +/* * Return name of cache file in the buffer that was passed. */ char * diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index a7fade9494c..67bea6f9102 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.39 2005/01/07 11:58:12 agc Exp $ */ +/* $NetBSD: version.h,v 1.40 2005/02/04 09:10:13 jlam 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 "20050106" +#define PKGTOOLS_VERSION "20050204" #endif /* _INST_LIB_VERSION_H_ */ |