Browse Source

Update MKit to v0.0.40

Alois Mahdal 6 years ago
parent
commit
7292a6539f

+ 1
- 1
mkit.ini View File

61
     share   = src/help
61
     share   = src/help
62
     share   = src/complete
62
     share   = src/complete
63
 
63
 
64
-#mkit version=0.0.35
64
+#mkit version=0.0.40

+ 1
- 1
packaging/debian/control View File

29
  shellfu-bash-saturnin (<< __VDEP_SATURNIN_LT__),
29
  shellfu-bash-saturnin (<< __VDEP_SATURNIN_LT__),
30
 Description: __MKIT_PROJ_TAGLINE__
30
 Description: __MKIT_PROJ_TAGLINE__
31
 
31
 
32
-# control file built with MKit __MKIT_SELF_VERSION__
32
+# control file built with MKit __MKIT_MKIT_VERSION__

+ 1
- 1
packaging/template.spec View File

43
 
43
 
44
 %changelog
44
 %changelog
45
 
45
 
46
-# specfile built with MKit __MKIT_SELF_VERSION__
46
+# specfile built with MKit __MKIT_MKIT_VERSION__

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

71
     local line          # each line on stdin
71
     local line          # each line on stdin
72
     local mname         # each macro name
72
     local mname         # each macro name
73
     local -A MacroMap   # macro value map
73
     local -A MacroMap   # macro value map
74
+    MacroMap[__MKIT_MKIT_VERSION__]=$MKIT_VERSION
74
     MacroMap[__MKIT_PROJ_NAME__]=$(ini 1value project:name)
75
     MacroMap[__MKIT_PROJ_NAME__]=$(ini 1value project:name)
75
     MacroMap[__MKIT_PROJ_CODENAME__]=$(ini 1value project:codename)
76
     MacroMap[__MKIT_PROJ_CODENAME__]=$(ini 1value project:codename)
76
     MacroMap[__MKIT_PROJ_LICENSE__]=$(ini 1value project:license)
77
     MacroMap[__MKIT_PROJ_LICENSE__]=$(ini 1value project:license)
79
     MacroMap[__MKIT_PROJ_MAINTAINER__]=$(ini 1value project:maintainer)
80
     MacroMap[__MKIT_PROJ_MAINTAINER__]=$(ini 1value project:maintainer)
80
     MacroMap[__MKIT_PROJ_VCS_BROWSER__]=$(ini 1value project:vcs_browser)
81
     MacroMap[__MKIT_PROJ_VCS_BROWSER__]=$(ini 1value project:vcs_browser)
81
     MacroMap[__MKIT_PROJ_GIT_LASTHASH__]=$(__cached git_lasthash)
82
     MacroMap[__MKIT_PROJ_GIT_LASTHASH__]=$(__cached git_lasthash)
83
+    MacroMap[__MKIT_PROJ_GIT_LASTSUMMARY__]=$(__cached git_lastsummary)
82
     MacroMap[__MKIT_PROJ_VERSION__]=$(__cached semver)
84
     MacroMap[__MKIT_PROJ_VERSION__]=$(__cached semver)
83
-    MacroMap[__MKIT_SELF_VERSION__]=$MKIT_VERSION
84
     for section in "$@"; do
85
     for section in "$@"; do
85
         for mname in $(ini lskeys "$section"); do
86
         for mname in $(ini lskeys "$section"); do
86
             MacroMap[$mname]=$(ini values "$section:$mname")
87
             MacroMap[$mname]=$(ini values "$section:$mname")
161
     #
162
     #
162
     local file=$1
163
     local file=$1
163
     mkdir -p "$MKIT_LOCAL"
164
     mkdir -p "$MKIT_LOCAL"
164
-    echo "$file" >> "$MKIT_LOCAL/built.lst"
165
+    echo "1:$file" >> "$MKIT_LOCAL/built.lst"
165
 }
166
 }
166
 
167
 
167
 _mkit_data() {
168
 _mkit_data() {
176
     sections+=( $(ini lssect | grep ':macros$') )
177
     sections+=( $(ini lssect | grep ':macros$') )
177
     {
178
     {
178
         echo "(builtin):"
179
         echo "(builtin):"
180
+        echo "  x_MKIT_MKIT_VERSION__ => '__MKIT_MKIT_VERSION__'"
179
         echo "  x_MKIT_PROJ_NAME__ => '__MKIT_PROJ_NAME__'"
181
         echo "  x_MKIT_PROJ_NAME__ => '__MKIT_PROJ_NAME__'"
180
         echo "  x_MKIT_PROJ_CODENAME__ => '__MKIT_PROJ_CODENAME__'"
182
         echo "  x_MKIT_PROJ_CODENAME__ => '__MKIT_PROJ_CODENAME__'"
181
         echo "  x_MKIT_PROJ_LICENSE__ => '__MKIT_PROJ_LICENSE__'"
183
         echo "  x_MKIT_PROJ_LICENSE__ => '__MKIT_PROJ_LICENSE__'"
184
         echo "  x_MKIT_PROJ_MAINTAINER__ => '__MKIT_PROJ_MAINTAINER__'"
186
         echo "  x_MKIT_PROJ_MAINTAINER__ => '__MKIT_PROJ_MAINTAINER__'"
185
         echo "  x_MKIT_PROJ_VCS_BROWSER__ => '__MKIT_PROJ_VCS_BROWSER__'"
187
         echo "  x_MKIT_PROJ_VCS_BROWSER__ => '__MKIT_PROJ_VCS_BROWSER__'"
186
         echo "  x_MKIT_PROJ_GIT_LASTHASH__ => '__MKIT_PROJ_GIT_LASTHASH__'"
188
         echo "  x_MKIT_PROJ_GIT_LASTHASH__ => '__MKIT_PROJ_GIT_LASTHASH__'"
189
+        echo "  x_MKIT_PROJ_GIT_LASTSUMMARY__ => '__MKIT_PROJ_GIT_LASTSUMMARY__'"
187
         echo "  x_MKIT_PROJ_VERSION__ => '__MKIT_PROJ_VERSION__'"
190
         echo "  x_MKIT_PROJ_VERSION__ => '__MKIT_PROJ_VERSION__'"
188
-        echo "  x_MKIT_SELF_VERSION__ => '__MKIT_SELF_VERSION__'"
189
         for section in "${sections[@]}"; do
191
         for section in "${sections[@]}"; do
190
             echo "$section:"
192
             echo "$section:"
191
             for macro in $(ini lskeys "$section"); do
193
             for macro in $(ini lskeys "$section"); do
212
     #
214
     #
213
     # Clean up tree after building
215
     # Clean up tree after building
214
     #
216
     #
215
-    test -f "$MKIT_LOCAL/built.lst" && {
216
-        <"$MKIT_LOCAL/built.lst" grep -v -e '\.\.' -e ^/ \
217
-          | xargs -r rm -rf
218
-        rm -f "$MKIT_LOCAL/built.lst"
219
-        rmdir --ignore-fail-on-non-empty "$MKIT_LOCAL"
220
-    }
217
+    local path
218
+    local line
219
+    local depth
220
+    test -f "$MKIT_LOCAL/built.lst" || return 0
221
+    {
222
+        cat "$MKIT_LOCAL/built.lst"
223
+        echo "1:$MKIT_LOCAL/built.lst"
224
+        echo "1:$MKIT_LOCAL"
225
+    } \
226
+      | grep -v -e '\.\.' -e ^/ -e '^~' \
227
+      | while IFS=: read -r depth path; do
228
+            test -e "$path" || continue
229
+            case $depth in
230
+                1)  warn "removing: $path"
231
+                    test -d "$path" \
232
+                     && rmdir -p --ignore-fail-on-non-empty "$path"
233
+                    test -f "$path" && rm "$path"
234
+                    ;;
235
+                r)  warn "removing recursively: $path"
236
+                    rm -r "$path"
237
+                    ;;
238
+                *)  warn "invalid built.lst format!"
239
+                    ;;
240
+            esac
241
+        done
221
     true
242
     true
222
 }
243
 }
223
 
244
 

+ 1
- 1
utils/mkit/include/deploy.sh View File

35
         find "$src" -type f \
35
         find "$src" -type f \
36
           | while read -r item; do
36
           | while read -r item; do
37
                 [[ $item =~ .skel$ ]] \
37
                 [[ $item =~ .skel$ ]] \
38
-                 && grep -q "${item%.skel}" "$MKIT_LOCAL/built.lst" \
38
+                 && grep -qe "${item%.skel}" "$MKIT_LOCAL/built.lst" \
39
                  && continue
39
                  && continue
40
                 __deploy_item "$item" "$dst${item#$src}" "$mode"
40
                 __deploy_item "$item" "$dst${item#$src}" "$mode"
41
             done
41
             done

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

103
     git_bool dirty && echo -n ".dirty"
103
     git_bool dirty && echo -n ".dirty"
104
 }
104
 }
105
 
105
 
106
+git_lastsummary() {
107
+    #
108
+    # Show last commit summary
109
+    #
110
+    # We can't do it outside git repo (or without git) but we should
111
+    # not be asked to; targets that don't require git should make use
112
+    # of cache built by dist target.
113
+    #
114
+    git_present || {
115
+        echo UNKNOWN_SUMMARY
116
+        warn "no git present; could not determine last summary"
117
+        return 3
118
+    }
119
+    git_bool dirty && {
120
+        echo "(index is dirty)"
121
+        return
122
+    }
123
+    git log -1 --format=oneline HEAD \
124
+      | cut -d' ' -f2-
125
+}
126
+
106
 semver() {
127
 semver() {
107
     #
128
     #
108
     # Build proper SemVer version string
129
     # Build proper SemVer version string
141
     local xyz           # base version string
162
     local xyz           # base version string
142
     local prerl         # pre-release keyword (from mkit.ini, eg. 'beta')
163
     local prerl         # pre-release keyword (from mkit.ini, eg. 'beta')
143
     local latest_tag    # latest git tag
164
     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)
165
+    local brname        # current branch name
166
+    local ghash         # current commit short hash
167
+    local is_tagged=T   # T if tagged (clean, no metadata), F if devel
168
+    local is_dirty=F    # F if dirty, T if clean
169
+    local stamp         # timestamp or nothing (see $MKIT_TSTAMP)
147
     local suffix        # version suffix
170
     local suffix        # version suffix
148
     prerl=$(ini 1value project:prerl)
171
     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) ;;
172
+    case $MKIT_TSTAMP in
173
+        none)   stamp= ;;
174
+        btime)  stamp=$(date -u +%Y%m%d%H%M%S) ;;
175
+        ctime)  stamp=$(date -d @"$(git_fact latest_cdate)" -u +%Y%m%d%H%M%S) ;;
153
     esac
176
     esac
154
     grep ":" <<<"$prerl" \
177
     grep ":" <<<"$prerl" \
155
      && warn "colon in project:prerl may corrupt version data: $prerl"
178
      && warn "colon in project:prerl may corrupt version data: $prerl"
168
     esac
191
     esac
169
     if ! git describe --tags --exact-match HEAD >&/dev/null;
192
     if ! git describe --tags --exact-match HEAD >&/dev/null;
170
     then    # we are at a later commit than the last tag
193
     then    # we are at a later commit than the last tag
171
-        commit="$(git_fact current_branch).g$(git_fact latest_sha)"
194
+        is_tagged=F
195
+        brname=$(git_fact current_branch | sed 's/[^[:alnum:]]/_/g')
196
+        ghash=$(git_fact latest_sha)
172
     fi
197
     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"   ;;
198
+    git_bool dirty && is_dirty=T
199
+    case "$is_dirty:$is_tagged:$stamp" in
200
+        F:T:*)  suffix=""                                 ;;
201
+        T:T:)   suffix="+dirty"                           ;;
202
+        T:T:*)  suffix="+t$stamp.dirty"                   ;;
203
+        F:F:)   suffix="+$brname.g$ghash"                 ;;
204
+        F:F:*)  suffix="+t$stamp.$brname.g$ghash"         ;;
205
+        T:F:)   suffix="+$brname.g$ghash.dirty"           ;;
206
+        T:F:*)  suffix="+t$stamp.$brname.g$ghash.dirty"   ;;
182
         *)      suffix=MKIT_BUG
207
         *)      suffix=MKIT_BUG
183
                 warn "MKIT_BUG: bad dirt/commit detection" ;;
208
                 warn "MKIT_BUG: bad dirt/commit detection" ;;
184
     esac
209
     esac

+ 53
- 15
utils/mkit/include/ini.sh View File

8
     #
8
     #
9
     local line      # each line
9
     local line      # each line
10
     while read -r line; do
10
     while read -r line; do
11
-        printf -- "%s\n" "$line"
11
+        printf -- '%s\n' "$line"
12
     done
12
     done
13
 }
13
 }
14
 
14
 
17
     # Expand reference value (prefix only)
17
     # Expand reference value (prefix only)
18
     #
18
     #
19
     local line      # each input line
19
     local line      # each input line
20
-    local suffix    # tail of the line
21
-    local ref       # reference
22
-    local value     # value if reference
23
     while read -r line; do                  # [foo:bar]/path
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
     done
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
 __ini_grepcmt() {
72
 __ini_grepcmt() {
34
     #
73
     #
35
     # Remove comments from INI file on stdin
74
     # Remove comments from INI file on stdin
85
                 \[*\])    ok=false; continue ;;
124
                 \[*\])    ok=false; continue ;;
86
             esac
125
             esac
87
             $ok || continue
126
             $ok || continue
88
-            printf -- "%s\n" "$line"
127
+            printf -- '%s\n' "$line"
89
         done \
128
         done \
90
       | sed -e 's/ *= */=/; s/ +$//; s/^//;'
129
       | sed -e 's/ *= */=/; s/ +$//; s/^//;'
91
 }
130
 }
102
     #
141
     #
103
     # List all section names
142
     # List all section names
104
     #
143
     #
105
-    local arg=$1    # unused argument
106
     grep -x '\[.*\]' | sed 's/^.//; s/.$//'
144
     grep -x '\[.*\]' | sed 's/^.//; s/.$//'
107
 }
145
 }
108
 
146
 
126
     local inc                       # file to include
164
     local inc                       # file to include
127
     local incre='\[INCLUDE:.*\]'    # include directive regex
165
     local incre='\[INCLUDE:.*\]'    # include directive regex
128
     local iline                     # include directive line
166
     local iline                     # include directive line
129
-    if iline=$(grep -m1 -x "$incre" "$MKIT_INI"); then
167
+    if iline=$(grep -m1 -xe "$incre" "$MKIT_INI"); then
130
         inc=${iline#*:}; inc=${inc%]}
168
         inc=${iline#*:}; inc=${inc%]}
131
-        grep -vx "$incre" "$inc"
132
-        grep -vx "$incre" "$MKIT_INI"
169
+        grep -vxe "$incre" "$inc"
170
+        grep -vxe "$incre" "$MKIT_INI"
133
     else
171
     else
134
         cat "$MKIT_INI"
172
         cat "$MKIT_INI"
135
     fi | __ini_grepcmt
173
     fi | __ini_grepcmt

+ 5
- 4
utils/mkit/include/release.sh View File

44
         at_relsrc)
44
         at_relsrc)
45
             oracle=$(ini 1value project:relsrc)
45
             oracle=$(ini 1value project:relsrc)
46
             git_fact current_branch \
46
             git_fact current_branch \
47
-              | grep -qFx "$oracle" \
47
+              | grep -qFxe "$oracle" \
48
              || die "you are not on release source branch: $oracle"
48
              || die "you are not on release source branch: $oracle"
49
             ;;
49
             ;;
50
         not_dirty)
50
         not_dirty)
70
         ini_version)
70
         ini_version)
71
             oracle=$(git_fact latest_version | __bump_version "$rlevel")
71
             oracle=$(git_fact latest_version | __bump_version "$rlevel")
72
             ini 1value project:version  \
72
             ini 1value project:version  \
73
-              | grep -qFx "$oracle" \
73
+              | grep -qFxe "$oracle" \
74
              || die "new version not in mkit.ini: $oracle"
74
              || die "new version not in mkit.ini: $oracle"
75
             ;;
75
             ;;
76
         *)
76
         *)
154
     git add mkit.ini \
154
     git add mkit.ini \
155
       || die "failed to add mkit.ini to the index"
155
       || die "failed to add mkit.ini to the index"
156
     cache=$(mktemp -t "mkit._vbump_gitmsg.XXXXXXXX")
156
     cache=$(mktemp -t "mkit._vbump_gitmsg.XXXXXXXX")
157
-    _vbump_gitmsg > "$cache"
157
+    _vbump_gitmsg "$nextver" > "$cache"
158
     git commit -e -F "$cache"   # note: reading from stdin will break vim
158
     git commit -e -F "$cache"   # note: reading from stdin will break vim
159
     rm "$cache"
159
     rm "$cache"
160
 }
160
 }
163
     #
163
     #
164
     # Compose git message template for 'Bump version' commit
164
     # Compose git message template for 'Bump version' commit
165
     #
165
     #
166
-    echo "Bump version"
166
+    local nextver=$1
167
+    echo "Bump version to $nextver"
167
     echo ""
168
     echo ""
168
     echo "Overview of changes:"
169
     echo "Overview of changes:"
169
     echo ""
170
     echo ""

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

71
 # For example, old yum version (as of RHEL-6) will not let you install
71
 # For example, old yum version (as of RHEL-6) will not let you install
72
 # version that it deems older than is installed, making it hard to
72
 # version that it deems older than is installed, making it hard to
73
 # continually upgrade during active development.  While packaging
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
 # considered same) this tag will make it more likely to "win" the build
75
 # considered same) this tag will make it more likely to "win" the build
76
 # you made later.
76
 # you made later.
77
 #
77
 #
81
 # Also note that 'btime' makes the version non-deterministic: merely
81
 # Also note that 'btime' makes the version non-deterministic: merely
82
 # initiating the build a second later will result in different version.
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
 # This MKit version
87
 # This MKit version
88
 #
88
 #
89
-MKIT_VERSION=0.0.35
89
+MKIT_VERSION=0.0.40

+ 3
- 3
utils/mkit/stub View File

162
             echo ''
162
             echo ''
163
             echo '%changelog'
163
             echo '%changelog'
164
             echo ''
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
         packaging/debian/copyright)
168
         packaging/debian/copyright)
185
             echo 'Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__'
185
             echo 'Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__'
186
             echo ' MKIT_STUB_DESCRIPTION'
186
             echo ' MKIT_STUB_DESCRIPTION'
187
             echo ''
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
         packaging/debian/changelog)
191
         packaging/debian/changelog)
686
     esac
686
     esac
687
     updating && init_from_existing
687
     updating && init_from_existing
688
     if test -n "$License"; then
688
     if test -n "$License"; then
689
-        known_licenses | grep -qxF "$License" \
689
+        known_licenses | grep -qxFe "$License" \
690
          || die "unknown license (use -L to get list): $License"
690
          || die "unknown license (use -L to get list): $License"
691
         MkLicense=true
691
         MkLicense=true
692
     fi
692
     fi