On 1 July 2015 at 15:24, Olivier Martin <Olivier.Martin@arm.com> wrote:

I have got the similar lines in my CI system. It is quite useful.

But I only enable the FIRMWARE_VER when the binary is produced by the CI.


I like the feature from the Linux script where it will use an (annotated) tag if one exists.  I thought that would be useful for releases.  But that's relies on the tags being annotated, which we rarely do.

 

When the engineer build the firmware on his/her machine I leave the version empty.


With our new Platforms releases, the users are all building from source now, so that's my main use case - to make sure they're building from the correct source ;-)

I'm also thinking about a similar patch for ARM-TF.


 

But your ‘-dirty’ addition is also useful.


Yes, it should help me identify sneaky users!!

 

 

 

From: Linaro-uefi [mailto:linaro-uefi-bounces@lists.linaro.org] On Behalf Of Ryan Harkin
Sent: 30 June 2015 17:22
To: Linaro UEFI Mailman List; Leif Lindholm
Subject: [Linaro-uefi] [RFC] Use commit id as default FIRMWARE_VER

 

Hello UEFI builders!

I'd like your feedback on this patch.

I often look at boot logs from LAVA and other people and don't quite know where the UEFI binary came from.  With ones that I've provided, I can often recognise the build date stamp.  But at other times, I'm simply trying to work out if someone is building the code they say they are, or some other code.

As the commit message says, rather than leaving the version string blank, my patch will append the git commit id of the current commit, with "dirty" appended if the user is building with uncommited mods.

I considered including the code from linux scripts/setlocalversion, but apart from giving me a "-" at the front, I thought it was overkill.

Comments?

Cheers,

Ryan.

 

--

From af952a40005536215cedbbeea9102915e461486f Mon Sep 17 00:00:00 2001
From: Ryan Harkin <ryan.harkin@linaro.org>
Date: Tue, 30 Jun 2015 15:10:56 +0100
Subject: [PATCH] Use commit id as default FIRMWARE_VER

If a FIRMWARE_VER setting is not provided and we are building from a GIT
repo, provide a default value based on the SHA ID of the commit where we
built from.

If the repo has local uncommited changes, then we mark the version
string with "-dirty".

This is based loosely on the same idea from the linux kernel in:
    scripts/setlocalversion

Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
---
 uefi-build.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/uefi-build.sh b/uefi-build.sh
index 486cf86..60ea872 100755
--- a/uefi-build.sh
+++ b/uefi-build.sh
@@ -27,6 +27,16 @@ function build_platform
     PLATFORM_DSC="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $board get -o dsc`"
     PLATFORM_ARCH="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $board get -o arch`"
 
+    if [[ $PLATFORM_BUILDFLAGS != *"FIRMWARE_VER"* ]]; then
+        if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
+            FIRMWARE_VER=`git rev-parse --short HEAD`
+            if ! git diff-index --quiet HEAD --; then
+                FIRMWARE_VER="${FIRMWARE_VER}-dirty"
+            fi
+            PLATFORM_BUILDFLAGS="$PLATFORM_BUILDFLAGS -D FIRMWARE_VER=$FIRMWARE_VER"
+        fi
+    fi
+
     set_cross_compile
     CROSS_COMPILE="$TEMP_CROSS_COMPILE"
 
--
2.1.0


-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782