Ver código fonte

Initial commit

Alois Mahdal 5 anos atrás
commit
ea02458569

+ 1
- 0
.gitignore Ver arquivo

@@ -0,0 +1 @@
1
+relics

+ 361
- 0
LICENSE.md Ver arquivo

@@ -0,0 +1,361 @@
1
+### GNU GENERAL PUBLIC LICENSE
2
+
3
+Version 2, June 1991
4
+
5
+    Copyright (C) 1989, 1991 Free Software Foundation, Inc.  
6
+    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
7
+
8
+    Everyone is permitted to copy and distribute verbatim copies
9
+    of this license document, but changing it is not allowed.
10
+
11
+### Preamble
12
+
13
+The licenses for most software are designed to take away your freedom
14
+to share and change it. By contrast, the GNU General Public License is
15
+intended to guarantee your freedom to share and change free
16
+software--to make sure the software is free for all its users. This
17
+General Public License applies to most of the Free Software
18
+Foundation's software and to any other program whose authors commit to
19
+using it. (Some other Free Software Foundation software is covered by
20
+the GNU Lesser General Public License instead.) You can apply it to
21
+your programs, too.
22
+
23
+When we speak of free software, we are referring to freedom, not
24
+price. Our General Public Licenses are designed to make sure that you
25
+have the freedom to distribute copies of free software (and charge for
26
+this service if you wish), that you receive source code or can get it
27
+if you want it, that you can change the software or use pieces of it
28
+in new free programs; and that you know you can do these things.
29
+
30
+To protect your rights, we need to make restrictions that forbid
31
+anyone to deny you these rights or to ask you to surrender the rights.
32
+These restrictions translate to certain responsibilities for you if
33
+you distribute copies of the software, or if you modify it.
34
+
35
+For example, if you distribute copies of such a program, whether
36
+gratis or for a fee, you must give the recipients all the rights that
37
+you have. You must make sure that they, too, receive or can get the
38
+source code. And you must show them these terms so they know their
39
+rights.
40
+
41
+We protect your rights with two steps: (1) copyright the software, and
42
+(2) offer you this license which gives you legal permission to copy,
43
+distribute and/or modify the software.
44
+
45
+Also, for each author's protection and ours, we want to make certain
46
+that everyone understands that there is no warranty for this free
47
+software. If the software is modified by someone else and passed on,
48
+we want its recipients to know that what they have is not the
49
+original, so that any problems introduced by others will not reflect
50
+on the original authors' reputations.
51
+
52
+Finally, any free program is threatened constantly by software
53
+patents. We wish to avoid the danger that redistributors of a free
54
+program will individually obtain patent licenses, in effect making the
55
+program proprietary. To prevent this, we have made it clear that any
56
+patent must be licensed for everyone's free use or not licensed at
57
+all.
58
+
59
+The precise terms and conditions for copying, distribution and
60
+modification follow.
61
+
62
+### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
63
+
64
+**0.** This License applies to any program or other work which
65
+contains a notice placed by the copyright holder saying it may be
66
+distributed under the terms of this General Public License. The
67
+"Program", below, refers to any such program or work, and a "work
68
+based on the Program" means either the Program or any derivative work
69
+under copyright law: that is to say, a work containing the Program or
70
+a portion of it, either verbatim or with modifications and/or
71
+translated into another language. (Hereinafter, translation is
72
+included without limitation in the term "modification".) Each licensee
73
+is addressed as "you".
74
+
75
+Activities other than copying, distribution and modification are not
76
+covered by this License; they are outside its scope. The act of
77
+running the Program is not restricted, and the output from the Program
78
+is covered only if its contents constitute a work based on the Program
79
+(independent of having been made by running the Program). Whether that
80
+is true depends on what the Program does.
81
+
82
+**1.** You may copy and distribute verbatim copies of the Program's
83
+source code as you receive it, in any medium, provided that you
84
+conspicuously and appropriately publish on each copy an appropriate
85
+copyright notice and disclaimer of warranty; keep intact all the
86
+notices that refer to this License and to the absence of any warranty;
87
+and give any other recipients of the Program a copy of this License
88
+along with the Program.
89
+
90
+You may charge a fee for the physical act of transferring a copy, and
91
+you may at your option offer warranty protection in exchange for a
92
+fee.
93
+
94
+**2.** You may modify your copy or copies of the Program or any
95
+portion of it, thus forming a work based on the Program, and copy and
96
+distribute such modifications or work under the terms of Section 1
97
+above, provided that you also meet all of these conditions:
98
+
99
+  
100
+**a)** You must cause the modified files to carry prominent notices
101
+stating that you changed the files and the date of any change.
102
+
103
+  
104
+**b)** You must cause any work that you distribute or publish, that in
105
+whole or in part contains or is derived from the Program or any part
106
+thereof, to be licensed as a whole at no charge to all third parties
107
+under the terms of this License.
108
+
109
+  
110
+**c)** If the modified program normally reads commands interactively
111
+when run, you must cause it, when started running for such interactive
112
+use in the most ordinary way, to print or display an announcement
113
+including an appropriate copyright notice and a notice that there is
114
+no warranty (or else, saying that you provide a warranty) and that
115
+users may redistribute the program under these conditions, and telling
116
+the user how to view a copy of this License. (Exception: if the
117
+Program itself is interactive but does not normally print such an
118
+announcement, your work based on the Program is not required to print
119
+an announcement.)
120
+
121
+These requirements apply to the modified work as a whole. If
122
+identifiable sections of that work are not derived from the Program,
123
+and can be reasonably considered independent and separate works in
124
+themselves, then this License, and its terms, do not apply to those
125
+sections when you distribute them as separate works. But when you
126
+distribute the same sections as part of a whole which is a work based
127
+on the Program, the distribution of the whole must be on the terms of
128
+this License, whose permissions for other licensees extend to the
129
+entire whole, and thus to each and every part regardless of who wrote
130
+it.
131
+
132
+Thus, it is not the intent of this section to claim rights or contest
133
+your rights to work written entirely by you; rather, the intent is to
134
+exercise the right to control the distribution of derivative or
135
+collective works based on the Program.
136
+
137
+In addition, mere aggregation of another work not based on the Program
138
+with the Program (or with a work based on the Program) on a volume of
139
+a storage or distribution medium does not bring the other work under
140
+the scope of this License.
141
+
142
+**3.** You may copy and distribute the Program (or a work based on it,
143
+under Section 2) in object code or executable form under the terms of
144
+Sections 1 and 2 above provided that you also do one of the following:
145
+
146
+  
147
+**a)** Accompany it with the complete corresponding machine-readable
148
+source code, which must be distributed under the terms of Sections 1
149
+and 2 above on a medium customarily used for software interchange; or,
150
+
151
+  
152
+**b)** Accompany it with a written offer, valid for at least three
153
+years, to give any third party, for a charge no more than your cost of
154
+physically performing source distribution, a complete machine-readable
155
+copy of the corresponding source code, to be distributed under the
156
+terms of Sections 1 and 2 above on a medium customarily used for
157
+software interchange; or,
158
+
159
+  
160
+**c)** Accompany it with the information you received as to the offer
161
+to distribute corresponding source code. (This alternative is allowed
162
+only for noncommercial distribution and only if you received the
163
+program in object code or executable form with such an offer, in
164
+accord with Subsection b above.)
165
+
166
+The source code for a work means the preferred form of the work for
167
+making modifications to it. For an executable work, complete source
168
+code means all the source code for all modules it contains, plus any
169
+associated interface definition files, plus the scripts used to
170
+control compilation and installation of the executable. However, as a
171
+special exception, the source code distributed need not include
172
+anything that is normally distributed (in either source or binary
173
+form) with the major components (compiler, kernel, and so on) of the
174
+operating system on which the executable runs, unless that component
175
+itself accompanies the executable.
176
+
177
+If distribution of executable or object code is made by offering
178
+access to copy from a designated place, then offering equivalent
179
+access to copy the source code from the same place counts as
180
+distribution of the source code, even though third parties are not
181
+compelled to copy the source along with the object code.
182
+
183
+**4.** You may not copy, modify, sublicense, or distribute the Program
184
+except as expressly provided under this License. Any attempt otherwise
185
+to copy, modify, sublicense or distribute the Program is void, and
186
+will automatically terminate your rights under this License. However,
187
+parties who have received copies, or rights, from you under this
188
+License will not have their licenses terminated so long as such
189
+parties remain in full compliance.
190
+
191
+**5.** You are not required to accept this License, since you have not
192
+signed it. However, nothing else grants you permission to modify or
193
+distribute the Program or its derivative works. These actions are
194
+prohibited by law if you do not accept this License. Therefore, by
195
+modifying or distributing the Program (or any work based on the
196
+Program), you indicate your acceptance of this License to do so, and
197
+all its terms and conditions for copying, distributing or modifying
198
+the Program or works based on it.
199
+
200
+**6.** Each time you redistribute the Program (or any work based on
201
+the Program), the recipient automatically receives a license from the
202
+original licensor to copy, distribute or modify the Program subject to
203
+these terms and conditions. You may not impose any further
204
+restrictions on the recipients' exercise of the rights granted herein.
205
+You are not responsible for enforcing compliance by third parties to
206
+this License.
207
+
208
+**7.** If, as a consequence of a court judgment or allegation of
209
+patent infringement or for any other reason (not limited to patent
210
+issues), conditions are imposed on you (whether by court order,
211
+agreement or otherwise) that contradict the conditions of this
212
+License, they do not excuse you from the conditions of this License.
213
+If you cannot distribute so as to satisfy simultaneously your
214
+obligations under this License and any other pertinent obligations,
215
+then as a consequence you may not distribute the Program at all. For
216
+example, if a patent license would not permit royalty-free
217
+redistribution of the Program by all those who receive copies directly
218
+or indirectly through you, then the only way you could satisfy both it
219
+and this License would be to refrain entirely from distribution of the
220
+Program.
221
+
222
+If any portion of this section is held invalid or unenforceable under
223
+any particular circumstance, the balance of the section is intended to
224
+apply and the section as a whole is intended to apply in other
225
+circumstances.
226
+
227
+It is not the purpose of this section to induce you to infringe any
228
+patents or other property right claims or to contest validity of any
229
+such claims; this section has the sole purpose of protecting the
230
+integrity of the free software distribution system, which is
231
+implemented by public license practices. Many people have made
232
+generous contributions to the wide range of software distributed
233
+through that system in reliance on consistent application of that
234
+system; it is up to the author/donor to decide if he or she is willing
235
+to distribute software through any other system and a licensee cannot
236
+impose that choice.
237
+
238
+This section is intended to make thoroughly clear what is believed to
239
+be a consequence of the rest of this License.
240
+
241
+**8.** If the distribution and/or use of the Program is restricted in
242
+certain countries either by patents or by copyrighted interfaces, the
243
+original copyright holder who places the Program under this License
244
+may add an explicit geographical distribution limitation excluding
245
+those countries, so that distribution is permitted only in or among
246
+countries not thus excluded. In such case, this License incorporates
247
+the limitation as if written in the body of this License.
248
+
249
+**9.** The Free Software Foundation may publish revised and/or new
250
+versions of the General Public License from time to time. Such new
251
+versions will be similar in spirit to the present version, but may
252
+differ in detail to address new problems or concerns.
253
+
254
+Each version is given a distinguishing version number. If the Program
255
+specifies a version number of this License which applies to it and
256
+"any later version", you have the option of following the terms and
257
+conditions either of that version or of any later version published by
258
+the Free Software Foundation. If the Program does not specify a
259
+version number of this License, you may choose any version ever
260
+published by the Free Software Foundation.
261
+
262
+**10.** If you wish to incorporate parts of the Program into other
263
+free programs whose distribution conditions are different, write to
264
+the author to ask for permission. For software which is copyrighted by
265
+the Free Software Foundation, write to the Free Software Foundation;
266
+we sometimes make exceptions for this. Our decision will be guided by
267
+the two goals of preserving the free status of all derivatives of our
268
+free software and of promoting the sharing and reuse of software
269
+generally.
270
+
271
+**NO WARRANTY**
272
+
273
+**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
274
+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
275
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
276
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
277
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
278
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
279
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
280
+PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
281
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
282
+
283
+**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
284
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
285
+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
286
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
287
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
288
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
289
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
290
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
291
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
292
+DAMAGES.
293
+
294
+### END OF TERMS AND CONDITIONS
295
+
296
+### How to Apply These Terms to Your New Programs
297
+
298
+If you develop a new program, and you want it to be of the greatest
299
+possible use to the public, the best way to achieve this is to make it
300
+free software which everyone can redistribute and change under these
301
+terms.
302
+
303
+To do so, attach the following notices to the program. It is safest to
304
+attach them to the start of each source file to most effectively
305
+convey the exclusion of warranty; and each file should have at least
306
+the "copyright" line and a pointer to where the full notice is found.
307
+
308
+    one line to give the program's name and an idea of what it does.
309
+    Copyright (C) yyyy  name of author
310
+
311
+    This program is free software; you can redistribute it and/or
312
+    modify it under the terms of the GNU General Public License
313
+    as published by the Free Software Foundation; either version 2
314
+    of the License, or (at your option) any later version.
315
+
316
+    This program is distributed in the hope that it will be useful,
317
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
318
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
319
+    GNU General Public License for more details.
320
+
321
+    You should have received a copy of the GNU General Public License
322
+    along with this program; if not, write to the Free Software
323
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
324
+
325
+Also add information on how to contact you by electronic and paper
326
+mail.
327
+
328
+If the program is interactive, make it output a short notice like this
329
+when it starts in an interactive mode:
330
+
331
+    Gnomovision version 69, Copyright (C) year name of author
332
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
333
+    type `show w'.  This is free software, and you are welcome
334
+    to redistribute it under certain conditions; type `show c' 
335
+    for details.
336
+
337
+The hypothetical commands \`show w' and \`show c' should show the
338
+appropriate parts of the General Public License. Of course, the
339
+commands you use may be called something other than \`show w' and
340
+\`show c'; they could even be mouse-clicks or menu items--whatever
341
+suits your program.
342
+
343
+You should also get your employer (if you work as a programmer) or
344
+your school, if any, to sign a "copyright disclaimer" for the program,
345
+if necessary. Here is a sample; alter the names:
346
+
347
+    Yoyodyne, Inc., hereby disclaims all copyright
348
+    interest in the program `Gnomovision'
349
+    (which makes passes at compilers) written 
350
+    by James Hacker.
351
+
352
+    signature of Ty Coon, 1 April 1989
353
+    Ty Coon, President of Vice
354
+
355
+This General Public License does not permit incorporating your program
356
+into proprietary programs. If your program is a subroutine library,
357
+you may consider it more useful to permit linking proprietary
358
+applications with the library. If this is what you want to do, use the
359
+[GNU Lesser General Public
360
+License](https://www.gnu.org/licenses/lgpl.html) instead of this
361
+License.

+ 5
- 0
Makefile Ver arquivo

@@ -0,0 +1,5 @@
1
+# MORF - Modernization Oracle/Result Framework
2
+# See LICENSE.md file for copyright and license details.
3
+
4
+MKIT_DIR=utils/mkit
5
+include $(MKIT_DIR)/mkit.mk

+ 4
- 0
README.md Ver arquivo

@@ -0,0 +1,4 @@
1
+DUMMY
2
+=====
3
+
4
+Just a dummy package for testing purposes

+ 33
- 0
mkit.ini Ver arquivo

@@ -0,0 +1,33 @@
1
+[project]
2
+    version     = 0.0.0
3
+    name        = DUMMY
4
+    tagline     = Just a dummy package
5
+    pkgname     = dummy
6
+    maintainer  = Alois Mahdal <netvor+dummy@vornet.cz>
7
+    vcs_browser = https://gitea.vornet.cz/netvor/dummy.git
8
+    relsrc      = master
9
+    reldst      = last
10
+
11
+[dist]
12
+    tarball  = LICENSE.md
13
+    tarball  = Makefile
14
+    tarball  = README.md
15
+    tarball  = mkit.ini
16
+    tarball  = packaging
17
+    tarball  = src
18
+    tarball  = utils
19
+    rpmstuff = packaging/template.spec
20
+
21
+[ENV]
22
+    PREFIX = /usr/local
23
+
24
+[roots]
25
+    bin = [ENV:PREFIX]/bin
26
+
27
+[modes]
28
+    bin = 755
29
+
30
+[files]
31
+    bin = src/app dummy
32
+
33
+#mkit version=0.0.37

+ 8
- 0
notes/el7toel8-extras.repo Ver arquivo

@@ -0,0 +1,8 @@
1
+[rhel-7-extras]
2
+name=RHEL 7 Extras repository
3
+baseurl=http://download.eng.bos.redhat.com/rel-eng/latest-EXTRAS-7.6-RHEL-7/compose/Server/$basearch/os/
4
+skip_if_unavailable=True
5
+gpgcheck=0
6
+repo_gpgcheck=0
7
+enabled=1
8
+enabled_metadata=1

+ 134
- 0
notes/morf-logo-glcee.svg Ver arquivo

@@ -0,0 +1,134 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+<svg
5
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
6
+   xmlns:cc="http://creativecommons.org/ns#"
7
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
+   xmlns:svg="http://www.w3.org/2000/svg"
9
+   xmlns="http://www.w3.org/2000/svg"
10
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12
+   width="100mm"
13
+   height="100mm"
14
+   viewBox="0 0 100 100"
15
+   version="1.1"
16
+   id="svg8"
17
+   inkscape:version="0.92.4 (unknown)"
18
+   sodipodi:docname="morf-logo-glcee.svg"
19
+   inkscape:export-filename="/home/amahdal/morf-logo-glcee.png"
20
+   inkscape:export-xdpi="36.110001"
21
+   inkscape:export-ydpi="36.110001">
22
+  <defs
23
+     id="defs2" />
24
+  <sodipodi:namedview
25
+     id="base"
26
+     pagecolor="#ffffff"
27
+     bordercolor="#666666"
28
+     borderopacity="1.0"
29
+     inkscape:pageopacity="0.0"
30
+     inkscape:pageshadow="2"
31
+     inkscape:zoom="1.4"
32
+     inkscape:cx="163.80063"
33
+     inkscape:cy="173.94626"
34
+     inkscape:document-units="mm"
35
+     inkscape:current-layer="g4348"
36
+     inkscape:document-rotation="0"
37
+     showgrid="false"
38
+     fit-margin-top="0"
39
+     fit-margin-left="0"
40
+     fit-margin-right="0"
41
+     fit-margin-bottom="0"
42
+     inkscape:window-width="1622"
43
+     inkscape:window-height="632"
44
+     inkscape:window-x="314"
45
+     inkscape:window-y="704"
46
+     inkscape:window-maximized="0" />
47
+  <metadata
48
+     id="metadata5">
49
+    <rdf:RDF>
50
+      <cc:Work
51
+         rdf:about="">
52
+        <dc:format>image/svg+xml</dc:format>
53
+        <dc:type
54
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
55
+        <dc:title></dc:title>
56
+      </cc:Work>
57
+    </rdf:RDF>
58
+  </metadata>
59
+  <g
60
+     inkscape:label="Layer 1"
61
+     inkscape:groupmode="layer"
62
+     id="layer1"
63
+     transform="translate(-54.294445,-56.026081)">
64
+    <rect
65
+       style="vector-effect:none;fill:none;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linejoin:round"
66
+       id="rect4339"
67
+       width="100"
68
+       height="100"
69
+       x="54.294445"
70
+       y="56.026081" />
71
+    <g
72
+       id="g4360"
73
+       transform="matrix(1.6182467,0,0,1.6182467,-48.428089,-27.025727)">
74
+      <g
75
+         id="g4348">
76
+        <rect
77
+           style="vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.48392004;stroke-linejoin:round"
78
+           id="rect4271"
79
+           width="50"
80
+           height="34.916595"
81
+           x="68.925453"
82
+           y="64.692909" />
83
+        <rect
84
+           style="vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.54776043;stroke-linejoin:round"
85
+           id="rect4325"
86
+           width="47.091389"
87
+           height="5.604784"
88
+           x="70.23336"
89
+           y="66.121056" />
90
+        <text
91
+           xml:space="preserve"
92
+           style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:4.34198856px;line-height:1.25;font-family:Inconsolata;-inkscape-font-specification:'Inconsolata, Medium';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;stroke-width:0.10855193"
93
+           x="112.96418"
94
+           y="70.149734"
95
+           id="text4329"><tspan
96
+             sodipodi:role="line"
97
+             id="tspan4331"
98
+             x="112.96418"
99
+             y="70.149734"
100
+             style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.92400002px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.10855193">x</tspan></text>
101
+        <text
102
+           xml:space="preserve"
103
+           style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:13.18676186px;line-height:1.25;font-family:Inconsolata;-inkscape-font-specification:'Inconsolata, Medium';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;stroke-width:0.82417262"
104
+           x="83.293869"
105
+           y="64.179756"
106
+           id="text4335"
107
+           transform="scale(0.91371456,1.0944337)"><tspan
108
+             sodipodi:role="line"
109
+             id="tspan4333"
110
+             x="83.293869"
111
+             y="64.179756"
112
+             style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:13.18676186px;font-family:Inconsolata;-inkscape-font-specification:'Inconsolata, Medium';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.82417262">…</tspan></text>
113
+        <rect
114
+           style="vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linejoin:round"
115
+           id="rect4337"
116
+           width="2.819777"
117
+           height="2.919831"
118
+           x="71.262665"
119
+           y="67.537613" />
120
+      </g>
121
+      <text
122
+         id="text4269"
123
+         y="91.463326"
124
+         x="71.89093"
125
+         style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:12.04153347px;line-height:1.25;font-family:Inconsolata;-inkscape-font-specification:'Inconsolata, Medium';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke-width:0.30103803"
126
+         xml:space="preserve"><tspan
127
+           style="stroke-width:0.30103803"
128
+           y="91.463326"
129
+           x="71.89093"
130
+           id="tspan4323"
131
+           sodipodi:role="line">$ morf ▂</tspan></text>
132
+    </g>
133
+  </g>
134
+</svg>

+ 134
- 0
notes/morf-logo.svg Ver arquivo

@@ -0,0 +1,134 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+<svg
5
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
6
+   xmlns:cc="http://creativecommons.org/ns#"
7
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
+   xmlns:svg="http://www.w3.org/2000/svg"
9
+   xmlns="http://www.w3.org/2000/svg"
10
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12
+   width="100mm"
13
+   height="100mm"
14
+   viewBox="0 0 100 100"
15
+   version="1.1"
16
+   id="svg8"
17
+   inkscape:version="0.92.4 (unknown)"
18
+   sodipodi:docname="morf-logo.svg"
19
+   inkscape:export-filename="/home/amahdal/bitmap.png"
20
+   inkscape:export-xdpi="36.110001"
21
+   inkscape:export-ydpi="36.110001">
22
+  <defs
23
+     id="defs2" />
24
+  <sodipodi:namedview
25
+     id="base"
26
+     pagecolor="#ffffff"
27
+     bordercolor="#666666"
28
+     borderopacity="1.0"
29
+     inkscape:pageopacity="0.0"
30
+     inkscape:pageshadow="2"
31
+     inkscape:zoom="1.979899"
32
+     inkscape:cx="164.62284"
33
+     inkscape:cy="269.36611"
34
+     inkscape:document-units="mm"
35
+     inkscape:current-layer="g4348"
36
+     inkscape:document-rotation="0"
37
+     showgrid="false"
38
+     fit-margin-top="0"
39
+     fit-margin-left="0"
40
+     fit-margin-right="0"
41
+     fit-margin-bottom="0"
42
+     inkscape:window-width="1920"
43
+     inkscape:window-height="790"
44
+     inkscape:window-x="0"
45
+     inkscape:window-y="640"
46
+     inkscape:window-maximized="0" />
47
+  <metadata
48
+     id="metadata5">
49
+    <rdf:RDF>
50
+      <cc:Work
51
+         rdf:about="">
52
+        <dc:format>image/svg+xml</dc:format>
53
+        <dc:type
54
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
55
+        <dc:title></dc:title>
56
+      </cc:Work>
57
+    </rdf:RDF>
58
+  </metadata>
59
+  <g
60
+     inkscape:label="Layer 1"
61
+     inkscape:groupmode="layer"
62
+     id="layer1"
63
+     transform="translate(-54.294445,-56.026081)">
64
+    <rect
65
+       style="vector-effect:none;fill:none;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linejoin:round"
66
+       id="rect4339"
67
+       width="100"
68
+       height="100"
69
+       x="54.294445"
70
+       y="56.026081" />
71
+    <g
72
+       id="g4360"
73
+       transform="matrix(1.6182467,0,0,1.6182467,-48.428089,-38.5936)">
74
+      <g
75
+         id="g4348">
76
+        <rect
77
+           style="vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.57908547;stroke-linejoin:round"
78
+           id="rect4271"
79
+           width="50"
80
+           height="50"
81
+           x="68.925453"
82
+           y="64.692909" />
83
+        <rect
84
+           style="vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.54776043;stroke-linejoin:round"
85
+           id="rect4325"
86
+           width="47.091389"
87
+           height="5.604784"
88
+           x="70.23336"
89
+           y="66.121056" />
90
+        <text
91
+           xml:space="preserve"
92
+           style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:4.34198856px;line-height:1.25;font-family:Inconsolata;-inkscape-font-specification:'Inconsolata, Medium';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;stroke-width:0.10855193"
93
+           x="113.04676"
94
+           y="70.025864"
95
+           id="text4329"><tspan
96
+             sodipodi:role="line"
97
+             id="tspan4331"
98
+             x="113.04676"
99
+             y="70.025864"
100
+             style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.92400002px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.10855193">x</tspan></text>
101
+        <text
102
+           xml:space="preserve"
103
+           style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:13.18676186px;line-height:1.25;font-family:Inconsolata;-inkscape-font-specification:'Inconsolata, Medium';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;stroke-width:0.82417262"
104
+           x="83.293869"
105
+           y="64.179756"
106
+           id="text4335"
107
+           transform="scale(0.91371456,1.0944337)"><tspan
108
+             sodipodi:role="line"
109
+             id="tspan4333"
110
+             x="83.293869"
111
+             y="64.179756"
112
+             style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:13.18676186px;font-family:Inconsolata;-inkscape-font-specification:'Inconsolata, Medium';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.82417262">…</tspan></text>
113
+        <rect
114
+           style="vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linejoin:round"
115
+           id="rect4337"
116
+           width="2.819777"
117
+           height="2.919831"
118
+           x="71.262665"
119
+           y="67.537613" />
120
+      </g>
121
+      <text
122
+         id="text4269"
123
+         y="105.60374"
124
+         x="71.89093"
125
+         style="font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:12.04153347px;line-height:1.25;font-family:Inconsolata;-inkscape-font-specification:'Inconsolata, Medium';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke-width:0.30103803"
126
+         xml:space="preserve"><tspan
127
+           style="stroke-width:0.30103803"
128
+           y="105.60374"
129
+           x="71.89093"
130
+           id="tspan4323"
131
+           sodipodi:role="line">$ morf ▂</tspan></text>
132
+    </g>
133
+  </g>
134
+</svg>

+ 28
- 0
packaging/template.spec Ver arquivo

@@ -0,0 +1,28 @@
1
+Name:           __MKIT_PROJ_PKGNAME__
2
+Version:        __MKIT_PROJ_VERSION__
3
+Release:        1%{?dist}
4
+Summary:        __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__
5
+URL:            __MKIT_PROJ_VCS_BROWSER__
6
+License:        GPLv2
7
+Source0:        %{name}-%{version}.tar.gz
8
+BuildArch:      noarch
9
+
10
+Requires: bash
11
+%description
12
+This is a dummy package that only contains one dummy command.
13
+
14
+%prep
15
+%setup -q
16
+
17
+%build
18
+make %{?_smp_mflags} PREFIX=/usr
19
+
20
+%install
21
+%make_install PREFIX=/usr
22
+
23
+%files
24
+%{_bindir}/%{name}
25
+
26
+%changelog
27
+
28
+# specfile built with MKit __MKIT_MKIT_VERSION__

+ 3
- 0
src/app.skel Ver arquivo

@@ -0,0 +1,3 @@
1
+#!/bin/bash
2
+
3
+echo "this command does not do anything except printing this text" >&2

+ 66
- 0
utils/bkr_sutagent Ver arquivo

@@ -0,0 +1,66 @@
1
+#!/bin/bash
2
+#shellcheck disable=SC1090
3
+
4
+. "$(sfpath)" || exit 3
5
+
6
+shellfu import pretty
7
+
8
+shellfu import sutagent
9
+
10
+usage() {
11
+    mkusage "" "--help" \
12
+        -- \
13
+        "This is a special-purpose tool to regenerate BeakerLib version of" \
14
+        "SUT installation agent used with 'morf install'."                  \
15
+        ""                                                                  \
16
+        "In order to create a Beaker task to use SUT agent, call this tool" \
17
+        "without any arguments and save the contents as an executable along"\
18
+        "the task.  In runtest.sh, start a phase and call the executable as"\
19
+        "described in documentation of sutagent__install() function (access"\
20
+        "that by calling 'sfdoc sutagent')."                                \
21
+        ""                                                                  \
22
+        "One such task is /distribution/upgrade/install-sut."
23
+}
24
+
25
+mkagent() {
26
+    #
27
+    # Create agent script
28
+    #
29
+    mkfunc
30
+    echo '. /usr/bin/rhts-environment.sh || exit 1'
31
+    echo '. /usr/share/beakerlib/beakerlib.sh || exit 1'
32
+    echo 'sutagent__install "$@"'
33
+}
34
+
35
+mkfunc() {
36
+    #
37
+    # Create agent script declarations
38
+    #
39
+    local raw
40
+    raw=$(mktemp -t bkr_sutagent.XXXXXXXX)
41
+    #shellcheck disable=SC2016
42
+    {
43
+        echo '#!/bin/bash'
44
+        echo ''
45
+        echo '. "$(sfpath)" || exit 3'
46
+        echo ''
47
+        echo 'PRETTY=beakerlib'
48
+        echo 'PRETTY_VERBOSE=true'
49
+        echo 'PRETTY_DEBUG=true'
50
+        echo ''
51
+        echo 'shellfu import sutagent'
52
+    } > "$raw"
53
+    chmod +x "$raw"
54
+    sfembed "$raw"
55
+    rm "$raw"
56
+}
57
+
58
+main() {
59
+    while true; do case $1 in
60
+        "")  break ;;
61
+        -*)  usage ;;
62
+    esac done
63
+    mkagent
64
+}
65
+
66
+main "$@"

+ 290
- 0
utils/mkit/include/build.sh Ver arquivo

@@ -0,0 +1,290 @@
1
+#!/bin/bash
2
+# MKit - simple install helper
3
+# See LICENSE file for copyright and license details.
4
+
5
+mkit_import ini
6
+mkit_import facts
7
+
8
+
9
+__build1() {
10
+    #
11
+    # Process one skeleton $1 of type $3 (or guessed) to path $2
12
+    #
13
+    local srcpath=$1    # skeleton path
14
+    local dstpath=$2    # destination meaty animal path
15
+    local ftype=$3      # file/builder type
16
+    test -n "$dstpath"  || dstpath=${srcpath%.skel}
17
+    test -n "$ftype"    || ftype=$(__guess_ftype "$dstpath")
18
+    debug_var srcpath dstpath ftype
19
+    <"$srcpath" __build1_ftype "$ftype" >"$dstpath"
20
+    __rec_built "$dstpath"
21
+}
22
+
23
+__build1_ftype() {
24
+    #
25
+    # Build a file of type $1; fom stdin to stdout
26
+    #
27
+    local ftype=$1      # file/builder type
28
+    case $ftype in
29
+        MKIT_COMMON)    __expand_macros "macros" ;;
30
+        rpmstuff)       __expand_macros "macros" "rpmstuff:macros" ;;
31
+        debstuff)       __expand_macros "macros" "debstuff:macros" ;;
32
+        *)              die "unknown file type: $ftype" ;;
33
+    esac
34
+}
35
+
36
+__expand_line() {
37
+    #
38
+    # Expand macro from $MacroMap in single line $1
39
+    #
40
+    # If macro value has multiple lines, repeat original line with
41
+    # different substitution.
42
+    #
43
+    # E.g. if macro value is "foo\nbar" and macro name is __FOO__,
44
+    # line `see: "__FOO__"` will expand to two lines: `see: "foo"`
45
+    # and `see: "bar"`.
46
+    #
47
+    local line=$1   # line to process
48
+    local mname     # macro name
49
+    local mvline    # line of macro value
50
+    local xline     # expanded line
51
+    xline=$line
52
+    for mname in "${!MacroMap[@]}"; do
53
+        if ! test "${line//$mname}" == "$line"; then
54
+            xline=$(
55
+                while IFS= read -r mvline; do
56
+                    echo "${line//$mname/$mvline}"
57
+                done <<<"${MacroMap[$mname]}"
58
+            )
59
+        fi
60
+        line=$xline
61
+    done
62
+    echo "$xline"
63
+    return 1
64
+}
65
+
66
+__expand_macros() {
67
+    #
68
+    # Read stdin, expanding macros from sections $@
69
+    #
70
+    local section       # each section to expand macros from
71
+    local line          # each line on stdin
72
+    local mname         # each macro name
73
+    local -A MacroMap   # macro value map
74
+    MacroMap[__MKIT_MKIT_VERSION__]=$MKIT_VERSION
75
+    MacroMap[__MKIT_PROJ_NAME__]=$(ini 1value project:name)
76
+    MacroMap[__MKIT_PROJ_CODENAME__]=$(ini 1value project:codename)
77
+    MacroMap[__MKIT_PROJ_LICENSE__]=$(ini 1value project:license)
78
+    MacroMap[__MKIT_PROJ_PKGNAME__]=$(ini 1value project:pkgname)
79
+    MacroMap[__MKIT_PROJ_TAGLINE__]=$(ini 1value project:tagline)
80
+    MacroMap[__MKIT_PROJ_MAINTAINER__]=$(ini 1value project:maintainer)
81
+    MacroMap[__MKIT_PROJ_VCS_BROWSER__]=$(ini 1value project:vcs_browser)
82
+    MacroMap[__MKIT_PROJ_GIT_LASTHASH__]=$(__cached git_lasthash)
83
+    MacroMap[__MKIT_PROJ_VERSION__]=$(__cached semver)
84
+    for section in "$@"; do
85
+        for mname in $(ini lskeys "$section"); do
86
+            MacroMap[$mname]=$(ini values "$section:$mname")
87
+        done
88
+    done
89
+    debug_var MacroMap
90
+    while IFS= read -r line; do
91
+        __expand_line "$line"
92
+    done
93
+}
94
+
95
+__guess_ftype() {
96
+    #
97
+    # Guess file type from destination path $1
98
+    #
99
+    local dstpath=$1    # destination path
100
+    case $dstpath in
101
+        *)    echo MKIT_COMMON ;;
102
+    esac
103
+}
104
+
105
+__qfs() {
106
+    #
107
+    # Quote for our sed scipt's RHS
108
+    #
109
+    sed '
110
+        s:\\:\\\\:g
111
+        s:|:\\|:g
112
+    '
113
+}
114
+
115
+__cached() {
116
+    #
117
+    # Cached value $1 of function $1()
118
+    #
119
+    # In order to support git-less builds, some values might be cached
120
+    # in $MKIT_LOCAL.  This function gets file $1 from that cache (cache
121
+    # hit) or re-creates it (cache miss), but prints its body in either
122
+    # case.
123
+    #
124
+    # The command to re-create file is the same as the key (ie. no
125
+    # arguments).
126
+    #
127
+    local name=$1
128
+    __local_get "$name" && return 0
129
+    "$name" | __local_putb "$name"
130
+    __local_get "$name"
131
+}
132
+
133
+__local_putb() {
134
+    #
135
+    # Make file $1 in $MKIT_LOCAL from stdin and mark as built
136
+    #
137
+    local fpath=$1
138
+    __local_put "$fpath" && __rec_built "$MKIT_LOCAL/$fpath"
139
+}
140
+
141
+__local_put() {
142
+    #
143
+    # Make file $1 in $MKIT_LOCAL from stdin
144
+    #
145
+    local fpath="$MKIT_LOCAL/$1"
146
+    { mkdir -p "${fpath%/*}" && cat >"$fpath"; } \
147
+     || die "cannot write to local cache: $fpath"
148
+}
149
+
150
+__local_get() {
151
+    #
152
+    # Read file $1 in $MKIT_LOCAL
153
+    #
154
+    local fpath="$MKIT_LOCAL/$1"
155
+    cat "$fpath" 2>/dev/null
156
+}
157
+
158
+__rec_built() {
159
+    #
160
+    # Record file $1 for deletion on `clean`
161
+    #
162
+    local file=$1
163
+    mkdir -p "$MKIT_LOCAL"
164
+    echo "$file" >> "$MKIT_LOCAL/built.lst"
165
+}
166
+
167
+_mkit_data() {
168
+    #
169
+    # Build sampler showing all macro values
170
+    #
171
+    local macro
172
+    local section
173
+    local sections
174
+    sections=()
175
+    ini lskeys macros | grep -q . && sections=(macros)
176
+    sections+=( $(ini lssect | grep ':macros$') )
177
+    {
178
+        echo "(builtin):"
179
+        echo "  x_MKIT_MKIT_VERSION__ => '__MKIT_MKIT_VERSION__'"
180
+        echo "  x_MKIT_PROJ_NAME__ => '__MKIT_PROJ_NAME__'"
181
+        echo "  x_MKIT_PROJ_CODENAME__ => '__MKIT_PROJ_CODENAME__'"
182
+        echo "  x_MKIT_PROJ_LICENSE__ => '__MKIT_PROJ_LICENSE__'"
183
+        echo "  x_MKIT_PROJ_PKGNAME__ => '__MKIT_PROJ_PKGNAME__'"
184
+        echo "  x_MKIT_PROJ_TAGLINE__ => '__MKIT_PROJ_TAGLINE__'"
185
+        echo "  x_MKIT_PROJ_MAINTAINER__ => '__MKIT_PROJ_MAINTAINER__'"
186
+        echo "  x_MKIT_PROJ_VCS_BROWSER__ => '__MKIT_PROJ_VCS_BROWSER__'"
187
+        echo "  x_MKIT_PROJ_GIT_LASTHASH__ => '__MKIT_PROJ_GIT_LASTHASH__'"
188
+        echo "  x_MKIT_PROJ_VERSION__ => '__MKIT_PROJ_VERSION__'"
189
+        for section in "${sections[@]}"; do
190
+            echo "$section:"
191
+            for macro in $(ini lskeys "$section"); do
192
+                echo "  x${macro:1} => '$macro'"
193
+            done
194
+        done
195
+    } \
196
+      | __expand_macros "MKIT_BUILTIN" "${sections[@]}" \
197
+      | sed '/^  x/ s|x|_|'
198
+}
199
+
200
+build() {
201
+    #
202
+    # Add meat to all skeletons
203
+    #
204
+    local srcpath   # each source path
205
+    find . -type f -name '*.skel' \
206
+     | while read -r srcpath; do
207
+           __build1 "$srcpath"
208
+       done
209
+}
210
+
211
+clean() {
212
+    #
213
+    # Clean up tree after building
214
+    #
215
+    test -f "$MKIT_LOCAL/built.lst" && {
216
+        <"$MKIT_LOCAL/built.lst" grep -v -e '\.\.' -e ^/ \
217
+          | xargs -r rm -rf
218
+        rm -f "$MKIT_LOCAL/built.lst"
219
+        rmdir --ignore-fail-on-non-empty "$MKIT_LOCAL"
220
+    }
221
+    true
222
+}
223
+
224
+debstuff() {
225
+    #
226
+    # Build Debian stuff (eamed tarball, debian dir)
227
+    #
228
+    local version       # package version
229
+    local debian_skel   # 'debian' folder skeleton
230
+    local dfsrc         # each source file from ^^
231
+    local dftgt         # each built packaging file
232
+    version=$(__cached semver)
233
+
234
+    # tarball - we should already have by means of 'dist'
235
+    #
236
+    mv "${MKIT_PROJ_PKGNAME}-$version.tar.gz" \
237
+       "${MKIT_PROJ_PKGNAME}_$version.orig.tar.gz" \
238
+     || die "could not rename tarball"
239
+    __rec_built "${MKIT_PROJ_PKGNAME}_$version.orig.tar.gz"
240
+
241
+    # read content of each mandatory file from debian_skel
242
+    #
243
+    debian_skel=$(ini 1value dist:debstuff)
244
+    test -n "$debian_skel" || die "dist:debstuff not specified"
245
+    test -d "$debian_skel" || die "debian directory template found: $debian_skel"
246
+    mkdir -p debian/source
247
+    find "$debian_skel" -type f \
248
+      | while read -r dfsrc; do
249
+            dftgt="debian/${dfsrc#$debian_skel}"
250
+            mkdir -p "$(dirname "$dftgt")"
251
+            __build1 "$dfsrc" "$dftgt" debstuff
252
+        done
253
+    __rec_built debian
254
+}
255
+
256
+dist() {
257
+    #
258
+    # Create distributable tarball
259
+    #
260
+    #FIXME: lacking Makefile skills, we do this step twice for
261
+    #       rpmstuff, hence -f hack for gzip
262
+    #
263
+    local version           # tarball version
264
+    local git_lasthash      # last git commit hash
265
+    local dirname           # directory and tarball name
266
+    version=$(semver)
267
+    dirname=$MKIT_PROJ_PKGNAME-$version
268
+    git_lasthash=$(git_lasthash)
269
+    mkdir -p "$dirname"
270
+    ini values "dist:tarball" | xargs -I DIST_ITEM cp -R DIST_ITEM "$dirname"
271
+    mkdir -p "$dirname/.mkit"
272
+    echo -n "$version" > "$dirname/.mkit/semver"
273
+    echo -n "$git_lasthash" > "$dirname/.mkit/git_lasthash"
274
+    tar -cf "$dirname.tar" "$dirname"
275
+    gzip -f "$dirname.tar"      # see above FIXME
276
+    __rec_built "$dirname.tar.gz"
277
+    rm -rf "$dirname"
278
+}
279
+
280
+rpmstuff() {
281
+    #
282
+    # Build specfile
283
+    #
284
+    local specname=$MKIT_PROJ_PKGNAME.spec      # .spec filename
285
+    local specsrc                               # source of specfile
286
+    specsrc="$(ini 1value "dist:rpmstuff")"
287
+    test -n "$specsrc" || die "dist:rpmstuff not specified"
288
+    test -f "$specsrc" || die "specfile template not found: $specsrc"
289
+    __build1 "$specsrc" "$specname" rpmstuff
290
+}

+ 130
- 0
utils/mkit/include/deploy.sh Ver arquivo

@@ -0,0 +1,130 @@
1
+#!/bin/bash
2
+# MKit - simple install helper
3
+# See LICENSE file for copyright and license details.
4
+
5
+mkit_import ini
6
+
7
+__deploy_item() {
8
+    #
9
+    # Deploy item and make it look like wanted
10
+    #
11
+    # usage: __deploy_item src dst [mode]
12
+    #
13
+    # Both src and dst must be names of actual items[1],
14
+    # whereas dst must not exist.  On update, dst is
15
+    # usually to be replaced but that is uninstall's
16
+    # job!
17
+    #
18
+    #  [1] Ie. src=foo and dst=/foo/bar does *always*
19
+    #      mean that foo will become 'bar'.  This is
20
+    #      different than traditional `cp` behavior,
21
+    #      when this depends if 'bar' already exists
22
+    #      as a directory.
23
+    #
24
+    # If mode is omitted or empty, MKIT_DEFAULT_MODE is
25
+    # used instead.
26
+    #
27
+    # Directories are copied recursively, and mode is
28
+    # applied only to files.
29
+    #
30
+    local src=$1                            # source path
31
+    local dst=$2                            # destination path
32
+    local mode=${3:-$MKIT_DEFAULT_MODE}     # mode
33
+    local item                              # each in directory
34
+    if test -d "$src"; then
35
+        find "$src" -type f \
36
+          | while read -r item; do
37
+                [[ $item =~ .skel$ ]] \
38
+                 && grep -qe "${item%.skel}" "$MKIT_LOCAL/built.lst" \
39
+                 && continue
40
+                __deploy_item "$item" "$dst${item#$src}" "$mode"
41
+            done
42
+    else
43
+        test "$mode" == "SRC" && mode=$(stat -c "%a" "$src")
44
+        __maybe install -DTvm "$mode" "$src" "$dst"
45
+    fi
46
+}
47
+
48
+__get_dst() {
49
+    #
50
+    # Find out target path for src file $2 of group $1
51
+    #
52
+    local grp=$1        # deploy group
53
+    local src=$2        # each source
54
+    local dst=$3        # alternative destination name
55
+    test -n "$dst" || dst=${src##*/}
56
+    echo "$(__get_root "$grp")/$dst"
57
+}
58
+
59
+__get_root() {
60
+    #
61
+    # Find out target root for group $1
62
+    #
63
+    local grp=$1        # deploy group
64
+    local root          # root for this group
65
+    local destdir       # value of DESTDIR
66
+    root=$(ini 1value "roots:$grp")
67
+    destdir=$(ini 1value ENV:DESTDIR)
68
+    destdir=${destdir%/}
69
+    case $destdir:$root in
70
+        *:)     die "missing in config.ini: roots:$grp" ;;
71
+        :*)     echo "$root" ;;
72
+        *:*)    echo "$destdir/$root" ;;
73
+    esac
74
+}
75
+
76
+__maybe() {
77
+    #
78
+    # Call the deploy command $1 $@ unless in dry mode
79
+    #
80
+    debug "$@"
81
+    local cmd="$1"; shift
82
+    $MKIT_DRY && return
83
+    case "$cmd" in
84
+        cp|rm|rmdir|chmod|mkdir) $cmd "$@" ;;
85
+        install)                 command -p install "$@" ;;
86
+        *)                       die "bad command called";;
87
+    esac
88
+}
89
+
90
+install() {
91
+    #
92
+    # Install product
93
+    #
94
+    local group     # each deploy group
95
+    local mode      # mode (group-specific)
96
+    local src       # each source path
97
+    local dst       # each (final absolute) destination path
98
+    ini lskeys "files" \
99
+      | sort \
100
+      | uniq \
101
+      | while read -r group; do
102
+            mode=$(ini 1value "modes:$group")
103
+            ini values "files:$group" \
104
+              | while read -r src dst; do
105
+                    dst=$(__get_dst "$group" "$src" "$dst")
106
+                    __deploy_item "$src" "$dst" "$mode"
107
+                done
108
+        done
109
+    test -f "$MKIT_LOCAL/autoclean" && clean
110
+    true
111
+}
112
+
113
+uninstall() {
114
+    #
115
+    # Uninstall product
116
+    #
117
+    local group     # each deploy group
118
+    local src       # each source path
119
+    local dst       # each (final absolute) destination path
120
+    ini lskeys "files" \
121
+      | sort \
122
+      | uniq \
123
+      | while read -r group; do
124
+            ini values "files:$group" \
125
+              | while read -r src dst; do
126
+                    dst=$(__get_dst "$group" "$src" "$dst")
127
+                    __maybe rm -vrf "$dst"
128
+                done
129
+        done
130
+}

+ 191
- 0
utils/mkit/include/facts.sh Ver arquivo

@@ -0,0 +1,191 @@
1
+#!/bin/bash
2
+# MKit - simple install helper
3
+# See LICENSE file for copyright and license details.
4
+
5
+mkit_import ini
6
+
7
+git_bool() {
8
+    #
9
+    # Get git bool (ie. exit status counts) $1
10
+    #
11
+    local bool_name=$1      # name of boolean to get
12
+    git_present || warn "can't give bool outside git repo: $bool_name"
13
+    case "$bool_name" in
14
+        dirty_files)
15
+            git diff-files | grep -qm 1 .
16
+            ;;
17
+        dirty_index)
18
+            git diff-index HEAD | grep -qm 1 .
19
+            ;;
20
+        dirty)
21
+            git_bool dirty_files || git_bool dirty_index
22
+            ;;
23
+        *)
24
+            warn "unknown git bool asked: $bool_name"
25
+            return 2
26
+            ;;
27
+    esac
28
+}
29
+
30
+git_fact() {
31
+    #
32
+    # Get git fact $1
33
+    #
34
+    local fact_name=$1      # name of fact to get
35
+    git_present || warn "can't give fact outside git repo: $fact_name"
36
+    case "$fact_name" in
37
+        latest_tag)
38
+            git log --format="%d" \
39
+              | sed 's/,/\n/g' \
40
+              | sed 's/^[[:blank:]]*//' \
41
+              | grep -E '^\(?tag' \
42
+              | tr -cd '[[:digit:]].v\n' \
43
+              | grep . -m 1
44
+            ;;
45
+        latest_version)
46
+            git_fact latest_tag | git_tag2ver
47
+            ;;
48
+        current_branch)
49
+            git rev-parse --abbrev-ref HEAD
50
+            ;;
51
+        reldiff)
52
+            git log --oneline "$(git_fact latest_tag)..HEAD" --name-only
53
+            ;;
54
+        latest_sha)
55
+            git log -1 --pretty=format:%h HEAD
56
+            ;;
57
+        latest_cdate)
58
+            git log -1 --format=%ct HEAD
59
+            ;;
60
+        *)
61
+            warn "unknown git fact asked: $fact_name"
62
+            ;;
63
+    esac
64
+}
65
+
66
+git_present() {
67
+    #
68
+    # True if we're in a git repo
69
+    #
70
+    git rev-parse HEAD >&/dev/null
71
+}
72
+
73
+git_tag2ver() {
74
+    #
75
+    # Convert tag to version
76
+    #
77
+    sed s/^v//
78
+}
79
+
80
+git_ver2tag() {
81
+    #
82
+    # Convert version to tag
83
+    #
84
+    sed s/^/v/
85
+}
86
+
87
+git_lasthash() {
88
+    #
89
+    # Show last commit hash (with .dirty suffix if needed)
90
+    #
91
+    # We can't do it outside git repo (or without git) but we should
92
+    # not be asked to; targets that don't require git should make use
93
+    # of cache built by dist target.
94
+    #
95
+    local last_hash     # last commit hash
96
+    git_present || {
97
+        echo UNKNOWN_HASH
98
+        warn "no git present; could not determine last hash"
99
+        return 3
100
+    }
101
+    last_hash=$(git rev-parse HEAD)
102
+    echo -n "$last_hash"
103
+    git_bool dirty && echo -n ".dirty"
104
+}
105
+
106
+semver() {
107
+    #
108
+    # Build proper SemVer version string
109
+    #
110
+    # Build version string from available info using following
111
+    # logic:
112
+    #
113
+    #  1. Use version from last git tag (or mkit.ini if there is no
114
+    #     tag, which is possible on new project)
115
+    #  2. if set, add project:prerl (from mkit.ini) as pre-release ID
116
+    #     (afer dash)
117
+    #  3. if we are at a later commit than the last tag, add branch
118
+    #     name and commit sha1 to build metadata (after plus sign)
119
+    #  4. if the tree is "dirty", i.e. has uncommited changes,
120
+    #     add "dirty" to build metadata
121
+    #
122
+    # The version is compatible with SemVer 2.0.0.
123
+    #
124
+    # Examples:
125
+    #
126
+    #     foo v1.0.7                            # all clear; proper release
127
+    #     foo v1.0.7-beta                       # mkit.ini: project:prerl="beta"
128
+    #     foo v1.0.7-beta+g1aef811.master       # ^^ + some commits after
129
+    #     foo v1.0.7-beta+gf14fc4f.api2         # ^^ + on a feature branch
130
+    #     foo v1.0.7-beta+gf14fc4f.api2.dirty   # ^^ + tree edited
131
+    #     foo v1.0.7-beta+dirty                 # tag OK but tree edited
132
+    #     foo v1.0.7+dirty                      # ^^ but no pre-release id
133
+    #
134
+    # Note that versions with "dirty" should be perceived as kind of
135
+    # dangerous outside developer's own machine.  Versions with sha1 are
136
+    # safer but must not be released.
137
+    #
138
+    # FIXME:  Using project:prerl for release IDs may not be compatible with
139
+    #         release strategy implemented in release.sh
140
+    #
141
+    local xyz           # base version string
142
+    local prerl         # pre-release keyword (from mkit.ini, eg. 'beta')
143
+    local latest_tag    # latest git tag
144
+    local brname        # current branch name
145
+    local ghash         # current commit short hash
146
+    local is_tagged=T   # T if tagged (clean, no metadata), F if devel
147
+    local is_dirty=F    # F if dirty, T if clean
148
+    local stamp         # timestamp or nothing (see $MKIT_TSTAMP)
149
+    local suffix        # version suffix
150
+    prerl=$(ini 1value project:prerl)
151
+    case $MKIT_TSTAMP in
152
+        none)   stamp= ;;
153
+        btime)  stamp=$(date -u +%Y%m%d%H%M%S) ;;
154
+        ctime)  stamp=$(date -d @"$(git_fact latest_cdate)" -u +%Y%m%d%H%M%S) ;;
155
+    esac
156
+    grep ":" <<<"$prerl" \
157
+     && warn "colon in project:prerl may corrupt version data: $prerl"
158
+    git_present || {
159
+        echo UNKNOWN_VERSION
160
+        warn "no git present; could not determine SemVer"
161
+        return 3
162
+    }
163
+    latest_tag=$(git_fact latest_tag)
164
+    case $latest_tag in
165
+        v*) xyz=${latest_tag:1} ;;
166
+        "") warn "no tags, using base version from mkit.ini (ok for new project)"
167
+            xyz=$(ini 1value project:version) ;;
168
+        *)  warn "bad form of last tag, using base version from mkit.ini: tag is '$latest_tag'"
169
+            xyz=$(ini 1value project:version) ;;
170
+    esac
171
+    if ! git describe --tags --exact-match HEAD >&/dev/null;
172
+    then    # we are at a later commit than the last tag
173
+        is_tagged=F
174
+        brname=$(git_fact current_branch)
175
+        ghash=$(git_fact latest_sha)
176
+    fi
177
+    git_bool dirty && is_dirty=T
178
+    case "$is_dirty:$is_tagged:$stamp" in
179
+        F:T:*)  suffix=""                                 ;;
180
+        T:T:)   suffix="+dirty"                           ;;
181
+        T:T:*)  suffix="+t$stamp.dirty"                   ;;
182
+        F:F:)   suffix="+$brname.g$ghash"                 ;;
183
+        F:F:*)  suffix="+t$stamp.$brname.g$ghash"         ;;
184
+        T:F:)   suffix="+$brname.g$ghash.dirty"           ;;
185
+        T:F:*)  suffix="+t$stamp.$brname.g$ghash.dirty"   ;;
186
+        *)      suffix=MKIT_BUG
187
+                warn "MKIT_BUG: bad dirt/commit detection" ;;
188
+    esac
189
+    test -n "$prerl" && suffix="-$prerl$suffix"
190
+    echo "$xyz$suffix"
191
+}

+ 215
- 0
utils/mkit/include/ini.sh Ver arquivo

@@ -0,0 +1,215 @@
1
+#!/bin/bash
2
+# MKit - simple install helper
3
+# See LICENSE file for copyright and license details.
4
+
5
+__ini_cat() {
6
+    #
7
+    # A no-op for text stream
8
+    #
9
+    local line      # each line
10
+    while read -r line; do
11
+        printf -- '%s\n' "$line"
12
+    done
13
+}
14
+
15
+__ini_expand() {
16
+    #
17
+    # Expand reference value (prefix only)
18
+    #
19
+    local line      # each input line
20
+    while read -r line; do                  # [foo:bar]/path
21
+        __ini_expandln "$line"
22
+    done
23
+}
24
+
25
+__ini_expandln() {
26
+    #
27
+    # Fully expand references in line $1
28
+    #
29
+    local line_orig=$1          # original line
30
+    local line_todo=$line_orig  # current state
31
+    local line_done             # next state
32
+    local Depth=0               # current depth
33
+    local MaxDepth=10           # maximum depth
34
+    while true; do
35
+        ((Depth++))
36
+        debug_var line_todo
37
+        test "$Depth" -le "$MaxDepth" || {
38
+            warn "expansion error: reached maximum depth: $Depth > $MaxDepth"
39
+            warn "    original line: $line_orig"
40
+            warn "    expanded line: $line_todo"
41
+            return 3
42
+        }
43
+        line_done=$(__ini_expandln_once "$line_todo")
44
+        debug_var line_done
45
+        test "$line_done" == "$line_todo" && break
46
+        line_todo=$line_done
47
+    done
48
+    echo "$line_done"
49
+}
50
+
51
+__ini_expandln_once() {
52
+    #
53
+    # Run through line $1 once and replace all references
54
+    #
55
+    local line=$1   # line to expand
56
+    local ref       # full reference (incl. brackets)
57
+    local ipath     # just ini path from ^^ (stripped brackets)
58
+    local value     # value of reference
59
+    local refs=()   # all references found in line
60
+    mapfile -t refs <<<"$(grep -Eo '[[][^]]+[]]' <<< "$line_todo")"
61
+    debug_var refs
62
+    for ref in "${refs[@]}"; do
63
+        test -n "$ref" || continue
64
+        ipath=${ref#[}; ipath=${ipath%]}
65
+        value=$(ini 1value "$ipath")
66
+        debug_var line ref ipath value
67
+        line=$(sed "s|\\[$ipath\\]|$value|" <<<"$line")
68
+    done
69
+    echo "$line"
70
+}
71
+
72
+__ini_grepcmt() {
73
+    #
74
+    # Remove comments from INI file on stdin
75
+    #
76
+    grep -v '^[[:space:]]*#'
77
+}
78
+
79
+__ini_grepkey() {
80
+    #
81
+    # Read key from a section
82
+    #
83
+    local wnt=$1    # wanted key
84
+    grep '.' \
85
+      | sed -e 's/ *= */=/; s/ +$//; s/^//;' \
86
+      | grep -e "^$wnt=" \
87
+      | cut -d= -f2- \
88
+      | __ini_maybe_expand
89
+}
90
+
91
+__ini_greppath() {
92
+    #
93
+    # Read key from the right section
94
+    #
95
+    # E.g. `files:share:my/lib.sh` should read
96
+    #
97
+    #     [files:share]
98
+    #         my/lib.sh   = proj/my/lib.sh
99
+    #
100
+    local wnt=$1                    # wanted path
101
+    local wntkey=${wnt##*:}         # ^^ key part
102
+    local wntsec=${wnt%:$wntkey}    # ^^ section part
103
+    local override                  # ENV override (only ENV section)
104
+    if test "$wntsec" = 'ENV'; then
105
+        override=${!wntkey}
106
+        test -n "$override" \
107
+         && echo "$override" \
108
+         && return
109
+    fi
110
+    __ini_grepsec "$wntsec" | __ini_grepkey "$wntkey"
111
+}
112
+
113
+__ini_grepsec() {
114
+    #
115
+    # Read one INI section
116
+    #
117
+    local wnt=$1        # wanted section name
118
+    local ok=false      # are we in the section?
119
+    local line          # each input line
120
+    grep '.' \
121
+      | while read -r line; do
122
+            case "$line" in
123
+                \[$wnt\]) ok=true;  continue ;;
124
+                \[*\])    ok=false; continue ;;
125
+            esac
126
+            $ok || continue
127
+            printf -- '%s\n' "$line"
128
+        done \
129
+      | sed -e 's/ *= */=/; s/ +$//; s/^//;'
130
+}
131
+
132
+__ini_lskeys() {
133
+    #
134
+    # List keys from a section
135
+    #
136
+    local sct=$1    # section of interest
137
+    __ini_grepsec "$sct" | cut -d= -f1 | awk '!x[$0]++'
138
+}
139
+
140
+__ini_lssect() {
141
+    #
142
+    # List all section names
143
+    #
144
+    grep -x '\[.*\]' | sed 's/^.//; s/.$//'
145
+}
146
+
147
+__ini_maybe_expand() {
148
+    #
149
+    # Decide whether or not to expand
150
+    #
151
+    if test "$MKIT_INI_EXPAND" -gt 0; then
152
+        MKIT_INI_EXPAND=$(( --MKIT_INI_EXPAND )) __ini_expand
153
+    else
154
+        __ini_cat
155
+    fi
156
+}
157
+
158
+__ini_body() {
159
+    #
160
+    # Produce mkit.ini body including INCLUDE
161
+    #
162
+    # Note: recursive includes are not supported.
163
+    #
164
+    local inc                       # file to include
165
+    local incre='\[INCLUDE:.*\]'    # include directive regex
166
+    local iline                     # include directive line
167
+    if iline=$(grep -m1 -xe "$incre" "$MKIT_INI"); then
168
+        inc=${iline#*:}; inc=${inc%]}
169
+        grep -vxe "$incre" "$inc"
170
+        grep -vxe "$incre" "$MKIT_INI"
171
+    else
172
+        cat "$MKIT_INI"
173
+    fi | __ini_grepcmt
174
+}
175
+
176
+ini() {
177
+    #
178
+    # do ini operation
179
+    #
180
+    local op=$1             # operator
181
+    local arg=$2            # argument
182
+    local fn                # internal function implementing $op
183
+    local limit=__ini_cat    # limiting internal function
184
+    case $op in
185
+        lskeys) fn=__ini_lskeys   ;;
186
+        lssect) fn=__ini_lssect   ;;
187
+        sec)    fn=__ini_grepsec  ;;
188
+        values) fn=__ini_greppath ;;
189
+        1value) fn=__ini_greppath; limit="tail -1" ;;
190
+        *)      die "incorrect use of \`ini()\`"
191
+    esac
192
+    __ini_body | $fn "$arg" | $limit
193
+}
194
+
195
+update_version() {
196
+    #
197
+    # Change project:version in mkit.ini at path $2 to value $1
198
+    #
199
+    local version=$1    # new version
200
+    local inifile=$2    # mkit.ini path
201
+    local tmp           # mkit.ini cache
202
+    tmp=$(mktemp -t mkit.update_version.XXXXXXXX)
203
+    <"$inifile" perl -e '
204
+        my $hit = 0;
205
+        my $done = 0;
206
+        foreach (<STDIN>) {
207
+            if      ($done) { print; next; }
208
+            elsif   (m/\[project\]/) { $hit++; print; next; }
209
+            elsif   (m/\[/) { $hit = 0; print; next; }
210
+            elsif   ($hit) { s/\bversion\b( *)=( *).*/version$1=$2$ARGV[0]/ and $done++; print; }
211
+            else { print; next; }
212
+        }
213
+    ' "$version" >"$tmp" || die "failed to update version in mkit.ini"
214
+    mv "$tmp" "$inifile"
215
+}

+ 162
- 0
utils/mkit/include/mkit.sh Ver arquivo

@@ -0,0 +1,162 @@
1
+#!/bin/bash
2
+# MKit - simple install helper
3
+# See LICENSE file for copyright and license details.
4
+
5
+die() {
6
+    #
7
+    # Exit with message and non-zero exit status
8
+    #
9
+    echo "fatal: $*" >&2
10
+    exit 4
11
+}
12
+
13
+mkit_import() {
14
+    #
15
+    # Import mkit module $1.sh
16
+    #
17
+    # Check for module, source it and die with reasonable message if needed.
18
+    #
19
+    local modname=$1
20
+    local modpath
21
+    modpath="$MKIT_DIR/include/$modname.sh"
22
+    test -f "$modpath" || die "no such module: $modpath"
23
+    bash -n "$modpath" || die "bad syntax: $modpath"
24
+    #shellcheck disable=SC1090
25
+    . "$modpath" || die "failed to import: $modname"
26
+}
27
+
28
+mkit_import build
29
+mkit_import deploy
30
+mkit_import release
31
+mkit_import ini
32
+
33
+__valid_targets() {
34
+    #
35
+    # List valid routes
36
+    #
37
+    echo _mkit_data
38
+    echo build
39
+    echo clean
40
+    echo debstuff
41
+    echo dist
42
+    echo install
43
+    echo release
44
+    echo release_x
45
+    echo release_y
46
+    echo release_z
47
+    echo rpmstuff
48
+    echo uninstall
49
+    echo vbump
50
+    echo vbump_x
51
+    echo vbump_y
52
+    echo vbump_z
53
+}
54
+
55
+debug() {
56
+    #
57
+    # Print debug message
58
+    #
59
+    $MKIT_DEBUG || return 0
60
+    echo "MKIT_DEBUG: ${FUNCNAME[1]}()" "$@" >&2
61
+}
62
+
63
+debug_var() {
64
+    #
65
+    # Print debug message
66
+    #
67
+    $MKIT_DEBUG || return 0
68
+    local __mkit_debug_var_name__       # variable name to debug
69
+    local decl                          # declare string
70
+    for __mkit_debug_var_name__ in "$@"; do
71
+        {
72
+            decl=$(declare -p "$__mkit_debug_var_name__")
73
+            decl=${decl#declare ?? }
74
+            echo "MKIT_DEBUG: ${FUNCNAME[1]}(): $decl"
75
+        } >&2
76
+    done
77
+}
78
+
79
+__compver() {
80
+    #
81
+    # True if version $1 matches our version
82
+    #
83
+    # If our x is 0, check first two fragments, otherwise check just
84
+    # the x.  Fragments must equal.
85
+    #
86
+    local their_ver=$1      # their version
87
+    local our_x             # our X
88
+    local our_y             # our Y
89
+    local their_x           # their X
90
+    local their_y           # their Y
91
+    their_x=${their_ver%%.*}
92
+    their_y=${their_ver##$their_x.}
93
+    their_y=${their_y%%.*}
94
+    our_x=${MKIT_VERSION%%.*}
95
+    our_y=${MKIT_VERSION##$our_x.}
96
+    our_y=${our_y%%.*}
97
+    debug_var MKIT_VERSION our_x our_y their_ver their_x their_y
98
+    test "$their_x" -eq "$our_x" || return 1
99
+    test "$our_x" -eq 0 && {
100
+        test "$their_y" = "$our_y"
101
+        return $?
102
+    }
103
+    return 0
104
+}
105
+
106
+__chkiniversion() {
107
+    #
108
+    # Check if ini version is supported
109
+    #
110
+    # Look for "#mkit version=0.0.0" or similar in first or last
111
+    # 3 lines of the file; then check if the version is supported.
112
+    #
113
+    local ver_line      # line declaring version
114
+    local their_ver     # the declared version
115
+    ver_line=$(
116
+        {
117
+            head -3 "$MKIT_INI"
118
+            tail -3 "$MKIT_INI"
119
+        } | grep -m 1 -E '^# *mkit +version *= *v?[0-9]+\.[0-9]+\.[0-9]+'
120
+    )
121
+    test -n "$ver_line" \
122
+     || die "version mark ('#mkit version=x.y.z') not found in: $MKIT_INI"
123
+    their_ver="$(tr -d '[:blank:]v' <<<"${ver_line##*=}")"
124
+    __compver "$their_ver" \
125
+     || die "bad mkit.ini version: $their_ver does not match $MKIT_VERSION"
126
+}
127
+
128
+mkit_init() {
129
+    #
130
+    # Do basic initialization
131
+    #
132
+    # Check for ini file and some variables
133
+    #
134
+    $MKIT_DRY && MKIT_DEBUG=true
135
+    #shellcheck disable=SC2034
136
+    MKIT_PROJ_PKGNAME=$(ini 1value "project:pkgname")
137
+    test -f "$MKIT_INI" || die "cannot find mkit.ini: $MKIT_INI"
138
+    __chkiniversion
139
+}
140
+
141
+route() {
142
+    #
143
+    # Call correct function based on $1
144
+    #
145
+    if __valid_targets | grep -qwx "^$1"; then
146
+        "$1"
147
+    else
148
+        {
149
+            echo "usage: $(basename "$0") TARGET"
150
+            echo
151
+            echo "valid targets:"
152
+            __valid_targets | sed 's/^/    /'
153
+        } >&2
154
+    fi
155
+}
156
+
157
+warn() {
158
+    #
159
+    # Print warning message
160
+    #
161
+    echo "$@" >&2
162
+}

+ 232
- 0
utils/mkit/include/release.sh Ver arquivo

@@ -0,0 +1,232 @@
1
+#!/bin/bash
2
+# MKit - simple install helper
3
+# See LICENSE file for copyright and license details.
4
+
5
+mkit_import ini
6
+mkit_import facts
7
+
8
+__bump_version() {
9
+    #
10
+    # Bump version on stdin by level $1 (x, y or z)
11
+    #
12
+    local rlevel=$1     # release level
13
+    local old           # old version
14
+    local oldx          # ... X
15
+    local oldz          # ... Z
16
+    local oldy          # ... Y
17
+    local tmpy          # Y parsing cache
18
+    local new           # bumped version
19
+    read -r old
20
+    oldx=${old%.*.*}
21
+    oldz=${old#*.*.}
22
+    tmpy=${old%.*}
23
+    oldy=${tmpy#*.}
24
+    case $rlevel in
25
+        x) new="$((oldx+MKIT_BUMPSIZE)).0.0"            ;;
26
+        y) new="$oldx.$((oldy+MKIT_BUMPSIZE)).0"        ;;
27
+        z) new="$oldx.$oldy.$((oldz+MKIT_BUMPSIZE))"    ;;
28
+        *) die "invalid release level: $1"  ;;
29
+    esac
30
+    echo "$new"
31
+}
32
+
33
+__relck() {
34
+    #
35
+    # Die if blocking condition $1 is detected
36
+    #
37
+    local condition=$1      # condition name
38
+    local oracle            # expected value
39
+    case "$condition" in
40
+        git_present)
41
+            git rev-parse HEAD >&/dev/null\
42
+             || die "cannot do this outside git repo"
43
+            ;;
44
+        at_relsrc)
45
+            oracle=$(ini 1value project:relsrc)
46
+            git_fact current_branch \
47
+              | grep -qFxe "$oracle" \
48
+             || die "you are not on release source branch: $oracle"
49
+            ;;
50
+        not_dirty)
51
+            git diff --shortstat 2>/dev/null \
52
+              | grep -q . \
53
+             && die "tree is dirty!"
54
+            ;;
55
+        tags_ok)
56
+            git_fact latest_tag \
57
+              | grep -q . \
58
+             || die "cannot find latest tag"
59
+            ;;
60
+        vbump_hot)
61
+            git diff-tree --no-commit-id --name-only -r HEAD \
62
+              | grep -qFx mkit.ini \
63
+             || die "last change must be version bump in mkit.ini"
64
+            ;;
65
+        no_wip)
66
+            git_fact reldiff \
67
+              | grep '^....... WIP ' \
68
+             && die "WIP commit since $(git_fact latest_tag)"
69
+            ;;
70
+        ini_version)
71
+            oracle=$(git_fact latest_version | __bump_version "$rlevel")
72
+            ini 1value project:version  \
73
+              | grep -qFxe "$oracle" \
74
+             || die "new version not in mkit.ini: $oracle"
75
+            ;;
76
+        *)
77
+            die "unknown release check: $condition"
78
+            ;;
79
+    esac
80
+}
81
+
82
+__release() {
83
+    #
84
+    # Prepare release
85
+    #
86
+    # Span release routines: make a signed tag, check branch
87
+    # and update release branch
88
+    #
89
+    # FIXME: Using project:prerl as build.sh:semver() does may not be
90
+    #        compatible with this release strategy
91
+    #
92
+    local rlevel=$1     # release level (x, y or z)
93
+    local newtag        # new tag
94
+    local relsrc        # release source branch (if any)
95
+    local reldst        # release destination branch (if any)
96
+
97
+    __relck git_present
98
+    __relck at_relsrc
99
+    __relck not_dirty
100
+    __relck tags_ok
101
+    __relck vbump_hot
102
+    __relck no_wip
103
+    __relck ini_version
104
+
105
+    newtag=$(git_fact latest_version | __bump_version "$rlevel" | git_ver2tag )
106
+    set -e
107
+    debug_var newtag
108
+    $MKIT_DRY && return
109
+    git tag -m "$(__release_msg)" "$newtag"
110
+
111
+    relsrc=$(ini 1value project:relsrc)
112
+    reldst=$(ini 1value project:reldst)
113
+    debug_var relsrc reldst
114
+    if test -n "$reldst" && test "$reldst" != "$relsrc"; then
115
+        git branch -f "$reldst" "$newtag"
116
+    fi
117
+}
118
+
119
+__release_msg() {
120
+    #
121
+    # Generate message for annotated tag
122
+    #
123
+    # The last commit before issuing a release must be "Bump version" commit
124
+    # suggested by _vbump_gitmsg() and  manually edited by user.  Since the
125
+    # commit contains changelog, this function just uses the message body.
126
+    #
127
+    # The sort message (first line) is replaced with a nicer one (with project
128
+    # name, codename and version).
129
+    #
130
+    echo "$(ini 1value project:name) $newtag - $(ini 1value project:codename)"
131
+    echo
132
+    git show -s --format=%B \
133
+      | tail -n +3
134
+}
135
+
136
+__vbump() {
137
+    #
138
+    # Do version bump at level $1
139
+    #
140
+    # Perform checks, compute new version, update mkit.ini and initiate
141
+    # 'Bump version' commit with changelog template.
142
+    #
143
+    local rlevel=$1     # bump level (x, y or z)
144
+    local nextver       # version after the bump
145
+    local cache         # cache for the message
146
+    __relck git_present
147
+    __relck at_relsrc
148
+    __relck not_dirty
149
+    nextver=$(ini 1value project:version | __bump_version "$rlevel")
150
+    debug_var nextver
151
+    $MKIT_DRY && return
152
+    update_version "$nextver" mkit.ini \
153
+      || die "failed to update version in mkit.ini"
154
+    git add mkit.ini \
155
+      || die "failed to add mkit.ini to the index"
156
+    cache=$(mktemp -t "mkit._vbump_gitmsg.XXXXXXXX")
157
+    _vbump_gitmsg > "$cache"
158
+    git commit -e -F "$cache"   # note: reading from stdin will break vim
159
+    rm "$cache"
160
+}
161
+
162
+_vbump_gitmsg() {
163
+    #
164
+    # Compose git message template for 'Bump version' commit
165
+    #
166
+    echo "Bump version"
167
+    echo ""
168
+    echo "Overview of changes:"
169
+    echo ""
170
+    git_fact reldiff \
171
+      | sed '
172
+            s/^[a-f0-9]\{7\} /\n *  &/; t PATHS
173
+            s/^/        /
174
+            :PATHS
175
+        '
176
+}
177
+
178
+release() {
179
+    #
180
+    # Perform release on Z level
181
+    #
182
+    __release z
183
+}
184
+
185
+release_x() {
186
+    #
187
+    # Perform release on X level
188
+    #
189
+    __release x
190
+}
191
+
192
+release_y() {
193
+    #
194
+    # Perform release on Y level
195
+    #
196
+    __release y
197
+}
198
+
199
+release_z() {
200
+    #
201
+    # Perform release on Z level
202
+    #
203
+    __release z
204
+}
205
+
206
+vbump() {
207
+    #
208
+    # Perform version bump on Z level
209
+    #
210
+    __vbump z
211
+}
212
+
213
+vbump_x() {
214
+    #
215
+    # Perform version bump on X level
216
+    #
217
+    __vbump x
218
+}
219
+
220
+vbump_y() {
221
+    #
222
+    # Perform version bump on Y level
223
+    #
224
+    __vbump y
225
+}
226
+
227
+vbump_z() {
228
+    #
229
+    # Perform version bump on Z level
230
+    #
231
+    __vbump z
232
+}

+ 89
- 0
utils/mkit/include/vars.sh Ver arquivo

@@ -0,0 +1,89 @@
1
+#!/bin/bash
2
+#shellcheck disable=SC2034
3
+# MKit - simple install helper
4
+# See LICENSE file for copyright and license details.
5
+
6
+
7
+#
8
+# Bump size (for vbump_? and release_?)
9
+#
10
+MKIT_BUMPSIZE=${MKIT_BUMPSIZE:-1}
11
+
12
+#
13
+# Debug mode (true|false)
14
+#
15
+MKIT_DEBUG=${MKIT_DEBUG:-false}
16
+
17
+#
18
+# Default deploy mode for files
19
+#
20
+MKIT_DEFAULT_MODE="644"
21
+
22
+#
23
+# Dry mode (true|false)
24
+#
25
+# Set to true to not install anything. Implies MKIT_DEBUG.
26
+#
27
+MKIT_DRY=${MKIT_DRY:-false}
28
+
29
+#
30
+# Path to mkit.ini
31
+#
32
+MKIT_INI=${MKIT_INI:-mkit.ini}
33
+
34
+#
35
+# Limit ini expansion depth
36
+#
37
+# To avoid endless loops, this value is subtracted each
38
+# time ini() expands a reference; when zero is reached,
39
+# no more expansions happen.
40
+#
41
+MKIT_INI_EXPAND=2
42
+
43
+#
44
+# Path to MKit local config and temp
45
+#
46
+# Typically hidden in project root, here MKit can
47
+# save its temporary lists.
48
+#
49
+MKIT_LOCAL=${MKIT_LOCAL:-.mkit}
50
+
51
+#
52
+# Package name
53
+#
54
+# Used as base for tarball and in some default macros.
55
+#
56
+MKIT_PROJ_PKGNAME=""
57
+
58
+#
59
+# Add time-based ordinal tag to SemVer build data?
60
+#
61
+# Can be 'none', 'ctime' or 'btime'.
62
+#
63
+# If 'ctime', devel builds have also timestamp-based tag in format of
64
+# `t%Y%m%d%H%M%S`, that is, a small character 't' followed by timestamp
65
+# without non-digit characters.  The timestamps are in UTC, ie. timezones
66
+# need not apply.  'btime' has the same format, except that it's derived
67
+# from build time, while 'ctime' is from last commit's commit date.
68
+#
69
+# This helps with deploying development builds where packaging system
70
+# is not SemVer-compliant and makes it hard to install arbitrary version.
71
+# For example, old yum version (as of RHEL-6) will not let you install
72
+# version that it deems older than is installed, making it hard to
73
+# continually upgrade during active development.  While packaging
74
+# systems have their own rules (and SemVer says both versions should be
75
+# considered same) this tag will make it more likely to "win" the build
76
+# you made later.
77
+#
78
+# Note that this does not affect clean builds (ie. builds from clean
79
+# repo with HEAD corresponding to latest version tag.).
80
+#
81
+# Also note that 'btime' makes the version non-deterministic: merely
82
+# initiating the build a second later will result in different version.
83
+#
84
+MKIT_TSTAMP=${MKIT_TSTAMP:-ctime}
85
+
86
+#
87
+# This MKit version
88
+#
89
+MKIT_VERSION=0.0.37

+ 34
- 0
utils/mkit/make Ver arquivo

@@ -0,0 +1,34 @@
1
+#!/bin/bash
2
+#shellcheck disable=SC2034
3
+# mkit - simple install helper
4
+# See LICENSE file for copyright and license details.
5
+
6
+init_core() {
7
+    #
8
+    # Load core module (or die)
9
+    #
10
+    #shellcheck disable=SC1090
11
+    . "$MKIT_DIR/include/mkit.sh" \
12
+     && . "$MKIT_DIR/include/vars.sh" \
13
+     && return 0
14
+    echo "failed to load core; check if MKIT_DIR is set properly: $MKIT_DIR" >&2
15
+    exit 9
16
+}
17
+
18
+#
19
+# Path to MKit dir (where 'include' is)
20
+#
21
+MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
22
+
23
+
24
+init_core
25
+
26
+case "$1" in
27
+    -V|--version-semver)    echo "$MKIT_VERSION"; exit 0 ;;
28
+    --version)              echo "Mkit (Simple Makefile target helper) $MKIT_VERSION"
29
+                            exit 0 ;;
30
+esac
31
+
32
+mkit_init
33
+
34
+route "$@"

+ 56
- 0
utils/mkit/mkit.mk Ver arquivo

@@ -0,0 +1,56 @@
1
+# mkit - Simple Makefile target helper
2
+# See LICENSE file for copyright and license details.
3
+
4
+export MKIT_DIR
5
+
6
+all: build
7
+
8
+_mkit_data:
9
+	@"$(MKIT_DIR)"/make _mkit_data
10
+
11
+build:
12
+	@"$(MKIT_DIR)"/make build
13
+
14
+clean:
15
+	@"$(MKIT_DIR)"/make clean
16
+
17
+debstuff: dist
18
+	@"$(MKIT_DIR)"/make debstuff
19
+
20
+dist: clean
21
+	@"$(MKIT_DIR)"/make dist
22
+
23
+rpmstuff: dist
24
+	@"$(MKIT_DIR)"/make rpmstuff
25
+
26
+install: all
27
+	@"$(MKIT_DIR)"/make install
28
+
29
+release:
30
+	@"$(MKIT_DIR)"/make release
31
+
32
+release_x:
33
+	@"$(MKIT_DIR)"/make release_x
34
+
35
+release_y:
36
+	@"$(MKIT_DIR)"/make release_y
37
+
38
+release_z:
39
+	@"$(MKIT_DIR)"/make release_z
40
+
41
+uninstall:
42
+	@"$(MKIT_DIR)"/make uninstall
43
+
44
+vbump:
45
+	@"$(MKIT_DIR)"/make vbump
46
+
47
+vbump_x:
48
+	@"$(MKIT_DIR)"/make vbump_x
49
+
50
+vbump_y:
51
+	@"$(MKIT_DIR)"/make vbump_y
52
+
53
+vbump_z:
54
+	@"$(MKIT_DIR)"/make vbump_z
55
+
56
+.PHONY: all _mkit_data clean dist rpmstuff install uninstall release release_x release_y release_z vbump vbump_x vbump_y vbump_z

+ 715
- 0
utils/mkit/stub Ver arquivo

@@ -0,0 +1,715 @@
1
+#!/bin/bash
2
+# mkit - simple install helper
3
+# See LICENSE file for copyright and license details.
4
+
5
+init_core() {
6
+    #
7
+    # Load core modules (or die)
8
+    #
9
+    #shellcheck disable=SC1090
10
+    . "$MKIT_DIR/include/mkit.sh" \
11
+     && . "$MKIT_DIR/include/vars.sh" \
12
+     && return 0
13
+    echo "failed to load core; check if MKIT_DIR is set properly: $MKIT_DIR" >&2
14
+    exit 9
15
+}
16
+
17
+#
18
+# Path to MKit dir (where 'include' is)
19
+#
20
+MKIT_DIR=${MKIT_DIR:-$(dirname "$0")}
21
+
22
+init_core
23
+
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"
36
+
37
+
38
+deploy() {
39
+    local file=$1       # which known file?
40
+    local any_name=${NiceName:-$PackageName}
41
+    local tmp
42
+    tmp=$(mktemp -t mkit.stub.deploy.XXXXXXX)
43
+    mkdir -p "$(dirname "$file")"
44
+    case $file in
45
+
46
+        Makefile)
47
+            echo -n "# $any_name"
48
+            test -n "$Tagline" && echo -n " - $Tagline"
49
+            echo
50
+            $MkLicense && echo '# See LICENSE.md file for copyright and license details.'
51
+            echo ''
52
+            echo 'MKIT_DIR=utils/mkit'
53
+            #shellcheck disable=SC2016
54
+            echo 'include $(MKIT_DIR)/mkit.mk'
55
+            ;;
56
+
57
+        README.md)
58
+            echo "$any_name"
59
+            tr -c '=\n' '=' <<<"$any_name"
60
+            echo ''
61
+            if test -n "$Tagline"; then
62
+                echo "$Tagline"
63
+            else
64
+                echo "(Nothing to say about this project.)"
65
+            fi
66
+            ;;
67
+
68
+        */mkit.ini|mkit.ini)
69
+            echo "[project]"
70
+            {
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"
80
+            } | reformat_section
81
+            if updating; then
82
+                remake_section dist
83
+                remake_section ENV
84
+                remake_section roots
85
+                remake_section macros
86
+                remake_section modes
87
+                remake_section files
88
+            else
89
+                echo ""
90
+                echo "[dist]"
91
+                {
92
+                    $MkLicense  && echo "tarball = LICENSE.md"
93
+                    $MkMakefile && echo "tarball = Makefile"
94
+                    $MkReadme   && echo "tarball = README.md"
95
+                    echo "tarball = mkit.ini"
96
+                    $MkPackaging && echo "tarball = packaging"
97
+                    echo "tarball = src"
98
+                    echo "tarball = tests"
99
+                    echo "tarball = utils"
100
+                    $MkPackaging && echo "rpmstuff = packaging/template.spec"
101
+                    $MkPackaging && echo "debstuff = packaging/debian"
102
+                } | reformat_section
103
+                echo ""
104
+                echo "[ENV]"
105
+                {
106
+                    echo "    PREFIX = /usr/local"
107
+                } | reformat_section
108
+                echo ""
109
+                echo "[roots]"
110
+                {
111
+                    echo "bin = [ENV:PREFIX]/bin"
112
+                    echo "doc = [ENV:PREFIX]/share/doc/$PackageName"
113
+                } | reformat_section
114
+                echo ""
115
+                echo "[macros]"
116
+                {
117
+                    echo "__${PackageName^^}_FOO__ = Barr.."
118
+                } | reformat_section
119
+                echo ""
120
+                echo "[modes]"
121
+                {
122
+                    echo "bin = 755"
123
+                    echo "doc = 644"
124
+                } | reformat_section
125
+                echo ""
126
+                echo "[files]"
127
+                {
128
+                    echo "bin = src/$PackageName"
129
+                    $MkLicense && echo "doc = LICENSE.md"
130
+                    $MkReadme  && echo "doc = README.md"
131
+                } | reformat_section
132
+            fi
133
+            echo ""
134
+            echo "#mkit version=$MKIT_VERSION"
135
+            ;;
136
+
137
+        packaging/template.spec)
138
+            echo 'Name:       __MKIT_PROJ_PKGNAME__'
139
+            echo 'Version:    __MKIT_PROJ_VERSION__'
140
+            echo 'Release:    1%{?dist}'
141
+            echo 'Summary:    __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__'
142
+            test -n "$VcsBrowser" && echo 'URL:        __MKIT_PROJ_VCS_BROWSER__'
143
+            $MkLicense && echo "License:    $License"
144
+            echo 'Source0:    %{name}-%{version}.tar.gz'
145
+            echo 'BuildArch:  noarch'
146
+            echo ''
147
+            echo 'Requires: MKIT_STUB_REQUIRES'
148
+            echo '%description'
149
+            echo 'MKIT_STUB_DESCRIPTION'
150
+            echo ''
151
+            echo '%prep'
152
+            echo '%setup -q'
153
+            echo ''
154
+            echo '%build'
155
+            echo 'make %{?_smp_mflags} PREFIX=/usr'
156
+            echo ''
157
+            echo '%install'
158
+            echo '%make_install PREFIX=/usr'
159
+            echo ''
160
+            echo '%files'
161
+            echo 'MKIT_STUB_FILELIST'
162
+            echo ''
163
+            echo '%changelog'
164
+            echo ''
165
+            echo '# specfile built with MKit __MKIT_MKIT_VERSION__'
166
+            ;;
167
+
168
+        packaging/debian/copyright)
169
+            echo ""
170
+            ;;
171
+
172
+        packaging/debian/control)
173
+            echo 'Source: __MKIT_PROJ_PKGNAME__'
174
+            echo 'Maintainer: __MKIT_PROJ_MAINTAINER__'
175
+            test -n "$VcsBrowser" && echo 'Vcs-Browser: __MKIT_PROJ_VCS_BROWSER__'
176
+            echo 'Section: misc'
177
+            echo 'Priority: extra'
178
+            echo 'Standards-Version: 3.9.2'
179
+            echo 'Build-Depends:'
180
+            echo ' debhelper (>= 9),'
181
+            echo ''
182
+            echo 'Package: __MKIT_PROJ_PKGNAME__'
183
+            echo 'Architecture: all'
184
+            echo 'Depends: MKIT_STUB_REQUIRES'
185
+            echo 'Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__'
186
+            echo ' MKIT_STUB_DESCRIPTION'
187
+            echo ''
188
+            echo '# control file built with MKit __MKIT_MKIT_VERSION__'
189
+            ;;
190
+
191
+        packaging/debian/changelog)
192
+            echo '__MKIT_PROJ_PKGNAME__ (__MKIT_PROJ_VERSION__-1) UNRELEASED; urgency=medium'
193
+            echo ''
194
+            echo '  * Initial release. (Closes: #XXXXXX)'
195
+            echo ''
196
+            echo " -- __MKIT_PROJ_MAINTAINER__  $(date -R)"
197
+            ;;
198
+
199
+        packaging/debian/compat)
200
+            echo 9
201
+            ;;
202
+
203
+        packaging/debian/rules)
204
+            echo '#!/usr/bin/make -f'
205
+            echo ''
206
+            echo '%:'
207
+            echo ''
208
+            echo '	dh $@'
209
+            echo ''
210
+            echo 'override_dh_auto_install:'
211
+            echo ''
212
+            echo '	make install PREFIX=/usr DESTDIR=debian/tmp'
213
+            ;;
214
+
215
+        packaging/debian/source/format)
216
+            echo '3.0 (quilt)'
217
+            ;;
218
+
219
+        packaging/debian/install)
220
+            echo MKIT_STUB_FILELIST
221
+            ;;
222
+
223
+        src/*.skel)
224
+            echo 'echo "my version is: __MKIT_PROJ_VERSION__"'
225
+            echo 'echo "And that'"'"'s all, folks!"'
226
+            ;;
227
+
228
+        LICENSE.md)
229
+            local url   # license URL
230
+            url="${MKIT_STUB_LICENSES[$License]}"
231
+            curl -sf "$url" \
232
+             || die "failed to download license: $url"
233
+            ;;
234
+
235
+        .mkit/autoclean)
236
+            ;;
237
+
238
+        MKIT_STUB_README.md)
239
+            echo "FINISHING MKIT CONFIGURATION"
240
+            echo "============================"
241
+            echo ""
242
+            echo "Congratulations, your new project has been configured!"
243
+            echo ""
244
+            echo "However, the *stub* script is not able to figure out"
245
+            echo "everything, so few things still need to be done manually."
246
+            echo "This document will guide you throught the rest of the"
247
+            echo "process."
248
+            echo ""
249
+            echo ""
250
+            echo "Structure"
251
+            echo "---------"
252
+            echo ""
253
+            echo "First, let's go through the directory structure:"
254
+            echo ""
255
+            echo " *  *src* directory - here is your main place to store"
256
+            echo "    source files.  This includes also documents like user"
257
+            echo "    manuals---IOW, anything intended to end up on user's"
258
+            echo "    machine should be uder 'src'."
259
+            echo ""
260
+            echo "    Note that during build time, files named ending with"
261
+            echo "    '.skel' are subject to macro expansion, see mkit.ini"
262
+            echo "    section below for details."
263
+            echo ""
264
+            echo " *  *notes* directory - here you shall store notes"
265
+            echo "    intended for people contributing to your project,"
266
+            echo "    for instance, guidelines, coding style documents,"
267
+            echo "    TODOs, ideas, plans..."
268
+            echo ""
269
+            echo " *  *utils* directory - here you shall store utilities"
270
+            echo "    and scripts that will help you with project maintenance,"
271
+            echo "    and that, unlike software like compilers or versioning"
272
+            echo "    systems, can (and should) be embedded inside the"
273
+            echo "    repository."
274
+            echo ""
275
+            echo "    MKit itself is one nice example. :)"
276
+
277
+            if $MkPackaging; then
278
+            echo ""
279
+            echo " *  *packaging* directory contains templates that enable"
280
+            echo "    MKit create raw stuffs used to create DEB or RPM"
281
+            echo "    packages.  Similar to '.skel' files in 'src', all files"
282
+            echo "    here are automatically considered for macro expansion,"
283
+            echo "    no matter how they are named (see mkit.ini section"
284
+            echo "    below)."
285
+            echo ""
286
+            echo "    NOTE: these templates, as well as any packages created by"
287
+            echo "    them are intended only for experimental, private use and"
288
+            echo "    testing."
289
+            echo ""
290
+            echo "    Should you have ambition to create 'real' packages for"
291
+            echo "    OS distribution such as Debian or Fedora (what a great"
292
+            echo "    idea!), be prepared that you will need to follow their"
293
+            echo "    guidelines.  This will most probably mean huge changes"
294
+            echo "    to these packages or even changes to your workflow."
295
+            echo ""
296
+            echo ""
297
+            echo "Placeholders"
298
+            echo "------------"
299
+            echo ""
300
+            echo "At places where *stub* script did not have way to get all"
301
+            echo "information automatically, it has inserted placeholders."
302
+            echo "You will need to go through all of these placeholders and"
303
+            echo "replace them with proper data."
304
+            echo ""
305
+            echo "Please follow instructions:"
306
+            echo ""
307
+            echo " 1. Look for placeholders starting with \`MKIT_STUB_\`"
308
+            echo "    prefix by calling this command:"
309
+            echo ""
310
+            echo "        grep -l MKIT_STUB_ -r"
311
+            echo ""
312
+            echo " 2. Go through each file and locate the placeholder.  (You"
313
+            echo "    will also see placeholders like \`__MKIT_*__\`, you can"
314
+            echo "    ignore those."
315
+            echo ""
316
+            echo " 3. Replace placeholder with appropriate information:"
317
+            echo ""
318
+            echo "     *  \`MKIT_STUB_REQUIRES\` - Requirements of your"
319
+            echo "        project."
320
+            echo ""
321
+            echo "     *  \`MKIT_STUB_DESCRIPTION\` - Description of your"
322
+            echo "        project (few sentences to paragraphs)."
323
+            echo ""
324
+            echo "     *  \`MKIT_STUB_FILELIST\` - List of full paths to"
325
+            echo "        your files after installation."
326
+            echo ""
327
+            echo "        Note that in case of debian/install files, PREFIX"
328
+            echo "        based paths (eg. /usr/bin) in this file should be as"
329
+            echo "        if PREFIX was /usr."
330
+            echo ""
331
+            echo "        In case of Fedora-based distro, you should make use"
332
+            echo "        of RPM macros:"
333
+            echo ""
334
+            echo "            https://fedoraproject.org/wiki/Packaging:RPMMacros"
335
+            echo ""
336
+            echo "    Refer to these documents for further details:"
337
+            echo ""
338
+            echo "        http://rpm-guide.readthedocs.io/"
339
+            echo "        https://www.debian.org/doc/manuals/maint-guide/"
340
+            fi
341
+
342
+            echo ""
343
+            echo ""
344
+            echo "mkit.ini"
345
+            echo "--------"
346
+            echo ""
347
+            echo "Most sections still need to be reviewed. In order to do"
348
+            echo "that, you will need to understand how MKit works:"
349
+            echo ""
350
+            echo " 1. First, you need to define *roles* your files will play"
351
+            echo "    when they are installed on user's file systems.  These"
352
+            echo "    roles then imply where and how the files should be"
353
+            echo "    deployed."
354
+            echo ""
355
+            echo "    Typical example of a role is e.g. 'bin' for commands"
356
+            echo "    (normally under '/usr/bin' or '/usr/local/bin'), 'doc'"
357
+            echo "    for documents or 'lib' for libraries."
358
+            echo ""
359
+            echo " 2. Next, in \`[roots]\` section, you have to set target"
360
+            echo "    root directory for each role.  However, in order to"
361
+            echo "    enable people to implement local conventions, it is"
362
+            echo "    considered a good manner to also respect PREFIX"
363
+            echo "    environment variable.  For this reason, most paths"
364
+            echo "    need to start with \`[ENV:PREFIX]\`."
365
+            echo ""
366
+            echo " 3. \`[files]\` section is where you assign actual files"
367
+            echo "    from your repository to their final paths.  The format"
368
+            echo "    is \`ROLE = REPOPATH [RENAMED]\`, where ROLE is file's"
369
+            echo "    role, REPOPATH is relative path to the file."
370
+            echo ""
371
+            echo "    Final path is then composed by taking path assigned to"
372
+            echo "    ROLE and appending file's name.  However, if you need"
373
+            echo "    the deployed file to have different name than in the"
374
+            echo "    codebase, you can specify the other name as RENAMED."
375
+            echo ""
376
+            echo "    Note that you don't need to address every single file"
377
+            echo "    individually, if in your repo you have a directory with"
378
+            echo "    100 files of the same role, you can add just path to the"
379
+            echo "    directory itself."
380
+            echo ""
381
+            echo " 4. If some roles require special permissions on your files,"
382
+            echo "    \`[modes]\` section is your friend.  Permissions here"
383
+            echo "    should be in UNIX octal format."
384
+            echo ""
385
+            echo " 5. Next, \`[macros]\` section allows you to define own"
386
+            echo "    placeholders that will be replaced when your scripts are"
387
+            echo "    built.  Each file in 'src' directory that is named with"
388
+            echo "    '.skel' suffix, and each file from 'packaging' directory"
389
+            echo "    (no matter its name), can contain one or more of macros"
390
+            echo "    defined here, plus range of macros automatically defined"
391
+            echo "    by MKit.  During build, these macros are replaced with"
392
+            echo "    their actual values."
393
+            echo ""
394
+            echo " 6. Less interesting, but important section is \`[dist]\`,"
395
+            echo "    which lists files in your codebase that will be added"
396
+            echo "    to distribution tarball (part of \"stuffs\" mentioned"
397
+            echo "    above).  Listing directory here will include all its"
398
+            echo "    contents, and normally it's OK to be very inclusive, so"
399
+            echo "    most of the time this section should be OK."
400
+            echo ""
401
+            echo " 7. Even less interesting is section \`[ENV]\`.  It is"
402
+            echo "    special in that it provides *default* value for an"
403
+            echo "    environment variable.  You almost never need to touch"
404
+            echo "    this."
405
+            echo ""
406
+            echo " 8. Finally, the most interesting section!  \`[project]\`,"
407
+            echo "    provides most general information for your project such"
408
+            echo "    as name and version."
409
+            echo ""
410
+            echo "    Note that the \`version\` key is another \"special"
411
+            echo "    snowflake\" -- it is now set to 0.0.0, and you **should"
412
+            echo "    not need** to change  it manually.  When you feel you"
413
+            echo "    a are ready to release next version of your evolving"
414
+            echo "    project, simply call \`make vbump\` and MKit will take"
415
+            echo "    care of everything!"
416
+
417
+            if $MkMakefile; then
418
+            echo ""
419
+            echo ""
420
+            echo "Makefile"
421
+            echo "--------"
422
+            echo ""
423
+            echo "*stub* script also created a Makefile for you, but all"
424
+            echo "it really does is include MKit's own mkit.mk, which in turn"
425
+            echo "only maps \`make\` targets to actual mkit script calls."
426
+            echo "Unless your project already uses GNU Make, you should not"
427
+            echo "need to change this file."
428
+            fi
429
+
430
+            if $MkReadme; then
431
+            echo ""
432
+            echo ""
433
+            echo "README.md"
434
+            echo "---------"
435
+            echo ""
436
+            echo "Each serious project needs a serious README.  Which is why"
437
+            echo "*stub* has created a 'stub' of one for you."
438
+            fi
439
+
440
+            echo ""
441
+            echo ""
442
+            echo "The final touch"
443
+            echo "---------------"
444
+            echo ""
445
+            echo "Once you have reviewed everything, just delete this file!"
446
+            ;;
447
+
448
+    esac >"$tmp"
449
+    cat "$tmp" > "$file"
450
+    rm "$tmp"
451
+}
452
+
453
+known_licenses() {
454
+    local key
455
+    local first=true
456
+    for key in "${!MKIT_STUB_LICENSES[@]}"; do
457
+        $first && echo "$key"  && continue
458
+        echo ", $key"
459
+    done
460
+}
461
+
462
+usage() {
463
+    {
464
+        echo "Usage:"
465
+        echo "   stub [options] new PKGNAME"
466
+        echo "   stub [options] update"
467
+        echo "   stub -L"
468
+        echo ""
469
+        echo "Options:"
470
+        echo ""
471
+        echo "    -c CODENAME   your project codename"
472
+        echo "    -t TAGLINE    your project tagline"
473
+        echo "    -b RELSRC     pre-release branch"
474
+        echo "    -B RELDST     post-release branch"
475
+        echo "    -n NICENAME   your project's 'nice' name"
476
+        echo "    -l LICENSE    your options's license (see -L)"
477
+        echo "    -m MAINT      project maintainer's name and e-mail"
478
+        echo "    -v URL        URL to public code browser"
479
+        echo "    -V VERSION    initial version (default: 0.0.0)"
480
+        echo "    -a            enable autoclean ('make clean' after"
481
+        echo "                  each 'make install')"
482
+        echo "    -g            make git commits before and adter"
483
+        echo "                  (implies -y)"
484
+        echo "    -y            don't ask, just do it"
485
+        echo "    -R            skip creating README.md"
486
+        echo "    -M            skip creating Makefile"
487
+        echo "    -P            skip creating packaging templates"
488
+        echo "    -L            list known licenses and exit"
489
+        echo ""
490
+        echo "PKGNAME should be packaging-friendly name, ie. consist"
491
+        echo "only of small letters, numbers, underscore and dash."
492
+        echo "For your 'real' name, use NICENAME, which can be any"
493
+        echo "string."
494
+    } >&2
495
+    exit 2
496
+}
497
+
498
+confirm() {
499
+    local response      # user's response to our warning
500
+    $Force && return 0
501
+    {
502
+        echo "Warning: This operation can be destructive for your"
503
+        echo "current codebase.  At least following files will be"
504
+        echo "created or overwritten:"
505
+        echo ""
506
+        $MkPackaging    && echo " *  'packaging' directory (pass -P to avoid)"
507
+        $MkMakefile     && echo " *  'Makefile' (pass -M to avoid)"
508
+        $MkReadme       && echo " *  'README.md' (pass -R to avoid)"
509
+        $MkLicense      && echo " *  'LICENSE.md' (omit -l to avoid)"
510
+        echo " *  'mkit.ini'"
511
+        echo ""
512
+        read -p "Type 'yes' to proceed: " -r response
513
+    } >&2
514
+    test "$response" == "yes" && return 0
515
+    warn "Aborting."
516
+    return 1
517
+}
518
+
519
+mkcommit_backup() {
520
+    git ls-files --others \
521
+      | grep -qv -e '^utils/mkit$' -e '^utils/mkit/' \
522
+     || { warn "nothing to back up"; return 0; }
523
+    git add .                           || return
524
+    git rm -r --cached utils/mkit       || return
525
+    git commit -m "WIP [mkit/stub] backup" || return
526
+}
527
+
528
+mkcommit_mkit_code() {
529
+    git ls-files --others \
530
+      | grep -q -e '^utils/mkit$' -e '^utils/mkit/' \
531
+     || return 0
532
+    git add utils/mkit || return
533
+    git commit -m "WIP [mkit/stub] Add MKit version v$MKIT_VERSION" || return
534
+}
535
+
536
+mkcommit_mkit_conf() {
537
+    local msg       # commit message (the important art
538
+    git add . || return
539
+    case $Action in
540
+        new)    msg="Add MKit configuration stub" ;;
541
+        update) msg="Update MKit configuration"   ;;
542
+    esac
543
+    git commit -m "WIP [mkit/stub] $msg" || return
544
+}
545
+
546
+deploy_packaging() {
547
+    rm -rf packaging
548
+    deploy packaging/template.spec
549
+    deploy packaging/debian/copyright
550
+    deploy packaging/debian/control
551
+    deploy packaging/debian/changelog
552
+    deploy packaging/debian/compat
553
+    deploy packaging/debian/install
554
+    deploy packaging/debian/rules
555
+    deploy packaging/debian/source/format
556
+}
557
+
558
+init_from_existing() {
559
+    #
560
+    # Initialize variables from old mkit.ini
561
+    #
562
+    test -f "$MKIT_INI" \
563
+     || die "mkit.ini not found; aborting update: $MKIT_INI"
564
+    user_gave Codename    || Codename=$(ini_raw1v project:codename)
565
+    user_gave License     || License=$(ini_raw1v project:license)
566
+    user_gave Maintainer  || Maintainer=$(ini_raw1v project:maintainer)
567
+    user_gave NiceName    || NiceName=$(ini_raw1v project:name)
568
+    user_gave PackageName || PackageName=$(ini_raw1v project:pkgname)
569
+    user_gave RelDst      || RelDst=$(ini_raw1v project:reldst)
570
+    user_gave RelSrc      || RelSrc=$(ini_raw1v project:relsrc)
571
+    user_gave Tagline     || Tagline=$(ini_raw1v project:tagline)
572
+    user_gave VcsBrowser  || VcsBrowser=$(ini_raw1v project:vcs_browser)
573
+    user_gave Version     || Version=$(ini_raw1v project:version)
574
+}
575
+
576
+ini_raw1v() {
577
+    #
578
+    # Read raw scalar from mkit.ini
579
+    #
580
+    local path=$1
581
+    MKIT_INI_EXPAND=0 ini 1value "$path"
582
+}
583
+
584
+user_gave() {
585
+    #
586
+    # True if user gave value to variable $1
587
+    #
588
+    local var=$1    # name of the variable
589
+    { test "${UserGave[$var]}" == 1; } 2>/dev/null
590
+}
591
+
592
+updating() {
593
+    #
594
+    # Are we updating?
595
+    #
596
+    test "$Action" == update
597
+}
598
+
599
+remake_section() {
600
+    #
601
+    # Re-compose mkit.ini section $1
602
+    #
603
+    local section=$1
604
+    local key
605
+    local value
606
+    ini lskeys "$section" | grep -q . \
607
+     || return 1
608
+    echo ""
609
+    echo "[$section]"
610
+    ini lskeys "$section" \
611
+      | while read -r key; do
612
+            MKIT_INI_EXPAND=0 ini values "$section:$key" \
613
+              | while read -r value; do
614
+                    echo "$key = $value"
615
+                done
616
+        done \
617
+      | reformat_section
618
+}
619
+
620
+reformat_section() {
621
+    #
622
+    # Re-format "k = v" on stdin as "nice" ini section
623
+    #
624
+    local key
625
+    local eq
626
+    local value
627
+    while read -r key eq value; do
628
+        test "$eq" == "=" || {
629
+            warn "ignoring malformed ini line: $key $eq $value"
630
+            continue
631
+        }
632
+        echo "$key = $value"
633
+    done \
634
+      | sed 's/ *= */=/; s/^ *//; s/ *$//' \
635
+      | column -t -s= -o' = ' \
636
+      | sed 's/^/    /'
637
+}
638
+
639
+main() {
640
+    local NiceName          # human-readable project name
641
+    local PackageName       # machine-safe project (package) name
642
+    local RelSrc            # pre-release branch
643
+    local RelDst            # post-release branch
644
+    local Codename          # release codename
645
+    local Tagline           # project tagline
646
+    local Maintainer        # project maintainer (Name + e-mail)
647
+    local VcsBrowser        # VCS browser (eg. GitHub URL)
648
+    local Version=0.0.0     # project version
649
+    local AutoClean=false   # touch .mkit/autoclean?
650
+    local MkCommits=false   # create pre/post git commits?
651
+    local Force=false       # go without asking?
652
+    local MkReadme=true     # create README.md?
653
+    local MkMakefile=true   # create Makefile?
654
+    local MkPackaging=true  # create packaging templates?
655
+    local MkLicense=false   # create LICENSE.md file
656
+    local Action            # 'update' to respect existing, 'new' to force
657
+                            # rewrite incl. MKIT_STUB_* placeholders
658
+    declare -A UserGave
659
+    while true; do case $1 in
660
+        -n) NiceName=$2;   UserGave[NiceName]=1;   shift 2 || usage ;;
661
+        -b) RelSrc=$2;     UserGave[RelSrc]=1;     shift 2 || usage ;;
662
+        -B) RelDst=$2;     UserGave[RelDst]=1;     shift 2 || usage ;;
663
+        -c) Codename=$2;   UserGave[Codename]=1;   shift 2 || usage ;;
664
+        -t) Tagline=$2;    UserGave[Tagline]=1;    shift 2 || usage ;;
665
+        -l) License=$2;    UserGave[License]=1;    shift 2 || usage ;;
666
+        -m) Maintainer=$2; UserGave[Maintainer]=1; shift 2 || usage ;;
667
+        -v) VcsBrowser=$2; UserGave[VcsBrowser]=1; shift 2 || usage ;;
668
+        -V) Version=$2;    UserGave[Version]=1;    shift 2 || usage ;;
669
+        -M) MkMakefile=false;   shift ;;
670
+        -R) MkReadme=false;     shift ;;
671
+        -a) AutoClean=true;     shift ;;
672
+        -y) Force=true;         shift ;;
673
+        -g) MkCommits=true;     shift ;;
674
+        -P) MkPackaging=false;  shift ;;
675
+        -L) known_licenses | tr , '\n'; exit 0 ;;
676
+        -*) usage ;;
677
+        *)  break ;;
678
+    esac done
679
+    Action=$1; PackageName=$2
680
+    case $Action:$PackageName in
681
+        new:)     usage ;;
682
+        new:*)    :     ;;
683
+        update:)  :     ;;
684
+        update:*) usage ;;
685
+        *)        usage ;;
686
+    esac
687
+    updating && init_from_existing
688
+    if test -n "$License"; then
689
+        known_licenses | grep -qxFe "$License" \
690
+         || die "unknown license (use -L to get list): $License"
691
+        MkLicense=true
692
+    fi
693
+    if $MkCommits; then
694
+        mkcommit_backup || die "failed creating backup commit"
695
+        Force=true
696
+    fi
697
+    confirm            || return 1
698
+    deploy "$MKIT_INI"
699
+    deploy src/"$PackageName".skel
700
+    $MkMakefile     && deploy Makefile
701
+    $MkReadme       && deploy README.md
702
+    $MkLicense      && deploy LICENSE.md
703
+    $AutoClean      && deploy .mkit/autoclean
704
+    $MkPackaging    && deploy_packaging
705
+    if $MkCommits; then
706
+        mkcommit_mkit_code || die "failed creating post-commit"
707
+        mkcommit_mkit_conf || die "failed creating post-commit"
708
+    fi
709
+    deploy MKIT_STUB_README.md
710
+    warn "Configuration stub built, follow instructions in"
711
+    warn "MKIT_STUB_README.md to finish configuration."
712
+    return 0
713
+}
714
+
715
+main "$@"