commit: 99d8bde7f0a189f78c740996892b49437e7995cc
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 24 16:23:27 2025 +0000
Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Fri Jan 24 16:45:07 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=99d8bde7
portageq: Allow envvar to treat a trailing * as a wildcard
This matches multiple variables, which is particularly useful in
multilib situations.
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
NEWS | 7 +++++++
bin/portageq | 24 ++++++++++++++++--------
lib/portage/tests/emerge/conftest.py | 1 +
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/NEWS b/NEWS
index d0f5ff4ef6..a380e0c92e 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,13 @@ Release notes take the form of the following optional
categories:
* Bug fixes
* Cleanups
+portage-3.0.68 (UNRELEASED)
+--------------
+
+Features:
+* Allow "portageq envvar" to treat a trailing * as a wildcard, matching
multiple
+ variables. Useful for multilib.
+
portage-3.0.67 (2025-01-22)
--------------
diff --git a/bin/portageq b/bin/portageq
index 7d521b6ba5..e89c453686 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -877,15 +877,22 @@ try:
file=sys.stderr,
)
- value = portage.settings.get(arg)
- if value is None:
- value = ""
- exit_status = 1
-
- if verbose:
- print(arg + "=" + shlex.quote(value))
+ if arg.endswith("*"):
+ arg = arg[0:-1]
+ keys = [key for key in portage.settings.keys() if
key.startswith(arg)]
else:
- print(value)
+ keys = (arg,)
+
+ for key in keys:
+ value = portage.settings.get(key)
+ if value is None:
+ value = ""
+ exit_status = 1
+
+ if verbose:
+ print(key + "=" + shlex.quote(value))
+ else:
+ print(value)
return exit_status
@@ -893,6 +900,7 @@ try:
"envvar"
] = """<variable>+
Returns a specific environment variable as exists prior to
ebuild.sh.
+ Variable names can end with * to match multiple variables.
Similar to: emerge --verbose --info | grep -E '^<variable>='
"""
envvar.__doc__ = docstrings["envvar"]
diff --git a/lib/portage/tests/emerge/conftest.py
b/lib/portage/tests/emerge/conftest.py
index ce86dc4fcd..043c3821c2 100644
--- a/lib/portage/tests/emerge/conftest.py
+++ b/lib/portage/tests/emerge/conftest.py
@@ -536,6 +536,7 @@ def _generate_all_baseline_commands(playground, binhost):
"EROOT",
"PORTAGE_CONFIGROOT",
"PORTAGE_TMPDIR",
+ "CHOST*",
"USERLAND",
)
test_commands["etc-update"] = EtcUpdate()