From 3e391ef7abaf60b6a6966121a586b6e69b43f080 Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Mon, 28 Dec 2020 17:22:14 -0500 Subject: dev-util/meson-format-array: new package Bug: https://bugs.gentoo.org/759433 Signed-off-by: Mike Gilbert --- .../meson-format-array/files/meson-format-array | 24 ++++++++++++++++++++++ .../meson-format-array/meson-format-array-0.ebuild | 22 ++++++++++++++++++++ dev-util/meson-format-array/metadata.xml | 8 ++++++++ 3 files changed, 54 insertions(+) create mode 100644 dev-util/meson-format-array/files/meson-format-array create mode 100644 dev-util/meson-format-array/meson-format-array-0.ebuild create mode 100644 dev-util/meson-format-array/metadata.xml diff --git a/dev-util/meson-format-array/files/meson-format-array b/dev-util/meson-format-array/files/meson-format-array new file mode 100644 index 000000000000..a6d722dc30b6 --- /dev/null +++ b/dev-util/meson-format-array/files/meson-format-array @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +import itertools +import shlex +import sys + +def quote(s): + return "'" + s.replace("\\", "\\\\").replace("'", "\\'") + "'" + +def main(args): + # Split each argument according to shell rules + args = (shlex.split(x) for x in args) + + # Flatten the resulting list of lists + args = itertools.chain.from_iterable(args) + + # Add quotes and escape embedded quotes + args = (quote(x) for x in args) + + # Format the result + print("[" + ", ".join(args) + "]") + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/dev-util/meson-format-array/meson-format-array-0.ebuild b/dev-util/meson-format-array/meson-format-array-0.ebuild new file mode 100644 index 000000000000..1d252e83121e --- /dev/null +++ b/dev-util/meson-format-array/meson-format-array-0.ebuild @@ -0,0 +1,22 @@ +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 +PYTHON_COMPAT=( python3_{6..9} ) + +inherit python-r1 + +DESCRIPTION="Format shell expressions into a meson array" +HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage" + +LICENSE="GPL-2" +SLOT="0" +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" + +REQUIRED_USE="${PYTHON_REQUIRED_USE}" +RDEPEND="${PYTHON_DEPS}" +S="${WORKDIR}" + +src_install() { + python_foreach_impl python_doscript "${FILESDIR}"/meson-format-array +} diff --git a/dev-util/meson-format-array/metadata.xml b/dev-util/meson-format-array/metadata.xml new file mode 100644 index 000000000000..de09ffd8b089 --- /dev/null +++ b/dev-util/meson-format-array/metadata.xml @@ -0,0 +1,8 @@ + + + + + floppym@gentoo.org + Mike Gilbert + + -- cgit v1.2.3-65-gdbad