#!/bin/bash
#
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Generate version information for the EC binary

if ghash=`git rev-parse --short --verify HEAD 2>/dev/null`; then
	if gdesc=`git describe --dirty --match='v*' 2>/dev/null`; then
		IFS="-" fields=($gdesc)
		tag="${fields[0]}"
		IFS="." vernum=($tag)
		numcommits=$((${vernum[2]}+${fields[1]:-0}))
		ver_major="${vernum[0]}"
		ver_branch="${vernum[1]}"
	else
		numcommits=`git rev-list HEAD | wc -l`
		ver_major="v0"
		ver_branch="0"
	fi
	# avoid putting the -dirty attribute if only the timestamp
	# changed
	git status > /dev/null 2>&1

	dirty=`sh -c "[ '$(git diff-index --name-only HEAD)' ] && echo '-dirty'"`
	ver="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
else
	ver="no_version"
fi
echo "#define VERSION \"${ver}\""
echo "#define DATE \"`date '+%F %T'`\""
echo "#define BUILDER \"${USER}@`hostname`\""

#!/bin/bash
#
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Generate version information for the EC binary

if ghash=`git rev-parse --short --verify HEAD 2>/dev/null`; then
	if gdesc=`git describe --dirty --match='v*' 2>/dev/null`; then
		IFS="-" fields=($gdesc)
		tag="${fields[0]}"
		IFS="." vernum=($tag)
		numcommits=$((${vernum[2]}+${fields[1]:-0}))
		ver_major="${vernum[0]}"
		ver_branch="${vernum[1]}"
	else
		numcommits=`git rev-list HEAD | wc -l`
		ver_major="v0"
		ver_branch="0"
	fi
	# avoid putting the -dirty attribute if only the timestamp
	# changed
	git status > /dev/null 2>&1

	dirty=`sh -c "[ '$(git diff-index --name-only HEAD)' ] && echo '-dirty'"`
	ver="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
else
	ver="no_version"
fi
echo "#ifdef SHIFT_CODE_FOR_TEST"
echo "#define VERSION \"${ver}_shift\""
echo "#else"
echo "#define VERSION \"${ver}\""
echo "#endif"
echo "#define DATE \"`date '+%F %T'`\""
echo "#define BUILDER \"${USER}@`hostname`\""

Append "shift" to version string in shifted image
Append "shift" to version string in shifted image

For EC update test, we produce binary-wise shifted image. To make it
easier to tell if update has succeeded, let's append "shift" to the
verison in this image.

BUG=chrome-os-partner:10264
TEST=Build shifted image and check the version string.

Change-Id: I16187611cf61fc97a74bc3707a77ad9ad5274f37
Reviewed-on: https://gerrit.chromium.org/gerrit/27577
Reviewed-by: Randall Spangler <62698fdbb84d1779579ee80c3f39fac22017e5bc@chromium.org>
Reviewed-by: Hung-Te Lin <8a7fce4940baad93a69f5073b383c85deed9d9c4@chromium.org>
Commit-Ready: Vic Yang <5fd92abeee651458f98e2856f4f200ee971cee4d@chromium.org>
Tested-by: Vic Yang <5fd92abeee651458f98e2856f4f200ee971cee4d@chromium.org>
