Pārlūkot izejas kodu

Adopt versionong mechanics from fastfoo

Alois Mahdal 9 gadus atpakaļ
vecāks
revīzija
ebc8637832
2 mainītis faili ar 35 papildinājumiem un 3 dzēšanām
  1. 1
    0
      .gitignore
  2. 34
    3
      setup/mk.sh

+ 1
- 0
.gitignore Parādīt failu

1
 .autoclean
1
 .autoclean
2
+eecc-*.tar.gz

+ 34
- 3
setup/mk.sh Parādīt failu

38
     dstpath=${srcpath%.skel}
38
     dstpath=${srcpath%.skel}
39
     perl -pe "
39
     perl -pe "
40
         s|__EECC_INI_PATH__|$EECC_INI_PATH_GLOBAL:\\\$HOME/$EECC_INI_PATH_USER|;
40
         s|__EECC_INI_PATH__|$EECC_INI_PATH_GLOBAL:\\\$HOME/$EECC_INI_PATH_USER|;
41
-        s|__VERSION__|$VERSION|;
41
+        s|__VERSION__|$(get_version)|;
42
     " < $srcpath > $dstpath
42
     " < $srcpath > $dstpath
43
     echo $dstpath >> built.list
43
     echo $dstpath >> built.list
44
 }
44
 }
60
 }
60
 }
61
 
61
 
62
 dist() {
62
 dist() {
63
-    local dirname=eecc-${VERSION}
63
+    local version=$(get_version)
64
+    local dirname=eecc-$version
64
     mkdir -p $dirname
65
     mkdir -p $dirname
65
     cp -R   bin \
66
     cp -R   bin \
66
             config.mk \
67
             config.mk \
71
             test \
72
             test \
72
             utils \
73
             utils \
73
             $dirname
74
             $dirname
75
+    sed -ie "s/^VERSION = .*/VERSION = $version/" $dirname/config.mk
74
     tar -cf $dirname.tar $dirname
76
     tar -cf $dirname.tar $dirname
75
     gzip $dirname.tar
77
     gzip $dirname.tar
76
     rm -rf $dirname
78
     rm -rf $dirname
77
-    echo $dirname.tar.gz >> built.list
78
 }
79
 }
79
 
80
 
80
 install() {
81
 install() {
84
     test -f .autoclean && clean || :
85
     test -f .autoclean && clean || :
85
 }
86
 }
86
 
87
 
88
+get_version() {
89
+    local version=$VERSION
90
+    local stage=$STAGE
91
+    if git rev-parse HEAD >&/dev/null;
92
+    then    # we are in git repo... so we can get smart
93
+        local lasttag=$(git tag | grep ^v | tail -n1)
94
+        if ! git describe --tags --exact-match HEAD >&/dev/null;
95
+        then    # we are not at later commit than the last tag
96
+            local sha=g$(git describe --always HEAD)
97
+        fi
98
+        if test "$(git diff --shortstat 2>/dev/null)" != "";
99
+        then    # thr tree is "dirty", i.e. has been edited
100
+            local dirty=dirty
101
+        fi
102
+        version=${lasttag:1}
103
+        case $stage:$sha:$dirty in
104
+            ::)         suffix=""                    ;;
105
+            ::dirty)    suffix="+$dirty"             ;;
106
+            :g*:)       suffix="+$sha"               ;;
107
+            :g*:dirty)  suffix="+$sha.dirty"         ;;
108
+            *::)        suffix="-$stage"             ;;
109
+            *::dirty)   suffix="-$stage+$dirty"      ;;
110
+            *:g*:)      suffix="-$stage+$sha"        ;;
111
+            *:g*:dirty) suffix="-$stage+$sha.$dirty" ;;
112
+        esac
113
+        version=$version$suffix
114
+    fi
115
+    echo $version
116
+}
117
+
87
 run_test() {
118
 run_test() {
88
     pushd test
119
     pushd test
89
     find -maxdepth 1 -type f \! -name '*.skel' | while read test;
120
     find -maxdepth 1 -type f \! -name '*.skel' | while read test;