Parcourir la source

Update MKit to v0.0.14

Alois Mahdal il y a 8 ans
Parent
révision
e89c2f166b

+ 5
- 5
utils/mkit/include/build.sh Voir le fichier

@@ -168,8 +168,8 @@ debstuff() {
168 168
 
169 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 173
     test -d "$debian_skel" || die "debian directory template found: $debian_skel"
174 174
     mkdir -p debian/source
175 175
     local dfsrc dftgt
@@ -194,7 +194,7 @@ dist() {
194 194
     local git_lasthash=$(git_lasthash)
195 195
     local dirname=$MKIT_PROJ_PKGNAME-$version
196 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 198
     update_version "$version" "$dirname/mkit.ini"
199 199
     mkdir -p "$dirname/.mkit"
200 200
     echo -n "$git_lasthash" > "$dirname/.mkit/git_lasthash"
@@ -210,8 +210,8 @@ rpmstuff() {
210 210
     # Build specfile
211 211
     #
212 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 215
     test -f "$specsrc" || die "specfile template not found: $specsrc"
216 216
     _build1 "$specsrc" "$specname"
217 217
 }

+ 16
- 10
utils/mkit/include/deploy.sh Voir le fichier

@@ -46,12 +46,14 @@ _get_dst() {
46 46
     #
47 47
     local grp=$1
48 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 54
 _get_root() {
53 55
     #
54
-    # Find out target rooot for group $1
56
+    # Find out target root for group $1
55 57
     #
56 58
     local grp="$1"
57 59
     local root=$(ini 1value "roots:$grp")
@@ -83,14 +85,16 @@ install() {
83 85
     # Install product
84 86
     #
85 87
     local dst group mode src
86
-    ini values "lists:group" \
88
+    ini lskeys "files" \
89
+      | sort \
90
+      | uniq \
87 91
       | while read group;
88 92
         do
89 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 96
                 do
93
-                    dst=$(_get_dst "$group" "$src")
97
+                    dst=$(_get_dst "$group" "$src" "$dst")
94 98
                     _deploy_item "$src" "$dst" "$mode"
95 99
                 done
96 100
         done
@@ -103,13 +107,15 @@ uninstall() {
103 107
     # Uninstall product
104 108
     #
105 109
     local dst group src
106
-    ini values "lists:group" \
110
+    ini lskeys "files" \
111
+      | sort \
112
+      | uniq \
107 113
       | while read group;
108 114
         do
109
-            ini lskeys "files:$group" \
110
-              | while read src;
115
+            ini values "files:$group" \
116
+              | while read src dst;
111 117
                 do
112
-                    dst=$(_get_dst "$group" "$src")
118
+                    dst=$(_get_dst "$group" "$src" "$dst")
113 119
                     _maybe rm -vrf "$dst"
114 120
                 done
115 121
         done

+ 5
- 5
utils/mkit/include/facts.sh Voir le fichier

@@ -33,12 +33,12 @@ git_fact() {
33 33
     git_present || warn "can't give fact outside git repo: $fact_name"
34 34
     case "$fact_name" in
35 35
         latest_tag)
36
-            git log --format="%D" \
36
+            git log --format="%d" \
37 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 43
         latest_version)
44 44
             git_fact latest_tag | git_tag2ver

+ 0
- 1
utils/mkit/include/ini.sh Voir le fichier

@@ -111,7 +111,6 @@ ini() {
111 111
     local arg=$2
112 112
     local fn
113 113
     local limit=_ini_cat
114
-    debug_var op arg
115 114
     case $op in
116 115
         lskeys) fn=_ini_lskeys   ;;
117 116
         sec)    fn=_ini_grepsec  ;;

+ 48
- 5
utils/mkit/include/mkit.sh Voir le fichier

@@ -5,11 +5,6 @@
5 5
 . "$MKIT_DIR/include/release.sh" || die "cannot import release.sh"
6 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 8
 _valid_targets() {
14 9
     #
15 10
     # List valid routes
@@ -63,14 +58,62 @@ die() {
63 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 107
 mkit_init() {
67 108
     #
68 109
     # Do basic initialization
69 110
     #
70 111
     # Check for ini file and some variables
71 112
     #
113
+    $MKIT_DRY && MKIT_DEBUG=true
72 114
     MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
73 115
     test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
116
+    _chkiniversion
74 117
     test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
75 118
      || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
76 119
 }

+ 8
- 1
utils/mkit/include/release.sh Voir le fichier

@@ -85,6 +85,7 @@ _release() {
85 85
     #
86 86
     local rlevel=$1
87 87
     local newtag
88
+    local reldst
88 89
 
89 90
     _relck git_present
90 91
     _relck at_relsrc
@@ -99,7 +100,13 @@ _release() {
99 100
     debug_var newtag
100 101
     $MKIT_DRY && return
101 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 112
 _vbump() {

+ 56
- 5
utils/mkit/make Voir le fichier

@@ -6,12 +6,63 @@ die() {
6 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 67
 . "$MKIT_DIR/include/mkit.sh" || die "failed to init; check if MKIT_DIR is set properly: $MKIT_DIR"
17 68