commit:     5630d4912d5a9c83778d7995502310e3854844dd
Author:     Alfred Wingate <parona <AT> protonmail <DOT> com>
AuthorDate: Sat Feb 21 13:33:40 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Mar  4 16:49:45 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=5630d491

emerge: differentiate between unset and empty variables in --info

Directly use _aux_env_search instead of relying on aux_get for better
flexibility. aux_get documentation either way implies reading CFLAGS etc
would be unexpected.

> This automatically caches selected keys that are frequently needed
> by emerge for **dependency calculations**.

There could be some code cleanup as well, but there might be breakage in
other tools that expect aux_get to be able to read arbitrary files in
/var/db/pkg/category/cpv/.

Signed-off-by: Alfred Wingate <parona <AT> protonmail.com>
Part-of: https://github.com/gentoo/portage/pull/1558
Closes: https://github.com/gentoo/portage/pull/1558
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/_emerge/actions.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/_emerge/actions.py b/lib/_emerge/actions.py
index 84c2136189..068d8d8eff 100644
--- a/lib/_emerge/actions.py
+++ b/lib/_emerge/actions.py
@@ -2260,7 +2260,7 @@ def action_info(settings, trees, myopts, myfiles):
         # Get our global settings (we only print stuff if it varies from
         # the current config)
         mydesiredvars = ["CHOST", "CFLAGS", "CXXFLAGS", "FEATURES", "LDFLAGS"]
-        auxkeys = mydesiredvars + list(vardb._aux_cache_keys)
+        auxkeys = list(vardb._aux_cache_keys)
         pkgsettings = portage.config(clone=settings)
 
         # Loop through each package
@@ -2315,9 +2315,17 @@ def action_info(settings, trees, myopts, myfiles):
 
             append(f"{pkg_use_display(pkg, myopts)}")
             if pkg_type == "installed":
+                unset_var = []
+                env_results = vardb._aux_env_search(cpv, mydesiredvars)
                 for myvar in mydesiredvars:
-                    if metadata[myvar].split() != settings.get(myvar, 
"").split():
-                        append(f'{myvar}="{metadata[myvar]}"')
+                    myval = env_results.get(myvar)
+                    if myval is None:
+                        unset_var.append(myvar)
+                    elif myval.split() != settings.get(myvar, "").split():
+                        append(f'{myvar}="{myval}"')
+                if len(unset_var) > 0:
+                    unset_var_string = ", ".join(unset_var)
+                    append(f"Unset: {unset_var_string}")
             append("")
             append("")
             writemsg_stdout("\n".join(output_buffer), noiselevel=-1)

Reply via email to