diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-07-09 20:27:50 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-07-09 20:29:33 -0400 |
commit | c914b148e5137c60561028e09859e2747ff6f3ad (patch) | |
tree | 0aa7364b994705ab9e0a7772e90caba8e1c872f5 /tools | |
parent | 17a367e0c43fe255f5736b8fe07110b541183e8e (diff) | |
download | rockbox-c914b148e5137c60561028e09859e2747ff6f3ad.tar.gz rockbox-c914b148e5137c60561028e09859e2747ff6f3ad.zip |
build: Get rid of svn vestiges from version script
Set 10-character git shortrevs for consistency with modern git
defaults
Change-Id: I694f09acd5da1c9b837c9a71a82bd7b72578efd7
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/version.sh | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/tools/version.sh b/tools/version.sh index 6d6b6ed13a..1863789917 100755 --- a/tools/version.sh +++ b/tools/version.sh | |||
@@ -12,40 +12,18 @@ | |||
12 | 12 | ||
13 | # Prints the revision of the repository. | 13 | # Prints the revision of the repository. |
14 | # | 14 | # |
15 | # The format is rNNNNN[M]-YYMMDD | 15 | # The format is rNNNNNNNNNN[M]-YYMMDD |
16 | # | 16 | # |
17 | # The M indicates the revision isn't matched to a pure Subversion ID, usually | 17 | # The M indicates the revision has been locally modified |
18 | # because it's built from something like GIT. | 18 | # |
19 | 19 | # This logic is pulled from the Linux's scripts/setlocalversion (also GPL) | |
20 | svnversion_safe() { | 20 | # and tweaked for rockbox. |
21 | # LANG=C forces svnversion to not localize "exported". | ||
22 | if OUTPUT=`LANG=C svnversion "$@"`; then | ||
23 | if [ "$OUTPUT" = "exported" ]; then | ||
24 | echo "unknown" | ||
25 | else | ||
26 | echo "r$OUTPUT" | ||
27 | fi | ||
28 | else | ||
29 | echo "unknown" | ||
30 | fi | ||
31 | } | ||
32 | |||
33 | # This logic is pulled from the Linux's scripts/setlocalversion (also GPL) and tweaked for | ||
34 | # rockbox. If the commit information for HEAD has a svn-id in it we report that instead of | ||
35 | # the git id | ||
36 | gitversion() { | 21 | gitversion() { |
37 | export GIT_DIR="$1/.git" | 22 | export GIT_DIR="$1/.git" |
38 | 23 | ||
39 | # This verifies we are in a git directory | 24 | # This verifies we are in a git directory |
40 | if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then | 25 | if head=`git rev-parse --verify --short=10 HEAD 2>/dev/null`; then |
41 | 26 | ||
42 | # Get the svn revision of the most recent git-svn commit | ||
43 | version=`git log --pretty=format:'%b' --grep='git-svn-id: svn' -1 | tail -n 1 | perl -ne 'm/@(\d*)/; print "r" . $1;'` | ||
44 | mod="" | ||
45 | # Is this a git-svn commit? | ||
46 | if ! git log -1 --pretty=format:"%b" | grep -q "git-svn-id: svn" ; then | ||
47 | version="$head" | ||
48 | fi | ||
49 | # Are there uncommitted changes? | 27 | # Are there uncommitted changes? |
50 | export GIT_WORK_TREE="$1" | 28 | export GIT_WORK_TREE="$1" |
51 | if git diff --name-only HEAD | read dummy; then | 29 | if git diff --name-only HEAD | read dummy; then |
@@ -54,7 +32,7 @@ gitversion() { | |||
54 | mod="M" | 32 | mod="M" |
55 | fi | 33 | fi |
56 | 34 | ||
57 | echo "${version}${mod}" | 35 | echo "${head}${mod}" |
58 | # All done with git | 36 | # All done with git |
59 | exit | 37 | exit |
60 | fi | 38 | fi |
@@ -69,18 +47,12 @@ if [ -n "$1" ]; then TOP=$1; else TOP=..; fi | |||
69 | if [ -z $VERSION ]; then | 47 | if [ -z $VERSION ]; then |
70 | # If the VERSIONFILE exisits we use that | 48 | # If the VERSIONFILE exisits we use that |
71 | VERSIONFILE=docs/VERSION | 49 | VERSIONFILE=docs/VERSION |
72 | if [ -r $TOP/$VERSIONFILE ]; then VER=`cat $TOP/$VERSIONFILE`; | 50 | if [ -r $TOP/$VERSIONFILE ]; then |
51 | VER=`cat $TOP/$VERSIONFILE`; | ||
73 | else | 52 | else |
74 | # Ok, we need to derive it from the Version Control system | 53 | # Ok, we need to derive it from the Version Control system |
75 | if [ -d "$TOP/.git" ]; then | 54 | if [ -d "$TOP/.git" ]; then |
76 | VER=`gitversion $TOP` | 55 | VER=`gitversion $TOP` |
77 | else | ||
78 | VER=`svnversion_safe $TOP`; | ||
79 | if [ "$VER" = "unknown" ]; then | ||
80 | # try getting it from a subdir to test if perhaps they are symlinked | ||
81 | # from the root | ||
82 | VER=`svnversion_safe $TOP/tools`; | ||
83 | fi | ||
84 | fi | 56 | fi |
85 | fi | 57 | fi |
86 | VERSION=$VER-`date -u +%y%m%d` | 58 | VERSION=$VER-`date -u +%y%m%d` |