Bladeren bron

Update own dogfood

Alois Mahdal 7 jaren geleden
bovenliggende
commit
0b0009eafa
4 gewijzigde bestanden met toevoegingen van 197 en 97 verwijderingen
  1. 1
    0
      utils/mkit/include/build.sh
  2. 1
    1
      utils/mkit/include/ini.sh
  3. 1
    1
      utils/mkit/include/vars.sh
  4. 194
    95
      utils/mkit/stub

+ 1
- 0
utils/mkit/include/build.sh Bestand weergeven

@@ -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;"

+ 1
- 1
utils/mkit/include/ini.sh Bestand weergeven

@@ -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() {

+ 1
- 1
utils/mkit/include/vars.sh Bestand weergeven

@@ -57,4 +57,4 @@ MKIT_PROJ_PKGNAME=""
57 57
 #
58 58
 # This MKit version
59 59
 #
60
-MKIT_VERSION=0.0.20+devel.g7c137e5
60
+MKIT_VERSION=0.0.21+HEAD.g47f8848

utils/mkit/newstub → utils/mkit/stub Bestand weergeven

@@ -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
 
@@ -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 "    __BIN_DIR__ = [roots:bin]"
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'
@@ -134,7 +147,7 @@ deploy() {
134 147
             echo '%make_install'
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
             ;;
@@ -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 -lw 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,13 +309,13 @@ 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 ""
308 321
             echo "    Refer to these documents for further details:"
@@ -399,7 +412,7 @@ deploy() {
399 412
             echo "Makefile"
400 413
             echo "--------"
401 414
             echo ""
402
-            echo "*newstub* script also created a Makefile for you, but all"
415
+            echo "*stub* script also created a Makefile for you, but all"
403 416
             echo "it really does is include MKit's own mkit.mk, which in turn"
404 417
             echo "only maps \`make\` targets to actual mkit script calls."
405 418
             echo "Unless your project already uses GNU Make, you should not"
@@ -413,7 +426,7 @@ deploy() {
413 426
             echo "---------"
414 427
             echo ""
415 428
             echo "Each serious project needs a serious README.  Which is why"
416
-            echo "*newstub* has created a 'stub' of one for you."
429
+            echo "*stub* has created a 'stub' of one for you."
417 430
             fi
418 431
 
419 432
             echo ""
@@ -424,13 +437,15 @@ deploy() {
424 437
             echo "Once you have reviewed everything, just delete this file!"
425 438
             ;;
426 439
 
427
-    esac >"$file"
440
+    esac >"$tmp"
441
+    cat "$tmp" > "$file"
442
+    rm "$tmp"
428 443
 }
429 444
 
430 445
 known_licenses() {
431 446
     local key
432 447
     local first=true
433
-    for key in "${!MKIT_INIT_LICENSES[@]}"; do
448
+    for key in "${!MKIT_STUB_LICENSES[@]}"; do
434 449
         $first && echo "$key"  && continue
435 450
         echo ", $key"
436 451
     done
@@ -439,8 +454,9 @@ known_licenses() {
439 454
 usage() {
440 455
     {
441 456
         echo "Usage:"
442
-        echo "   newstub [options] NAME"
443
-        echo "   newstub -L"
457
+        echo "   stub [options] new PKGNAME"
458
+        echo "   stub [options] update"
459
+        echo "   stub -L"
444 460
         echo ""
445 461
         echo "Options:"
446 462
         echo ""
@@ -452,6 +468,7 @@ usage() {
452 468
         echo "    -l LICENSE    your options's license (see -L)"
453 469
         echo "    -m MAINT      project maintainer's name and e-mail"
454 470
         echo "    -v URL        URL to public code browser"
471
+        echo "    -V VERSION    initial version (default: 0.0.0)"
455 472
         echo "    -a            enable autoclean ('make clean' after"
456 473
         echo "                  each 'make install')"
457 474
         echo "    -g            make git commits before and adter"
@@ -462,7 +479,7 @@ usage() {
462 479
         echo "    -P            skip creating packaging templates"
463 480
         echo "    -L            list know licenses and exit"
464 481
         echo ""
465
-        echo "NAME should be packaging-friendly name, ie. consist"
482
+        echo "PKGNAME should be packaging-friendly name, ie. consist"
466 483
         echo "only of small letters, numbers, underscore and dash."
467 484
         echo "For your 'real' name, use NICENAME, which can be any"
468 485
         echo "string."
@@ -478,10 +495,10 @@ confirm() {
478 495
         echo "current codebase.  At least following files will be"
479 496
         echo "created or overwritten:"
480 497
         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)"
498
+        $MkPackaging    && echo " *  'packaging' directory (pass -P to avoid)"
499
+        $MkMakefile     && echo " *  'Makefile' (pass -M to avoid)"
500
+        $MkReadme       && echo " *  'README.md' (pass -R to avoid)"
501
+        $MkLicense      && echo " *  'LICENSE.md' (omit -l to avoid)"
485 502
         echo " *  'mkit.ini'"
486 503
         echo ""
487 504
         read -p "Type 'yes' to proceed: " -r response
@@ -497,20 +514,25 @@ mkcommit_backup() {
497 514
      || { warn "nothing to back up"; return 0; }
498 515
     git add .                           || return
499 516
     git rm -r --cached utils/mkit       || return
500
-    git commit -m "WIP [mkit/newstub] backup"   || return
517
+    git commit -m "WIP [mkit/stub] backup" || return
501 518
 }
502 519
 
503 520
 mkcommit_mkit_code() {
504 521
     git ls-files --others \
505 522
       | grep -q -e '^utils/mkit$' -e '^utils/mkit/' \
506 523
      || return 0
507
-    git add utils/mkit                                         || return
508
-    git commit -m "WIP [mkit/newstub] Add MKit version v$MKIT_VERSION" || return
524
+    git add utils/mkit || return
525
+    git commit -m "WIP [mkit/stub] Add MKit version v$MKIT_VERSION" || return
509 526
 }
510 527
 
511 528
 mkcommit_mkit_conf() {
512
-    git add .                                                  || return
513
-    git commit -m "WIP [mkit/newstub] Add MKit configuration stub" || return
529
+    local msg       # commit message (the important art
530
+    git add . || return
531
+    case $Action in
532
+        new)    msg="Add MKit configuration stub" ;;
533
+        update) msg="Update MKit configuration"   ;;
534
+    esac
535
+    git commit -m "WIP [mkit/stub] $msg" || return
514 536
 }
515 537
 
516 538
 deploy_packaging() {
@@ -526,6 +548,69 @@ deploy_packaging() {
526 548
     deploy packaging/template.spec
527 549
 }
528 550
 
551
+init_from_existing() {
552
+    #
553
+    # Initialize variables from old mkit.ini
554
+    #
555
+    test -f "$MKIT_INI" \
556
+     || die "mkit.ini not found; aborting update: $MKIT_INI"
557
+    user_gave Codename    || Codename=$(ini_raw1v project:codename)
558
+    user_gave License     || License=$(ini_raw1v project:license)
559
+    user_gave Maintainer  || Maintainer=$(ini_raw1v project:maintainer)
560
+    user_gave NiceName    || NiceName=$(ini_raw1v project:name)
561
+    user_gave PackageName || PackageName=$(ini_raw1v project:pkgname)
562
+    user_gave RelDst      || RelDst=$(ini_raw1v project:reldst)
563
+    user_gave RelSrc      || RelSrc=$(ini_raw1v project:relsrc)
564
+    user_gave Tagline     || Tagline=$(ini_raw1v project:tagline)
565
+    user_gave VcsBrowser  || VcsBrowser=$(ini_raw1v project:vcs_browser)
566
+    user_gave Version     || Version=$(ini_raw1v project:version)
567
+}
568
+
569
+ini_raw1v() {
570
+    #
571
+    # Read raw scalar from mkit.ini
572
+    #
573
+    local path=$1
574
+    MKIT_INI_EXPAND=0 ini 1value "$path"
575
+}
576
+
577
+user_gave() {
578
+    #
579
+    # True if user gave value to variable $1
580
+    #
581
+    local var=$1    # name of the variable
582
+    { test "${UserGave[$var]}" == 1; } 2>/dev/null
583
+}
584
+
585
+updating() {
586
+    #
587
+    # Are we updating?
588
+    #
589
+    test "$Action" == update
590
+}
591
+
592
+remake_section() {
593
+    #
594
+    # Re-compose mkit.ini section $1
595
+    #
596
+    local section=$1
597
+    local key
598
+    local value
599
+    ini lskeys "$section" | grep -q . \
600
+     || return 1
601
+    echo ""
602
+    echo "[$section]"
603
+    ini lskeys "$section" \
604
+      | while read -r key; do
605
+            MKIT_INI_EXPAND=0 ini values "$section:$key" \
606
+              | while read -r value; do
607
+                    echo "$key = $value"
608
+                done
609
+        done \
610
+      | column -to' ' \
611
+      | sed 's/^/    /'
612
+}
613
+
529 614
 main() {
530 615
     local NiceName          # human-readable project name
531 616
     local PackageName       # machine-safe project (package) name
@@ -535,21 +620,27 @@ main() {
535 620
     local Tagline           # project tagline
536 621
     local Maintainer        # project maintainer (Name + e-mail)
537 622
     local VcsBrowser        # VCS browser (eg. GitHub URL)
623
+    local Version=0.0.0     # project version
538 624
     local AutoClean=false   # touch .mkit/autoclean?
539 625
     local MkCommits=false   # create pre/post git commits?
540 626
     local Force=false       # go without asking?
541 627
     local MkReadme=true     # create README.md?
542 628
     local MkMakefile=true   # create Makefile?
543 629
     local MkPackaging=true  # create packaging templates?
630
+    local MkLicense=false   # create LICENSE.md file
631
+    local Action            # 'update' to respect existing, 'new' to force
632
+                            # rewrite incl. MKIT_STUB_* placeholders
633
+    declare -A UserGave
544 634
     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 ;;
635
+        -n) NiceName=$2;   UserGave[NiceName]=1;   shift 2 || usage ;;
636
+        -b) RelSrc=$2;     UserGave[RelSrc]=1;     shift 2 || usage ;;
637
+        -B) RelDst=$2;     UserGave[RelDst]=1;     shift 2 || usage ;;
638
+        -c) Codename=$2;   UserGave[Codename]=1;   shift 2 || usage ;;
639
+        -t) Tagline=$2;    UserGave[Tagline]=1;    shift 2 || usage ;;
640
+        -l) License=$2;    UserGave[License]=1;    shift 2 || usage ;;
641
+        -m) Maintainer=$2; UserGave[Maintainer]=1; shift 2 || usage ;;
642
+        -v) VcsBrowser=$2; UserGave[VcsBrowser]=1; shift 2 || usage ;;
643
+        -V) Version=$2;    UserGave[Version]=1;    shift 2 || usage ;;
553 644
         -M) MkMakefile=false;   shift ;;
554 645
         -R) MkReadme=false;     shift ;;
555 646
         -a) AutoClean=true;     shift ;;
@@ -560,31 +651,39 @@ main() {
560 651
         -*) usage ;;
561 652
         *)  break ;;
562 653
     esac done
563
-    PackageName="$1"
564
-    test -n "$PackageName" || usage
565
-    if test -n "$License"; then
654
+    Action=$1; PackageName=$2
655
+    case $Action:$PackageName in
656
+        new:)     usage ;;
657
+        new:*)    :     ;;
658
+        update:)  :     ;;
659
+        update:*) usage ;;
660
+        *)        usage ;;
661
+    esac
662
+    updating && init_from_existing
663
+    if $MkLicense; then
566 664
         known_licenses | grep -qxF "$License" \
567 665
          || die "unknown license (use -L to get list): $License"
666
+        MkLicense=true
568 667
     fi
569 668
     if $MkCommits; then
570 669
         mkcommit_backup || die "failed creating backup commit"
571 670
         Force=true
572 671
     fi
573 672
     confirm            || return 1
574
-    deploy mkit.ini
673
+    deploy "$MKIT_INI"
575 674
     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
675
+    $MkMakefile     && deploy Makefile
676
+    $MkReadme       && deploy README.md
677
+    $MkLicense      && deploy LICENSE.md
678
+    $AutoClean      && deploy .mkit/autoclean
679
+    $MkPackaging    && deploy_packaging
581 680
     if $MkCommits; then
582 681
         mkcommit_mkit_code || die "failed creating post-commit"
583 682
         mkcommit_mkit_conf || die "failed creating post-commit"
584 683
     fi
585
-    deploy MKIT_NEWSTUB_README.md
684
+    deploy MKIT_STUB_README.md
586 685
     warn "Configuration stub built, follow instructions in"
587
-    warn "MKIT_NEWSTUB_README.md to finish configuration."
686
+    warn "MKIT_STUB_README.md to finish configuration."
588 687
     return 0
589 688
 }
590 689