1 |
commit: 3e391ef7abaf60b6a6966121a586b6e69b43f080 |
2 |
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Dec 28 22:22:14 2020 +0000 |
4 |
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Dec 28 22:32:58 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3e391ef7 |
7 |
|
8 |
dev-util/meson-format-array: new package |
9 |
|
10 |
Bug: https://bugs.gentoo.org/759433 |
11 |
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> |
12 |
|
13 |
.../meson-format-array/files/meson-format-array | 24 ++++++++++++++++++++++ |
14 |
.../meson-format-array/meson-format-array-0.ebuild | 22 ++++++++++++++++++++ |
15 |
dev-util/meson-format-array/metadata.xml | 8 ++++++++ |
16 |
3 files changed, 54 insertions(+) |
17 |
|
18 |
diff --git a/dev-util/meson-format-array/files/meson-format-array b/dev-util/meson-format-array/files/meson-format-array |
19 |
new file mode 100644 |
20 |
index 00000000000..a6d722dc30b |
21 |
--- /dev/null |
22 |
+++ b/dev-util/meson-format-array/files/meson-format-array |
23 |
@@ -0,0 +1,24 @@ |
24 |
+#!/usr/bin/env python3 |
25 |
+ |
26 |
+import itertools |
27 |
+import shlex |
28 |
+import sys |
29 |
+ |
30 |
+def quote(s): |
31 |
+ return "'" + s.replace("\\", "\\\\").replace("'", "\\'") + "'" |
32 |
+ |
33 |
+def main(args): |
34 |
+ # Split each argument according to shell rules |
35 |
+ args = (shlex.split(x) for x in args) |
36 |
+ |
37 |
+ # Flatten the resulting list of lists |
38 |
+ args = itertools.chain.from_iterable(args) |
39 |
+ |
40 |
+ # Add quotes and escape embedded quotes |
41 |
+ args = (quote(x) for x in args) |
42 |
+ |
43 |
+ # Format the result |
44 |
+ print("[" + ", ".join(args) + "]") |
45 |
+ |
46 |
+if __name__ == "__main__": |
47 |
+ main(sys.argv[1:]) |
48 |
|
49 |
diff --git a/dev-util/meson-format-array/meson-format-array-0.ebuild b/dev-util/meson-format-array/meson-format-array-0.ebuild |
50 |
new file mode 100644 |
51 |
index 00000000000..1d252e83121 |
52 |
--- /dev/null |
53 |
+++ b/dev-util/meson-format-array/meson-format-array-0.ebuild |
54 |
@@ -0,0 +1,22 @@ |
55 |
+# Copyright 2020 Gentoo Authors |
56 |
+# Distributed under the terms of the GNU General Public License v2 |
57 |
+ |
58 |
+EAPI=7 |
59 |
+PYTHON_COMPAT=( python3_{6..9} ) |
60 |
+ |
61 |
+inherit python-r1 |
62 |
+ |
63 |
+DESCRIPTION="Format shell expressions into a meson array" |
64 |
+HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage" |
65 |
+ |
66 |
+LICENSE="GPL-2" |
67 |
+SLOT="0" |
68 |
+KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" |
69 |
+ |
70 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE}" |
71 |
+RDEPEND="${PYTHON_DEPS}" |
72 |
+S="${WORKDIR}" |
73 |
+ |
74 |
+src_install() { |
75 |
+ python_foreach_impl python_doscript "${FILESDIR}"/meson-format-array |
76 |
+} |
77 |
|
78 |
diff --git a/dev-util/meson-format-array/metadata.xml b/dev-util/meson-format-array/metadata.xml |
79 |
new file mode 100644 |
80 |
index 00000000000..de09ffd8b08 |
81 |
--- /dev/null |
82 |
+++ b/dev-util/meson-format-array/metadata.xml |
83 |
@@ -0,0 +1,8 @@ |
84 |
+<?xml version="1.0" encoding="UTF-8"?> |
85 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
86 |
+<pkgmetadata> |
87 |
+ <maintainer type="person"> |
88 |
+ <email>floppym@g.o</email> |
89 |
+ <name>Mike Gilbert</name> |
90 |
+ </maintainer> |
91 |
+</pkgmetadata> |