[packages/rpm-pld-macros] __noautodep_helper: rewrite from shell+awk to Lua
arekm
arekm at pld-linux.org
Sun Mar 22 04:13:21 CET 2026
commit 2c05e420387c2ab5710e1a34e23390bbcda26730
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sun Mar 22 04:10:32 2026 +0100
__noautodep_helper: rewrite from shell+awk to Lua
The old %(echo '%*' | awk '...') broke when _noautoreq/_noautoprov
values contained single quotes (e.g. 'pear(Foo.php)'), causing
"sh: syntax error: unexpected '('" and silently disabling dependency
filtering. The awk printf() also crashed on %{macro} references
(e.g. %{moz_caps}), treating % as format specifiers.
Reproducer - php-pear-HTML_CSS which defines:
%define _noautoreq 'pear(HTML_TestListener.php)' 'pear(TestUnit.php)' ...
Using %{lua:...} avoids shell entirely.
macros.pld | 34 +++++++++++++++++-----------------
rpm-pld-macros.spec | 2 +-
2 files changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/rpm-pld-macros.spec b/rpm-pld-macros.spec
index 3675fb9..cade216 100644
--- a/rpm-pld-macros.spec
+++ b/rpm-pld-macros.spec
@@ -1,4 +1,4 @@
-%define rpm_macros_rev 2.055
+%define rpm_macros_rev 2.056
%define find_lang_rev 1.42
# split into individual X_prov_ver if there is a reason to desync
%define prov_ver 4.15
diff --git a/macros.pld b/macros.pld
index 4153703..5b6e48b 100644
--- a/macros.pld
+++ b/macros.pld
@@ -1149,24 +1149,24 @@ fi; \
%{?_noautoreq_py3egg: %{__noauto_regexp_helper -p python3egg %{_noautoreq_py3egg}}} \
%{nil}
-%__noautodep_helper() %(echo '%*' | awk 'BEGIN {
- RS = "\n([ \t]+\n)+";
- FS = " ";
+# Convert whitespace-separated list of dependency patterns into a single
+# alternation regex: "pat1 pat2 pat3" → "(pat1|pat2|pat3)"
+# Used by __requires_exclude / __provides_exclude to filter auto-dependencies.
+# Strips single quotes from patterns (some specs quote _noautoreq values)
+# and skips #-comment tokens.
+%__noautodep_helper() %{lua:
+local args = rpm.expand("%*")
+local result = {}
+for token in args:gmatch("%S+") do
+ token = token:gsub("'", "")
+ if token ~= "" and not token:match("^#") then
+ table.insert(result, token)
+ end
+end
+if #result > 0 then
+ print("(" .. table.concat(result, "|") .. ")")
+end
}
-{
- split($0, F);
- if (length(F) > 0) {
- printf("(");
- for (i=1; i<=length(F); i++) {
- s = F[i];
- sub(/#.*/, "z&z", s);
- if (s ~ /^$/) { continue; };
- printf(s);
- if (i != length(F)) { printf("|"); };
- };
- printf(")");
- }
-}')
%__requires_exclude_from %{__noautodep_helper %{__noautoreqfiles}}%{nil}
%__provides_exclude_from %{__noautodep_helper %{__noautoprovfiles}}%{nil}
%__requires_exclude %{__noautodep_helper %{__noautoreq}}%{nil}
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/rpm-pld-macros.git/commitdiff/2c05e420387c2ab5710e1a34e23390bbcda26730
More information about the pld-cvs-commit
mailing list