Kaynağa Gözat

Produce "nice" mkit.ini right away

Not just on update but also on creation.
Alois Mahdal 7 yıl önce
ebeveyn
işleme
b1ed732f5e
1 değiştirilmiş dosya ile 59 ekleme ve 28 silme
  1. 59
    28
      src/stub

+ 59
- 28
src/stub Dosyayı Görüntüle

@@ -68,15 +68,17 @@ deploy() {
68 68
 
69 69
         */mkit.ini|mkit.ini)
70 70
             echo "[project]"
71
-            echo "    version     = $Version"
72
-            test -n "$Codename"     && echo "    codename    = $Codename"
73
-            test -n "$NiceName"     && echo "    name        = $NiceName"
74
-            test -n "$Tagline"      && echo "    tagline     = $Tagline"
75
-            test -n "$PackageName"  && echo "    pkgname     = $PackageName"
76
-            test -n "$Maintainer"   && echo "    maintainer  = $Maintainer"
77
-            test -n "$VcsBrowser"   && echo "    vcs_browser = $VcsBrowser"
78
-            test -n "$RelSrc"       && echo "    relsrc      = $RelSrc"
79
-            test -n "$RelDst"       && echo "    reldst      = $RelDst"
71
+            {
72
+                echo "version = $Version"
73
+                test -n "$Codename"     && echo "codename    = $Codename"
74
+                test -n "$NiceName"     && echo "name        = $NiceName"
75
+                test -n "$Tagline"      && echo "tagline     = $Tagline"
76
+                test -n "$PackageName"  && echo "pkgname     = $PackageName"
77
+                test -n "$Maintainer"   && echo "maintainer  = $Maintainer"
78
+                test -n "$VcsBrowser"   && echo "vcs_browser = $VcsBrowser"
79
+                test -n "$RelSrc"       && echo "relsrc      = $RelSrc"
80
+                test -n "$RelDst"       && echo "reldst      = $RelDst"
81
+            } | reformat_section
80 82
             if updating; then
81 83
                 remake_section dist
82 84
                 remake_section ENV
@@ -87,35 +89,47 @@ deploy() {
87 89
             else
88 90
                 echo ""
89 91
                 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"
92
+                {
93
+                    $MkLicense  && echo "tarball = LICENSE.md"
94
+                    $MkMakefile && echo "tarball = Makefile"
95
+                    $MkReadme   && echo "tarball = README.md"
96
+                    echo "tarball = mkit.ini"
97
+                    $MkPackaging && echo "tarball = packaging"
98
+                    echo "tarball = src"
99
+                    echo "tarball = tests"
100
+                    echo "tarball = utils"
101
+                    $MkPackaging && echo "rpmstuff = packaging/template.spec"
102
+                    $MkPackaging && echo "debstuff = packaging/debian"
103
+                } | reformat_section
100 104
                 echo ""
101 105
                 echo "[ENV]"
102
-                echo "    PREFIX = /usr/local"
106
+                {
107
+                    echo "    PREFIX = /usr/local"
108
+                } | reformat_section
103 109
                 echo ""
104 110
                 echo "[roots]"
105
-                echo "    bin     = [ENV:PREFIX]/bin"
106
-                echo "    doc     = [ENV:PREFIX]/share/doc/$PackageName"
111
+                {
112
+                    echo "bin = [ENV:PREFIX]/bin"
113
+                    echo "doc = [ENV:PREFIX]/share/doc/$PackageName"
114
+                } | reformat_section
107 115
                 echo ""
108 116
                 echo "[tokens]"
109
-                echo "    __${PackageName^^}_FOO__ = Barr.."
117
+                {
118
+                    echo "__${PackageName^^}_FOO__ = Barr.."
119
+                } | reformat_section
110 120
                 echo ""
111 121
                 echo "[modes]"
112
-                echo "    bin     = 755"
113
-                echo "    doc     = 644"
122
+                {
123
+                    echo "bin = 755"
124
+                    echo "doc = 644"
125
+                } | reformat_section
114 126
                 echo ""
115 127
                 echo "[files]"
116
-                echo "    bin      = src/$PackageName"
117
-                $MkLicense && echo "    doc      = LICENSE.md"
118
-                $MkReadme  && echo "    doc      = README.md"
128
+                {
129
+                    echo "bin = src/$PackageName"
130
+                    $MkLicense && echo "doc = LICENSE.md"
131
+                    $MkReadme  && echo "doc = README.md"
132
+                } | reformat_section
119 133
             fi
120 134
             echo ""
121 135
             echo "#mkit version=$MKIT_VERSION"
@@ -613,6 +627,23 @@ remake_section() {
613 627
                     echo "$key = $value"
614 628
                 done
615 629
         done \
630
+      | reformat_section
631
+}
632
+
633
+reformat_section() {
634
+    #
635
+    # Re-format "k = v" on stdin as "nice" ini section
636
+    #
637
+    local key
638
+    local eq
639
+    local value
640
+    while read -r key eq value; do
641
+        test "$eq" == "=" || {
642
+            warn "ignoring malformed ini line: $key $eq $value"
643
+            continue
644
+        }
645
+        echo "$key = $value"
646
+    done \
616 647
       | column -to' ' \
617 648
       | sed 's/^/    /'
618 649
 }