pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files Update pkgtools/pkg_install...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/910896ea7dec
branches:  trunk
changeset: 488562:910896ea7dec
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Fri Feb 04 09:10:13 2005 +0000

description:
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:

 pkgtools/pkg_install/files/add/perform.c          |  39 ++++++---------------
 pkgtools/pkg_install/files/add/pkg_add.1          |  18 +++++++++-
 pkgtools/pkg_install/files/add/pkg_add.cat1       |  14 ++++++-
 pkgtools/pkg_install/files/delete/perform.c       |   6 ++-
 pkgtools/pkg_install/files/delete/pkg_delete.1    |  29 +++++++++++++++-
 pkgtools/pkg_install/files/delete/pkg_delete.cat1 |  17 +++++++++-
 pkgtools/pkg_install/files/lib/file.c             |  40 +++++++++++++++++++++-
 pkgtools/pkg_install/files/lib/lib.h              |  16 ++++++++-
 pkgtools/pkg_install/files/lib/pkgdb.c            |  23 ++++++++++++-
 pkgtools/pkg_install/files/lib/version.h          |   4 +-
 10 files changed, 163 insertions(+), 43 deletions(-)

diffs (truncated from 450 to 300 lines):

diff -r e438ec26ca18 -r 910896ea7dec pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Fri Feb 04 01:54:38 2005 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Fri Feb 04 09:10:13 2005 +0000
@@ -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 @@
                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 @@
                (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 @@
                }
                /* 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 @@
                }
                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 -r e438ec26ca18 -r 910896ea7dec pkgtools/pkg_install/files/add/pkg_add.1
--- a/pkgtools/pkg_install/files/add/pkg_add.1  Fri Feb 04 01:54:38 2005 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.1  Fri Feb 04 09:10:13 2005 +0000
@@ -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 @@
 .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 @@
 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 -r e438ec26ca18 -r 910896ea7dec pkgtools/pkg_install/files/add/pkg_add.cat1
--- a/pkgtools/pkg_install/files/add/pkg_add.cat1       Fri Feb 04 01:54:38 2005 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.cat1       Fri Feb 04 09:10:13 2005 +0000
@@ -285,7 +285,11 @@
      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 @@
                  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 @@
 
      Sure to be others.
 
-NetBSD 2.0                     December 10, 2004                    NetBSD 2.0
+NetBSD 2.0                     February 4, 2005                     NetBSD 2.0
diff -r e438ec26ca18 -r 910896ea7dec pkgtools/pkg_install/files/delete/perform.c
--- a/pkgtools/pkg_install/files/delete/perform.c       Fri Feb 04 01:54:38 2005 +0000
+++ b/pkgtools/pkg_install/files/delete/perform.c       Fri Feb 04 09:10:13 2005 +0000
@@ -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 @@
 
                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 @@
                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 -r e438ec26ca18 -r 910896ea7dec pkgtools/pkg_install/files/delete/pkg_delete.1
--- a/pkgtools/pkg_install/files/delete/pkg_delete.1    Fri Feb 04 01:54:38 2005 +0000
+++ b/pkgtools/pkg_install/files/delete/pkg_delete.1    Fri Feb 04 09:10:13 2005 +0000
@@ -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 @@
 .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 -r e438ec26ca18 -r 910896ea7dec pkgtools/pkg_install/files/delete/pkg_delete.cat1
--- a/pkgtools/pkg_install/files/delete/pkg_delete.cat1 Fri Feb 04 01:54:38 2005 +0000
+++ b/pkgtools/pkg_install/files/delete/pkg_delete.cat1 Fri Feb 04 09:10:13 2005 +0000
@@ -139,6 +139,21 @@
      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 @@
              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 -r e438ec26ca18 -r 910896ea7dec pkgtools/pkg_install/files/lib/file.c
--- a/pkgtools/pkg_install/files/lib/file.c     Fri Feb 04 01:54:38 2005 +0000
+++ b/pkgtools/pkg_install/files/lib/file.c     Fri Feb 04 09:10:13 2005 +0000
@@ -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 @@
 }
 
 void
+move_files(const char *dir, const char *pattern, const char *to)



Home | Main Index | Thread Index | Old Index