From: Ben Gras Date: Thu, 22 Jul 2010 08:28:12 +0000 (+0000) Subject: pkg_install: some uname normalisation. X-Git-Tag: v3.1.8~162 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/dnssec-revoke.html?a=commitdiff_plain;h=81f6039a7f3d41e41c1c0f371d5f0e9801b531e1;p=minix.git pkg_install: some uname normalisation. --- diff --git a/commands/pkg_install/add/perform.c b/commands/pkg_install/add/perform.c index 93921a5f3..3ffd48d74 100644 --- a/commands/pkg_install/add/perform.c +++ b/commands/pkg_install/add/perform.c @@ -46,6 +46,7 @@ __RCSID("$NetBSD: perform.c,v 1.97 2010/06/16 23:02:48 joerg Exp $"); #ifdef __minix #include +#include #endif #include @@ -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; }