Преглед на файлове

Add timestamp to dirty and devel builds

Helps ensure that a later devel build will install over older one.
Alois Mahdal преди 6 години
родител
ревизия
5a8f8c916d
променени са 2 файла, в които са добавени 31 реда и са изтрити 7 реда
  1. 15
    7
      src/include/facts.sh
  2. 16
    0
      src/include/vars.sh.skel

+ 15
- 7
src/include/facts.sh Целия файл

@@ -140,8 +140,13 @@ semver() {
140 140
     local latest_tag    # latest git tag
141 141
     local commit        # commit indicator (CURRENT_BRANCH.gHASH)
142 142
     local dirty=F       # F if dirty, T if clean
143
+    local btime         # hex timestamp or nothing (see $MKIT_TTAG)
143 144
     local suffix        # version suffix
144 145
     prerl=$(ini 1value project:prerl)
146
+    case $MKIT_TTAG in
147
+        none)   btime= ;;
148
+        btime)  btime=$(printf '%08x' "$(date +%s)") ;;
149
+    esac
145 150
     grep ":" <<<"$prerl" \
146 151
      && warn "colon in project:prerl may corrupt version data: $prerl"
147 152
     git_present || {
@@ -162,13 +167,16 @@ semver() {
162 167
         commit="$(git_fact current_branch).g$(git_fact latest_sha)"
163 168
     fi
164 169
     git_bool dirty && dirty=T
165
-    case "$dirty:$commit" in
166
-        F:)  suffix=""               ;;
167
-        T:)  suffix="+dirty"         ;;
168
-        F:*) suffix="+$commit"       ;;
169
-        T:*) suffix="+$commit.dirty" ;;
170
-        *)   suffix=MKIT_BUG
171
-             warn "MKIT_BUG: bad dirt/commit detection" ;;
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 180
     esac
173 181
     test -n "$prerl" && suffix="-$prerl$suffix"
174 182
     echo "$xyz$suffix"

+ 16
- 0
src/include/vars.sh.skel Целия файл

@@ -55,6 +55,22 @@ MKIT_LOCAL=${MKIT_LOCAL:-.mkit}
55 55
 #
56 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 75
 # This MKit version
60 76
 #