]> Zhao Yanbai Git Server - minix.git/commitdiff
pkg_install: some uname normalisation.
authorBen Gras <ben@minix3.org>
Thu, 22 Jul 2010 08:28:12 +0000 (08:28 +0000)
committerBen Gras <ben@minix3.org>
Thu, 22 Jul 2010 08:28:12 +0000 (08:28 +0000)
commands/pkg_install/add/perform.c

index 93921a5f35a245f4e2f337f4230dd8955b5c6245..3ffd48d740a7a6edea8d1fbbb713fabf05ed7b4a 100644 (file)
@@ -46,6 +46,7 @@ __RCSID("$NetBSD: perform.c,v 1.97 2010/06/16 23:02:48 joerg Exp $");
 
 #ifdef __minix
 #include <stdint.h>
+#include <assert.h>
 #endif
 
 #include <sys/utsname.h>
@@ -836,6 +837,26 @@ pkg_register_depends(struct pkg_task *pkg)
        free(text);
 }
 
+static void
+normalise_version(char *release, char *version)
+{
+       char actual_version[20];
+
+       assert(release && version);
+
+       if(strlen(release) > 0 && strlen(version) > 0)
+               sprintf(actual_version, "%s.%s", release, version);
+        else if(strlen(release) > 0)
+               strcpy(actual_version, release);
+       else if(strlen(version) > 0)
+               strcpy(actual_version, version);
+       else
+               errx(EXIT_FAILURE, "no version info");
+
+       strcpy(release, actual_version);
+       version[0] = '\0';
+}
+
 /*
  * Reduce the result from uname(3) to a canonical form.
  */
@@ -848,6 +869,7 @@ normalise_platform(struct utsname *host_name)
        span = strspn(host_name->release, "0123456789.");
        host_name->release[span] = '\0';
 #endif
+       normalise_version(host_name->release, host_name->version);
 }
 
 /*
@@ -882,24 +904,21 @@ check_platform(struct pkg_task *pkg)
            strcmp(effective_arch, pkg->buildinfo[BI_MACHINE_ARCH]) != 0)
                fatal = 1;
 
-       if (strcmp(host_uname.release, pkg->buildinfo[BI_OS_RELEASE]) != 0)
-               fatal = 1;
+       normalise_version(host_uname.release, host_uname.version);
 
-       if (strcmp(host_uname.version, pkg->buildinfo[BI_OS_VERSION]) != 0)
+       if (strcmp(host_uname.release, pkg->buildinfo[BI_OS_RELEASE]) != 0)
                fatal = 1;
 
        if (fatal) {
                warnx("Warning: package `%s' was built for a platform:",
                    pkg->pkgname);
-               warnx("%s/%s %s %s (pkg) vs. %s/%s %s %s (this host)",
+               warnx("%s/%s %s (pkg) vs. %s/%s %s (this host)",
                    pkg->buildinfo[BI_OPSYS],
                    pkg->buildinfo[BI_MACHINE_ARCH],
                    pkg->buildinfo[BI_OS_RELEASE],
-                   pkg->buildinfo[BI_OS_VERSION],
                    OPSYS_NAME,
                    effective_arch,
-                   host_uname.release,
-                       host_uname.version);
+                   host_uname.release);
                if (!Force && fatal)
                        return -1;
        }