pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc Sync with version 20040730 from src/usr.sbin/pkg_insta...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d0e6c5b7634a
branches:  trunk
changeset: 479178:d0e6c5b7634a
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Fri Aug 06 16:57:03 2004 +0000

description:
Sync with version 20040730 from src/usr.sbin/pkg_install on the HEAD:

> Re-work the code which checks the recorded build versions of a binary
> package to make pkg_add work properly when no +BUILD_INFO file exists.
>
> Modify the return value from read_buildinfo() to return 1 for success
> and 0 for failure.
>
> Use symbolic constants, rather than integers.
>
> If we can't read the build information, always tell of this fact.
>
> Bump version to 20040730
>
> Addresses PR 26429; a different version of these mods were verified to
> allow a +BUILD_INFO-less binary package to be added by Martin Husemann.

diffstat:

 doc/CHANGES                                       |    3 +-
 pkgtools/pkg_install/files/add/extract.c          |    4 +-
 pkgtools/pkg_install/files/add/perform.c          |  202 +++++++++++--------
 pkgtools/pkg_install/files/add/pkg_add.1          |    4 +-
 pkgtools/pkg_install/files/add/pkg_add.cat1       |  121 +++++------
 pkgtools/pkg_install/files/admin/main.c           |    6 +-
 pkgtools/pkg_install/files/bpm/bpm.sh             |  222 ----------------------
 pkgtools/pkg_install/files/bpm/bpm.sh.in          |  222 ++++++++++++++++++++++
 pkgtools/pkg_install/files/configure              |    3 +-
 pkgtools/pkg_install/files/configure.ac           |    6 +-
 pkgtools/pkg_install/files/create/pkg_create.1    |    4 +-
 pkgtools/pkg_install/files/create/pkg_create.cat1 |  102 +++++-----
 pkgtools/pkg_install/files/create/pl.c            |    6 +-
 pkgtools/pkg_install/files/info/pkg_info.1        |    6 +-
 pkgtools/pkg_install/files/info/pkg_info.cat1     |   10 +-
 pkgtools/pkg_install/files/info/show.c            |    8 +-
 pkgtools/pkg_install/files/lib/pen.c              |   17 +-
 pkgtools/pkg_install/files/lib/pkgdb.c            |    4 +-
 pkgtools/pkg_install/files/lib/plist.c            |    6 +-
 pkgtools/pkg_install/files/lib/version.h          |    4 +-
 pkgtools/pkg_install/files/view/linkfarm.sh.in    |   55 +++--
 pkgtools/pkg_install/files/view/pkg_view.1        |    4 +-
 pkgtools/pkg_install/files/view/pkg_view.cat1     |   48 ++--
 pkgtools/pkg_install/files/view/pkg_view.sh.in    |    2 +-
 24 files changed, 551 insertions(+), 518 deletions(-)

diffs (truncated from 1762 to 300 lines):

diff -r c961137a9305 -r d0e6c5b7634a doc/CHANGES
--- a/doc/CHANGES       Fri Aug 06 16:55:06 2004 +0000
+++ b/doc/CHANGES       Fri Aug 06 16:57:03 2004 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES,v 1.6813 2004/08/06 16:55:06 jlam Exp $
+$NetBSD: CHANGES,v 1.6814 2004/08/06 16:57:05 jlam Exp $
 
 Changes to the packages collection and infrastructure in 2004:
 
@@ -3749,3 +3749,4 @@
        Moved amavisd-new to security/amavisd-new [jlam 2004-08-06]
        Updated getmail to 4.0.8 [schmonz 2004-08-06]
        Updated libnbcompat to 20040805 [jlam 2004-08-06]
+       Updated pkg_install to 20040730 [jlam 2004-08-06]
diff -r c961137a9305 -r d0e6c5b7634a pkgtools/pkg_install/files/add/extract.c
--- a/pkgtools/pkg_install/files/add/extract.c  Fri Aug 06 16:55:06 2004 +0000
+++ b/pkgtools/pkg_install/files/add/extract.c  Fri Aug 06 16:57:03 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extract.c,v 1.7 2003/09/23 13:22:37 grant Exp $        */
+/*     $NetBSD: extract.c,v 1.8 2004/08/06 16:57:03 jlam Exp $ */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -11,7 +11,7 @@
 #if 0
 static const char *rcsid = "FreeBSD - Id: extract.c,v 1.17 1997/10/08 07:45:35 charnier Exp";
 #else
-__RCSID("$NetBSD: extract.c,v 1.7 2003/09/23 13:22:37 grant Exp $");
+__RCSID("$NetBSD: extract.c,v 1.8 2004/08/06 16:57:03 jlam Exp $");
 #endif
 #endif
 
diff -r c961137a9305 -r d0e6c5b7634a pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Fri Aug 06 16:55:06 2004 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Fri Aug 06 16:57:03 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.23 2004/05/08 16:54:28 grant Exp $       */
+/*     $NetBSD: perform.c,v 1.24 2004/08/06 16:57:03 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.23 2004/05/08 16:54:28 grant Exp $");
+__RCSID("$NetBSD: perform.c,v 1.24 2004/08/06 16:57:03 jlam Exp $");
 #endif
 #endif
 
@@ -58,14 +58,75 @@
 #include <sys/utsname.h>
 #endif
 
-static int read_buildinfo(char **);
-
 static char LogDir[FILENAME_MAX];
 static int zapLogDir;          /* Should we delete LogDir? */
 
 static package_t Plist;
 static char *Home;
 
+/* used in build information */
+enum {
+       Good,
+       Missing,
+       Warning,
+       Fatal
+};
+
+/* Read package build information */
+static int
+read_buildinfo(char **buildinfo)
+{
+       char   *key;
+       char   *line;
+       size_t  len;
+       FILE   *fp;
+
+       if ((fp = fopen(BUILD_INFO_FNAME, "r")) == NULL) {
+               warnx("unable to open %s file.", BUILD_INFO_FNAME);
+               return 0;
+       }
+
+       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, version, and
+                * dependency recommendations
+                */
+               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);
+                       else if (strcmp(key, "IGNORE_RECOMMENDED") == 0)
+                           buildinfo[BI_IGNORE_RECOMMENDED] = strdup(line);
+               }
+       }
+       (void) fclose(fp);
+       if (buildinfo[BI_OPSYS] == NULL ||
+           buildinfo[BI_OS_VERSION] == NULL ||
+           buildinfo[BI_MACHINE_ARCH] == NULL) {
+               warnx("couldn't extract build information from package.");
+               return 0;
+       }
+       return 1;
+}
+
 static int
 sanity_check(const char *pkg)
 {
@@ -288,10 +349,13 @@
                }
        }
 
-       /* Check OS, version and architecture */
-       if (read_buildinfo(buildinfo) != 0 && !Force) {
-               warnx("aborting.");
-               goto bomb;
+       /* Read the OS, version and architecture from BUILD_INFO file */
+       if (!read_buildinfo(buildinfo)) {
+               warn("can't read build information from %s", BUILD_INFO_FNAME);
+               if (!Force) {
+                       warnx("aborting.");
+                       goto bomb;
+               }
        }
 
        if (uname(&host_uname) < 0) {
@@ -301,34 +365,54 @@
                        goto bomb;
                }
        } else {
-               int     osbad = 0;
+               int     status = Good;
 
-               /* If either the OS or arch are different, bomb */
-               if (strcmp(OPSYS_NAME, buildinfo[BI_OPSYS]) != 0 ||
-               strcmp(MACHINE_ARCH, buildinfo[BI_MACHINE_ARCH]) != 0)
-                       osbad = 2;
+               /* check that we have read some values from buildinfo */
+               if (buildinfo[BI_OPSYS] == NULL) {
+                       warnx("Missing operating system value from build information");
+                       status = Missing;
+               }
+               if (buildinfo[BI_MACHINE_ARCH] == NULL) {
+                       warnx("Missing machine architecture value from build information");
+                       status = Missing;
+               }
+               if (buildinfo[BI_OS_VERSION] == NULL) {
+                       warnx("Missing operating system version value from build information");
+                       status = Missing;
+               }
+
+               if (status == Good) {
+                       /* If either the OS or arch are different, bomb */
+                       if (strcmp(OPSYS_NAME, buildinfo[BI_OPSYS]) != 0 ||
+                           strcmp(MACHINE_ARCH, buildinfo[BI_MACHINE_ARCH]) != 0) {
+                               status = Fatal;
+                       }
 
-               /* If OS and arch are the same, warn if version differs */
-               if (strcmp(OPSYS_NAME, buildinfo[BI_OPSYS]) == 0 &&
-                   strcmp(MACHINE_ARCH, buildinfo[BI_MACHINE_ARCH]) == 0) {
-                       if (strcmp(host_uname.release, buildinfo[BI_OS_VERSION]) != 0)
-                               osbad = 1;
-               } else
-                       osbad = 2;
+                       /* If OS and arch are the same, warn if version differs */
+                       if (strcmp(OPSYS_NAME, buildinfo[BI_OPSYS]) == 0 &&
+                           strcmp(MACHINE_ARCH, buildinfo[BI_MACHINE_ARCH]) == 0) {
+                               if (strcmp(host_uname.release, buildinfo[BI_OS_VERSION]) != 0) {
+                                       status = Warning;
+                               }
+                       } else {
+                               status = Fatal;
+                       }
 
-               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],
-                           OPSYS_NAME,
-                           MACHINE_ARCH,
-                           host_uname.release);
+                       if (status != Good) {
+                               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],
+                                   OPSYS_NAME,
+                                   MACHINE_ARCH,
+                                   host_uname.release);
+                       }
                }
-               if (!Force && (osbad >= 2)) {
-                           warnx("aborting.");
-                           goto bomb;
+
+               if (!Force && status == Fatal) {
+                       warnx("aborting.");
+                       goto bomb;
                }
        }
 
@@ -957,57 +1041,3 @@
        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, version, and
-                * dependency recommendations
-                */
-               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);
-                       else if (strcmp(key, "IGNORE_RECOMMENDED") == 0)
-                           buildinfo[BI_IGNORE_RECOMMENDED] = 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 c961137a9305 -r d0e6c5b7634a pkgtools/pkg_install/files/add/pkg_add.1
--- a/pkgtools/pkg_install/files/add/pkg_add.1  Fri Aug 06 16:55:06 2004 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.1  Fri Aug 06 16:57:03 2004 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_add.1,v 1.8 2004/04/11 06:56:11 rh Exp $
+.\" $NetBSD: pkg_add.1,v 1.9 2004/08/06 16:57:03 jlam Exp $
 .\"
 .\" FreeBSD install - a package for the installation and maintenance
 .\" of non-core utilities.
@@ -17,7 +17,7 @@
 .\"
 .\"     @(#)pkg_add.1
 .\"
-.Dd December 20, 2003
+.Dd April 11, 2004
 .Dt PKG_ADD 1
 .Os



Home | Main Index | Thread Index | Old Index