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 Sync pkgtools/pkg_install w...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2ba9fd457a42
branches:  trunk
changeset: 465052:2ba9fd457a42
user:      grant <grant%pkgsrc.org@localhost>
date:      Sat Dec 20 04:23:05 2003 +0000

description:
Sync pkgtools/pkg_install with src/usr.sbin/pkg_install from 20031220.
New features include OS/arch/version checking and a large speed
improvement to pkg_info.

diffstat:

 pkgtools/pkg_install/files/add/main.c       |    9 +-
 pkgtools/pkg_install/files/add/perform.c    |  122 ++++++++++++++++++++++++++-
 pkgtools/pkg_install/files/add/pkg_add.1    |   16 +++-
 pkgtools/pkg_install/files/add/pkg_add.cat1 |   31 ++++--
 pkgtools/pkg_install/files/configure        |    3 +-
 pkgtools/pkg_install/files/configure.ac     |    2 +-
 pkgtools/pkg_install/files/info/perform.c   |    6 +-
 pkgtools/pkg_install/files/lib/config.h.in  |    3 +
 pkgtools/pkg_install/files/lib/file.c       |  118 +++++---------------------
 pkgtools/pkg_install/files/lib/ftpio.c      |    9 +-
 pkgtools/pkg_install/files/lib/lib.h        |   18 +++-
 pkgtools/pkg_install/files/lib/version.h    |    4 +-
 12 files changed, 210 insertions(+), 131 deletions(-)

diffs (truncated from 673 to 300 lines):

diff -r 7d6991f69988 -r 2ba9fd457a42 pkgtools/pkg_install/files/add/main.c
--- a/pkgtools/pkg_install/files/add/main.c     Sat Dec 20 04:20:32 2003 +0000
+++ b/pkgtools/pkg_install/files/add/main.c     Sat Dec 20 04:23:05 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.5 2003/09/23 07:13:46 grant Exp $   */
+/*     $NetBSD: main.c,v 1.6 2003/12/20 04:23:05 grant Exp $   */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -11,7 +11,7 @@
 #if 0
 static char *rcsid = "from FreeBSD Id: main.c,v 1.16 1997/10/08 07:45:43 charnier Exp";
 #else
-__RCSID("$NetBSD: main.c,v 1.5 2003/09/23 07:13:46 grant Exp $");
+__RCSID("$NetBSD: main.c,v 1.6 2003/12/20 04:23:05 grant Exp $");
 #endif
 #endif
 
@@ -201,9 +201,8 @@
        }
 
        error += pkg_perform(&pkgs);
-       if (error  != 0) {
-               if (Verbose)
-                       warnx("%d package addition(s) failed", error);
+       if (error != 0) {
+               warnx("%d package addition%s failed", error, error == 1 ? "" : "s");
                exit(1);
        }
        exit(0);
diff -r 7d6991f69988 -r 2ba9fd457a42 pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Sat Dec 20 04:20:32 2003 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Sat Dec 20 04:23:05 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.12 2003/09/23 13:22:38 grant Exp $       */
+/*     $NetBSD: perform.c,v 1.13 2003/12/20 04:23:05 grant 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.12 2003/09/23 13:22:38 grant Exp $");
+__RCSID("$NetBSD: perform.c,v 1.13 2003/12/20 04:23:05 grant Exp $");
 #endif
 #endif
 
@@ -51,6 +51,11 @@
 #if HAVE_STRING_H
 #include <string.h>
 #endif
+#if HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
+
+static int read_buildinfo(char **);
 
 static char LogDir[FILENAME_MAX];
 static int zapLogDir;          /* Should we delete LogDir? */
@@ -117,14 +122,16 @@
        char    replace_from[FILENAME_MAX];
        char    replace_via[FILENAME_MAX];
        char    replace_to[FILENAME_MAX];
+       char   *buildinfo[BI_ENUM_COUNT];
        int     replacing = 0;
        char   *where_to;
        char   dbdir[FILENAME_MAX];
-       const char *exact, *extra1, *extra2;
+       const char *exact, *extra1;
        FILE   *cfile;
        int     errc;
        plist_t *p;
        struct stat sb;
+       struct utsname host_uname;
        int     inPlace;
        int     rc;
        Boolean is_depoted_pkg = FALSE;
@@ -185,11 +192,10 @@
                                                goto bomb;
                                        }
                                }
-                               extra1 = "--fast-read";
-                               extra2 = CONTENTS_FNAME;
+                               extra1 = CONTENTS_FNAME;
                        } else {
                                /* some values for stdin */
-                               extra1 = extra2 = NULL;
+                               extra1 = NULL;
                                sb.st_size = 100000;    /* Make up a plausible average size */
                        }
                        Home = make_playpen(playpen, sizeof(playpen), sb.st_size * 4);
@@ -197,7 +203,7 @@
                                warnx("unable to make playpen for %ld bytes",
                                      (long) (sb.st_size * 4));
                        where_to = Home;
-                       if (unpack(pkg, extra1, extra2)) {
+                       if (unpack(pkg, extra1)) {
                                warnx("unable to extract table of contents file from `%s' - not a package?",
                                      pkg);
                                goto bomb;
@@ -258,7 +264,7 @@
                                goto success;
 
                        /* Finally unpack the whole mess */
-                       if (unpack(pkg, NULL, NULL)) {
+                       if (unpack(pkg, NULL)) {
                                warnx("unable to extract `%s'!", pkg);
                                goto bomb;
                        }
@@ -276,6 +282,56 @@
                }
        }
 
+       /* Check OS, version and architecture */
+       if (read_buildinfo(buildinfo) != 0 && !Force) {
+               warnx("aborting.");
+               goto bomb;
+       }
+
+       if (uname(&host_uname) == 0) {
+               int     osbad = 0;
+
+               /* handle Darwin's uname(3) on powerpc writing
+                * "Power Macintosh" in struct uname.machine.
+                */
+               if (strcmp(host_uname.machine, "Power Macintosh") == 0)
+                       strcpy(host_uname.machine, "powerpc"); /* it fits */
+
+               /* If either the OS or arch are different, bomb */
+               if (strcmp(host_uname.sysname, buildinfo[BI_OPSYS]) != 0 ||
+               strcmp(host_uname.machine, buildinfo[BI_MACHINE_ARCH]) != 0)
+                       osbad = 2;
+
+               /* If OS and arch are the same, warn if version differs */
+               if (strcmp(host_uname.sysname, buildinfo[BI_OPSYS]) == 0 &&
+                   strcmp(host_uname.machine, buildinfo[BI_MACHINE_ARCH]) == 0) {
+                       if (strcmp(host_uname.release, buildinfo[BI_OS_VERSION]) != 0)
+                               osbad = 1;
+               } else
+                       osbad = 2;
+
+               if (osbad) {
+                       warnx("Package `%s' OS mismatch:", pkg);
+                       warnx("%s/%s %s (pkg) vs. %s/%s %s (this host)",
+                           buildinfo[BI_OPSYS],
+                           buildinfo[BI_MACHINE_ARCH],
+                           buildinfo[BI_OS_VERSION],
+                           host_uname.sysname,
+                           host_uname.machine,
+                           host_uname.release);
+               }
+               if (!Force && (osbad >= 2)) {
+                           warnx("aborting.");
+                           goto bomb;
+               }
+       } else {
+               warnx("uname() failed.");
+               if (!Force) {
+                       warnx("aborting.");
+                       goto bomb;
+               }
+       }
+
        /*
          * If we have a prefix, delete the first one we see and add this
          * one in place of it.
@@ -878,3 +934,53 @@
        
        return err_cnt;
 }
+
+/* Read package build information */
+static int
+read_buildinfo(char **buildinfo)
+{
+       char   *key;
+       char   *line;
+       size_t  len;
+       FILE   *fp;
+
+       fp = fopen(BUILD_INFO_FNAME, "r");
+       if (!fp) {
+               warnx("unable to open %s file.", BUILD_INFO_FNAME);
+               return 1;
+       }
+
+       while ((line = fgetln(fp, &len)) != NULL) {
+               if (line[len - 1] == '\n')
+                       line[len - 1] = '\0';
+
+               if ((key = strsep(&line, "=")) == NULL)
+                       continue;
+
+               /*
+                * pkgsrc used to create the BUILDINFO file using
+                * "key= value", so skip the space if it's there.
+                */
+               if (line == NULL)
+                       continue;
+               if (line[0] == ' ')
+                       line += sizeof(char);
+
+               /* we only care about opsys, arch and version */
+               if (line[0] != '\0') {
+                       if (strcmp(key, "OPSYS") == 0)
+                           buildinfo[BI_OPSYS] = strdup(line);
+                       else if (strcmp(key, "OS_VERSION") == 0)
+                           buildinfo[BI_OS_VERSION] = strdup(line);
+                       else if (strcmp(key, "MACHINE_ARCH") == 0)
+                           buildinfo[BI_MACHINE_ARCH] = strdup(line);
+               }
+       }
+       if (buildinfo[BI_OPSYS] == NULL ||
+           buildinfo[BI_OS_VERSION] == NULL ||
+           buildinfo[BI_MACHINE_ARCH] == NULL) {
+               warnx("couldn't extract build information from package.");
+               return 1;
+       }
+       return 0;
+}
diff -r 7d6991f69988 -r 2ba9fd457a42 pkgtools/pkg_install/files/add/pkg_add.1
--- a/pkgtools/pkg_install/files/add/pkg_add.1  Sat Dec 20 04:20:32 2003 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.1  Sat Dec 20 04:23:05 2003 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_add.1,v 1.6 2003/10/29 23:00:28 jlam Exp $
+.\" $NetBSD: pkg_add.1,v 1.7 2003/12/20 04:23:05 grant Exp $
 .\"
 .\" FreeBSD install - a package for the installation and maintenance
 .\" of non-core utilities.
@@ -17,7 +17,7 @@
 .\"
 .\"     @(#)pkg_add.1
 .\"
-.Dd October 3, 2003
+.Dd December 20, 2003
 .Dt PKG_ADD 1
 .Os
 .Sh NAME
@@ -112,6 +112,8 @@
 .Nm
 will still try to find and auto-install missing prerequisite packages,
 a failure to find one will not be fatal.
+This flag also overrides the fatal error when the operating system or
+architecture the package was built on differ from that of the host.
 .It Fl I
 If an installation script exists for a given package, do not execute it.
 .It Fl K Ar pkg_dbdir
@@ -358,6 +360,16 @@
 is enabled, the package is now extracted directly into its
 final location, otherwise it is extracted into the staging area.
 .It
+The package build information is extracted from the
+.Pa +BUILD_INFO
+file and compared against the result of
+.Xr uname 3 .
+If the operating system or architecture of the package differ from
+that of the host, installation is aborted.
+This behavior is overridable with the
+.Fl f
+flag.
+.It
 If the package contains a
 .Ar require
 script (see
diff -r 7d6991f69988 -r 2ba9fd457a42 pkgtools/pkg_install/files/add/pkg_add.cat1
--- a/pkgtools/pkg_install/files/add/pkg_add.cat1       Sat Dec 20 04:20:32 2003 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.cat1       Sat Dec 20 04:23:05 2003 +0000
@@ -48,7 +48,10 @@
      --ff      Force installation to proceed even if prerequisite packages are
              not installed or the requirements script fails.  Although ppkkgg__aadddd
              will still try to find and auto-install missing prerequisite
-             packages, a failure to find one will not be fatal.
+             packages, a failure to find one will not be fatal.  This flag
+             also overrides the fatal error when the operating system or
+             architecture the package was built on differ from that of the
+             host.
 
      --II      If an installation script exists for a given package, do not exe-
              cute it.
@@ -198,7 +201,13 @@
                 extracted directly into its final location, otherwise it is
                 extracted into the staging area.
 
-           6.   If the package contains a _r_e_q_u_i_r_e script (see pkg_create(1)),
+           6.   The package build information is extracted from the
+                _+_B_U_I_L_D___I_N_F_O file and compared against the result of uname(3).
+                If the operating system or architecture of the package differ
+                from that of the host, installation is aborted.  This behavior
+                is overridable with the --ff flag.
+
+           7.   If the package contains a _r_e_q_u_i_r_e script (see pkg_create(1)),
                 it is executed with the following arguments:
 
                 _p_k_g_-_n_a_m_e      The name of the package being installed
@@ -211,7 +220,7 @@
                 If the _r_e_q_u_i_r_e script exits with a non-zero status code, the
                 installation is terminated.
 
-           7.   If the package contains an _i_n_s_t_a_l_l script, it is executed with



Home | Main Index | Thread Index | Old Index