Browse Source

Initial commit

Already v0.11.0 since it's been used for ages as part of core Shellfu
installation.
Alois Mahdal 6 years ago
commit
751b92bd80
100 changed files with 9147 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 503
    0
      LICENSE.md
  3. 8
    0
      Makefile
  4. 4
    0
      README.md
  5. 38
    0
      mkit.ini
  6. 5
    0
      packaging/debian/changelog
  7. 1
    0
      packaging/debian/compat
  8. 24
    0
      packaging/debian/control
  9. 1
    0
      packaging/debian/copyright
  10. 1
    0
      packaging/debian/install
  11. 14
    0
      packaging/debian/rules
  12. 1
    0
      packaging/debian/source/format
  13. 44
    0
      packaging/template.spec
  14. 346
    0
      src/inigrep.sh.skel
  15. 3
    0
      tests/TF_HEADER
  16. 198
    0
      tests/inigrep_chars/TF_RUN
  17. 67
    0
      tests/inigrep_inigrep/TF_RUN
  18. 2
    0
      tests/inigrep_inigrep/oracle/both_keys_and_sections.stdout
  19. 3125
    0
      tests/inigrep_inigrep/oracle/games_with_spaces.stdout
  20. 1
    0
      tests/inigrep_inigrep/oracle/inlinecmt_hash.stdout
  21. 1
    0
      tests/inigrep_inigrep/oracle/inlinecmt_hash_and_strict.stdout
  22. 1
    0
      tests/inigrep_inigrep/oracle/inlinecmt_sc.stdout
  23. 1
    0
      tests/inigrep_inigrep/oracle/inlinecmt_sc_and_strict.stdout
  24. 2
    0
      tests/inigrep_inigrep/oracle/keys_only.stdout
  25. 2
    0
      tests/inigrep_inigrep/oracle/keys_sections_spaces.stdout
  26. 8
    0
      tests/inigrep_inigrep/oracle/list_keys.stdout
  27. 8
    0
      tests/inigrep_inigrep/oracle/list_paths.stdout
  28. 2
    0
      tests/inigrep_inigrep/oracle/list_sections.stdout
  29. 5
    0
      tests/inigrep_inigrep/oracle/list_tricky_all_keys.stdout
  30. 5
    0
      tests/inigrep_inigrep/oracle/list_tricky_all_paths.stdout
  31. 3
    0
      tests/inigrep_inigrep/oracle/list_tricky_all_sections.stdout
  32. 1
    0
      tests/inigrep_inigrep/oracle/list_tricky_k12_keys.stdout
  33. 1
    0
      tests/inigrep_inigrep/oracle/list_tricky_k12_paths.stdout
  34. 1
    0
      tests/inigrep_inigrep/oracle/list_tricky_k12_sections.stdout
  35. 2
    0
      tests/inigrep_inigrep/oracle/list_tricky_s1_keys.stdout
  36. 2
    0
      tests/inigrep_inigrep/oracle/list_tricky_s1_paths.stdout
  37. 1
    0
      tests/inigrep_inigrep/oracle/list_tricky_s1_sections.stdout
  38. 12
    0
      tests/inigrep_inigrep/oracle/merge_first.stdout
  39. 12
    0
      tests/inigrep_inigrep/oracle/merge_first_no1.stdout
  40. 12
    0
      tests/inigrep_inigrep/oracle/merge_first_no2.stdout
  41. 12
    0
      tests/inigrep_inigrep/oracle/merge_first_no3.stdout
  42. 6
    0
      tests/inigrep_inigrep/oracle/merge_first_none.stdout
  43. 21
    0
      tests/inigrep_inigrep/oracle/merge_first_strict.stdout
  44. 18
    0
      tests/inigrep_inigrep/oracle/merge_join.stdout
  45. 18
    0
      tests/inigrep_inigrep/oracle/merge_join_no1.stdout
  46. 18
    0
      tests/inigrep_inigrep/oracle/merge_join_no2.stdout
  47. 18
    0
      tests/inigrep_inigrep/oracle/merge_join_no3.stdout
  48. 6
    0
      tests/inigrep_inigrep/oracle/merge_join_none.stdout
  49. 33
    0
      tests/inigrep_inigrep/oracle/merge_join_strict.stdout
  50. 2
    0
      tests/inigrep_inigrep/oracle/path.stdout
  51. 2
    0
      tests/inigrep_inigrep/oracle/plain.stdout
  52. 5
    0
      tests/inigrep_inigrep/oracle/plain_strict.stdout
  53. 3
    0
      tests/inigrep_inigrep/oracle/sections_only.stdout
  54. 15
    0
      tests/inigrep_inigrep/oracle/strict_and_space.stdout
  55. 15
    0
      tests/inigrep_inigrep/oracle/strict_and_tab.stdout
  56. 6
    0
      tests/inigrep_inigrep/oracle/tricks_with_strange_naming.stdout
  57. 13
    0
      tests/inigrep_inigrep/test/both_keys_and_sections.stdin
  58. 3126
    0
      tests/inigrep_inigrep/test/games_with_spaces.stdin
  59. 9
    0
      tests/inigrep_inigrep/test/inlinecmt.stdin
  60. 5
    0
      tests/inigrep_inigrep/test/keys_only.stdin
  61. 13
    0
      tests/inigrep_inigrep/test/keys_sections_spaces.stdin
  62. 13
    0
      tests/inigrep_inigrep/test/list_keys.stdin
  63. 13
    0
      tests/inigrep_inigrep/test/list_paths.stdin
  64. 13
    0
      tests/inigrep_inigrep/test/list_sections.stdin
  65. 13
    0
      tests/inigrep_inigrep/test/list_tricky_all_keys.stdin
  66. 13
    0
      tests/inigrep_inigrep/test/list_tricky_all_paths.stdin
  67. 13
    0
      tests/inigrep_inigrep/test/list_tricky_all_sections.stdin
  68. 13
    0
      tests/inigrep_inigrep/test/list_tricky_k12_keys.stdin
  69. 13
    0
      tests/inigrep_inigrep/test/list_tricky_k12_paths.stdin
  70. 13
    0
      tests/inigrep_inigrep/test/list_tricky_k12_sections.stdin
  71. 13
    0
      tests/inigrep_inigrep/test/list_tricky_s1_keys.stdin
  72. 13
    0
      tests/inigrep_inigrep/test/list_tricky_s1_paths.stdin
  73. 13
    0
      tests/inigrep_inigrep/test/list_tricky_s1_sections.stdin
  74. 10
    0
      tests/inigrep_inigrep/test/merge-a/t.conf
  75. 10
    0
      tests/inigrep_inigrep/test/merge-b/t.conf
  76. 11
    0
      tests/inigrep_inigrep/test/merge_first.stdin
  77. 11
    0
      tests/inigrep_inigrep/test/merge_first_no1.stdin
  78. 11
    0
      tests/inigrep_inigrep/test/merge_first_no2.stdin
  79. 11
    0
      tests/inigrep_inigrep/test/merge_first_no3.stdin
  80. 11
    0
      tests/inigrep_inigrep/test/merge_first_none.stdin
  81. 11
    0
      tests/inigrep_inigrep/test/merge_first_strict.stdin
  82. 11
    0
      tests/inigrep_inigrep/test/merge_join.stdin
  83. 11
    0
      tests/inigrep_inigrep/test/merge_join_no1.stdin
  84. 11
    0
      tests/inigrep_inigrep/test/merge_join_no2.stdin
  85. 11
    0
      tests/inigrep_inigrep/test/merge_join_no3.stdin
  86. 11
    0
      tests/inigrep_inigrep/test/merge_join_none.stdin
  87. 11
    0
      tests/inigrep_inigrep/test/merge_join_strict.stdin
  88. 13
    0
      tests/inigrep_inigrep/test/path.stdin
  89. 2
    0
      tests/inigrep_inigrep/test/plain.stdin
  90. 5
    0
      tests/inigrep_inigrep/test/plain_strict.stdin
  91. 11
    0
      tests/inigrep_inigrep/test/sections_only.stdin
  92. 16
    0
      tests/inigrep_inigrep/test/strict_and_space.stdin
  93. 16
    0
      tests/inigrep_inigrep/test/strict_and_tab.stdin
  94. 12
    0
      tests/inigrep_inigrep/test/tricks_with_strange_naming.stdin
  95. 286
    0
      utils/mkit/include/build.sh
  96. 130
    0
      utils/mkit/include/deploy.sh
  97. 175
    0
      utils/mkit/include/facts.sh
  98. 178
    0
      utils/mkit/include/ini.sh
  99. 162
    0
      utils/mkit/include/mkit.sh
  100. 0
    0
      utils/mkit/include/release.sh

+ 1
- 0
.gitignore View File

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

+ 503
- 0
LICENSE.md View File

@@ -0,0 +1,503 @@
1
+### GNU LESSER GENERAL PUBLIC LICENSE
2
+
3
+Version 2.1, February 1999
4
+
5
+    Copyright (C) 1991, 1999 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
+    [This is the first released version of the Lesser GPL.  It also counts
12
+     as the successor of the GNU Library Public License, version 2, hence
13
+     the version number 2.1.]
14
+
15
+### Preamble
16
+
17
+The licenses for most software are designed to take away your freedom
18
+to share and change it. By contrast, the GNU General Public Licenses
19
+are intended to guarantee your freedom to share and change free
20
+software--to make sure the software is free for all its users.
21
+
22
+This license, the Lesser General Public License, applies to some
23
+specially designated software packages--typically libraries--of the
24
+Free Software Foundation and other authors who decide to use it. You
25
+can use it too, but we suggest you first think carefully about whether
26
+this license or the ordinary General Public License is the better
27
+strategy to use in any particular case, based on the explanations
28
+below.
29
+
30
+When we speak of free software, we are referring to freedom of use,
31
+not price. Our General Public Licenses are designed to make sure that
32
+you have the freedom to distribute copies of free software (and charge
33
+for this service if you wish); that you receive source code or can get
34
+it if you want it; that you can change the software and use pieces of
35
+it in new free programs; and that you are informed that you can do
36
+these things.
37
+
38
+To protect your rights, we need to make restrictions that forbid
39
+distributors to deny you these rights or to ask you to surrender these
40
+rights. These restrictions translate to certain responsibilities for
41
+you if you distribute copies of the library or if you modify it.
42
+
43
+For example, if you distribute copies of the library, whether gratis
44
+or for a fee, you must give the recipients all the rights that we gave
45
+you. You must make sure that they, too, receive or can get the source
46
+code. If you link other code with the library, you must provide
47
+complete object files to the recipients, so that they can relink them
48
+with the library after making changes to the library and recompiling
49
+it. And you must show them these terms so they know their rights.
50
+
51
+We protect your rights with a two-step method: (1) we copyright the
52
+library, and (2) we offer you this license, which gives you legal
53
+permission to copy, distribute and/or modify the library.
54
+
55
+To protect each distributor, we want to make it very clear that there
56
+is no warranty for the free library. Also, if the library is modified
57
+by someone else and passed on, the recipients should know that what
58
+they have is not the original version, so that the original author's
59
+reputation will not be affected by problems that might be introduced
60
+by others.
61
+
62
+Finally, software patents pose a constant threat to the existence of
63
+any free program. We wish to make sure that a company cannot
64
+effectively restrict the users of a free program by obtaining a
65
+restrictive license from a patent holder. Therefore, we insist that
66
+any patent license obtained for a version of the library must be
67
+consistent with the full freedom of use specified in this license.
68
+
69
+Most GNU software, including some libraries, is covered by the
70
+ordinary GNU General Public License. This license, the GNU Lesser
71
+General Public License, applies to certain designated libraries, and
72
+is quite different from the ordinary General Public License. We use
73
+this license for certain libraries in order to permit linking those
74
+libraries into non-free programs.
75
+
76
+When a program is linked with a library, whether statically or using a
77
+shared library, the combination of the two is legally speaking a
78
+combined work, a derivative of the original library. The ordinary
79
+General Public License therefore permits such linking only if the
80
+entire combination fits its criteria of freedom. The Lesser General
81
+Public License permits more lax criteria for linking other code with
82
+the library.
83
+
84
+We call this license the "Lesser" General Public License because it
85
+does Less to protect the user's freedom than the ordinary General
86
+Public License. It also provides other free software developers Less
87
+of an advantage over competing non-free programs. These disadvantages
88
+are the reason we use the ordinary General Public License for many
89
+libraries. However, the Lesser license provides advantages in certain
90
+special circumstances.
91
+
92
+For example, on rare occasions, there may be a special need to
93
+encourage the widest possible use of a certain library, so that it
94
+becomes a de-facto standard. To achieve this, non-free programs must
95
+be allowed to use the library. A more frequent case is that a free
96
+library does the same job as widely used non-free libraries. In this
97
+case, there is little to gain by limiting the free library to free
98
+software only, so we use the Lesser General Public License.
99
+
100
+In other cases, permission to use a particular library in non-free
101
+programs enables a greater number of people to use a large body of
102
+free software. For example, permission to use the GNU C Library in
103
+non-free programs enables many more people to use the whole GNU
104
+operating system, as well as its variant, the GNU/Linux operating
105
+system.
106
+
107
+Although the Lesser General Public License is Less protective of the
108
+users' freedom, it does ensure that the user of a program that is
109
+linked with the Library has the freedom and the wherewithal to run
110
+that program using a modified version of the Library.
111
+
112
+The precise terms and conditions for copying, distribution and
113
+modification follow. Pay close attention to the difference between a
114
+"work based on the library" and a "work that uses the library". The
115
+former contains code derived from the library, whereas the latter must
116
+be combined with the library in order to run.
117
+
118
+### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
119
+
120
+**0.** This License Agreement applies to any software library or other
121
+program which contains a notice placed by the copyright holder or
122
+other authorized party saying it may be distributed under the terms of
123
+this Lesser General Public License (also called "this License"). Each
124
+licensee is addressed as "you".
125
+
126
+A "library" means a collection of software functions and/or data
127
+prepared so as to be conveniently linked with application programs
128
+(which use some of those functions and data) to form executables.
129
+
130
+The "Library", below, refers to any such software library or work
131
+which has been distributed under these terms. A "work based on the
132
+Library" means either the Library or any derivative work under
133
+copyright law: that is to say, a work containing the Library or a
134
+portion of it, either verbatim or with modifications and/or translated
135
+straightforwardly into another language. (Hereinafter, translation is
136
+included without limitation in the term "modification".)
137
+
138
+"Source code" for a work means the preferred form of the work for
139
+making modifications to it. For a library, complete source code means
140
+all the source code for all modules it contains, plus any associated
141
+interface definition files, plus the scripts used to control
142
+compilation and installation of the library.
143
+
144
+Activities other than copying, distribution and modification are not
145
+covered by this License; they are outside its scope. The act of
146
+running a program using the Library is not restricted, and output from
147
+such a program is covered only if its contents constitute a work based
148
+on the Library (independent of the use of the Library in a tool for
149
+writing it). Whether that is true depends on what the Library does and
150
+what the program that uses the Library does.
151
+
152
+**1.** You may copy and distribute verbatim copies of the Library's
153
+complete source code as you receive it, in any medium, provided that
154
+you conspicuously and appropriately publish on each copy an
155
+appropriate copyright notice and disclaimer of warranty; keep intact
156
+all the notices that refer to this License and to the absence of any
157
+warranty; and distribute a copy of this License along with the
158
+Library.
159
+
160
+You may charge a fee for the physical act of transferring a copy, and
161
+you may at your option offer warranty protection in exchange for a
162
+fee.
163
+
164
+**2.** You may modify your copy or copies of the Library or any
165
+portion of it, thus forming a work based on the Library, and copy and
166
+distribute such modifications or work under the terms of Section 1
167
+above, provided that you also meet all of these conditions:
168
+
169
+-   **a)** The modified work must itself be a software library.
170
+-   **b)** You must cause the files modified to carry prominent
171
+    notices stating that you changed the files and the date of
172
+    any change.
173
+-   **c)** You must cause the whole of the work to be licensed at no
174
+    charge to all third parties under the terms of this License.
175
+-   **d)** If a facility in the modified Library refers to a function
176
+    or a table of data to be supplied by an application program that
177
+    uses the facility, other than as an argument passed when the
178
+    facility is invoked, then you must make a good faith effort to
179
+    ensure that, in the event an application does not supply such
180
+    function or table, the facility still operates, and performs
181
+    whatever part of its purpose remains meaningful.
182
+
183
+    (For example, a function in a library to compute square roots has
184
+    a purpose that is entirely well-defined independent of
185
+    the application. Therefore, Subsection 2d requires that any
186
+    application-supplied function or table used by this function must
187
+    be optional: if the application does not supply it, the square
188
+    root function must still compute square roots.)
189
+
190
+These requirements apply to the modified work as a whole. If
191
+identifiable sections of that work are not derived from the Library,
192
+and can be reasonably considered independent and separate works in
193
+themselves, then this License, and its terms, do not apply to those
194
+sections when you distribute them as separate works. But when you
195
+distribute the same sections as part of a whole which is a work based
196
+on the Library, the distribution of the whole must be on the terms of
197
+this License, whose permissions for other licensees extend to the
198
+entire whole, and thus to each and every part regardless of who wrote
199
+it.
200
+
201
+Thus, it is not the intent of this section to claim rights or contest
202
+your rights to work written entirely by you; rather, the intent is to
203
+exercise the right to control the distribution of derivative or
204
+collective works based on the Library.
205
+
206
+In addition, mere aggregation of another work not based on the Library
207
+with the Library (or with a work based on the Library) on a volume of
208
+a storage or distribution medium does not bring the other work under
209
+the scope of this License.
210
+
211
+**3.** You may opt to apply the terms of the ordinary GNU General
212
+Public License instead of this License to a given copy of the Library.
213
+To do this, you must alter all the notices that refer to this License,
214
+so that they refer to the ordinary GNU General Public License, version
215
+2, instead of to this License. (If a newer version than version 2 of
216
+the ordinary GNU General Public License has appeared, then you can
217
+specify that version instead if you wish.) Do not make any other
218
+change in these notices.
219
+
220
+Once this change is made in a given copy, it is irreversible for that
221
+copy, so the ordinary GNU General Public License applies to all
222
+subsequent copies and derivative works made from that copy.
223
+
224
+This option is useful when you wish to copy part of the code of the
225
+Library into a program that is not a library.
226
+
227
+**4.** You may copy and distribute the Library (or a portion or
228
+derivative of it, under Section 2) in object code or executable form
229
+under the terms of Sections 1 and 2 above provided that you accompany
230
+it with the complete corresponding machine-readable source code, which
231
+must be distributed under the terms of Sections 1 and 2 above on a
232
+medium customarily used for software interchange.
233
+
234
+If distribution of object code is made by offering access to copy from
235
+a designated place, then offering equivalent access to copy the source
236
+code from the same place satisfies the requirement to distribute the
237
+source code, even though third parties are not compelled to copy the
238
+source along with the object code.
239
+
240
+**5.** A program that contains no derivative of any portion of the
241
+Library, but is designed to work with the Library by being compiled or
242
+linked with it, is called a "work that uses the Library". Such a work,
243
+in isolation, is not a derivative work of the Library, and therefore
244
+falls outside the scope of this License.
245
+
246
+However, linking a "work that uses the Library" with the Library
247
+creates an executable that is a derivative of the Library (because it
248
+contains portions of the Library), rather than a "work that uses the
249
+library". The executable is therefore covered by this License. Section
250
+6 states terms for distribution of such executables.
251
+
252
+When a "work that uses the Library" uses material from a header file
253
+that is part of the Library, the object code for the work may be a
254
+derivative work of the Library even though the source code is not.
255
+Whether this is true is especially significant if the work can be
256
+linked without the Library, or if the work is itself a library. The
257
+threshold for this to be true is not precisely defined by law.
258
+
259
+If such an object file uses only numerical parameters, data structure
260
+layouts and accessors, and small macros and small inline functions
261
+(ten lines or less in length), then the use of the object file is
262
+unrestricted, regardless of whether it is legally a derivative work.
263
+(Executables containing this object code plus portions of the Library
264
+will still fall under Section 6.)
265
+
266
+Otherwise, if the work is a derivative of the Library, you may
267
+distribute the object code for the work under the terms of Section 6.
268
+Any executables containing that work also fall under Section 6,
269
+whether or not they are linked directly with the Library itself.
270
+
271
+**6.** As an exception to the Sections above, you may also combine or
272
+link a "work that uses the Library" with the Library to produce a work
273
+containing portions of the Library, and distribute that work under
274
+terms of your choice, provided that the terms permit modification of
275
+the work for the customer's own use and reverse engineering for
276
+debugging such modifications.
277
+
278
+You must give prominent notice with each copy of the work that the
279
+Library is used in it and that the Library and its use are covered by
280
+this License. You must supply a copy of this License. If the work
281
+during execution displays copyright notices, you must include the
282
+copyright notice for the Library among them, as well as a reference
283
+directing the user to the copy of this License. Also, you must do one
284
+of these things:
285
+
286
+-   **a)** Accompany the work with the complete corresponding
287
+    machine-readable source code for the Library including whatever
288
+    changes were used in the work (which must be distributed under
289
+    Sections 1 and 2 above); and, if the work is an executable linked
290
+    with the Library, with the complete machine-readable "work that
291
+    uses the Library", as object code and/or source code, so that the
292
+    user can modify the Library and then relink to produce a modified
293
+    executable containing the modified Library. (It is understood that
294
+    the user who changes the contents of definitions files in the
295
+    Library will not necessarily be able to recompile the application
296
+    to use the modified definitions.)
297
+-   **b)** Use a suitable shared library mechanism for linking with
298
+    the Library. A suitable mechanism is one that (1) uses at run time
299
+    a copy of the library already present on the user's computer
300
+    system, rather than copying library functions into the executable,
301
+    and (2) will operate properly with a modified version of the
302
+    library, if the user installs one, as long as the modified version
303
+    is interface-compatible with the version that the work was
304
+    made with.
305
+-   **c)** Accompany the work with a written offer, valid for at least
306
+    three years, to give the same user the materials specified in
307
+    Subsection 6a, above, for a charge no more than the cost of
308
+    performing this distribution.
309
+-   **d)** If distribution of the work is made by offering access to
310
+    copy from a designated place, offer equivalent access to copy the
311
+    above specified materials from the same place.
312
+-   **e)** Verify that the user has already received a copy of these
313
+    materials or that you have already sent this user a copy.
314
+
315
+For an executable, the required form of the "work that uses the
316
+Library" must include any data and utility programs needed for
317
+reproducing the executable from it. However, as a special exception,
318
+the materials to be distributed need not include anything that is
319
+normally distributed (in either source or binary form) with the major
320
+components (compiler, kernel, and so on) of the operating system on
321
+which the executable runs, unless that component itself accompanies
322
+the executable.
323
+
324
+It may happen that this requirement contradicts the license
325
+restrictions of other proprietary libraries that do not normally
326
+accompany the operating system. Such a contradiction means you cannot
327
+use both them and the Library together in an executable that you
328
+distribute.
329
+
330
+**7.** You may place library facilities that are a work based on the
331
+Library side-by-side in a single library together with other library
332
+facilities not covered by this License, and distribute such a combined
333
+library, provided that the separate distribution of the work based on
334
+the Library and of the other library facilities is otherwise
335
+permitted, and provided that you do these two things:
336
+
337
+-   **a)** Accompany the combined library with a copy of the same work
338
+    based on the Library, uncombined with any other
339
+    library facilities. This must be distributed under the terms of
340
+    the Sections above.
341
+-   **b)** Give prominent notice with the combined library of the fact
342
+    that part of it is a work based on the Library, and explaining
343
+    where to find the accompanying uncombined form of the same work.
344
+
345
+**8.** You may not copy, modify, sublicense, link with, or distribute
346
+the Library except as expressly provided under this License. Any
347
+attempt otherwise to copy, modify, sublicense, link with, or
348
+distribute the Library is void, and will automatically terminate your
349
+rights under this License. However, parties who have received copies,
350
+or rights, from you under this License will not have their licenses
351
+terminated so long as such parties remain in full compliance.
352
+
353
+**9.** You are not required to accept this License, since you have not
354
+signed it. However, nothing else grants you permission to modify or
355
+distribute the Library or its derivative works. These actions are
356
+prohibited by law if you do not accept this License. Therefore, by
357
+modifying or distributing the Library (or any work based on the
358
+Library), you indicate your acceptance of this License to do so, and
359
+all its terms and conditions for copying, distributing or modifying
360
+the Library or works based on it.
361
+
362
+**10.** Each time you redistribute the Library (or any work based on
363
+the Library), the recipient automatically receives a license from the
364
+original licensor to copy, distribute, link with or modify the Library
365
+subject to these terms and conditions. You may not impose any further
366
+restrictions on the recipients' exercise of the rights granted herein.
367
+You are not responsible for enforcing compliance by third parties with
368
+this License.
369
+
370
+**11.** If, as a consequence of a court judgment or allegation of
371
+patent infringement or for any other reason (not limited to patent
372
+issues), conditions are imposed on you (whether by court order,
373
+agreement or otherwise) that contradict the conditions of this
374
+License, they do not excuse you from the conditions of this License.
375
+If you cannot distribute so as to satisfy simultaneously your
376
+obligations under this License and any other pertinent obligations,
377
+then as a consequence you may not distribute the Library at all. For
378
+example, if a patent license would not permit royalty-free
379
+redistribution of the Library by all those who receive copies directly
380
+or indirectly through you, then the only way you could satisfy both it
381
+and this License would be to refrain entirely from distribution of the
382
+Library.
383
+
384
+If any portion of this section is held invalid or unenforceable under
385
+any particular circumstance, the balance of the section is intended to
386
+apply, and the section as a whole is intended to apply in other
387
+circumstances.
388
+
389
+It is not the purpose of this section to induce you to infringe any
390
+patents or other property right claims or to contest validity of any
391
+such claims; this section has the sole purpose of protecting the
392
+integrity of the free software distribution system which is
393
+implemented by public license practices. Many people have made
394
+generous contributions to the wide range of software distributed
395
+through that system in reliance on consistent application of that
396
+system; it is up to the author/donor to decide if he or she is willing
397
+to distribute software through any other system and a licensee cannot
398
+impose that choice.
399
+
400
+This section is intended to make thoroughly clear what is believed to
401
+be a consequence of the rest of this License.
402
+
403
+**12.** If the distribution and/or use of the Library is restricted in
404
+certain countries either by patents or by copyrighted interfaces, the
405
+original copyright holder who places the Library under this License
406
+may add an explicit geographical distribution limitation excluding
407
+those countries, so that distribution is permitted only in or among
408
+countries not thus excluded. In such case, this License incorporates
409
+the limitation as if written in the body of this License.
410
+
411
+**13.** The Free Software Foundation may publish revised and/or new
412
+versions of the Lesser General Public License from time to time. Such
413
+new versions will be similar in spirit to the present version, but may
414
+differ in detail to address new problems or concerns.
415
+
416
+Each version is given a distinguishing version number. If the Library
417
+specifies a version number of this License which applies to it and
418
+"any later version", you have the option of following the terms and
419
+conditions either of that version or of any later version published by
420
+the Free Software Foundation. If the Library does not specify a
421
+license version number, you may choose any version ever published by
422
+the Free Software Foundation.
423
+
424
+**14.** If you wish to incorporate parts of the Library into other
425
+free programs whose distribution conditions are incompatible with
426
+these, write to the author to ask for permission. For software which
427
+is copyrighted by the Free Software Foundation, write to the Free
428
+Software Foundation; we sometimes make exceptions for this. Our
429
+decision will be guided by the two goals of preserving the free status
430
+of all derivatives of our free software and of promoting the sharing
431
+and reuse of software generally.
432
+
433
+**NO WARRANTY**
434
+
435
+**15.** BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
436
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
437
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
438
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
439
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
440
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
441
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
442
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
443
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
444
+
445
+**16.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
446
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
447
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
448
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
449
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
450
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
451
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
452
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
453
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
454
+DAMAGES.
455
+
456
+### END OF TERMS AND CONDITIONS
457
+
458
+### How to Apply These Terms to Your New Libraries
459
+
460
+If you develop a new library, and you want it to be of the greatest
461
+possible use to the public, we recommend making it free software that
462
+everyone can redistribute and change. You can do so by permitting
463
+redistribution under these terms (or, alternatively, under the terms
464
+of the ordinary General Public License).
465
+
466
+To apply these terms, attach the following notices to the library. It
467
+is safest to attach them to the start of each source file to most
468
+effectively convey the exclusion of warranty; and each file should
469
+have at least the "copyright" line and a pointer to where the full
470
+notice is found.
471
+
472
+    one line to give the library's name and an idea of what it does.
473
+    Copyright (C) year  name of author
474
+
475
+    This library is free software; you can redistribute it and/or
476
+    modify it under the terms of the GNU Lesser General Public
477
+    License as published by the Free Software Foundation; either
478
+    version 2.1 of the License, or (at your option) any later version.
479
+
480
+    This library is distributed in the hope that it will be useful,
481
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
482
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
483
+    Lesser General Public License for more details.
484
+
485
+    You should have received a copy of the GNU Lesser General Public
486
+    License along with this library; if not, write to the Free Software
487
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
488
+
489
+Also add information on how to contact you by electronic and paper
490
+mail.
491
+
492
+You should also get your employer (if you work as a programmer) or
493
+your school, if any, to sign a "copyright disclaimer" for the library,
494
+if necessary. Here is a sample; alter the names:
495
+
496
+    Yoyodyne, Inc., hereby disclaims all copyright interest in
497
+    the library `Frob' (a library for tweaking knobs) written
498
+    by James Random Hacker.
499
+
500
+    signature of Ty Coon, 1 April 1990
501
+    Ty Coon, President of Vice
502
+
503
+That's all there is to it!

+ 8
- 0
Makefile View File

@@ -0,0 +1,8 @@
1
+# inigrep - Grep them INIs
2
+# See LICENSE.md file for copyright and license details.
3
+
4
+MKIT_DIR=utils/mkit
5
+include $(MKIT_DIR)/mkit.mk
6
+
7
+TF_DIR=utils/tfkit
8
+include $(TF_DIR)/tfkit.mk

+ 4
- 0
README.md View File

@@ -0,0 +1,4 @@
1
+inigrep
2
+=======
3
+
4
+Grep them INIs

+ 38
- 0
mkit.ini View File

@@ -0,0 +1,38 @@
1
+[project]
2
+    version     = 0.11.0
3
+    name        = inigrep
4
+    tagline     = Grep them INIs
5
+    pkgname     = shellfu-bash-inigrep
6
+    maintainer  = Alois Mahdal <netvor+inigrep@vornet.cz>
7
+    vcs_browser = https://github.com/AloisMahdal/shellfu-bash-inigrep
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  = tests
19
+    tarball  = utils
20
+    rpmstuff = packaging/template.spec
21
+    debstuff = packaging/debian
22
+
23
+[ENV]
24
+    PREFIX = /usr/local
25
+
26
+[roots]
27
+    doc   = [ENV:PREFIX]/share/doc/shellfu-bash-inigrep
28
+    sfmod = [ENV:PREFIX]/share/shellfu/include-bash
29
+
30
+[macros]
31
+    __SHELLFU_MODNAME__ = inigrep
32
+    __SHELLFU_MODDESC__ = inigrep is a Shellfu/Bash module for reading INI-like files.
33
+
34
+[files]
35
+    doc   = README.md
36
+    sfmod = src/inigrep.sh
37
+
38
+#mkit version=0.0.31

+ 5
- 0
packaging/debian/changelog View File

@@ -0,0 +1,5 @@
1
+__MKIT_PROJ_PKGNAME__ (__MKIT_PROJ_VERSION__-1) UNRELEASED; urgency=medium
2
+
3
+  * Initial release. (Closes: #XXXXXX)
4
+
5
+ -- __MKIT_PROJ_MAINTAINER__  Sat, 28 Apr 2018 00:06:58 +0200

+ 1
- 0
packaging/debian/compat View File

@@ -0,0 +1 @@
1
+9

+ 24
- 0
packaging/debian/control View File

@@ -0,0 +1,24 @@
1
+Source: __MKIT_PROJ_PKGNAME__
2
+Maintainer: __MKIT_PROJ_MAINTAINER__
3
+Vcs-Browser: __MKIT_PROJ_VCS_BROWSER__
4
+Section: misc
5
+Priority: extra
6
+Standards-Version: 3.9.2
7
+Build-Depends:
8
+ debhelper (>= 9),
9
+ shellfu (>= 0.11),
10
+ shellfu (<< 0.12),
11
+ shellfu-bash,
12
+ shellfu-bash-pretty,
13
+
14
+Package: __MKIT_PROJ_PKGNAME__
15
+Architecture: all
16
+Depends:
17
+ shellfu (>= 0.11),
18
+ shellfu (<< 0.12),
19
+ shellfu-bash,
20
+ shellfu-bash-pretty,
21
+Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__
22
+ __SHELLFU_MODDESC__
23
+
24
+# control file built with MKit __MKIT_SELF_VERSION__

+ 1
- 0
packaging/debian/copyright View File

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

+ 1
- 0
packaging/debian/install View File

@@ -0,0 +1 @@
1
+/usr/share/shellfu/include-bash/__SHELLFU_MODNAME__.sh

+ 14
- 0
packaging/debian/rules View File

@@ -0,0 +1,14 @@
1
+#!/usr/bin/make -f
2
+
3
+%:
4
+
5
+	dh $@
6
+
7
+override_dh_auto_install:
8
+
9
+	make install PREFIX=/usr DESTDIR=debian/tmp
10
+
11
+override_dh_auto_test:
12
+	make install PREFIX=/usr DESTDIR=debian/tmp
13
+	make test \
14
+		SHELLFU_PATH=$(shell pwd)/debian/tmp/usr/share/shellfu/include-bash

+ 1
- 0
packaging/debian/source/format View File

@@ -0,0 +1 @@
1
+3.0 (quilt)

+ 44
- 0
packaging/template.spec View File

@@ -0,0 +1,44 @@
1
+%global sfincb %{_datadir}/shellfu/include-bash
2
+%global sfmodn __SHELLFU_MODNAME__
3
+%global shellfu_req shellfu >= 0.11.0, shellfu < 0.12
4
+
5
+Name:       __MKIT_PROJ_PKGNAME__
6
+Version:    __MKIT_PROJ_VERSION__
7
+Release:    1%{?dist}
8
+Summary:    __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__
9
+URL:        __MKIT_PROJ_VCS_BROWSER__
10
+License:    LGPLv2
11
+Source0:    %{name}-%{version}.tar.gz
12
+BuildArch:  noarch
13
+BuildRequires: %shellfu_req
14
+BuildRequires: perl
15
+BuildRequires: shellfu-bash-pretty
16
+
17
+Requires: %shellfu_req
18
+Requires: perl
19
+Requires: shellfu-bash
20
+Requires: shellfu-bash-pretty
21
+%description
22
+__SHELLFU_MODDESC__
23
+
24
+%prep
25
+%setup -q
26
+
27
+%build
28
+make %{?_smp_mflags} PREFIX=/usr
29
+
30
+%install
31
+%make_install PREFIX=/usr
32
+
33
+%check
34
+make test \
35
+    SHELLFU_PATH=%{buildroot}/%{_datadir}/shellfu/include-bash
36
+
37
+%files
38
+%doc %{_docdir}/%{name}/README.md
39
+%{sfincb}/%{sfmodn}.sh
40
+
41
+
42
+%changelog
43
+
44
+# specfile built with MKit __MKIT_SELF_VERSION__

+ 346
- 0
src/inigrep.sh.skel View File

@@ -0,0 +1,346 @@
1
+#!/bin/bash
2
+
3
+shellfu import pretty
4
+
5
+#
6
+# grep for (some) INIs
7
+#
8
+# inigrep is designed to read a particular simplistic dialect of
9
+# INI configuration files.  In a sense, it can be considered as
10
+# a "grep for INIs", in that rather than parsing the file into
11
+# a typed memory structure for later access, it passes file each
12
+# time a query is done, and spits out relevant parts; treating
13
+# everything as text.  Hence, it's not intended as replacement
14
+# for a full-blown configuration system but rather a quick & dirty
15
+# "swiss axe" for quick & dirty scripts.
16
+#
17
+# That's not to say that you cannot do things nicely; but don't
18
+# count on speed -- well since you're using bash you obviously
19
+# don't -- and compliance -- simple things are simple, but there
20
+# are a bit unusual pitfalls.
21
+#
22
+#
23
+# The format by examples
24
+# ----------------------
25
+#
26
+# The most basic example understood by inigrep is identical
27
+# to most INI formats:
28
+#
29
+#     # Let's call this simple.ini
30
+#
31
+#     [foo]
32
+#         bar = baz
33
+#         qux = quux
34
+#
35
+#     [corge]
36
+#         grault = graply
37
+#
38
+# Structure here is obvious: two sections named `foo` and `corge`,
39
+# the first one has two key/value pairs and the other has one pair.
40
+#
41
+# Getting values from this file is trivial:
42
+#
43
+#     inigrep foo.bar simple.ini
44
+#     inigrep foo.qux simple.ini
45
+#     inigrep corge.grault simple.ini
46
+#
47
+# would list `baz`, `quux` and `graply`.
48
+#
49
+# This is where 80% of use cases are covered.
50
+#
51
+#
52
+# Multi-line
53
+# ----------
54
+#
55
+# Multi-line values are rather unusual but very simple:
56
+#
57
+#     [lipsum]
58
+#
59
+#         latin = Lorem ipsum dolor sit amet, consectetur adipiscing
60
+#         latin = elit, sed do eiusmod tempor incididunt ut labore et
61
+#         latin = dolore magna aliqua. Ut enim ad minim veniam, quis
62
+#         latin = ...
63
+#
64
+#         english = [32] But I must explain to you how all this mistaken
65
+#         english = idea of denouncing of a pleasure and praising pain
66
+#         english = was born and I will give you a complete account of
67
+#         english = ...
68
+#
69
+# This file can be read as:
70
+#
71
+#     inigrep lipsum.latin lipsum.ini
72
+#     inigrep lipsum.english lipsum.ini
73
+#
74
+#
75
+# Exploration
76
+# -----------
77
+#
78
+# Other than basic value retrieval, inigrep allows you to look around
79
+# first. For example, to list all keypaths available in a file:
80
+#
81
+#     inigrep -P simple.ini
82
+#
83
+# In case of simple.ini, this would print:
84
+#
85
+#     foo.bar
86
+#     foo.qux
87
+#     corge.grault
88
+#
89
+# Similarly:
90
+#
91
+#     inigrep -S simple.ini
92
+#
93
+# would list just the section names:
94
+#
95
+#     foo
96
+#     corge
97
+#
98
+# and
99
+#
100
+#     inigrep -K foo simple.ini
101
+#
102
+# would list all keys from section 'foo'
103
+#
104
+#     bar
105
+#     qux
106
+#
107
+
108
+
109
+_inigrep__fltcmt() {
110
+    #
111
+    # Just strip comments
112
+    #
113
+    perl -ne '
114
+        chomp;
115
+        next if m/^[[:space:]]*[#;]/;
116
+        s/  *#.*//;
117
+        s/  *;.*//;
118
+        print "$_\n" if $_;
119
+    '
120
+}
121
+
122
+
123
+_inigrep__fltkey() {
124
+    #
125
+    # Filter values from `key = value pairs`
126
+    #
127
+    # In listing mode, prints *key names* instead
128
+    #
129
+    local line      # every line
130
+    local key       # key name part
131
+    local value     # name part
132
+    while IFS= read -r line;                        # '  key  =  val  '
133
+    do
134
+        line="${line##*([[:space:]])}"              # line='key  =  val  '
135
+        key="${line%%*([[:space:]])=*}"             # key='key'
136
+        value="${line##$key*([[:space:]])=}"        # value='  val  '
137
+        $StrictMode || value="${value##*([[:space:]])}" # value='val'
138
+        test "$key" = "$WantedKey" || continue
139
+        $ListingMode || echos "$value"
140
+        $ListingMode && echos "$line"
141
+    done
142
+}
143
+
144
+
145
+_inigrep__fltsct() {
146
+    #
147
+    # Filter out only the wanted section body
148
+    #
149
+    # In listing mode prints also section name
150
+    #
151
+    local sct_ok=false  # is this the section we want?
152
+    local sct_name      # wanted section name
153
+    local line          # current line
154
+    while IFS= read -r line;
155
+    do
156
+        if [[ $line =~ ^[[:space:]]*\[[^]]*\].* ]];     # IOW: 'spaces[name]anything'
157
+        then
158
+            # hack out only the name between '[' and ']'
159
+            sct_name=$line
160
+            sct_name=${sct_name##*([[:space:]])[}   # drop leading space
161
+            sct_name=${sct_name%%]*}                # and trailing anything
162
+            if test "$sct_name" == "$WantedSection";
163
+            then
164
+                sct_ok=true;                            # our section
165
+                $ListingMode && echos "[$sct_name]";    # inform lister
166
+            else
167
+                sct_ok=false
168
+            fi
169
+            continue
170
+        else
171
+            $sct_ok || continue
172
+            $StrictMode || line="${line##*([[:space:]])}"
173
+            echos "$line"
174
+        fi
175
+    done
176
+}
177
+
178
+
179
+_inigrep__fltlst() {
180
+    #
181
+    # Filter only section/keys/path names from the stream
182
+    #
183
+    local line=""           # current line
184
+    local key="__NOKEY__"   # current key
185
+    local sct="__NOSCT__"   # current section
186
+    while read -r line;
187
+    do
188
+        case "$line" in
189
+            \[*\]) sct=${line#[}; sct=${sct%]}; key=__NOKEY__   ;;
190
+            *=*)   key="${line%%*([[:space:]])=*}" ;;   # key='key'
191
+            *)     continue ;;                          # whatever
192
+        esac
193
+        case "$Engine:$sct:$key" in
194
+            lspth:__NOSCT__:*)         echos "$sct.$key" ;;
195
+            lspth:*:__NOKEY__)         continue          ;;
196
+            lspth:*:*)                 echos "$sct.$key" ;;
197
+            lssct:__NOSCT__:*)         echos "$sct"      ;;
198
+            lssct:*:__NOKEY__)         echos "$sct"      ;;
199
+            lssct:*:*)                 continue          ;;
200
+            lskey:__NOSCT__:__NOKEY__) continue          ;;
201
+            lskey:__NOSCT__:*)         echos "$key"      ;;
202
+            lskey:*:__NOKEY__)         continue          ;;
203
+            lskey:*:*)                 echos "$key"      ;;
204
+        esac
205
+    done
206
+}
207
+
208
+
209
+_inigrep__query() {
210
+    #
211
+    # Query INI stream composed of files at $@ or stdin
212
+    #
213
+    # Compose filter pipe of potential parts and run it.
214
+    #
215
+    local pipe=""               # filter pipe
216
+    local ListingMode=false     # listing mode on?
217
+    local StrictMode=false      # strict mode on?
218
+    local ifile                 # current input file
219
+    local restore_shopt         # shopt backup (executable code)
220
+    case $Engine in
221
+        raw) StrictMode=true ;;
222
+        ls*) ListingMode=true ;;
223
+    esac
224
+    # which will come first? prefix all and strip the first prefix
225
+    #
226
+    $StrictMode                 || pipe+=" | _inigrep__fltcmt"
227
+    test -n "$WantedSection"    && pipe+=" | _inigrep__fltsct"
228
+    test -n "$WantedKey"        && pipe+=" | _inigrep__fltkey"
229
+    $ListingMode                && pipe+=" | _inigrep__fltlst"
230
+    $StrictMode                 || pipe+=" | grep ."
231
+    pipe="${pipe# | }"
232
+    test -z "$pipe" && pipe="cat"   # possible with raw mode and dot wildcard
233
+    debug -v pipe
234
+    # pray and run
235
+    #
236
+    restore_shopt=$(shopt -p extglob)
237
+    shopt -s extglob
238
+    for ifile in "$@";
239
+    do
240
+        case "$ifile" in
241
+            -) eval "$pipe" ;;
242
+            *) <"$ifile" eval "$pipe" ;;
243
+        esac
244
+    done
245
+    $restore_shopt
246
+}
247
+
248
+_inigrep__validate_ks() {
249
+    #
250
+    # Check $WantedSection ans $WantedKey for invalid chars and warn
251
+    #
252
+    case $WantedKey in
253
+        *\\*) warn "invalid char '\\' in key name: $WantedKey"; return 1 ;;
254
+        *[*)  warn "invalid char '[' in key name: $WantedKey"; return 1 ;;
255
+        *=*)  warn "invalid char '=' in key name: $WantedKey"; return 1 ;;
256
+    esac
257
+    case $WantedSection in
258
+        *]*)  warn "invalid char ']' in section name: $WantedSection"; return 1 ;;
259
+    esac
260
+}
261
+
262
+inigrep() {
263
+    #
264
+    # Query INI file(s) for data
265
+    #
266
+    # Usage:
267
+    #
268
+    #     inigrep [-1] [section].[key] [file]...
269
+    #     inigrep [-1] -e|--basic [section].[key] [file]...
270
+    #     inigrep [-1] -r|--raw [section].[key] [file]...
271
+    #     inigrep [-1] -K|--lskey section [file]...
272
+    #     inigrep [-1] -S|--lssct [file]...
273
+    #     inigrep [-1] -P|--lspth [file]...
274
+    #
275
+    # First form implies the basic engine.
276
+    #
277
+    # Option *-r* switches to raw mode, in which comments,
278
+    # empty lines and whitespace are all preserved in applicable
279
+    # contexts.
280
+    #
281
+    # Key *keypath* consists of section name and key name delimited
282
+    # by dot.  Note that keypath may contain dots but key may not.
283
+    #
284
+    # If *file* is not given or is a single dash, standard input
285
+    # is read.  Note that standard input is not duplicated in case
286
+    # of multiple dashes.
287
+    #
288
+    # If suitable key is found at multiple lines, all values
289
+    # are printed, which allows for creating multi-line values.
290
+    # Providing *-1* argument, however, always prints only one
291
+    # line.
292
+    #
293
+    # Options -K, -S and -P can be used for inspecting file structure;
294
+    # -K needs an argument of section name and will list all keys from
295
+    # that section.  -S will list all sections and -P will list all
296
+    # existing keypaths.
297
+    #
298
+    #
299
+    # #### Examples ####
300
+    #
301
+    # Having INI file such as
302
+    #
303
+    #     [foo]
304
+    #     bar=baz
305
+    #     quux=qux
306
+    #     quux=qux2
307
+    #     quux=qux3
308
+    #
309
+    #  *  `inigrep foo.bar ./file.ini` gives "bar".
310
+    #  *  `inigrep foo.quux ./file.ini` gives three lines "qux", "qux2"
311
+    #     and "qux3".
312
+    #  *  `inigrep -P ./file.ini` gives two lines "foo.bar" and "foo.quux".
313
+    #  *  `inigrep -K foo ./file.ini` gives two lines "bar" and "quux".
314
+    #  *  `inigrep -S ./file.ini` gives "foo".
315
+    #
316
+    local kpath=""              # desired key path
317
+    local one_line=false        # limit to single line
318
+    local Engine=ini            # engine: ini,raw,lspth,lssct,lskey
319
+    local WantedSection=""      # desired section name (in case of listing)
320
+    local WantedKey=""          # desired key name
321
+    while true; do case $1 in
322
+        -1|--one-line)  one_line=true;              shift        ;;
323
+        -e|--basic)     Engine=ini;    kpath="$2";  shift; break ;;
324
+        -r|--raw)       Engine=raw;    kpath="$2";  shift; break ;;
325
+        -K|--lskey)     Engine=lskey;  kpath="$2."; shift; break ;;
326
+        -P|--lspth)     Engine=lspth;  kpath=".";          break ;;
327
+        -S|--lssct)     Engine=lssct;  kpath=".";          break ;;
328
+        *)                                                 break ;;
329
+    esac done
330
+    test -n "$kpath" || kpath="$1" && shift
331
+    test -z "$*" && set -- -
332
+    debug -v one_line Engine kpath
333
+    debug "\$*='$*'"
334
+    WantedKey="${kpath##*.}"
335
+    WantedSection="${kpath%.$WantedKey}"
336
+    _inigrep__validate_ks || return 2
337
+    debug -v WantedKey WantedSection
338
+    if $one_line;
339
+    then
340
+        _inigrep__query "$@" | head -1
341
+    else
342
+        _inigrep__query "$@"
343
+    fi
344
+}
345
+
346
+#shellfu module-version=__MKIT_PROJ_VERSION__

+ 3
- 0
tests/TF_HEADER View File

@@ -0,0 +1,3 @@
1
+#!/bin/bash
2
+. "$(sfpath)" || exit 3
3
+echo "version: $(shellfu version inigrep)"

+ 198
- 0
tests/inigrep_chars/TF_RUN View File

@@ -0,0 +1,198 @@
1
+#!/bin/bash
2
+
3
+. "$TF_DIR/include/subtest.sh"
4
+. "$TF_DIR/include/tools.sh"
5
+
6
+. "$(sfpath)" || tf_exit_error "failed to init shellfu"
7
+export PRETTY=plain
8
+shellfu import inigrep  || tf_exit_error "failed to import inigrep"
9
+
10
+#shellcheck disable=SC2016
11
+specchar() {
12
+    #
13
+    # List all "special" chars and their names
14
+    #
15
+    local what=$1
16
+    {
17
+        echo ' space'
18
+        echo '!exclamation'
19
+        echo '"quote'
20
+        echo '#hash'
21
+        echo '$dollar'
22
+        echo '%percent'
23
+        echo '&ampersand'
24
+        echo "'apostrophe"
25
+        echo '(lbracket'
26
+        echo ')rbracket'
27
+        echo '*asterisk'
28
+        echo '+plus'
29
+        echo ',comma'
30
+        echo '-minus'
31
+        echo '.dot'
32
+        echo '/slash'
33
+        echo ':colon'
34
+        echo ';semicolon'
35
+        echo '<lt'
36
+        echo '=equal'
37
+        echo '>gt'
38
+        echo '?question'
39
+        echo '@at'
40
+        echo '[lsbracket'
41
+        echo '\backslash'
42
+        echo ']rsbracket'
43
+        echo '^caret'
44
+        echo '_underscore'
45
+        echo '`backtick'
46
+        echo '{lcbracket'
47
+        echo '|pipe'
48
+        echo '}rcbracket'
49
+        echo '~tilde'
50
+#       echo '☯yinyang'
51
+    } \
52
+      | case $what in
53
+            CHARS)  grep -o ^.       ;;
54
+            NAMES)  sed s/.//        ;;
55
+            "")     cat              ;;
56
+            *)      grep -x ".$what" \
57
+                      | grep -o ^.   ;;
58
+        esac
59
+}
60
+
61
+tf_enum_subtests() {
62
+    #
63
+    # Enumerate test names
64
+    #
65
+    {
66
+        specchar NAMES \
67
+          | sed s/^/k_/
68
+        specchar NAMES \
69
+          | sed s/^/s_/
70
+        specchar NAMES \
71
+          | sed s/^/v_/
72
+    } \
73
+      | grep -vxF k_dot
74
+}
75
+
76
+tf_do_subtest() {
77
+    local t_name=$1
78
+    local t_cmd
79
+    local char
80
+    local charname=${t_name:2}
81
+    local o_out="oracle/$t_name.stdout"
82
+    local o_err="oracle/$t_name.stderr"
83
+    local o_es=0
84
+    local t_in="test/$t_name.stdin"
85
+    char=$(specchar "$charname")
86
+    echo -n > "$o_out"
87
+    echo -n > "$o_err"
88
+
89
+    # Variables marked with "a" ant "z" are traps, what we want inigrep to
90
+    # catch is placed in $key_tt, $section_t or $value_tt
91
+    #
92
+    local section_a="section_a"
93
+    local section_t="section_t"
94
+    local section_z="section_z"
95
+    local key_aa="key_aa"
96
+    local key_az="key_az"
97
+    local key_ta="key_ta"
98
+    local key_tt="key_tt"
99
+    local key_tz="key_tz"
100
+    local key_za="key_za"
101
+    local key_zz="key_zz"
102
+    local value_aa="value_aa"
103
+    local value_az="value_az"
104
+    local value_ta="value_ta"
105
+    local value_tt="value_tt"
106
+    local value_tz="value_tz"
107
+    local value_za="value_za"
108
+    local value_zz="value_zz"
109
+
110
+    # test input
111
+    #
112
+    case $t_name in
113
+        v_*)
114
+            value_ta="anoter value with $charname ($char) inside"
115
+            value_tt="value with $charname ($char) inside"
116
+            value_tz="yet anoter value with $charname ($char) inside"
117
+            ;;
118
+        s_*)
119
+            section_a="another_section_with_${charname}${char}inside"
120
+            section_t="section_with_${charname}${char}inside"
121
+            section_z="yet_another_section_with_${charname}${char}inside"
122
+            value_tt="value from section with $charname inside"
123
+            ;;
124
+        k_*)
125
+            key_ta="another_key_with_${charname}${char}inside"
126
+            key_tt="key_with_${charname}${char}inside"
127
+            key_tz="yet_another_key_with_${charname}${char}inside"
128
+            value_tt="value for key with $charname inside"
129
+            ;;
130
+    esac
131
+    {
132
+        echo "#t_name:   $t_name"
133
+        echo "#charname: $charname"
134
+        echo "#char:     $char"
135
+        echo
136
+        echo "[$section_a]"
137
+        echo "    $key_aa = $value_aa"
138
+        echo "    $key_az = $value_az"
139
+        echo
140
+        echo "[$section_t]"
141
+        echo "    $key_ta = $value_ta"
142
+        echo "    $key_tt = $value_tt"  # aiming THIS; rest is traps
143
+        echo "    $key_tz = $value_tz"
144
+        echo
145
+        echo "[$section_z]"
146
+        echo "    $key_za = $value_za"
147
+        echo "    $key_zz = $value_zz"
148
+        echo
149
+    } > "$t_in"
150
+
151
+    # test command
152
+    #
153
+    case $t_name in
154
+        v_*)           t_cmd="inigrep section_t.key_tt"                               ;;
155
+        s_apostrophe)  t_cmd='inigrep "section_with_apostrophe'"'"'inside.key_tt"'    ;;
156
+        s_*)           t_cmd="inigrep 'section_with_${charname}${char}inside.key_tt'" ;;
157
+        k_apostrophe)  t_cmd='inigrep "section_t.key_with_apostrophe'"'"'inside"'     ;;
158
+        k_*)           t_cmd="inigrep 'section_t.key_with_${charname}${char}inside'"  ;;
159
+    esac
160
+
161
+    # oracle output
162
+    #
163
+    case $t_name in
164
+        v_*)    echo "value with $charname ($char) inside"      ;;
165
+        s_*)    echo "value from section with $charname inside" ;;
166
+        k_*)    echo "value for key with $charname inside"      ;;
167
+    esac > "$o_out"
168
+
169
+    case $t_name in
170
+        k_backslash)
171
+            o_es=2
172
+            echo -n '' > "$o_out"
173
+            echo "invalid char '\\' in key name: $key_tt" > "$o_err"
174
+            ;;
175
+        k_equal)
176
+            o_es=2
177
+            echo -n '' > "$o_out"
178
+            echo "invalid char '=' in key name: $key_tt" > "$o_err"
179
+            ;;
180
+        k_lsbracket)
181
+            o_es=2
182
+            echo -n '' > "$o_out"
183
+            echo "invalid char '[' in key name: $key_tt" > "$o_err"
184
+            ;;
185
+        s_rsbracket)
186
+            o_es=2
187
+            echo -n '' > "$o_out"
188
+            echo "invalid char ']' in section name: $section_t" > "$o_err"
189
+            ;;
190
+    esac
191
+
192
+    # pray and...
193
+    #
194
+    tf_testflt -n "$t_name" -i "$t_in" -O "$o_out" -E "$o_err" -S $o_es "$t_cmd"
195
+}
196
+
197
+mkdir -p test oracle result
198
+tf_do_subtests

+ 67
- 0
tests/inigrep_inigrep/TF_RUN View File

@@ -0,0 +1,67 @@
1
+#!/bin/bash
2
+
3
+. "$TF_DIR/include/subtest.sh"
4
+. "$TF_DIR/include/tools.sh"
5
+
6
+. "$(sfpath)" || tf_exit_error "failed to init shellfu"
7
+shellfu import inigrep  || tf_exit_error "failed to import inigrep"
8
+
9
+tf_enum_subtests() {
10
+    echo "both_keys_and_sections"
11
+    echo "games_with_spaces"
12
+    echo "keys_only"
13
+    echo "keys_sections_spaces"
14
+#   echo "plain"            # FIXME: arguable
15
+#   echo "plain_strict"     # FIXME: arguable
16
+    echo "sections_only"
17
+    echo "tricks_with_strange_naming"
18
+    echo "strict_and_space"
19
+    echo "strict_and_tab"
20
+    echo "inlinecmt_hash"
21
+    echo "inlinecmt_sc"
22
+    echo "inlinecmt_hash_and_strict"
23
+    echo "inlinecmt_sc_and_strict"
24
+    echo "list_keys"
25
+    echo "list_paths"
26
+    echo "list_sections"
27
+    echo "list_tricky_all_keys"
28
+    echo "list_tricky_all_paths"
29
+    echo "list_tricky_all_sections"
30
+    echo "list_tricky_s1_keys"
31
+}
32
+
33
+tf_do_subtest() {
34
+    local name=$1
35
+    local t_in="test/$name.stdin"
36
+    local o_out="oracle/$name.stdout"
37
+    case $name in
38
+        inlinecmt_*)                t_in="test/inlinecmt.stdin" ;;
39
+    esac
40
+    local cmd
41
+    case $name in
42
+        both_keys_and_sections)     cmd='inigrep section1.key1' ;;
43
+        games_with_spaces)          cmd='inigrep "maybe spaced.spaced key"' ;;
44
+        keys_only)                  cmd='inigrep .key1' ;;
45
+        keys_sections_spaces)       cmd='inigrep section1.key1' ;;
46
+        plain)                      cmd='inigrep .' ;;
47
+        plain_strict)               cmd='inigrep -r .' ;;
48
+        sections_only)              cmd='inigrep section2.' ;;
49
+        tricks_with_strange_naming) cmd='inigrep "section with/ slash and spaces".' ;;
50
+        strict_and_space)           cmd='inigrep -r myscript.py' ;;
51
+        strict_and_tab)             cmd='inigrep -r my_script.py' ;;
52
+        inlinecmt_hash)             cmd='inigrep joe.score' ;;
53
+        inlinecmt_sc)               cmd='inigrep bob.score' ;;
54
+        inlinecmt_hash_and_strict)  cmd='inigrep -r joe.catchphrase' ;;
55
+        inlinecmt_sc_and_strict)    cmd='inigrep -r bob.catchphrase' ;;
56
+        list_keys)                  cmd='inigrep -K ""' ;;
57
+        list_paths)                 cmd='inigrep -P' ;;
58
+        list_sections)              cmd='inigrep -S' ;;
59
+        list_tricky_all_keys)       cmd='inigrep -K ""' ;;
60
+        list_tricky_all_paths)      cmd='inigrep -P' ;;
61
+        list_tricky_all_sections)   cmd='inigrep -S' ;;
62
+        list_tricky_s1_keys)        cmd='inigrep -K s1' ;;
63
+    esac
64
+    tf_testflt -n "$name" -i "$t_in" -O "$o_out" "$cmd"
65
+}
66
+
67
+tf_do_subtests

+ 2
- 0
tests/inigrep_inigrep/oracle/both_keys_and_sections.stdout View File

@@ -0,0 +1,2 @@
1
+value11
2
+key=value11

+ 3125
- 0
tests/inigrep_inigrep/oracle/games_with_spaces.stdout
File diff suppressed because it is too large
View File


+ 1
- 0
tests/inigrep_inigrep/oracle/inlinecmt_hash.stdout View File

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

+ 1
- 0
tests/inigrep_inigrep/oracle/inlinecmt_hash_and_strict.stdout View File

@@ -0,0 +1 @@
1
+ I'm a C# developer    # but is a proud programmer

+ 1
- 0
tests/inigrep_inigrep/oracle/inlinecmt_sc.stdout View File

@@ -0,0 +1 @@
1
+1024

+ 1
- 0
tests/inigrep_inigrep/oracle/inlinecmt_sc_and_strict.stdout View File

@@ -0,0 +1 @@
1
+ hey; I'm Bob!         ; and that he's fun to meet!

+ 2
- 0
tests/inigrep_inigrep/oracle/keys_only.stdout View File

@@ -0,0 +1,2 @@
1
+value1
2
+key=value1

+ 2
- 0
tests/inigrep_inigrep/oracle/keys_sections_spaces.stdout View File

@@ -0,0 +1,2 @@
1
+value11
2
+key=value11

+ 8
- 0
tests/inigrep_inigrep/oracle/list_keys.stdout View File

@@ -0,0 +1,8 @@
1
+key1
2
+key1
3
+key2
4
+key2
5
+key1
6
+key1
7
+key2
8
+key2

+ 8
- 0
tests/inigrep_inigrep/oracle/list_paths.stdout View File

@@ -0,0 +1,8 @@
1
+section1.key1
2
+section1.key1
3
+section1.key2
4
+section1.key2
5
+section2.key1
6
+section2.key1
7
+section2.key2
8
+section2.key2

+ 2
- 0
tests/inigrep_inigrep/oracle/list_sections.stdout View File

@@ -0,0 +1,2 @@
1
+section1
2
+section2

+ 5
- 0
tests/inigrep_inigrep/oracle/list_tricky_all_keys.stdout View File

@@ -0,0 +1,5 @@
1
+k00
2
+k11
3
+k12
4
+k21
5
+k22

+ 5
- 0
tests/inigrep_inigrep/oracle/list_tricky_all_paths.stdout View File

@@ -0,0 +1,5 @@
1
+__NOSCT__.k00
2
+s1.k11
3
+s1.k12
4
+s2.k21
5
+s2.k22

+ 3
- 0
tests/inigrep_inigrep/oracle/list_tricky_all_sections.stdout View File

@@ -0,0 +1,3 @@
1
+__NOSCT__
2
+s1
3
+s2

+ 1
- 0
tests/inigrep_inigrep/oracle/list_tricky_k12_keys.stdout View File

@@ -0,0 +1 @@
1
+k12

+ 1
- 0
tests/inigrep_inigrep/oracle/list_tricky_k12_paths.stdout View File

@@ -0,0 +1 @@
1
+s1.k12

+ 1
- 0
tests/inigrep_inigrep/oracle/list_tricky_k12_sections.stdout View File

@@ -0,0 +1 @@
1
+s1

+ 2
- 0
tests/inigrep_inigrep/oracle/list_tricky_s1_keys.stdout View File

@@ -0,0 +1,2 @@
1
+k11
2
+k12

+ 2
- 0
tests/inigrep_inigrep/oracle/list_tricky_s1_paths.stdout View File

@@ -0,0 +1,2 @@
1
+s1.k11
2
+s1.k12

+ 1
- 0
tests/inigrep_inigrep/oracle/list_tricky_s1_sections.stdout View File

@@ -0,0 +1 @@
1
+s1

+ 12
- 0
tests/inigrep_inigrep/oracle/merge_first.stdout View File

@@ -0,0 +1,12 @@
1
+[s1]
2
+    k1=file-a-s1k1
3
+    k2=file-a-s1k2
4
+[s2]
5
+    k1=file-a-s2k1
6
+    k2=file-a-s2k2
7
+[s1]
8
+    k1=file-s-s1k1
9
+    k2=file-s-s1k2
10
+[s2]
11
+    k1=file-s-s2k1
12
+    k2=file-s-s2k2

+ 12
- 0
tests/inigrep_inigrep/oracle/merge_first_no1.stdout View File

@@ -0,0 +1,12 @@
1
+[s1]
2
+    k1=file-a-s1k1
3
+    k2=file-a-s1k2
4
+[s2]
5
+    k1=file-a-s2k1
6
+    k2=file-a-s2k2
7
+[s1]
8
+    k1=file-s-s1k1
9
+    k2=file-s-s1k2
10
+[s2]
11
+    k1=file-s-s2k1
12
+    k2=file-s-s2k2

+ 12
- 0
tests/inigrep_inigrep/oracle/merge_first_no2.stdout View File

@@ -0,0 +1,12 @@
1
+[s1]
2
+    k1=file-a-s1k1
3
+    k2=file-a-s1k2
4
+[s2]
5
+    k1=file-a-s2k1
6
+    k2=file-a-s2k2
7
+[s1]
8
+    k1=file-s-s1k1
9
+    k2=file-s-s1k2
10
+[s2]
11
+    k1=file-s-s2k1
12
+    k2=file-s-s2k2

+ 12
- 0
tests/inigrep_inigrep/oracle/merge_first_no3.stdout View File

@@ -0,0 +1,12 @@
1
+[s1]
2
+    k1=file-a-s1k1
3
+    k2=file-a-s1k2
4
+[s2]
5
+    k1=file-a-s2k1
6
+    k2=file-a-s2k2
7
+[s1]
8
+    k1=file-s-s1k1
9
+    k2=file-s-s1k2
10
+[s2]
11
+    k1=file-s-s2k1
12
+    k2=file-s-s2k2

+ 6
- 0
tests/inigrep_inigrep/oracle/merge_first_none.stdout View File

@@ -0,0 +1,6 @@
1
+[s1]
2
+    k1=file-s-s1k1
3
+    k2=file-s-s1k2
4
+[s2]
5
+    k1=file-s-s2k1
6
+    k2=file-s-s2k2

+ 21
- 0
tests/inigrep_inigrep/oracle/merge_first_strict.stdout View File

@@ -0,0 +1,21 @@
1
+#   #
2
+# A #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-a-s1k1
7
+    k2=file-a-s1k2
8
+[s2]
9
+    k1=file-a-s2k1
10
+    k2=file-a-s2k2
11
+#   #
12
+# S #
13
+#   #
14
+
15
+[s1]
16
+    k1=file-s-s1k1
17
+    k2=file-s-s1k2
18
+[s2]
19
+    k1=file-s-s2k1
20
+    k2=file-s-s2k2
21
+

+ 18
- 0
tests/inigrep_inigrep/oracle/merge_join.stdout View File

@@ -0,0 +1,18 @@
1
+[s1]
2
+    k1=file-a-s1k1
3
+    k2=file-a-s1k2
4
+[s2]
5
+    k1=file-a-s2k1
6
+    k2=file-a-s2k2
7
+[s1]
8
+    k1=file-b-s1k1
9
+    k2=file-b-s1k2
10
+[s2]
11
+    k1=file-b-s2k1
12
+    k2=file-b-s2k2
13
+[s1]
14
+    k1=file-s-s1k1
15
+    k2=file-s-s1k2
16
+[s2]
17
+    k1=file-s-s2k1
18
+    k2=file-s-s2k2

+ 18
- 0
tests/inigrep_inigrep/oracle/merge_join_no1.stdout View File

@@ -0,0 +1,18 @@
1
+[s1]
2
+    k1=file-a-s1k1
3
+    k2=file-a-s1k2
4
+[s2]
5
+    k1=file-a-s2k1
6
+    k2=file-a-s2k2
7
+[s1]
8
+    k1=file-b-s1k1
9
+    k2=file-b-s1k2
10
+[s2]
11
+    k1=file-b-s2k1
12
+    k2=file-b-s2k2
13
+[s1]
14
+    k1=file-s-s1k1
15
+    k2=file-s-s1k2
16
+[s2]
17
+    k1=file-s-s2k1
18
+    k2=file-s-s2k2

+ 18
- 0
tests/inigrep_inigrep/oracle/merge_join_no2.stdout View File

@@ -0,0 +1,18 @@
1
+[s1]
2
+    k1=file-a-s1k1
3
+    k2=file-a-s1k2
4
+[s2]
5
+    k1=file-a-s2k1
6
+    k2=file-a-s2k2
7
+[s1]
8
+    k1=file-b-s1k1
9
+    k2=file-b-s1k2
10
+[s2]
11
+    k1=file-b-s2k1
12
+    k2=file-b-s2k2
13
+[s1]
14
+    k1=file-s-s1k1
15
+    k2=file-s-s1k2
16
+[s2]
17
+    k1=file-s-s2k1
18
+    k2=file-s-s2k2

+ 18
- 0
tests/inigrep_inigrep/oracle/merge_join_no3.stdout View File

@@ -0,0 +1,18 @@
1
+[s1]
2
+    k1=file-a-s1k1
3
+    k2=file-a-s1k2
4
+[s2]
5
+    k1=file-a-s2k1
6
+    k2=file-a-s2k2
7
+[s1]
8
+    k1=file-b-s1k1
9
+    k2=file-b-s1k2
10
+[s2]
11
+    k1=file-b-s2k1
12
+    k2=file-b-s2k2
13
+[s1]
14
+    k1=file-s-s1k1
15
+    k2=file-s-s1k2
16
+[s2]
17
+    k1=file-s-s2k1
18
+    k2=file-s-s2k2

+ 6
- 0
tests/inigrep_inigrep/oracle/merge_join_none.stdout View File

@@ -0,0 +1,6 @@
1
+[s1]
2
+    k1=file-s-s1k1
3
+    k2=file-s-s1k2
4
+[s2]
5
+    k1=file-s-s2k1
6
+    k2=file-s-s2k2

+ 33
- 0
tests/inigrep_inigrep/oracle/merge_join_strict.stdout View File

@@ -0,0 +1,33 @@
1
+# file: test/merge-a/t.conf
2
+#   #
3
+# A #
4
+#   #
5
+
6
+[s1]
7
+    k1=file-a-s1k1
8
+    k2=file-a-s1k2
9
+[s2]
10
+    k1=file-a-s2k1
11
+    k2=file-a-s2k2
12
+# file: test/merge-b/t.conf
13
+#   #
14
+# B #
15
+#   #
16
+
17
+[s1]
18
+    k1=file-b-s1k1
19
+    k2=file-b-s1k2
20
+[s2]
21
+    k1=file-b-s2k1
22
+    k2=file-b-s2k2
23
+#   #
24
+# S #
25
+#   #
26
+
27
+[s1]
28
+    k1=file-s-s1k1
29
+    k2=file-s-s1k2
30
+[s2]
31
+    k1=file-s-s2k1
32
+    k2=file-s-s2k2
33
+

+ 2
- 0
tests/inigrep_inigrep/oracle/path.stdout View File

@@ -0,0 +1,2 @@
1
+value11
2
+key=value11

+ 2
- 0
tests/inigrep_inigrep/oracle/plain.stdout View File

@@ -0,0 +1,2 @@
1
+hello
2
+hello1

+ 5
- 0
tests/inigrep_inigrep/oracle/plain_strict.stdout View File

@@ -0,0 +1,5 @@
1
+# some strict-ish comments
2
+
3
+# and empty lines
4
+hello
5
+hello1

+ 3
- 0
tests/inigrep_inigrep/oracle/sections_only.stdout View File

@@ -0,0 +1,3 @@
1
+line21
2
+line22
3
+line23

+ 15
- 0
tests/inigrep_inigrep/oracle/strict_and_space.stdout View File

@@ -0,0 +1,15 @@
1
+#!/usr/bin/python
2
+
3
+
4
+class Myclass(object):
5
+
6
+    def __init__(self, status="OK"):
7
+        self.status = status
8
+
9
+    def check(self):
10
+        print "I guess I'm %s" % self.status
11
+
12
+
13
+if __name__ == "__main__":
14
+    c = Myclass()
15
+    c.check()

+ 15
- 0
tests/inigrep_inigrep/oracle/strict_and_tab.stdout View File

@@ -0,0 +1,15 @@
1
+#!/usr/bin/python
2
+
3
+
4
+class Myclass(object):
5
+
6
+	def __init__(self, status="OK"):
7
+		self.status = status
8
+
9
+	def check(self):
10
+		print "I guess I'm %s" % self.status
11
+
12
+
13
+if __name__ == "__main__":
14
+	c = Myclass()
15
+	c.check()

+ 6
- 0
tests/inigrep_inigrep/oracle/tricks_with_strange_naming.stdout View File

@@ -0,0 +1,6 @@
1
+[line starting with lbracket
2
+key=value[with[lbracket
3
+soon following
4
+another_key]with]rbracket
5
+and a line ending with rbracket]
6
+=and_a_nameless_value

+ 13
- 0
tests/inigrep_inigrep/test/both_keys_and_sections.stdin View File

@@ -0,0 +1,13 @@
1
+[section1]
2
+free form in s1
3
+key1=value11
4
+key1=key=value11
5
+key2=value12
6
+key2=key=value12
7
+[section2]
8
+free form in s2
9
+key1=value21
10
+key1=key=value21
11
+key2=value22
12
+key2=key=value22
13
+another free form in s2

+ 3126
- 0
tests/inigrep_inigrep/test/games_with_spaces.stdin
File diff suppressed because it is too large
View File


+ 9
- 0
tests/inigrep_inigrep/test/inlinecmt.stdin View File

@@ -0,0 +1,9 @@
1
+[joe]                                   # He's a nice guy
2
+
3
+    score = 0                           # he can't play games
4
+    catchphrase = I'm a C# developer    # but is a proud programmer
5
+
6
+[bob]                                   ; We don't know much about him yet
7
+
8
+    score = 1024                        ; except that he pretty much beats us all ;)
9
+    catchphrase = hey; I'm Bob!         ; and that he's fun to meet!

+ 5
- 0
tests/inigrep_inigrep/test/keys_only.stdin View File

@@ -0,0 +1,5 @@
1
+free form
2
+key1=value1
3
+key1=key=value1
4
+key2=value2
5
+key2=key=value2

+ 13
- 0
tests/inigrep_inigrep/test/keys_sections_spaces.stdin View File

@@ -0,0 +1,13 @@
1
+[section1]
2
+    free form in s1
3
+	key1=value11
4
+    key1=key=value11
5
+	key2=value12
6
+    key2=key=value12
7
+[section2]
8
+    free form in s2
9
+	key1=value21
10
+	key1=key=value21
11
+    key2=value22
12
+    key2=key=value22
13
+	another free form in s2

+ 13
- 0
tests/inigrep_inigrep/test/list_keys.stdin View File

@@ -0,0 +1,13 @@
1
+[section1]
2
+free form in s1
3
+key1=value11
4
+key1=key=value11
5
+key2=value12
6
+key2=key=value12
7
+[section2]
8
+free form in s2
9
+key1=value21
10
+key1=key=value21
11
+key2=value22
12
+key2=key=value22
13
+another free form in s2

+ 13
- 0
tests/inigrep_inigrep/test/list_paths.stdin View File

@@ -0,0 +1,13 @@
1
+[section1]
2
+free form in s1
3
+key1=value11
4
+key1=key=value11
5
+key2=value12
6
+key2=key=value12
7
+[section2]
8
+free form in s2
9
+key1=value21
10
+key1=key=value21
11
+key2=value22
12
+key2=key=value22
13
+another free form in s2

+ 13
- 0
tests/inigrep_inigrep/test/list_sections.stdin View File

@@ -0,0 +1,13 @@
1
+[section1]
2
+free form in s1
3
+key1=value11
4
+key1=key=value11
5
+key2=value12
6
+key2=key=value12
7
+[section2]
8
+free form in s2
9
+key1=value21
10
+key1=key=value21
11
+key2=value22
12
+key2=key=value22
13
+another free form in s2

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_all_keys.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_all_paths.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_all_sections.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_k12_keys.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_k12_paths.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_k12_sections.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_s1_keys.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_s1_paths.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 13
- 0
tests/inigrep_inigrep/test/list_tricky_s1_sections.stdin View File

@@ -0,0 +1,13 @@
1
+k00=v00
2
+
3
+# cmt1
4
+[s1]
5
+    free form
6
+    k11=v11
7
+	k12=v12
8
+
9
+# cmt2
10
+[s2]
11
+free form
12
+k21=v21
13
+k22=v22

+ 10
- 0
tests/inigrep_inigrep/test/merge-a/t.conf View File

@@ -0,0 +1,10 @@
1
+#   #
2
+# A #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-a-s1k1
7
+    k2=file-a-s1k2
8
+[s2]
9
+    k1=file-a-s2k1
10
+    k2=file-a-s2k2

+ 10
- 0
tests/inigrep_inigrep/test/merge-b/t.conf View File

@@ -0,0 +1,10 @@
1
+#   #
2
+# B #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-b-s1k1
7
+    k2=file-b-s1k2
8
+[s2]
9
+    k1=file-b-s2k1
10
+    k2=file-b-s2k2

+ 11
- 0
tests/inigrep_inigrep/test/merge_first.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_first_no1.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_first_no2.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_first_no3.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_first_none.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_first_strict.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_join.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_join_no1.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_join_no2.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_join_no3.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_join_none.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 11
- 0
tests/inigrep_inigrep/test/merge_join_strict.stdin View File

@@ -0,0 +1,11 @@
1
+#   #
2
+# S #
3
+#   #
4
+
5
+[s1]
6
+    k1=file-s-s1k1
7
+    k2=file-s-s1k2
8
+[s2]
9
+    k1=file-s-s2k1
10
+    k2=file-s-s2k2
11
+

+ 13
- 0
tests/inigrep_inigrep/test/path.stdin View File

@@ -0,0 +1,13 @@
1
+[section1]
2
+free form in s1
3
+key1=value11
4
+key1=key=value11
5
+key2=value12
6
+key2=key=value12
7
+[section2]
8
+free form in s2
9
+key1=value21
10
+key1=key=value21
11
+key2=value22
12
+key2=key=value22
13
+another free form in s2

+ 2
- 0
tests/inigrep_inigrep/test/plain.stdin View File

@@ -0,0 +1,2 @@
1
+hello
2
+hello1

+ 5
- 0
tests/inigrep_inigrep/test/plain_strict.stdin View File

@@ -0,0 +1,5 @@
1
+# some strict-ish comments
2
+
3
+# and empty lines
4
+hello
5
+hello1

+ 11
- 0
tests/inigrep_inigrep/test/sections_only.stdin View File

@@ -0,0 +1,11 @@
1
+[section1]
2
+line11
3
+line12
4
+[section2]
5
+line21
6
+line22
7
+line23
8
+[section3]
9
+line31
10
+line32
11
+line33

+ 16
- 0
tests/inigrep_inigrep/test/strict_and_space.stdin View File

@@ -0,0 +1,16 @@
1
+[myscript]
2
+py =#!/usr/bin/python
3
+py =
4
+py =
5
+py =class Myclass(object):
6
+py =
7
+py =    def __init__(self, status="OK"):
8
+py =        self.status = status
9
+py =
10
+py =    def check(self):
11
+py =        print "I guess I'm %s" % self.status
12
+py =
13
+py =
14
+py =if __name__ == "__main__":
15
+py =    c = Myclass()
16
+py =    c.check()

+ 16
- 0
tests/inigrep_inigrep/test/strict_and_tab.stdin View File

@@ -0,0 +1,16 @@
1
+[my_script]
2
+py =#!/usr/bin/python
3
+py =
4
+py =
5
+py =class Myclass(object):
6
+py =
7
+py =	def __init__(self, status="OK"):
8
+py =		self.status = status
9
+py =
10
+py =	def check(self):
11
+py =		print "I guess I'm %s" % self.status
12
+py =
13
+py =
14
+py =if __name__ == "__main__":
15
+py =	c = Myclass()
16
+py =	c.check()

+ 12
- 0
tests/inigrep_inigrep/test/tricks_with_strange_naming.stdin View File

@@ -0,0 +1,12 @@
1
+[section with/ slash and spaces]
2
+    [line starting with lbracket
3
+    key=value[with[lbracket
4
+    soon following
5
+    another_key]with]rbracket
6
+    and a line ending with rbracket]
7
+=and_a_nameless_value
8
+[other section]
9
+with some
10
+more
11
+ [and/ another/ ]
12
+    that we do not want

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

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

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

@@ -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 -q "${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
+}

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

@@ -0,0 +1,175 @@
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
+        *)
58
+            warn "unknown git fact asked: $fact_name"
59
+            ;;
60
+    esac
61
+}
62
+
63
+git_present() {
64
+    #
65
+    # True if we're in a git repo
66
+    #
67
+    git rev-parse HEAD >&/dev/null
68
+}
69
+
70
+git_tag2ver() {
71
+    #
72
+    # Convert tag to version
73
+    #
74
+    sed s/^v//
75
+}
76
+
77
+git_ver2tag() {
78
+    #
79
+    # Convert version to tag
80
+    #
81
+    sed s/^/v/
82
+}
83
+
84
+git_lasthash() {
85
+    #
86
+    # Show last commit hash (with .dirty suffix if needed)
87
+    #
88
+    # We can't do it outside git repo (or without git) but we should
89
+    # not be asked to; targets that don't require git should make use
90
+    # of cache built by dist target.
91
+    #
92
+    local last_hash     # last commit hash
93
+    git_present || {
94
+        echo UNKNOWN_HASH
95
+        warn "no git present; could not determine last hash"
96
+        return 3
97
+    }
98
+    last_hash=$(git rev-parse HEAD)
99
+    echo -n "$last_hash"
100
+    git_bool dirty && echo -n ".dirty"
101
+}
102
+
103
+semver() {
104
+    #
105
+    # Build proper SemVer version string
106
+    #
107
+    # Build version string from available info using following
108
+    # logic:
109
+    #
110
+    #  1. Use version from last git tag (or mkit.ini if there is no
111
+    #     tag, which is possible on new project)
112
+    #  2. if set, add project:prerl (from mkit.ini) as pre-release ID
113
+    #     (afer dash)
114
+    #  3. if we are at a later commit than the last tag, add branch
115
+    #     name and commit sha1 to build metadata (after plus sign)
116
+    #  4. if the tree is "dirty", i.e. has uncommited changes,
117
+    #     add "dirty" to build metadata
118
+    #
119
+    # The version is compatible with SemVer 2.0.0.
120
+    #
121
+    # Examples:
122
+    #
123
+    #     foo v1.0.7                            # all clear; proper release
124
+    #     foo v1.0.7-beta                       # mkit.ini: project:prerl="beta"
125
+    #     foo v1.0.7-beta+g1aef811.master       # ^^ + some commits after
126
+    #     foo v1.0.7-beta+gf14fc4f.api2         # ^^ + on a feature branch
127
+    #     foo v1.0.7-beta+gf14fc4f.api2.dirty   # ^^ + tree edited
128
+    #     foo v1.0.7-beta+dirty                 # tag OK but tree edited
129
+    #     foo v1.0.7+dirty                      # ^^ but no pre-release id
130
+    #
131
+    # Note that versions with "dirty" should be perceived as kind of
132
+    # dangerous outside developer's own machine.  Versions with sha1 are
133
+    # safer but must not be released.
134
+    #
135
+    # FIXME:  Using project:prerl for release IDs may not be compatible with
136
+    #         release strategy implemented in release.sh
137
+    #
138
+    local xyz           # base version string
139
+    local prerl         # pre-release keyword (from mkit.ini, eg. 'beta')
140
+    local latest_tag    # latest git tag
141
+    local commit        # commit indicator (CURRENT_BRANCH.gHASH)
142
+    local dirty         # 0 if dirty, 1 if clean
143
+    local suffix        # version suffix
144
+    prerl=$(ini 1value project:prerl)
145
+    grep ":" <<<"$prerl" \
146
+     && warn "colon in project:prerl may corrupt version data: $prerl"
147
+    git_present || {
148
+        echo UNKNOWN_VERSION
149
+        warn "no git present; could not determine SemVer"
150
+        return 3
151
+    }
152
+    latest_tag=$(git_fact latest_tag)
153
+    case $latest_tag in
154
+        v*) xyz=${latest_tag:1} ;;
155
+        "") warn "no tags, using base version from mkit.ini (ok for new project)"
156
+            xyz=$(ini 1value project:version) ;;
157
+        *)  warn "bad form of last tag, using base version from mkit.ini: tag is '$latest_tag'"
158
+            xyz=$(ini 1value project:version) ;;
159
+    esac
160
+    if ! git describe --tags --exact-match HEAD >&/dev/null;
161
+    then    # we are at a later commit than the last tag
162
+        commit="$(git_fact current_branch).g$(git_fact latest_sha)"
163
+    fi
164
+    git_bool dirty; dirty=$?
165
+    case "$dirty:$commit" in
166
+        1:)  suffix=""               ;;
167
+        0:)  suffix="+dirty"         ;;
168
+        1:*) suffix="+$commit"       ;;
169
+        0:*) suffix="+$commit.dirty" ;;
170
+        *)   suffix=MKIT_BUG
171
+             warn "MKIT_BUG: bad dirt/commit detection" ;;
172
+    esac
173
+    test -n "$prerl" && suffix="-$prerl$suffix"
174
+    echo "$xyz$suffix"
175
+}

+ 178
- 0
utils/mkit/include/ini.sh View File

@@ -0,0 +1,178 @@
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
+    local suffix    # tail of the line
21
+    local ref       # reference
22
+    local value     # value if reference
23
+    while read -r line; do                  # [foo:bar]/path
24
+        suffix="${line#\[*\]}"              # /path
25
+        ref="${line%$suffix}"               # [foo:bar]
26
+        ref="${ref%\]}"                     # [foo:bar
27
+        ref="${ref#\[}"                     # foo:bar
28
+        value="$(ini 1value "$ref")"        # foo_bar_value
29
+        printf -- "%s\n" "$value$suffix"    # foo_bar_value/path
30
+    done
31
+}
32
+
33
+__ini_grepcmt() {
34
+    #
35
+    # Remove comments from INI file on stdin
36
+    #
37
+    grep -v '^[[:space:]]*#'
38
+}
39
+
40
+__ini_grepkey() {
41
+    #
42
+    # Read key from a section
43
+    #
44
+    local wnt=$1    # wanted key
45
+    grep '.' \
46
+      | sed -e 's/ *= */=/; s/ +$//; s/^//;' \
47
+      | grep -e "^$wnt=" \
48
+      | cut -d= -f2- \
49
+      | __ini_maybe_expand
50
+}
51
+
52
+__ini_greppath() {
53
+    #
54
+    # Read key from the right section
55
+    #
56
+    # E.g. `files:share:my/lib.sh` should read
57
+    #
58
+    #     [files:share]
59
+    #         my/lib.sh   = proj/my/lib.sh
60
+    #
61
+    local wnt=$1                    # wanted path
62
+    local wntkey=${wnt##*:}         # ^^ key part
63
+    local wntsec=${wnt%:$wntkey}    # ^^ section part
64
+    local override                  # ENV override (only ENV section)
65
+    if test "$wntsec" = 'ENV'; then
66
+        override=${!wntkey}
67
+        test -n "$override" \
68
+         && echo "$override" \
69
+         && return
70
+    fi
71
+    __ini_grepsec "$wntsec" | __ini_grepkey "$wntkey"
72
+}
73
+
74
+__ini_grepsec() {
75
+    #
76
+    # Read one INI section
77
+    #
78
+    local wnt=$1        # wanted section name
79
+    local ok=false      # are we in the section?
80
+    local line          # each input line
81
+    grep '.' \
82
+      | grep -v '\s*#' \
83
+      | while read -r line; do
84
+            case "$line" in
85
+                \[$wnt\]) ok=true;  continue ;;
86
+                \[*\])    ok=false; continue ;;
87
+            esac
88
+            $ok || continue
89
+            printf -- "%s\n" "$line"
90
+        done \
91
+      | sed -e 's/ *= */=/; s/ +$//; s/^//;'
92
+}
93
+
94
+__ini_lskeys() {
95
+    #
96
+    # List keys from a section
97
+    #
98
+    local sct=$1    # section of interest
99
+    __ini_grepsec "$sct" | cut -d= -f1 | awk '!x[$0]++'
100
+}
101
+
102
+__ini_lssect() {
103
+    #
104
+    # List all section names
105
+    #
106
+    local arg=$1    # unused argument
107
+    grep -x '\[.*\]' | sed 's/^.//; s/.$//'
108
+}
109
+
110
+__ini_maybe_expand() {
111
+    #
112
+    # Decide whether or not to expand
113
+    #
114
+    if test "$MKIT_INI_EXPAND" -gt 0; then
115
+        MKIT_INI_EXPAND=$(( --MKIT_INI_EXPAND )) __ini_expand
116
+    else
117
+        __ini_cat
118
+    fi
119
+}
120
+
121
+__ini_body() {
122
+    #
123
+    # Produce mkit.ini body including INCLUDE
124
+    #
125
+    # Note: recursive includes are not supported.
126
+    #
127
+    local inc                       # file to include
128
+    local incre='\[INCLUDE:.*\]'    # include directive regex
129
+    local iline                     # include directive line
130
+    if iline=$(grep -m1 -x "$incre" "$MKIT_INI"); then
131
+        inc=${iline#*:}; inc=${inc%]}
132
+        grep -vx "$incre" "$inc"
133
+        grep -vx "$incre" "$MKIT_INI"
134
+    else
135
+        cat "$MKIT_INI"
136
+    fi | __ini_grepcmt
137
+}
138
+
139
+ini() {
140
+    #
141
+    # do ini operation
142
+    #
143
+    local op=$1             # operator
144
+    local arg=$2            # argument
145
+    local fn                # internal function implementing $op
146
+    local limit=__ini_cat    # limiting internal function
147
+    case $op in
148
+        lskeys) fn=__ini_lskeys   ;;
149
+        lssect) fn=__ini_lssect   ;;
150
+        sec)    fn=__ini_grepsec  ;;
151
+        values) fn=__ini_greppath ;;
152
+        1value) fn=__ini_greppath; limit="tail -1" ;;
153
+        *)      die "incorrect use of \`ini()\`"
154
+    esac
155
+    __ini_body | $fn "$arg" | $limit
156
+}
157
+
158
+update_version() {
159
+    #
160
+    # Change project:version in mkit.ini at path $2 to value $1
161
+    #
162
+    local version=$1    # new version
163
+    local inifile=$2    # mkit.ini path
164
+    local tmp           # mkit.ini cache
165
+    tmp=$(mktemp -t mkit.update_version.XXXXXXXX)
166
+    <"$inifile" perl -e '
167
+        my $hit = 0;
168
+        my $done = 0;
169
+        foreach (<STDIN>) {
170
+            if      ($done) { print; next; }
171
+            elsif   (m/\[project\]/) { $hit++; print; next; }
172
+            elsif   (m/\[/) { $hit = 0; print; next; }
173
+            elsif   ($hit) { s/\bversion\b( *)=( *).*/version$1=$2$ARGV[0]/ and $done++; print; }
174
+            else { print; next; }
175
+        }
176
+    ' "$version" >"$tmp" || die "failed to update version in mkit.ini"
177
+    mv "$tmp" "$inifile"
178
+}

+ 162
- 0
utils/mkit/include/mkit.sh View File

@@ -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
+}

+ 0
- 0
utils/mkit/include/release.sh View File


Some files were not shown because too many files changed in this diff