Browse Source

Update MKit to v0.0.37

Alois Mahdal 5 years ago
parent
commit
7eee5bb2fc

+ 1
- 1
packaging/debian/control View File

@@ -265,4 +265,4 @@ Description: Shellfu/sh module for terminal color names
265 265
  common ANSI color names.
266 266
 
267 267
 
268
-# control file built with MKit __MKIT_SELF_VERSION__
268
+# control file built with MKit __MKIT_MKIT_VERSION__

+ 1
- 1
packaging/template.spec View File

@@ -213,4 +213,4 @@ make test \
213 213
 
214 214
 %changelog
215 215
 
216
-# specfile built with MKit __MKIT_SELF_VERSION__
216
+# specfile built with MKit __MKIT_MKIT_VERSION__

+ 2
- 2
utils/mkit/include/build.sh View File

@@ -71,6 +71,7 @@ __expand_macros() {
71 71
     local line          # each line on stdin
72 72
     local mname         # each macro name
73 73
     local -A MacroMap   # macro value map
74
+    MacroMap[__MKIT_MKIT_VERSION__]=$MKIT_VERSION
74 75
     MacroMap[__MKIT_PROJ_NAME__]=$(ini 1value project:name)
75 76
     MacroMap[__MKIT_PROJ_CODENAME__]=$(ini 1value project:codename)
76 77
     MacroMap[__MKIT_PROJ_LICENSE__]=$(ini 1value project:license)
@@ -80,7 +81,6 @@ __expand_macros() {
80 81
     MacroMap[__MKIT_PROJ_VCS_BROWSER__]=$(ini 1value project:vcs_browser)
81 82
     MacroMap[__MKIT_PROJ_GIT_LASTHASH__]=$(__cached git_lasthash)
82 83
     MacroMap[__MKIT_PROJ_VERSION__]=$(__cached semver)
83
-    MacroMap[__MKIT_SELF_VERSION__]=$MKIT_VERSION
84 84
     for section in "$@"; do
85 85
         for mname in $(ini lskeys "$section"); do
86 86
             MacroMap[$mname]=$(ini values "$section:$mname")
@@ -176,6 +176,7 @@ _mkit_data() {
176 176
     sections+=( $(ini lssect | grep ':macros$') )
177 177
     {
178 178
         echo "(builtin):"
179
+        echo "  x_MKIT_MKIT_VERSION__ => '__MKIT_MKIT_VERSION__'"
179 180
         echo "  x_MKIT_PROJ_NAME__ => '__MKIT_PROJ_NAME__'"
180 181
         echo "  x_MKIT_PROJ_CODENAME__ => '__MKIT_PROJ_CODENAME__'"
181 182
         echo "  x_MKIT_PROJ_LICENSE__ => '__MKIT_PROJ_LICENSE__'"
@@ -185,7 +186,6 @@ _mkit_data() {
185 186
         echo "  x_MKIT_PROJ_VCS_BROWSER__ => '__MKIT_PROJ_VCS_BROWSER__'"
186 187
         echo "  x_MKIT_PROJ_GIT_LASTHASH__ => '__MKIT_PROJ_GIT_LASTHASH__'"
187 188
         echo "  x_MKIT_PROJ_VERSION__ => '__MKIT_PROJ_VERSION__'"
188
-        echo "  x_MKIT_SELF_VERSION__ => '__MKIT_SELF_VERSION__'"
189 189
         for section in "${sections[@]}"; do
190 190
             echo "$section:"
191 191
             for macro in $(ini lskeys "$section"); do

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

@@ -141,15 +141,17 @@ semver() {
141 141
     local xyz           # base version string
142 142
     local prerl         # pre-release keyword (from mkit.ini, eg. 'beta')
143 143
     local latest_tag    # latest git tag
144
-    local commit        # commit indicator (CURRENT_BRANCH.gHASH)
145
-    local dirty=F       # F if dirty, T if clean
146
-    local btime         # timestamp or nothing (see $MKIT_TTAG)
144
+    local brname        # current branch name
145
+    local ghash         # current commit short hash
146
+    local is_tagged=T   # T if tagged (clean, no metadata), F if devel
147
+    local is_dirty=F    # F if dirty, T if clean
148
+    local stamp         # timestamp or nothing (see $MKIT_TSTAMP)
147 149
     local suffix        # version suffix
148 150
     prerl=$(ini 1value project:prerl)
149
-    case $MKIT_TTAG in
150
-        none)   btime= ;;
151
-        btime)  btime=$(date -u +%Y%m%d%H%M%S) ;;
152
-        ctime)  btime=$(date -d @"$(git_fact latest_cdate)" -u +%Y%m%d%H%M%S) ;;
151
+    case $MKIT_TSTAMP in
152
+        none)   stamp= ;;
153
+        btime)  stamp=$(date -u +%Y%m%d%H%M%S) ;;
154
+        ctime)  stamp=$(date -d @"$(git_fact latest_cdate)" -u +%Y%m%d%H%M%S) ;;
153 155
     esac
154 156
     grep ":" <<<"$prerl" \
155 157
      && warn "colon in project:prerl may corrupt version data: $prerl"
@@ -168,17 +170,19 @@ semver() {
168 170
     esac
169 171
     if ! git describe --tags --exact-match HEAD >&/dev/null;
170 172
     then    # we are at a later commit than the last tag
171
-        commit="$(git_fact current_branch).g$(git_fact latest_sha)"
173
+        is_tagged=F
174
+        brname=$(git_fact current_branch)
175
+        ghash=$(git_fact latest_sha)
172 176
     fi
173
-    git_bool dirty && dirty=T
174
-    case "$dirty:$btime:$commit" in
175
-        F:*:)   suffix=""                       ;;
176
-        T::)    suffix="+dirty"                 ;;
177
-        T:*:)   suffix="+t$btime.dirty"           ;;
178
-        F::*)   suffix="+$commit"               ;;
179
-        F:*:*)  suffix="+t$btime.$commit"         ;;
180
-        T::*)   suffix="+$commit.dirty"         ;;
181
-        T:*:*)  suffix="+t$btime.$commit.dirty"   ;;
177
+    git_bool dirty && is_dirty=T
178
+    case "$is_dirty:$is_tagged:$stamp" in
179
+        F:T:*)  suffix=""                                 ;;
180
+        T:T:)   suffix="+dirty"                           ;;
181
+        T:T:*)  suffix="+t$stamp.dirty"                   ;;
182
+        F:F:)   suffix="+$brname.g$ghash"                 ;;
183
+        F:F:*)  suffix="+t$stamp.$brname.g$ghash"         ;;
184
+        T:F:)   suffix="+$brname.g$ghash.dirty"           ;;
185
+        T:F:*)  suffix="+t$stamp.$brname.g$ghash.dirty"   ;;
182 186
         *)      suffix=MKIT_BUG
183 187
                 warn "MKIT_BUG: bad dirt/commit detection" ;;
184 188
     esac

+ 50
- 12
utils/mkit/include/ini.sh View File

@@ -8,7 +8,7 @@ __ini_cat() {
8 8
     #
9 9
     local line      # each line
10 10
     while read -r line; do
11
-        printf -- "%s\n" "$line"
11
+        printf -- '%s\n' "$line"
12 12
     done
13 13
 }
14 14
 
@@ -17,19 +17,58 @@ __ini_expand() {
17 17
     # Expand reference value (prefix only)
18 18
     #
19 19
     local line      # each input line
20
-    local suffix    # tail of the line
21
-    local ref       # reference
22
-    local value     # value if reference
23 20
     while read -r line; do                  # [foo:bar]/path
24
-        suffix="${line#\[*\]}"              # /path
25
-        ref="${line%$suffix}"               # [foo:bar]
26
-        ref="${ref%\]}"                     # [foo:bar
27
-        ref="${ref#\[}"                     # foo:bar
28
-        value="$(ini 1value "$ref")"        # foo_bar_value
29
-        printf -- "%s\n" "$value$suffix"    # foo_bar_value/path
21
+        __ini_expandln "$line"
30 22
     done
31 23
 }
32 24
 
25
+__ini_expandln() {
26
+    #
27
+    # Fully expand references in line $1
28
+    #
29
+    local line_orig=$1          # original line
30
+    local line_todo=$line_orig  # current state
31
+    local line_done             # next state
32
+    local Depth=0               # current depth
33
+    local MaxDepth=10           # maximum depth
34
+    while true; do
35
+        ((Depth++))
36
+        debug_var line_todo
37
+        test "$Depth" -le "$MaxDepth" || {
38
+            warn "expansion error: reached maximum depth: $Depth > $MaxDepth"
39
+            warn "    original line: $line_orig"
40
+            warn "    expanded line: $line_todo"
41
+            return 3
42
+        }
43
+        line_done=$(__ini_expandln_once "$line_todo")
44
+        debug_var line_done
45
+        test "$line_done" == "$line_todo" && break
46
+        line_todo=$line_done
47
+    done
48
+    echo "$line_done"
49
+}
50
+
51
+__ini_expandln_once() {
52
+    #
53
+    # Run through line $1 once and replace all references
54
+    #
55
+    local line=$1   # line to expand
56
+    local ref       # full reference (incl. brackets)
57
+    local ipath     # just ini path from ^^ (stripped brackets)
58
+    local value     # value of reference
59
+    local refs=()   # all references found in line
60
+    mapfile -t refs <<<"$(grep -Eo '[[][^]]+[]]' <<< "$line_todo")"
61
+    debug_var refs
62
+    for ref in "${refs[@]}"; do
63
+        test -n "$ref" || continue
64
+        ipath=${ref#[}; ipath=${ipath%]}
65
+        value=$(ini 1value "$ipath")
66
+        debug_var line ref ipath value
67
+        line=$(sed "s|\\[$ipath\\]|$value|" <<<"$line")
68
+    done
69
+    echo "$line"
70
+}
71
+
33 72
 __ini_grepcmt() {
34 73
     #
35 74
     # Remove comments from INI file on stdin
@@ -85,7 +124,7 @@ __ini_grepsec() {
85 124
                 \[*\])    ok=false; continue ;;
86 125
             esac
87 126
             $ok || continue
88
-            printf -- "%s\n" "$line"
127
+            printf -- '%s\n' "$line"
89 128
         done \
90 129
       | sed -e 's/ *= */=/; s/ +$//; s/^//;'
91 130
 }
@@ -102,7 +141,6 @@ __ini_lssect() {
102 141
     #
103 142
     # List all section names
104 143
     #
105
-    local arg=$1    # unused argument
106 144
     grep -x '\[.*\]' | sed 's/^.//; s/.$//'
107 145
 }
108 146
 

+ 3
- 3
utils/mkit/include/vars.sh View File

@@ -71,7 +71,7 @@ MKIT_PROJ_PKGNAME=""
71 71
 # For example, old yum version (as of RHEL-6) will not let you install
72 72
 # version that it deems older than is installed, making it hard to
73 73
 # continually upgrade during active development.  While packaging
74
-# systems have their own rukes (and SemVer says both versions should be
74
+# systems have their own rules (and SemVer says both versions should be
75 75
 # considered same) this tag will make it more likely to "win" the build
76 76
 # you made later.
77 77
 #
@@ -81,9 +81,9 @@ MKIT_PROJ_PKGNAME=""
81 81
 # Also note that 'btime' makes the version non-deterministic: merely
82 82
 # initiating the build a second later will result in different version.
83 83
 #
84
-MKIT_TTAG=${MKIT_TTAG:-ctime}
84
+MKIT_TSTAMP=${MKIT_TSTAMP:-ctime}
85 85
 
86 86
 #
87 87
 # This MKit version
88 88
 #
89
-MKIT_VERSION=0.0.36
89
+MKIT_VERSION=0.0.37

+ 2
- 2
utils/mkit/stub View File

@@ -162,7 +162,7 @@ deploy() {
162 162
             echo ''
163 163
             echo '%changelog'
164 164
             echo ''
165
-            echo '# specfile built with MKit __MKIT_SELF_VERSION__'
165
+            echo '# specfile built with MKit __MKIT_MKIT_VERSION__'
166 166
             ;;
167 167
 
168 168
         packaging/debian/copyright)
@@ -185,7 +185,7 @@ deploy() {
185 185
             echo 'Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__'
186 186
             echo ' MKIT_STUB_DESCRIPTION'
187 187
             echo ''
188
-            echo '# control file built with MKit __MKIT_SELF_VERSION__'
188
+            echo '# control file built with MKit __MKIT_MKIT_VERSION__'
189 189
             ;;
190 190
 
191 191
         packaging/debian/changelog)