Browse Source

Update MKit to v0.0.33

Alois Mahdal 6 years ago
parent
commit
a72d01686b
4 changed files with 43 additions and 16 deletions
  1. 9
    5
      utils/mkit/include/build.sh
  2. 17
    9
      utils/mkit/include/facts.sh
  3. 0
    1
      utils/mkit/include/ini.sh
  4. 17
    1
      utils/mkit/include/vars.sh

+ 9
- 5
utils/mkit/include/build.sh View File

47
     local line=$1   # line to process
47
     local line=$1   # line to process
48
     local mname     # macro name
48
     local mname     # macro name
49
     local mvline    # line of macro value
49
     local mvline    # line of macro value
50
+    local xline     # expanded line
51
+    xline=$line
50
     for mname in "${!MacroMap[@]}"; do
52
     for mname in "${!MacroMap[@]}"; do
51
         if ! test "${line//$mname}" == "$line"; then
53
         if ! test "${line//$mname}" == "$line"; then
52
-            while IFS= read -r mvline; do
53
-                echo "${line//$mname/$mvline}"
54
-            done <<<"${MacroMap[$mname]}"
55
-            return 0
54
+            xline=$(
55
+                while IFS= read -r mvline; do
56
+                    echo "${line//$mname/$mvline}"
57
+                done <<<"${MacroMap[$mname]}"
58
+            )
56
         fi
59
         fi
60
+        line=$xline
57
     done
61
     done
58
-    echo "$line"
62
+    echo "$xline"
59
     return 1
63
     return 1
60
 }
64
 }
61
 
65
 

+ 17
- 9
utils/mkit/include/facts.sh View File

139
     local prerl         # pre-release keyword (from mkit.ini, eg. 'beta')
139
     local prerl         # pre-release keyword (from mkit.ini, eg. 'beta')
140
     local latest_tag    # latest git tag
140
     local latest_tag    # latest git tag
141
     local commit        # commit indicator (CURRENT_BRANCH.gHASH)
141
     local commit        # commit indicator (CURRENT_BRANCH.gHASH)
142
-    local dirty         # 0 if dirty, 1 if clean
142
+    local dirty=F       # F if dirty, T if clean
143
+    local btime         # hex timestamp or nothing (see $MKIT_TTAG)
143
     local suffix        # version suffix
144
     local suffix        # version suffix
144
     prerl=$(ini 1value project:prerl)
145
     prerl=$(ini 1value project:prerl)
146
+    case $MKIT_TTAG in
147
+        none)   btime= ;;
148
+        btime)  btime=$(printf '%08x' "$(date +%s)") ;;
149
+    esac
145
     grep ":" <<<"$prerl" \
150
     grep ":" <<<"$prerl" \
146
      && warn "colon in project:prerl may corrupt version data: $prerl"
151
      && warn "colon in project:prerl may corrupt version data: $prerl"
147
     git_present || {
152
     git_present || {
161
     then    # we are at a later commit than the last tag
166
     then    # we are at a later commit than the last tag
162
         commit="$(git_fact current_branch).g$(git_fact latest_sha)"
167
         commit="$(git_fact current_branch).g$(git_fact latest_sha)"
163
     fi
168
     fi
164
-    git_bool dirty; dirty=$?
165
-    case "$dirty:$commit" in
166
-        1:)  suffix=""               ;;
167
-        0:)  suffix="+dirty"         ;;
168
-        1:*) suffix="+$commit"       ;;
169
-        0:*) suffix="+$commit.dirty" ;;
170
-        *)   suffix=MKIT_BUG
171
-             warn "MKIT_BUG: bad dirt/commit detection" ;;
169
+    git_bool dirty && dirty=T
170
+    case "$dirty:$btime:$commit" in
171
+        F:*:)   suffix=""                       ;;
172
+        T::)    suffix="+dirty"                 ;;
173
+        T:*:)   suffix="+t$btime.dirty"           ;;
174
+        F::*)   suffix="+$commit"               ;;
175
+        F:*:*)  suffix="+t$btime.$commit"         ;;
176
+        T::*)   suffix="+$commit.dirty"         ;;
177
+        T:*:*)  suffix="+t$btime.$commit.dirty"   ;;
178
+        *)      suffix=MKIT_BUG
179
+                warn "MKIT_BUG: bad dirt/commit detection" ;;
172
     esac
180
     esac
173
     test -n "$prerl" && suffix="-$prerl$suffix"
181
     test -n "$prerl" && suffix="-$prerl$suffix"
174
     echo "$xyz$suffix"
182
     echo "$xyz$suffix"

+ 0
- 1
utils/mkit/include/ini.sh View File

79
     local ok=false      # are we in the section?
79
     local ok=false      # are we in the section?
80
     local line          # each input line
80
     local line          # each input line
81
     grep '.' \
81
     grep '.' \
82
-      | grep -v '\s*#' \
83
       | while read -r line; do
82
       | while read -r line; do
84
             case "$line" in
83
             case "$line" in
85
                 \[$wnt\]) ok=true;  continue ;;
84
                 \[$wnt\]) ok=true;  continue ;;

+ 17
- 1
utils/mkit/include/vars.sh View File

55
 #
55
 #
56
 MKIT_PROJ_PKGNAME=""
56
 MKIT_PROJ_PKGNAME=""
57
 
57
 
58
+#
59
+# Add time-based ordinal tag to SemVer build data?
60
+#
61
+# Can be 'none' or 'btime'.
62
+#
63
+# If 'btime', devel builds have also 'tXXXXXXXX' tag, where each
64
+# 'X' is a hexa-decimal digit of Unix timestamp taken when build
65
+# is initiated.  This way, builds from same branch are guarranteed
66
+# to order based on build time (that is, until February 7th, 2106).
67
+#
68
+# Note that this makes devel and dirty builds non-deterministic,
69
+# but does not affect clean builds (ie. builds from clean repo
70
+# with HEAD corresponding to latest version tag.).
71
+#
72
+MKIT_TTAG=${MKIT_TTAG:-btime}
73
+
58
 #
74
 #
59
 # This MKit version
75
 # This MKit version
60
 #
76
 #
61
-MKIT_VERSION=0.0.31
77
+MKIT_VERSION=0.0.33