浏览代码

Update MKit to v0.0.14

Alois Mahdal 9 年前
父节点
当前提交
e89c2f166b

+ 5
- 5
utils/mkit/include/build.sh 查看文件

168
 
168
 
169
     # read content of each mandatory file from debian_skel
169
     # read content of each mandatory file from debian_skel
170
     #
170
     #
171
-    local debian_skel=$(ini 1value debstuff:debian_skel)
172
-    test -n "$debian_skel" || die "debstuff:debian_skel not specified"
171
+    local debian_skel=$(ini 1value dist:debstuff)
172
+    test -n "$debian_skel" || die "dist:debstuff not specified"
173
     test -d "$debian_skel" || die "debian directory template found: $debian_skel"
173
     test -d "$debian_skel" || die "debian directory template found: $debian_skel"
174
     mkdir -p debian/source
174
     mkdir -p debian/source
175
     local dfsrc dftgt
175
     local dfsrc dftgt
194
     local git_lasthash=$(git_lasthash)
194
     local git_lasthash=$(git_lasthash)
195
     local dirname=$MKIT_PROJ_PKGNAME-$version
195
     local dirname=$MKIT_PROJ_PKGNAME-$version
196
     mkdir -p "$dirname"
196
     mkdir -p "$dirname"
197
-    ini values "lists:dist" | xargs -I DIST_ITEM cp -R DIST_ITEM "$dirname"
197
+    ini values "dist:tarball" | xargs -I DIST_ITEM cp -R DIST_ITEM "$dirname"
198
     update_version "$version" "$dirname/mkit.ini"
198
     update_version "$version" "$dirname/mkit.ini"
199
     mkdir -p "$dirname/.mkit"
199
     mkdir -p "$dirname/.mkit"
200
     echo -n "$git_lasthash" > "$dirname/.mkit/git_lasthash"
200
     echo -n "$git_lasthash" > "$dirname/.mkit/git_lasthash"
210
     # Build specfile
210
     # Build specfile
211
     #
211
     #
212
     local specname="$MKIT_PROJ_PKGNAME.spec"
212
     local specname="$MKIT_PROJ_PKGNAME.spec"
213
-    local specsrc="$(ini 1value "rpmstuff:spec_skel")"
214
-    test -n "$specsrc" || die "rpmstuff:spec_skel not specified"
213
+    local specsrc="$(ini 1value "dist:rpmstuff")"
214
+    test -n "$specsrc" || die "dist:rpmstuff not specified"
215
     test -f "$specsrc" || die "specfile template not found: $specsrc"
215
     test -f "$specsrc" || die "specfile template not found: $specsrc"
216
     _build1 "$specsrc" "$specname"
216
     _build1 "$specsrc" "$specname"
217
 }
217
 }

+ 16
- 10
utils/mkit/include/deploy.sh 查看文件

46
     #
46
     #
47
     local grp=$1
47
     local grp=$1
48
     local src=$2
48
     local src=$2
49
-    echo "$(_get_root "$grp")/$(ini 1value "files:$grp:$src")"
49
+    local dst=$3
50
+    test -n "$dst" || dst=${src##*/}
51
+    echo "$(_get_root "$grp")/$dst"
50
 }
52
 }
51
 
53
 
52
 _get_root() {
54
 _get_root() {
53
     #
55
     #
54
-    # Find out target rooot for group $1
56
+    # Find out target root for group $1
55
     #
57
     #
56
     local grp="$1"
58
     local grp="$1"
57
     local root=$(ini 1value "roots:$grp")
59
     local root=$(ini 1value "roots:$grp")
83
     # Install product
85
     # Install product
84
     #
86
     #
85
     local dst group mode src
87
     local dst group mode src
86
-    ini values "lists:group" \
88
+    ini lskeys "files" \
89
+      | sort \
90
+      | uniq \
87
       | while read group;
91
       | while read group;
88
         do
92
         do
89
             mode=$(ini 1value "modes:$group")
93
             mode=$(ini 1value "modes:$group")
90
-            ini lskeys "files:$group" \
91
-              | while read src;
94
+            ini values "files:$group" \
95
+              | while read src dst;
92
                 do
96
                 do
93
-                    dst=$(_get_dst "$group" "$src")
97
+                    dst=$(_get_dst "$group" "$src" "$dst")
94
                     _deploy_item "$src" "$dst" "$mode"
98
                     _deploy_item "$src" "$dst" "$mode"
95
                 done
99
                 done
96
         done
100
         done
103
     # Uninstall product
107
     # Uninstall product
104
     #
108
     #
105
     local dst group src
109
     local dst group src
106
-    ini values "lists:group" \
110
+    ini lskeys "files" \
111
+      | sort \
112
+      | uniq \
107
       | while read group;
113
       | while read group;
108
         do
114
         do
109
-            ini lskeys "files:$group" \
110
-              | while read src;
115
+            ini values "files:$group" \
116
+              | while read src dst;
111
                 do
117
                 do
112
-                    dst=$(_get_dst "$group" "$src")
118
+                    dst=$(_get_dst "$group" "$src" "$dst")
113
                     _maybe rm -vrf "$dst"
119
                     _maybe rm -vrf "$dst"
114
                 done
120
                 done
115
         done
121
         done

+ 5
- 5
utils/mkit/include/facts.sh 查看文件

33
     git_present || warn "can't give fact outside git repo: $fact_name"
33
     git_present || warn "can't give fact outside git repo: $fact_name"
34
     case "$fact_name" in
34
     case "$fact_name" in
35
         latest_tag)
35
         latest_tag)
36
-            git log --format="%D" \
36
+            git log --format="%d" \
37
               | sed 's/,/\n/g' \
37
               | sed 's/,/\n/g' \
38
-              | sed 's/^[[:blank:]]*//; ' \
39
-              | grep -E '^tag: v[[:digit:]]+\.' \
40
-              | cut -d' ' -f2 \
41
-              | head -1
38
+              | sed 's/^[[:blank:]]*//' \
39
+              | grep -E '^\(?tag' \
40
+              | tr -cd '[[:digit:]].v\n' \
41
+              | grep . -m 1
42
             ;;
42
             ;;
43
         latest_version)
43
         latest_version)
44
             git_fact latest_tag | git_tag2ver
44
             git_fact latest_tag | git_tag2ver

+ 0
- 1
utils/mkit/include/ini.sh 查看文件

111
     local arg=$2
111
     local arg=$2
112
     local fn
112
     local fn
113
     local limit=_ini_cat
113
     local limit=_ini_cat
114
-    debug_var op arg
115
     case $op in
114
     case $op in
116
         lskeys) fn=_ini_lskeys   ;;
115
         lskeys) fn=_ini_lskeys   ;;
117
         sec)    fn=_ini_grepsec  ;;
116
         sec)    fn=_ini_grepsec  ;;

+ 48
- 5
utils/mkit/include/mkit.sh 查看文件

5
 . "$MKIT_DIR/include/release.sh" || die "cannot import release.sh"
5
 . "$MKIT_DIR/include/release.sh" || die "cannot import release.sh"
6
 . "$MKIT_DIR/include/ini.sh"    || die "cannot import ini.sh"
6
 . "$MKIT_DIR/include/ini.sh"    || die "cannot import ini.sh"
7
 
7
 
8
-MKIT_INI=${MKIT_INI:-mkit.ini}
9
-MKIT_INI_EXPAND=2
10
-MKIT_PROJ_PKGNAME=""
11
-MKIT_DEFAULT_MODE="644"
12
-
13
 _valid_targets() {
8
 _valid_targets() {
14
     #
9
     #
15
     # List valid routes
10
     # List valid routes
63
     exit 4
58
     exit 4
64
 }
59
 }
65
 
60
 
61
+_compver() {
62
+    #
63
+    # True if version $1 matches our version
64
+    #
65
+    # If our x is 0, check first two fragments, otherwise check just
66
+    # the x.  Fragments must equal.
67
+    #
68
+    local their_ver our_x our_y their_x their_y
69
+    their_ver="$1"
70
+    their_x=${their_ver%%.*}
71
+    their_y=${their_ver##$their_x.}
72
+    their_y=${their_y%%.*}
73
+    our_x=${MKIT_VERSION%%.*}
74
+    our_y=${MKIT_VERSION##$our_x.}
75
+    our_y=${our_y%%.*}
76
+    debug_var MKIT_VERSION our_x our_y their_ver their_x their_y
77
+    test "$their_x" -eq "$our_x" || return 1
78
+    test "$our_x" -eq 0 && {
79
+        test "$their_y" = "$our_y"
80
+        return $?
81
+    }
82
+    return 0
83
+}
84
+
85
+_chkiniversion() {
86
+    #
87
+    # Check if ini version is supported
88
+    #
89
+    # Look for "#mkit version=0.0.0" or similar in first or last
90
+    # 3 lines of the file; then check if the version is supported.
91
+    #
92
+    local ver_line
93
+    local their_ver
94
+    ver_line=$(
95
+        {
96
+            head -3 "$MKIT_INI"
97
+            tac "$MKIT_INI" | tail -3
98
+        } | grep -m 1 -E '^# *mkit +version *= *v?[0-9]+\.[0-9]+\.[0-9]+'
99
+    )
100
+    test -n "$ver_line" \
101
+     || die "version mark ('#mkit version=x.y.z') not found in: $MKIT_INI"
102
+    their_ver="$(tr -d '[:blank:]v' <<<"${ver_line##*=}")"
103
+    _compver "$their_ver" \
104
+     || die "bad mkit.ini version: $their_ver does not match $MKIT_VERSION"
105
+}
106
+
66
 mkit_init() {
107
 mkit_init() {
67
     #
108
     #
68
     # Do basic initialization
109
     # Do basic initialization
69
     #
110
     #
70
     # Check for ini file and some variables
111
     # Check for ini file and some variables
71
     #
112
     #
113
+    $MKIT_DRY && MKIT_DEBUG=true
72
     MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
114
     MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
73
     test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
115
     test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
116
+    _chkiniversion
74
     test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
117
     test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
75
      || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
118
      || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
76
 }
119
 }

+ 8
- 1
utils/mkit/include/release.sh 查看文件

85
     #
85
     #
86
     local rlevel=$1
86
     local rlevel=$1
87
     local newtag
87
     local newtag
88
+    local reldst
88
 
89
 
89
     _relck git_present
90
     _relck git_present
90
     _relck at_relsrc
91
     _relck at_relsrc
99
     debug_var newtag
100
     debug_var newtag
100
     $MKIT_DRY && return
101
     $MKIT_DRY && return
101
     git tag -m "$(ini 1value project:name) $newtag - $CODENAME" "$newtag"
102
     git tag -m "$(ini 1value project:name) $newtag - $CODENAME" "$newtag"
102
-    git branch -f "$(ini 1value project:reldst)" "$newtag"
103
+
104
+    reldst=$(ini 1value project:reldst)
105
+    debug_var reldst
106
+    if test -n "$reldst";
107
+    then
108
+        git branch -f "$reldst" "$newtag"
109
+    fi
103
 }
110
 }
104
 
111
 
105
 _vbump() {
112
 _vbump() {

+ 56
- 5
utils/mkit/make 查看文件

6
     echo "$@" && exit 9
6
     echo "$@" && exit 9
7
 }
7
 }
8
 
8
 
9
-export MKIT_VERSION=0.0.13
10
 
9
 
11
-export MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
12
-export MKIT_LOCAL=${MKIT_LOCAL:-.mkit}
13
-export MKIT_DRY=${MKIT_DRY:-false}
14
-export MKIT_DEBUG=${MKIT_DEBUG:-false}
10
+#
11
+# Debug mode (true|false)
12
+#
13
+MKIT_DEBUG=${MKIT_DEBUG:-false}
14
+
15
+#
16
+# Default deploy mode for files
17
+#
18
+MKIT_DEFAULT_MODE="644"
19
+
20
+#
21
+# Path to MKit dir (where 'include' is)
22
+#
23
+MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
24
+
25
+#
26
+# Dry mode (true|false)
27
+#
28
+# Set to true to not install anything. Implies MKIT_DEBUG.
29
+#
30
+MKIT_DRY=${MKIT_DRY:-false}
31
+
32
+#
33
+# Path to mkit.ini
34
+#
35
+MKIT_INI=${MKIT_INI:-mkit.ini}
36
+
37
+#
38
+# Limit ini expansion depth
39
+#
40
+# To avoid endless loops, this value is subtracted each
41
+# time ini() expands a reference; when zero is reached,
42
+# no more expansions happen.
43
+#
44
+MKIT_INI_EXPAND=2
45
+
46
+#
47
+# Path to MKit local config and temp
48
+#
49
+# Typically hidden in project root, here MKit can
50
+# save its temporary lists.
51
+#
52
+MKIT_LOCAL=${MKIT_LOCAL:-.mkit}
53
+
54
+#
55
+# Package name
56
+#
57
+# Used as base for tarball and in some default tokens.
58
+#
59
+MKIT_PROJ_PKGNAME=""
60
+
61
+#
62
+# This MKit version
63
+#
64
+MKIT_VERSION=0.0.14
65
+
15
 
66
 
16
 . "$MKIT_DIR/include/mkit.sh" || die "failed to init; check if MKIT_DIR is set properly: $MKIT_DIR"
67
 . "$MKIT_DIR/include/mkit.sh" || die "failed to init; check if MKIT_DIR is set properly: $MKIT_DIR"
17
 
68