|
@@ -58,6 +58,52 @@ die() {
|
58
|
58
|
exit 4
|
59
|
59
|
}
|
60
|
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
|
+
|
61
|
107
|
mkit_init() {
|
62
|
108
|
#
|
63
|
109
|
# Do basic initialization
|
|
@@ -67,6 +113,7 @@ mkit_init() {
|
67
|
113
|
$MKIT_DRY && MKIT_DEBUG=true
|
68
|
114
|
MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
|
69
|
115
|
test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
|
|
116
|
+ _chkiniversion
|
70
|
117
|
test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
|
71
|
118
|
|| die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
|
72
|
119
|
}
|