Browse Source

Update MKit to v0.0.25

Alois Mahdal 7 years ago
parent
commit
a7771dd02e

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

@@ -17,8 +17,7 @@ _build1() {
17 17
     test -n "$ftype"    || ftype=$(_guess_ftype "$dstpath")
18 18
     debug_var srcpath dstpath ftype
19 19
     <"$srcpath" _build1_ftype "$ftype" >"$dstpath"
20
-    mkdir -p "$MKIT_LOCAL"
21
-    echo "$dstpath" >> "$MKIT_LOCAL/built.lst"
20
+    rec_built "$dstpath"
22 21
 }
23 22
 
24 23
 _build1_ftype() {
@@ -120,7 +119,8 @@ build() {
120 119
     # Add meat to all skeletons
121 120
     #
122 121
     local srcpath   # each source path
123
-    find -type f -name '*.skel' \
122
+    semver >/dev/null
123
+    find . -type f -name '*.skel' \
124 124
      | while read -r srcpath; do
125 125
            _build1 "$srcpath"
126 126
        done
@@ -137,8 +137,7 @@ build_manpages() {
137 137
           | while read -r manfile; do
138 138
                 mdfile="$manfile.md"
139 139
                 ronn -r "$mdfile"
140
-                mkdir -p "$MKIT_LOCAL"
141
-                echo "$manfile" >> "$MKIT_LOCAL/built.lst"
140
+                rec_built "$manfile"
142 141
             done
143 142
     else
144 143
         echo "ronn is not installed"
@@ -174,7 +173,7 @@ debstuff() {
174 173
     mv "${MKIT_PROJ_PKGNAME}-$version.tar.gz" \
175 174
        "${MKIT_PROJ_PKGNAME}_$version.orig.tar.gz" \
176 175
      || die "could not rename tarball"
177
-    echo "${MKIT_PROJ_PKGNAME}_$version.orig.tar.gz" >> "$MKIT_LOCAL/built.lst"
176
+    rec_built "${MKIT_PROJ_PKGNAME}_$version.orig.tar.gz"
178 177
 
179 178
     # read content of each mandatory file from debian_skel
180 179
     #
@@ -188,7 +187,7 @@ debstuff() {
188 187
             mkdir -p "$(dirname "$dftgt")"
189 188
             _build1 "$dfsrc" "$dftgt" debstuff
190 189
         done
191
-    echo debian >> "$MKIT_LOCAL/built.lst"
190
+    rec_built debian
192 191
 }
193 192
 
194 193
 dist() {
@@ -211,8 +210,7 @@ dist() {
211 210
     echo -n "$git_lasthash" > "$dirname/.mkit/git_lasthash"
212 211
     tar -cf "$dirname.tar" "$dirname"
213 212
     gzip -f "$dirname.tar"      # see above FIXME
214
-    mkdir -p "$MKIT_LOCAL"
215
-    echo "$dirname.tar.gz" >> "$MKIT_LOCAL/built.lst"
213
+    rec_built "$dirname.tar.gz"
216 214
     rm -rf "$dirname"
217 215
 }
218 216
 

+ 2
- 0
utils/mkit/include/facts.sh View File

@@ -154,6 +154,7 @@ semver() {
154 154
     local commit        # commit indicator (CURRENT_BRANCH.gHASH)
155 155
     local dirty         # 0 if dirty, 1 if clean
156 156
     local suffix        # version suffix
157
+    local_get semver && return 0
157 158
     version=$(ini 1value project:version)
158 159
     prerl=$(ini 1value project:prerl)
159 160
     grep ":" <<<"$prerl" \
@@ -178,5 +179,6 @@ semver() {
178 179
         test -n "$prerl" && suffix="-$prerl$suffix"
179 180
         version="$version$suffix"
180 181
     fi
182
+    local_putb semver <<<"$version"
181 183
     echo "$version"
182 184
 }

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

@@ -125,6 +125,31 @@ _chkiniversion() {
125 125
      || die "bad mkit.ini version: $their_ver does not match $MKIT_VERSION"
126 126
 }
127 127
 
128
+local_putb() {
129
+    #
130
+    # Make file $1 in $MKIT_LOCAL from stdin and mark as built
131
+    #
132
+    local fpath=$1
133
+    local_put "$fpath" && rec_built "$MKIT_LOCAL/$fpath"
134
+}
135
+
136
+local_put() {
137
+    #
138
+    # Make file $1 in $MKIT_LOCAL from stdin
139
+    #
140
+    local fpath="$MKIT_LOCAL/$1"
141
+    { mkdir -p "${fpath%/*}" && cat >"$fpath"; } \
142
+     || die "cannot write to local cache: $fpath"
143
+}
144
+
145
+local_get() {
146
+    #
147
+    # Read file $1 in $MKIT_LOCAL
148
+    #
149
+    local fpath="$MKIT_LOCAL/$1"
150
+    cat "$fpath" 2>/dev/null
151
+}
152
+
128 153
 mkit_init() {
129 154
     #
130 155
     # Do basic initialization
@@ -132,11 +157,19 @@ mkit_init() {
132 157
     # Check for ini file and some variables
133 158
     #
134 159
     $MKIT_DRY && MKIT_DEBUG=true
160
+    #shellcheck disable=SC2034
135 161
     MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
136 162
     test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
137 163
     _chkiniversion
138
-    test -n "$(tr -d '[:space:]' <<<"$MKIT_LOCAL")" \
139
-     || die "MKIT_LOCAL must be non-blank: '$MKIT_LOCAL'"
164
+}
165
+
166
+rec_built() {
167
+    #
168
+    # Record file $1 for deletion on `clean`
169
+    #
170
+    local file=$1
171
+    mkdir -p "$MKIT_LOCAL"
172
+    echo "$file" >> "$MKIT_LOCAL/built.lst"
140 173
 }
141 174
 
142 175
 route() {

+ 2
- 1
utils/mkit/include/vars.sh View File

@@ -1,4 +1,5 @@
1 1
 #!/bin/bash
2
+#shellcheck disable=SC2034
2 3
 # MKit - simple install helper
3 4
 # See LICENSE file for copyright and license details.
4 5
 
@@ -57,4 +58,4 @@ MKIT_PROJ_PKGNAME=""
57 58
 #
58 59
 # This MKit version
59 60
 #
60
-MKIT_VERSION=0.0.24
61
+MKIT_VERSION=0.0.25