* [PATCH 1/1] version.sh: update to get version with git correctly
@ 2016-05-03 5:48 Yongqin Liu
2016-05-31 9:50 ` Johannes Berg
0 siblings, 1 reply; 2+ messages in thread
From: Yongqin Liu @ 2016-05-03 5:48 UTC (permalink / raw)
To: linux-wireless; +Cc: johannes.berg, filbranden, Yongqin Liu
update to get the version information from the
git repository where this file is located instead of the
the current directory where it is executed, otherwise if
there is .git directory in the current directory, it will
get the wrong version information.
And improved the version check since the tag information
may not be mirrored like what AOSP does now.
Change-Id: I321113b74bf2a955c202f47dca68c1183ca55318
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
---
version.sh | 42 ++++++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/version.sh b/version.sh
index 7ccd419..c8111a6 100755
--- a/version.sh
+++ b/version.sh
@@ -3,20 +3,38 @@
VERSION="4.3"
OUT="$1"
-if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then
- git update-index --refresh --unmerged > /dev/null
- descr=$(git describe --match=v*)
+# get the absolute path for the OUT file
+OUT_NAME=$(basename ${OUT})
+OUT_DIR=$(cd $(dirname ${OUT}); pwd)
+OUT="${OUT_DIR}/${OUT_NAME}"
+
+# the version check should be under the source directory
+# where this script is located, instead of the currect directory
+# where this script is excuted.
+SRC_DIR=$(dirname $0)
+SRC_DIR=$(cd ${SRC_DIR}; pwd)
+cd "${SRC_DIR}"
- # on git builds check that the version number above
- # is correct...
- [ "${descr%%-*}" = "v$VERSION" ] || exit 2
+v=""
+if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then
+ git update-index --refresh --unmerged > /dev/null
+ descr=$(git describe --match=v* 2>/dev/null)
+ if [ $? -eq 0 ]; then
+ # on git builds check that the version number above
+ # is correct...
+ if [ "${descr%%-*}" = "v$VERSION" ]; then
+ v="${descr#v}"
+ if git diff-index --name-only HEAD | read dummy ; then
+ v="$v"-dirty
+ fi
+ fi
+ fi
+fi
- v="${descr#v}"
- if git diff-index --name-only HEAD | read dummy ; then
- v="$v"-dirty
- fi
-else
- v="$VERSION"
+# set to the default version when failed to get the version
+# information with git
+if [ -z "${v}" ]; then
+ v="$VERSION"
fi
echo '#include "iw.h"' > "$OUT"
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] version.sh: update to get version with git correctly
2016-05-03 5:48 [PATCH 1/1] version.sh: update to get version with git correctly Yongqin Liu
@ 2016-05-31 9:50 ` Johannes Berg
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2016-05-31 9:50 UTC (permalink / raw)
To: Yongqin Liu, linux-wireless; +Cc: filbranden
On Tue, 2016-05-03 at 13:48 +0800, Yongqin Liu wrote:
> update to get the version information from the
> git repository where this file is located instead of the
> the current directory where it is executed, otherwise if
> there is .git directory in the current directory, it will
> get the wrong version information.
>
> And improved the version check since the tag information
> may not be mirrored like what AOSP does now.
Applied.
> Change-Id: I321113b74bf2a955c202f47dca68c1183ca55318
>
I don't really need a change-id though :)
johannes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-31 9:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-03 5:48 [PATCH 1/1] version.sh: update to get version with git correctly Yongqin Liu
2016-05-31 9:50 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).