Browse Source

Update MKit to v0.0.24

Alois Mahdal 6 years ago
parent
commit
25ceea5816

+ 1
- 0
utils/mkit/include/build.sh View File

@@ -81,6 +81,7 @@ _expand_tokens() {
81 81
         done
82 82
         echo "s|__MKIT_PROJ_NAME__|$(ini 1value project:name | _qfs)|g;"
83 83
         echo "s|__MKIT_PROJ_CODENAME__|$(ini 1value project:codename | _qfs)|g;"
84
+        echo "s|__MKIT_PROJ_LICENSE__|$(ini 1value project:license | _qfs)|g;"
84 85
         echo "s|__MKIT_PROJ_PKGNAME__|$(ini 1value project:pkgname | _qfs)|g;"
85 86
         echo "s|__MKIT_PROJ_TAGLINE__|$(ini 1value project:tagline | _qfs)|g;"
86 87
         echo "s|__MKIT_PROJ_MAINTAINER__|$(ini 1value project:maintainer | _qfs)|g;"

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

@@ -2,6 +2,8 @@
2 2
 # MKit - simple install helper
3 3
 # See LICENSE file for copyright and license details.
4 4
 
5
+mkit_import ini
6
+
5 7
 _deploy_item() {
6 8
     #
7 9
     # Deploy item and make it look like wanted

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

@@ -90,7 +90,7 @@ _ini_lskeys() {
90 90
     # List keys from a section
91 91
     #
92 92
     local sct=$1    # section of interest
93
-    _ini_grepsec "$sct" | cut -d= -f1 | sort | uniq
93
+    _ini_grepsec "$sct" | cut -d= -f1 | awk '!x[$0]++'
94 94
 }
95 95
 
96 96
 _ini_maybe_expand() {

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

@@ -40,11 +40,13 @@ _valid_targets() {
40 40
     echo debstuff
41 41
     echo dist
42 42
     echo install
43
+    echo release
43 44
     echo release_x
44 45
     echo release_y
45 46
     echo release_z
46 47
     echo rpmstuff
47 48
     echo uninstall
49
+    echo vbump
48 50
     echo vbump_x
49 51
     echo vbump_y
50 52
     echo vbump_z
@@ -113,7 +115,7 @@ _chkiniversion() {
113 115
     ver_line=$(
114 116
         {
115 117
             head -3 "$MKIT_INI"
116
-            tac "$MKIT_INI" | tail -3
118
+            tail -3 "$MKIT_INI"
117 119
         } | grep -m 1 -E '^# *mkit +version *= *v?[0-9]+\.[0-9]+\.[0-9]+'
118 120
     )
119 121
     test -n "$ver_line" \

+ 18
- 2
utils/mkit/include/release.sh View File

@@ -91,6 +91,7 @@ _release() {
91 91
     #
92 92
     local rlevel=$1     # release level (x, y or z)
93 93
     local newtag        # new tag
94
+    local relsrc        # release source branch (if any)
94 95
     local reldst        # release destination branch (if any)
95 96
 
96 97
     _relck git_present
@@ -107,9 +108,10 @@ _release() {
107 108
     $MKIT_DRY && return
108 109
     git tag -m "$(_release_msg)" "$newtag"
109 110
 
111
+    relsrc=$(ini 1value project:relsrc)
110 112
     reldst=$(ini 1value project:reldst)
111
-    debug_var reldst
112
-    if test -n "$reldst"; then
113
+    debug_var relsrc reldst
114
+    if test -n "$reldst" && test "$reldst" != "$relsrc"; then
113 115
         git branch -f "$reldst" "$newtag"
114 116
     fi
115 117
 }
@@ -169,6 +171,13 @@ _vbump_gitmsg() {
169 171
         '
170 172
 }
171 173
 
174
+release() {
175
+    #
176
+    # Perform release on Z level
177
+    #
178
+    _release z
179
+}
180
+
172 181
 release_x() {
173 182
     #
174 183
     # Perform release on X level
@@ -190,6 +199,13 @@ release_z() {
190 199
     _release z
191 200
 }
192 201
 
202
+vbump() {
203
+    #
204
+    # Perform version bump on Z level
205
+    #
206
+    _vbump z
207
+}
208
+
193 209
 vbump_x() {
194 210
     #
195 211
     # Perform version bump on X level

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

@@ -57,4 +57,4 @@ MKIT_PROJ_PKGNAME=""
57 57
 #
58 58
 # This MKit version
59 59
 #
60
-MKIT_VERSION=0.0.21
60
+MKIT_VERSION=0.0.24

+ 3
- 3
utils/mkit/make View File

@@ -24,9 +24,9 @@ MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
24 24
 init_core
25 25
 
26 26
 case "$1" in
27
-    --version-semver) echo "$MKIT_VERSION"; exit 0 ;;
28
-    --version)        echo "Mkit (Simple Makefile target helper) $MKIT_VERSION"
29
-                      exit 0 ;;
27
+    -V|--version-semver)    echo "$MKIT_VERSION"; exit 0 ;;
28
+    --version)              echo "Mkit (Simple Makefile target helper) $MKIT_VERSION"
29
+                            exit 0 ;;
30 30
 esac
31 31
 
32 32
 mkit_init

+ 3
- 3
utils/mkit/mkit.mk View File

@@ -27,7 +27,7 @@ install: all
27 27
 	@$(MKIT_DIR)/make install
28 28
 
29 29
 release:
30
-	@$(MKIT_DIR)/make release_z
30
+	@$(MKIT_DIR)/make release
31 31
 
32 32
 release_x:
33 33
 	@$(MKIT_DIR)/make release_x
@@ -42,7 +42,7 @@ uninstall:
42 42
 	@$(MKIT_DIR)/make uninstall
43 43
 
44 44
 vbump:
45
-	@$(MKIT_DIR)/make vbump_z
45
+	@$(MKIT_DIR)/make vbump
46 46
 
47 47
 vbump_x:
48 48
 	@$(MKIT_DIR)/make vbump_x
@@ -53,4 +53,4 @@ vbump_y:
53 53
 vbump_z:
54 54
 	@$(MKIT_DIR)/make vbump_z
55 55
 
56
-.PHONY: all clean dist rpmstuff install uninstall release_x release_y release_z vbump_x vbump_y vbump_z
56
+.PHONY: all clean dist rpmstuff install uninstall release release_x release_y release_z vbump vbump_x vbump_y vbump_z

utils/mkit/newstub → utils/mkit/stub View File

@@ -21,21 +21,25 @@ MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
21 21
 
22 22
 init_core
23 23
 
24
-declare -A MKIT_INIT_LICENSES
25
-MKIT_INIT_LICENSES[GPLv1]="http://www.gnu.org/licenses/old-licenses/gpl-1.0.md"
26
-MKIT_INIT_LICENSES[GPLv2]="http://www.gnu.org/licenses/old-licenses/gpl-2.0.md"
27
-MKIT_INIT_LICENSES[GPLv3]="http://www.gnu.org/licenses/gpl-3.0.md"
28
-MKIT_INIT_LICENSES[LGPLv2]="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.md"
29
-MKIT_INIT_LICENSES[LGPLv3]="http://www.gnu.org/licenses/lgpl-3.0.md"
30
-MKIT_INIT_LICENSES[AGPLv3]="http://www.gnu.org/licenses/agpl-3.0.md"
31
-MKIT_INIT_LICENSES[FDLv1.3]="http://www.gnu.org/licenses/fdl-1.3.md"
32
-MKIT_INIT_LICENSES[FDLv1.2]="http://www.gnu.org/licenses/old-licenses/fdl-1.2.md"
33
-MKIT_INIT_LICENSES[FDLv1.1]="http://www.gnu.org/licenses/old-licenses/fdl-1.1.md"
24
+mkit_import ini
25
+
26
+declare -A MKIT_STUB_LICENSES
27
+MKIT_STUB_LICENSES[GPLv1]="http://www.gnu.org/licenses/old-licenses/gpl-1.0.md"
28
+MKIT_STUB_LICENSES[GPLv2]="http://www.gnu.org/licenses/old-licenses/gpl-2.0.md"
29
+MKIT_STUB_LICENSES[GPLv3]="http://www.gnu.org/licenses/gpl-3.0.md"
30
+MKIT_STUB_LICENSES[LGPLv2]="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.md"
31
+MKIT_STUB_LICENSES[LGPLv3]="http://www.gnu.org/licenses/lgpl-3.0.md"
32
+MKIT_STUB_LICENSES[AGPLv3]="http://www.gnu.org/licenses/agpl-3.0.md"
33
+MKIT_STUB_LICENSES[FDLv1.3]="http://www.gnu.org/licenses/fdl-1.3.md"
34
+MKIT_STUB_LICENSES[FDLv1.2]="http://www.gnu.org/licenses/old-licenses/fdl-1.2.md"
35
+MKIT_STUB_LICENSES[FDLv1.1]="http://www.gnu.org/licenses/old-licenses/fdl-1.1.md"
34 36
 
35 37
 
36 38
 deploy() {
37 39
     local file=$1       # which known file?
38 40
     local any_name=${NiceName:-$PackageName}
41
+    local tmp
42
+    tmp=$(mktemp -t mkit.stub.deploy.XXXXXXX)
39 43
     mkdir -p "$(dirname "$file")"
40 44
     case $file in
41 45
 
@@ -43,7 +47,7 @@ deploy() {
43 47
             echo -n "# $any_name"
44 48
             test -n "$Tagline" && echo -n " - $Tagline"
45 49
             echo
46
-            echo '# See LICENSE.md file for copyright and license details.'
50
+            $MkLicense && echo '# See LICENSE.md file for copyright and license details.'
47 51
             echo ''
48 52
             echo 'MKIT_DIR=utils/mkit'
49 53
             #shellcheck disable=SC2016
@@ -62,11 +66,9 @@ deploy() {
62 66
             fi
63 67
             ;;
64 68
 
65
-        mkit.ini)
66
-            echo "#mkit version=$MKIT_VERSION"
67
-            echo ""
69
+        */mkit.ini|mkit.ini)
68 70
             echo "[project]"
69
-            echo "    version     = 0.0.0"
71
+            echo "    version     = $Version"
70 72
             test -n "$Codename"     && echo "    codename    = $Codename"
71 73
             test -n "$NiceName"     && echo "    name        = $NiceName"
72 74
             test -n "$Tagline"      && echo "    tagline     = $Tagline"
@@ -75,37 +77,48 @@ deploy() {
75 77
             test -n "$VcsBrowser"   && echo "    vcs_browser = $VcsBrowser"
76 78
             test -n "$RelSrc"       && echo "    relsrc      = $RelSrc"
77 79
             test -n "$RelDst"       && echo "    reldst      = $RelDst"
80
+            if updating; then
81
+                remake_section dist
82
+                remake_section ENV
83
+                remake_section roots
84
+                remake_section tokens
85
+                remake_section modes
86
+                remake_section files
87
+            else
88
+                echo ""
89
+                echo "[dist]"
90
+                $MkLicense  && echo "    tarball = LICENSE.md"
91
+                $MkMakefile && echo "    tarball = Makefile"
92
+                $MkReadme   && echo "    tarball = README.md"
93
+                echo "    tarball = mkit.ini"
94
+                $MkPackaging && echo "    tarball = packaging"
95
+                echo "    tarball = src"
96
+                echo "    tarball = tests"
97
+                echo "    tarball = utils"
98
+                $MkPackaging && echo "    rpmstuff = packaging/template.spec"
99
+                $MkPackaging && echo "    debstuff = packaging/debian"
100
+                echo ""
101
+                echo "[ENV]"
102
+                echo "    PREFIX = /usr/local"
103
+                echo ""
104
+                echo "[roots]"
105
+                echo "    bin     = [ENV:PREFIX]/bin"
106
+                echo "    doc     = [ENV:PREFIX]/share/doc/$PackageName"
107
+                echo ""
108
+                echo "[tokens]"
109
+                echo "    __${PackageName^^}_FOO__ = Barr.."
110
+                echo ""
111
+                echo "[modes]"
112
+                echo "    bin     = 755"
113
+                echo "    doc     = 644"
114
+                echo ""
115
+                echo "[files]"
116
+                echo "    bin      = src/$PackageName"
117
+                $MkLicense && echo "    doc      = LICENSE.md"
118
+                $MkReadme  && echo "    doc      = README.md"
119
+            fi
78 120
             echo ""
79
-            echo "[dist]"
80
-            echo "    tarball = LICENSE.md"
81
-            $MkMakefile && echo "    tarball = Makefile"
82
-            $MkReadme   && echo "    tarball = README.md"
83
-            echo "    tarball = mkit.ini"
84
-            $MkPackaging && echo "    tarball = packaging"
85
-            echo "    tarball = src"
86
-            echo "    tarball = tests"
87
-            echo "    tarball = utils"
88
-            $MkPackaging && echo "    rpmstuff = packaging/template.spec"
89
-            $MkPackaging && echo "    debstuff = packaging/debian"
90
-            echo ""
91
-            echo "[ENV]"
92
-            echo "    PREFIX = /usr/local"
93
-            echo ""
94
-            echo "[roots]"
95
-            echo "    bin     = [ENV:PREFIX]/bin"
96
-            echo "    doc     = [ENV:PREFIX]/share/doc/$PackageName"
97
-            echo ""
98
-            echo "[tokens]"
99
-            echo "    __BIN_DIR__ = [roots:bin]"
100
-            echo ""
101
-            echo "[modes]"
102
-            echo "    bin     = 755"
103
-            echo "    doc     = 644"
104
-            echo ""
105
-            echo "[files]"
106
-            echo "    bin      = src/$PackageName"
107
-            $MkReadme && echo "    doc      = LICENSE.md"
108
-            test -n "$License" && echo "    doc      = README.md"
121
+            echo "#mkit version=$MKIT_VERSION"
109 122
             ;;
110 123
 
111 124
         packaging/template.spec)
@@ -114,15 +127,15 @@ deploy() {
114 127
             echo 'Release:	1%{?dist}'
115 128
             echo 'Summary:	__MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__'
116 129
             echo ''
117
-            echo "License:	$License"
130
+            $MkLicense && echo "License:	$License"
118 131
             echo 'Source0:	%{name}-%{version}.tar.gz'
119 132
             echo ''
120 133
             echo 'BuildArch:	noarch'
121 134
             echo 'BuildRequires:	coreutils git'
122
-            echo 'Requires:	MKIT_NEWSTUB_REQUIRES'
135
+            echo 'Requires:	MKIT_STUB_REQUIRES'
123 136
             echo ''
124 137
             echo '%description'
125
-            echo 'MKIT_NEWSTUB_DESCRIPTION'
138
+            echo 'MKIT_STUB_DESCRIPTION'
126 139
             echo ''
127 140
             echo '%prep'
128 141
             echo '%setup -q'
@@ -131,10 +144,10 @@ deploy() {
131 144
             echo 'make %{?_smp_mflags}'
132 145
             echo ''
133 146
             echo '%install'
134
-            echo '%make_install'
147
+            echo '%make_install PREFIX=/usr'
135 148
             echo ''
136 149
             echo '%files'
137
-            echo 'MKIT_NEWSTUB_FILELIST'
150
+            echo 'MKIT_STUB_FILELIST'
138 151
             echo ''
139 152
             echo '%changelog'
140 153
             echo ''
@@ -156,9 +169,9 @@ deploy() {
156 169
             echo ''
157 170
             echo 'Package: __MKIT_PROJ_PKGNAME__'
158 171
             echo 'Architecture: all'
159
-            echo 'Depends: MKIT_NEWSTUB_REQUIRES'
172
+            echo 'Depends: MKIT_STUB_REQUIRES'
160 173
             echo 'Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__'
161
-            echo ' MKIT_NEWSTUB_DESCRIPTION'
174
+            echo ' MKIT_STUB_DESCRIPTION'
162 175
             echo ''
163 176
             echo '# control file built with MKit __MKIT_SELF_VERSION__'
164 177
             ;;
@@ -184,7 +197,7 @@ deploy() {
184 197
             echo ''
185 198
             echo 'override_dh_auto_install:'
186 199
             echo ''
187
-            echo '	make install DESTDIR=debian/tmp'
200
+            echo '	make install PREFIX=/usr DESTDIR=debian/tmp'
188 201
             echo ''
189 202
             echo 'override_dh_usrlocal:'
190 203
             echo ''
@@ -196,7 +209,7 @@ deploy() {
196 209
             ;;
197 210
 
198 211
         packaging/debian/*.install)
199
-            echo MKIT_NEWSTUB_FILELIST
212
+            echo MKIT_STUB_FILELIST
200 213
             ;;
201 214
 
202 215
         src/*.skel)
@@ -206,7 +219,7 @@ deploy() {
206 219
 
207 220
         LICENSE.md)
208 221
             local url   # license URL
209
-            url="${MKIT_INIT_LICENSES[$License]}"
222
+            url="${MKIT_STUB_LICENSES[$License]}"
210 223
             curl -sf "$url" \
211 224
              || die "failed to download license: $url"
212 225
             ;;
@@ -214,13 +227,13 @@ deploy() {
214 227
         .mkit/autoclean)
215 228
             ;;
216 229
 
217
-        MKIT_NEWSTUB_README.md)
230
+        MKIT_STUB_README.md)
218 231
             echo "FINISHING MKIT CONFIGURATION"
219 232
             echo "============================"
220 233
             echo ""
221 234
             echo "Congratulations, your new project has been configured!"
222 235
             echo ""
223
-            echo "However, the *newstub* script is not able to figure out"
236
+            echo "However, the *stub* script is not able to figure out"
224 237
             echo "everything, so few things still need to be done manually."
225 238
             echo "This document will guide you throught the rest of the"
226 239
             echo "process."
@@ -278,17 +291,17 @@ deploy() {
278 291
             echo "Placeholders"
279 292
             echo "------------"
280 293
             echo ""
281
-            echo "At places where *newstub* script did not have way to get all"
294
+            echo "At places where *stub* script did not have way to get all"
282 295
             echo "information automatically, it has inserted placeholders."
283 296
             echo "You will need to go through all of these placeholders and"
284 297
             echo "replace them with proper data."
285 298
             echo ""
286 299
             echo "Please follow instructions:"
287 300
             echo ""
288
-            echo " 1. Look for placeholders starting with \`MKIT_NEWSTUB_\`"
301
+            echo " 1. Look for placeholders starting with \`MKIT_STUB_\`"
289 302
             echo "    prefix by calling this command:"
290 303
             echo ""
291
-            echo "        grep -lw MKIT_NEWSTUB_ -r"
304
+            echo "        grep -l MKIT_STUB_ -r"
292 305
             echo ""
293 306
             echo " 2. Go through each file and locate the placeholder.  (You"
294 307
             echo "    will also see placeholders like \`__MKIT_*__\`, you can"
@@ -296,15 +309,26 @@ deploy() {
296 309
             echo ""
297 310
             echo " 3. Replace placeholder with appropriate information:"
298 311
             echo ""
299
-            echo "     *  \`MKIT_NEWSTUB_REQUIRES\` - Requirements of your"
312
+            echo "     *  \`MKIT_STUB_REQUIRES\` - Requirements of your"
300 313
             echo "        project."
301 314
             echo ""
302
-            echo "     *  \`MKIT_NEWSTUB_DESCRIPTION\` - Description of your"
315
+            echo "     *  \`MKIT_STUB_DESCRIPTION\` - Description of your"
303 316
             echo "        project (few sentences to paragraphs)."
304 317
             echo ""
305
-            echo "     *  \`MKIT_NEWSTUB_FILELIST\` - List of full paths to"
318
+            echo "     *  \`MKIT_STUB_FILELIST\` - List of full paths to"
306 319
             echo "        your files after installation."
307 320
             echo ""
321
+            echo "        Note that in case of debian/package.install files,"
322
+            echo "        PREFIX based paths (eg. /usr/bin) in this file should"
323
+            echo "        should be as if PREFIX was /usr/local, despite PREFIX"
324
+            echo "        being set to /usr in debian/rules.  (Debian's script"
325
+            echo "        dh_usrlocal will take care of that.)"
326
+            echo ""
327
+            echo "        In case of Fedora-based distro, you should make use"
328
+            echo "        of RPM macros:"
329
+            echo ""
330
+            echo "            https://fedoraproject.org/wiki/Packaging:RPMMacros"
331
+            echo ""
308 332
             echo "    Refer to these documents for further details:"
309 333
             echo ""
310 334
             echo "        http://rpm-guide.readthedocs.io/"
@@ -399,7 +423,7 @@ deploy() {
399 423
             echo "Makefile"
400 424
             echo "--------"
401 425
             echo ""
402
-            echo "*newstub* script also created a Makefile for you, but all"
426
+            echo "*stub* script also created a Makefile for you, but all"
403 427
             echo "it really does is include MKit's own mkit.mk, which in turn"
404 428
             echo "only maps \`make\` targets to actual mkit script calls."
405 429
             echo "Unless your project already uses GNU Make, you should not"
@@ -413,7 +437,7 @@ deploy() {
413 437
             echo "---------"
414 438
             echo ""
415 439
             echo "Each serious project needs a serious README.  Which is why"
416
-            echo "*newstub* has created a 'stub' of one for you."
440
+            echo "*stub* has created a 'stub' of one for you."
417 441
             fi
418 442
 
419 443
             echo ""
@@ -424,13 +448,15 @@ deploy() {
424 448
             echo "Once you have reviewed everything, just delete this file!"
425 449
             ;;
426 450
 
427
-    esac >"$file"
451
+    esac >"$tmp"
452
+    cat "$tmp" > "$file"
453
+    rm "$tmp"
428 454
 }
429 455
 
430 456
 known_licenses() {
431 457
     local key
432 458
     local first=true
433
-    for key in "${!MKIT_INIT_LICENSES[@]}"; do
459
+    for key in "${!MKIT_STUB_LICENSES[@]}"; do
434 460
         $first && echo "$key"  && continue
435 461
         echo ", $key"
436 462
     done
@@ -439,8 +465,9 @@ known_licenses() {
439 465
 usage() {
440 466
     {
441 467
         echo "Usage:"
442
-        echo "   newstub [options] NAME"
443
-        echo "   newstub -L"
468
+        echo "   stub [options] new PKGNAME"
469
+        echo "   stub [options] update"
470
+        echo "   stub -L"
444 471
         echo ""
445 472
         echo "Options:"
446 473
         echo ""
@@ -452,6 +479,7 @@ usage() {
452 479
         echo "    -l LICENSE    your options's license (see -L)"
453 480
         echo "    -m MAINT      project maintainer's name and e-mail"
454 481
         echo "    -v URL        URL to public code browser"
482
+        echo "    -V VERSION    initial version (default: 0.0.0)"
455 483
         echo "    -a            enable autoclean ('make clean' after"
456 484
         echo "                  each 'make install')"
457 485
         echo "    -g            make git commits before and adter"
@@ -462,7 +490,7 @@ usage() {
462 490
         echo "    -P            skip creating packaging templates"
463 491
         echo "    -L            list know licenses and exit"
464 492
         echo ""
465
-        echo "NAME should be packaging-friendly name, ie. consist"
493
+        echo "PKGNAME should be packaging-friendly name, ie. consist"
466 494
         echo "only of small letters, numbers, underscore and dash."
467 495
         echo "For your 'real' name, use NICENAME, which can be any"
468 496
         echo "string."
@@ -478,10 +506,10 @@ confirm() {
478 506
         echo "current codebase.  At least following files will be"
479 507
         echo "created or overwritten:"
480 508
         echo ""
481
-        $MkPackaging        && echo " *  'packaging' directory (pass -P to avoid)"
482
-        $MkMakefile         && echo " *  'Makefile' (pass -M to avoid)"
483
-        $MkReadme           && echo " *  'README.md' (pass -R to avoid)"
484
-        test -n "$License"  && echo " *  'LICENSE.md' (omit -l to avoid)"
509
+        $MkPackaging    && echo " *  'packaging' directory (pass -P to avoid)"
510
+        $MkMakefile     && echo " *  'Makefile' (pass -M to avoid)"
511
+        $MkReadme       && echo " *  'README.md' (pass -R to avoid)"
512
+        $MkLicense      && echo " *  'LICENSE.md' (omit -l to avoid)"
485 513
         echo " *  'mkit.ini'"
486 514
         echo ""
487 515
         read -p "Type 'yes' to proceed: " -r response
@@ -497,20 +525,25 @@ mkcommit_backup() {
497 525
      || { warn "nothing to back up"; return 0; }
498 526
     git add .                           || return
499 527
     git rm -r --cached utils/mkit       || return
500
-    git commit -m "WIP [mkit/newstub] backup"   || return
528
+    git commit -m "WIP [mkit/stub] backup" || return
501 529
 }
502 530
 
503 531
 mkcommit_mkit_code() {
504 532
     git ls-files --others \
505 533
       | grep -q -e '^utils/mkit$' -e '^utils/mkit/' \
506 534
      || return 0
507
-    git add utils/mkit                                         || return
508
-    git commit -m "WIP [mkit/newstub] Add MKit version v$MKIT_VERSION" || return
535
+    git add utils/mkit || return
536
+    git commit -m "WIP [mkit/stub] Add MKit version v$MKIT_VERSION" || return
509 537
 }
510 538
 
511 539
 mkcommit_mkit_conf() {
512
-    git add .                                                  || return
513
-    git commit -m "WIP [mkit/newstub] Add MKit configuration stub" || return
540
+    local msg       # commit message (the important art
541
+    git add . || return
542
+    case $Action in
543
+        new)    msg="Add MKit configuration stub" ;;
544
+        update) msg="Update MKit configuration"   ;;
545
+    esac
546
+    git commit -m "WIP [mkit/stub] $msg" || return
514 547
 }
515 548
 
516 549
 deploy_packaging() {
@@ -523,7 +556,69 @@ deploy_packaging() {
523 556
     deploy packaging/debian/rules
524 557
     deploy packaging/debian/source/format
525 558
     deploy packaging/debian/"$PackageName".install
526
-    deploy packaging/template.spec
559
+}
560
+
561
+init_from_existing() {
562
+    #
563
+    # Initialize variables from old mkit.ini
564
+    #
565
+    test -f "$MKIT_INI" \
566
+     || die "mkit.ini not found; aborting update: $MKIT_INI"
567
+    user_gave Codename    || Codename=$(ini_raw1v project:codename)
568
+    user_gave License     || License=$(ini_raw1v project:license)
569
+    user_gave Maintainer  || Maintainer=$(ini_raw1v project:maintainer)
570
+    user_gave NiceName    || NiceName=$(ini_raw1v project:name)
571
+    user_gave PackageName || PackageName=$(ini_raw1v project:pkgname)
572
+    user_gave RelDst      || RelDst=$(ini_raw1v project:reldst)
573
+    user_gave RelSrc      || RelSrc=$(ini_raw1v project:relsrc)
574
+    user_gave Tagline     || Tagline=$(ini_raw1v project:tagline)
575
+    user_gave VcsBrowser  || VcsBrowser=$(ini_raw1v project:vcs_browser)
576
+    user_gave Version     || Version=$(ini_raw1v project:version)
577
+}
578
+
579
+ini_raw1v() {
580
+    #
581
+    # Read raw scalar from mkit.ini
582
+    #
583
+    local path=$1
584
+    MKIT_INI_EXPAND=0 ini 1value "$path"
585
+}
586
+
587
+user_gave() {
588
+    #
589
+    # True if user gave value to variable $1
590
+    #
591
+    local var=$1    # name of the variable
592
+    { test "${UserGave[$var]}" == 1; } 2>/dev/null
593
+}
594
+
595
+updating() {
596
+    #
597
+    # Are we updating?
598
+    #
599
+    test "$Action" == update
600
+}
601
+
602
+remake_section() {
603
+    #
604
+    # Re-compose mkit.ini section $1
605
+    #
606
+    local section=$1
607
+    local key
608
+    local value
609
+    ini lskeys "$section" | grep -q . \
610
+     || return 1
611
+    echo ""
612
+    echo "[$section]"
613
+    ini lskeys "$section" \
614
+      | while read -r key; do
615
+            MKIT_INI_EXPAND=0 ini values "$section:$key" \
616
+              | while read -r value; do
617
+                    echo "$key = $value"
618
+                done
619
+        done \
620
+      | column -to' ' \
621
+      | sed 's/^/    /'
527 622
 }
528 623
 
529 624
 main() {
@@ -535,21 +630,27 @@ main() {
535 630
     local Tagline           # project tagline
536 631
     local Maintainer        # project maintainer (Name + e-mail)
537 632
     local VcsBrowser        # VCS browser (eg. GitHub URL)
633
+    local Version=0.0.0     # project version
538 634
     local AutoClean=false   # touch .mkit/autoclean?
539 635
     local MkCommits=false   # create pre/post git commits?
540 636
     local Force=false       # go without asking?
541 637
     local MkReadme=true     # create README.md?
542 638
     local MkMakefile=true   # create Makefile?
543 639
     local MkPackaging=true  # create packaging templates?
640
+    local MkLicense=false   # create LICENSE.md file
641
+    local Action            # 'update' to respect existing, 'new' to force
642
+                            # rewrite incl. MKIT_STUB_* placeholders
643
+    declare -A UserGave
544 644
     while true; do case $1 in
545
-        -n) NiceName=$2;        shift 2 || usage ;;
546
-        -b) RelSrc=$2;          shift 2 || usage ;;
547
-        -B) RelDst=$2;          shift 2 || usage ;;
548
-        -c) Codename=$2;        shift 2 || usage ;;
549
-        -t) Tagline=$2;         shift 2 || usage ;;
550
-        -l) License=$2;         shift 2 || usage ;;
551
-        -m) Maintainer=$2;      shift 2 || usage ;;
552
-        -v) VcsBrowser=$2;      shift 2 || usage ;;
645
+        -n) NiceName=$2;   UserGave[NiceName]=1;   shift 2 || usage ;;
646
+        -b) RelSrc=$2;     UserGave[RelSrc]=1;     shift 2 || usage ;;
647
+        -B) RelDst=$2;     UserGave[RelDst]=1;     shift 2 || usage ;;
648
+        -c) Codename=$2;   UserGave[Codename]=1;   shift 2 || usage ;;
649
+        -t) Tagline=$2;    UserGave[Tagline]=1;    shift 2 || usage ;;
650
+        -l) License=$2;    UserGave[License]=1;    shift 2 || usage ;;
651
+        -m) Maintainer=$2; UserGave[Maintainer]=1; shift 2 || usage ;;
652
+        -v) VcsBrowser=$2; UserGave[VcsBrowser]=1; shift 2 || usage ;;
653
+        -V) Version=$2;    UserGave[Version]=1;    shift 2 || usage ;;
553 654
         -M) MkMakefile=false;   shift ;;
554 655
         -R) MkReadme=false;     shift ;;
555 656
         -a) AutoClean=true;     shift ;;
@@ -560,31 +661,39 @@ main() {
560 661
         -*) usage ;;
561 662
         *)  break ;;
562 663
     esac done
563
-    PackageName="$1"
564
-    test -n "$PackageName" || usage
664
+    Action=$1; PackageName=$2
665
+    case $Action:$PackageName in
666
+        new:)     usage ;;
667
+        new:*)    :     ;;
668
+        update:)  :     ;;
669
+        update:*) usage ;;
670
+        *)        usage ;;
671
+    esac
672
+    updating && init_from_existing
565 673
     if test -n "$License"; then
566 674
         known_licenses | grep -qxF "$License" \
567 675
          || die "unknown license (use -L to get list): $License"
676
+        MkLicense=true
568 677
     fi
569 678
     if $MkCommits; then
570 679
         mkcommit_backup || die "failed creating backup commit"
571 680
         Force=true
572 681
     fi
573 682
     confirm            || return 1
574
-    deploy mkit.ini
683
+    deploy "$MKIT_INI"
575 684
     deploy src/"$PackageName".skel
576
-    $MkMakefile        && deploy Makefile
577
-    $MkReadme          && deploy README.md
578
-    test -n "$License" && deploy LICENSE.md
579
-    $AutoClean         && deploy .mkit/autoclean
580
-    $MkPackaging       && deploy_packaging
685
+    $MkMakefile     && deploy Makefile
686
+    $MkReadme       && deploy README.md
687
+    $MkLicense      && deploy LICENSE.md
688
+    $AutoClean      && deploy .mkit/autoclean
689
+    $MkPackaging    && deploy_packaging
581 690
     if $MkCommits; then
582 691
         mkcommit_mkit_code || die "failed creating post-commit"
583 692
         mkcommit_mkit_conf || die "failed creating post-commit"
584 693
     fi
585
-    deploy MKIT_NEWSTUB_README.md
694
+    deploy MKIT_STUB_README.md
586 695
     warn "Configuration stub built, follow instructions in"
587
-    warn "MKIT_NEWSTUB_README.md to finish configuration."
696
+    warn "MKIT_STUB_README.md to finish configuration."
588 697
     return 0
589 698
 }
590 699