From 385f222d217188de7dd002c7a749886cf7ee7929 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Fri, 15 Feb 2019 10:26:16 -0800 Subject: gsctool: fix version string generation and processing Function reporting the version of the gsctool expects the VERSION variable generated by ./util/getversion.sh utility to start with a single underscore without a prefix. But the utility could be adding various prefixes to the VERSION string depending on the environment variable settings. Those settings are irrelevant for gsctool, it should ignore the prefix up to the first underscore character found in the VERSION string. Also, modify the Makefile to make sure the build date reported by getversion.sh is accurate. BRANCH=none BUG=chromium:932361 TEST=built gsctool and checked version reporting: make BOARD=cr50 CR50_DEV=1 gsctool ./gsctool -v Version: v2.0.821+e890d0974 tpm2:v0.0.320-e987095 \ cryptoc:v0.0.10-b256f39, built on 2019-02-15 10:25:08 \ by vbendeb@eskimo.mtv.corp.google.com Change-Id: I5fb6c4aa1dea6e857fffc7ec5e5a599d61175044 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/1474736 Commit-Ready: ChromeOS CL Exonerator Bot Reviewed-by: Namyoon Woo Reviewed-by: Nicolas Boichat --- extra/usb_updater/Makefile | 2 +- extra/usb_updater/gsctool.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/extra/usb_updater/Makefile b/extra/usb_updater/Makefile index fd616ec81f..7e9f11725b 100644 --- a/extra/usb_updater/Makefile +++ b/extra/usb_updater/Makefile @@ -63,7 +63,7 @@ usb_updater2: usb_updater2.c Makefile .PHONY: clean generated_version.h: $(GSCTOOL_SOURCES) - @../../util/getversion.sh > $@ + @(cd ../../; util/getversion.sh) > $@ clean: rm -rf $(PROGRAMS) *~ *.o *.d dp generated_version.h diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index 53273f8be5..e24306cbc2 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -2075,9 +2075,10 @@ static void process_factory_mode(struct transfer_descriptor *td, static void report_version(void) { /* Get version from the generated file, ignore the underscore prefix. */ - const char *v = VERSION + 1; + const char *v = strchr(VERSION, '_'); - printf("Version: %s, built on %s by %s\n", v, DATE, BUILDER); + printf("Version: %s, built on %s by %s\n", v ? v + 1 : "?", + DATE, BUILDER); exit(0); } -- cgit v1.2.1