From ee4e0b7c0ef8ab20a4a0865d2c68b99dbb68b98c Mon Sep 17 00:00:00 2001 From: Simon Rose <simon.rose@ess.eu> Date: Mon, 25 Jan 2021 17:49:37 +0100 Subject: [PATCH] Switched to + as build number separator --- configure/modules/CONFIG | 4 +- require-ess/src/require.c | 62 +++++++++++++++---------------- require-ess/src/version.h | 2 +- require-ess/tools/build_number.sh | 2 +- require-ess/tools/driver.makefile | 4 +- 5 files changed, 36 insertions(+), 38 deletions(-) diff --git a/configure/modules/CONFIG b/configure/modules/CONFIG index e9f0067b..3c30825d 100644 --- a/configure/modules/CONFIG +++ b/configure/modules/CONFIG @@ -1,6 +1,8 @@ # -*- mode: Makefile;-*- -E3_MODULE_VERSION:=$(E3_MODULE_VERSION)$(shell [[ "$(E3_MODULE_VERSION)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$$ ]] && echo -0) +BUILD_SEPARATOR = + + +E3_MODULE_VERSION:=$(E3_MODULE_VERSION)$(shell [[ "$(E3_MODULE_VERSION)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$$ ]] && echo $(BUILD_SEPARATOR)0) include $(EPICS_BASE)/configure/CONFIG_BASE_VERSION include $(REQUIRE_CONFIG)/CONFIG_REQUIRE diff --git a/require-ess/src/require.c b/require-ess/src/require.c index c725f37d..87972619 100644 --- a/require-ess/src/require.c +++ b/require-ess/src/require.c @@ -828,7 +828,7 @@ static int compareDigit(int found, int requested, char *name) */ static int compareVersions(const char *found, const char *request, int already_matched) { - semver_t sv_found, sv_request; + semver_t *sv_found, *sv_request; int match; debug("require: compareVersions(found=%s, request=%s)\n", found, request); @@ -844,51 +844,43 @@ static int compareVersions(const char *found, const char *request, int already_m return MISMATCH; } - /*sv_found = (semver_t *)calloc(1, sizeof(semver_t)); - sv_request = (semver_t *)calloc(1, sizeof(semver_t));*/ + sv_found = (semver_t *)calloc(1, sizeof(semver_t)); + sv_request = (semver_t *)calloc(1, sizeof(semver_t)); - parse_semver(found, &sv_found); - parse_semver(request, &sv_request); + parse_semver(found, sv_found); + parse_semver(request, sv_request); // test version, look for exact. - if (strlen(sv_request.test_str) > 0) + if (strlen(sv_request->test_str) > 0) { if (strcmp(found, request) == 0) { debug("require: compareVersions: Test version requested and found, matches exactly\n"); - return EXACT; + match = EXACT; } - - if (strlen(sv_found.test_str) > 0) + else if (strlen(sv_found->test_str) > 0) { debug("require: compareVersions: Test versions requested and found, no match\n"); - return MISMATCH; + match = MISMATCH; + } + else + { + debug("require: compareVersions: found numeric version, higher than test\n"); + match = HIGHER; } - - debug("require: compareVersions: found numeric version, higher than test\n"); - return HIGHER; - } - - if (strlen(sv_found.test_str) > 0) + } + else if (strlen(sv_found->test_str) > 0) { debug("require: compareVersions: Numeric version requested, test version found\n"); - return MISMATCH; + match = MISMATCH; } - - // At least three digits specifed - match = compareDigit(sv_found.major, sv_request.major, "major"); - if (match != MATCH) - return match; - match = compareDigit(sv_found.minor, sv_request.minor, "minor"); - if (match != MATCH) - return match; - match = compareDigit(sv_found.patch, sv_request.patch, "patch"); - if (match != MATCH) - return match; - - // build number not specified - if (sv_request.build == -1) - { + else if ((match = compareDigit(sv_found->major, sv_request->major, "major")) != MATCH) + ; + else if ((match = compareDigit(sv_found->minor, sv_request->minor, "minor")) != MATCH) + ; + else if ((match = compareDigit(sv_found->patch, sv_request->patch, "patch")) != MATCH) + ; + else if (sv_request->build == -1) { if (already_matched) { debug("require: compareVersions: No build number requested. Returning HIGHER\n"); @@ -899,8 +891,12 @@ static int compareVersions(const char *found, const char *request, int already_m debug("require: compareVersions: No build number requested. Returning MATCH\n"); return MATCH; } + } else { + match = compareDigit(sv_found->build, sv_request->build, "build"); } - return compareDigit(sv_found.build, sv_request.build, "build"); + cleanup_semver(sv_found); + cleanup_semver(sv_request); + return match; } /* require (module) diff --git a/require-ess/src/version.h b/require-ess/src/version.h index dd251116..e22a20c9 100644 --- a/require-ess/src/version.h +++ b/require-ess/src/version.h @@ -1,4 +1,4 @@ -#define VERSION_REGEX "^(([0-9]+)\\.([0-9]+)\\.([0-9]+)(\\-([0-9]+))?)?(.*)$" +#define VERSION_REGEX "^(([0-9]+)\\.([0-9]+)\\.([0-9]+)(\\+([0-9]+))?)?(.*)$" #define MAX_REGEX_GROUPS (7+1) #define MAJ_IX 2 diff --git a/require-ess/tools/build_number.sh b/require-ess/tools/build_number.sh index bfef0766..077cd151 100755 --- a/require-ess/tools/build_number.sh +++ b/require-ess/tools/build_number.sh @@ -16,7 +16,7 @@ v="$3" if [[ $v =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then # shellcheck disable=SC2012 - basename "$(ls -dvr "$p/$m/$v"?(-+([0-9])) 2>/dev/null | head -n 1)" + basename "$(ls -dvr "$p/$m/$v"?(++([0-9])) 2>/dev/null | head -n 1)" else echo "$v" fi \ No newline at end of file diff --git a/require-ess/tools/driver.makefile b/require-ess/tools/driver.makefile index 967314d2..df17899c 100644 --- a/require-ess/tools/driver.makefile +++ b/require-ess/tools/driver.makefile @@ -101,8 +101,8 @@ RM = rm -f CP = cp # This is to allow for build numbers in recognized versions. First regex is for grep, second for sed. -VERSIONGLOB = +([0-9]).+([0-9]).+([0-9])?(-+([0-9])) -VERSIONREGEX = [0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)? +VERSIONGLOB = +([0-9]).+([0-9]).+([0-9])?(++([0-9])) +VERSIONREGEX = [0-9]+\.[0-9]+\.[0-9]+(\+[0-9]+)? # Some generated file names: VERSIONFILE = ${PRJ}_version_${LIBVERSION}.c -- GitLab