From patchwork Wed Nov 11 04:40:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 542778 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BB3121402B0 for ; Wed, 11 Nov 2015 15:43:11 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 9EC811A0406 for ; Wed, 11 Nov 2015 15:43:11 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id C0B951A024B for ; Wed, 11 Nov 2015 15:42:51 +1100 (AEDT) Received: from localhost by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Nov 2015 14:42:50 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 11 Nov 2015 14:42:47 +1000 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: cyril.bur@au1.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 70BA32BB0052 for ; Wed, 11 Nov 2015 15:42:47 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAB4gdSV17367126 for ; Wed, 11 Nov 2015 15:42:47 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tAB4gFfN030738 for ; Wed, 11 Nov 2015 15:42:15 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tAB4gF55030293 for ; Wed, 11 Nov 2015 15:42:15 +1100 Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id C0EBFA03E1 for ; Wed, 11 Nov 2015 15:41:26 +1100 (AEDT) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Wed, 11 Nov 2015 15:40:02 +1100 Message-Id: <1447216804-21501-9-git-send-email-cyril.bur@au1.ibm.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1447216804-21501-1-git-send-email-cyril.bur@au1.ibm.com> References: <1447216804-21501-1-git-send-email-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15111104-0017-0000-0000-0000022F65A9 Subject: [Skiboot] [PATCH v2 08/10] external/gard: Add version information X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Method for recording version is identical to pflash. Uses the current skiboot version and any current repository state. Signed-off-by: Cyril Bur --- external/gard/Makefile | 20 +++++++++++++++----- external/gard/gard.c | 9 +++++++++ external/gard/rules.mk | 11 ++++++++++- external/gard/test/results/02-usage.out | 1 + external/gard/test/tests/02-usage | 2 ++ 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/external/gard/Makefile b/external/gard/Makefile index c3dc6fb..2f21607 100644 --- a/external/gard/Makefile +++ b/external/gard/Makefile @@ -6,7 +6,7 @@ include ../../external/common/rules.mk all: $(EXE) .PHONY: links -links: libflash ccan common +links: libflash ccan common make_version.sh libflash: ln -sf ../../libflash . @@ -17,17 +17,27 @@ ccan: common: ln -sf ../common . -check: all +make_version.sh: + ln -sf ../../make_version.sh + +#Rebuild version.o so that the the version always matches +#what the test suite will get from ./make_version.sh +check: version.o all @ln -sf ../../test/test.sh test/test.sh @test/test-gard $(OBJS): | links arch_links +.PHONY: VERSION-always +.version: VERSION-always + @echo $(GARD_VERSION) > $@.tmp + @cmp -s $@ $@.tmp || cp $@.tmp $@ + @rm -f $@.tmp + clean: arch_clean - rm -f $(OBJS) $(EXE) *.o *.d + rm -f $(OBJS) $(EXE) *.o *.d .version .version.tmp distclean: clean rm -f *.c~ *.h~ *.sh~ Makefile~ config.mk~ libflash/*.c~ libflash/*.h~ - rm -f libflash ccan .version .version.tmp - rm -f common io.h make_version.sh + rm -f libflash ccan common io.h make_version.sh diff --git a/external/gard/gard.c b/external/gard/gard.c index b656f40..e41047f 100644 --- a/external/gard/gard.c +++ b/external/gard/gard.c @@ -44,6 +44,9 @@ #define SYSFS_MTD_PATH "/sys/class/mtd/" #define FLASH_GARD_PART "GUARD" +/* Full gard version number (possibly includes gitid). */ +extern const char version[]; + struct gard_ctx { bool ecc; uint32_t f_size; @@ -637,10 +640,16 @@ struct { { "clear", "Clear GARD records", do_clear }, }; +static void print_version(void) +{ + printf("Open-Power GARD tool %s\n", version); +} + static void usage(const char *progname) { unsigned int i; + print_version(); fprintf(stderr, "Usage: %s [-a -e -f -p] []\n\n", progname); fprintf(stderr, "-e --ecc\n\tForce reading/writing with ECC bytes.\n\n"); diff --git a/external/gard/rules.mk b/external/gard/rules.mk index bef8fbb..a78a401 100644 --- a/external/gard/rules.mk +++ b/external/gard/rules.mk @@ -1,7 +1,7 @@ .DEFAULT_GOAL := all override CFLAGS += -O2 -Wall -Werror -I. -OBJS = gard.o +OBJS = version.o gard.o OBJS += libflash/file.o libflash/libflash.o libflash/libffs.o libflash/ecc.o libflash/blocklevel.o OBJS += common/arch_flash.o EXE = gard @@ -13,6 +13,15 @@ sbindir = $(prefix)/sbin datadir = $(prefix)/share mandir = $(datadir)/man +GARD_VERSION ?= $(shell ./make_version.sh $(EXE)) + +version.c: make_version.sh .version + @(if [ "a$(GARD_VERSION)" = "a" ]; then \ + echo "#error You need to set GARD_VERSION environment variable" > $@ ;\ + else \ + echo "const char version[] = \"$(GARD_VERSION)\";" ;\ + fi) > $@ + %.o : %.c $(CC) $(CFLAGS) -c $< -o $@ diff --git a/external/gard/test/results/02-usage.out b/external/gard/test/results/02-usage.out index e69de29..c862167 100644 --- a/external/gard/test/results/02-usage.out +++ b/external/gard/test/results/02-usage.out @@ -0,0 +1 @@ +Open-Power GARD tool VERSION diff --git a/external/gard/test/tests/02-usage b/external/gard/test/tests/02-usage index 768f5d0..45e5e02 100644 --- a/external/gard/test/tests/02-usage +++ b/external/gard/test/tests/02-usage @@ -5,6 +5,8 @@ if [ "$?" -ne 1 ] ; then fail_test fi +strip_version_from_result "gard" + diff_with_result pass_test