[Rpm-maint] [rpm-software-management/rpm] Drop support for external dependency generator (Issue #2373)
Denys Vlasenko
notifications at github.com
Mon May 8 15:29:49 UTC 2023
The startup costs are an issue when you need to start 8000 dependency generators.
"Old" dependency generator starts one external script per package. Then, the script can be written to be smart and start 8000 subtasks *in parallel*. It's not possible with the "new" generator.
I cooked up an ugly work-around:
First, kernel.spec %install section generates "provides" for ksyms and modaliases, and saves it in some temporary files.
Then, kernel-rpm-macros are modified to read these files if they exist, otherwise to run the usual dependency generator script as a child. Along the lines of:
--- a/provided_ksyms.attr
+++ b/provided_ksyms.attr
@@ -1,2 +1,45 @@
-%__provided_ksyms_provides /usr/lib/rpm/redhat/find-provides.ksyms
%__provided_ksyms_path> .*\.(ko|ko\.gz|ko\.bz2|ko\.xz|ko\.zst)$
+
+# Notes on Lua:
+# The backslash in strings (like "\n" newline) needs to be doubled
+# because we are inside rpm macro. Single backslashes before most chars
+# disappear (removed by rpm's parser), so "\n" turns into just "n".
+# In string.gsub patterns, unlike regexps, backslash has no special meaning.
+# It can't escape . and such. (Use one-character set [.] to represent
+# literal period, or lua's percent escape: %.)
+# Pipe (|) has no special meaning too.
+
+%__provided_ksyms_provides() %{lua:
+ function strip_compress_sfx(fn)
+ local cnt
+ fn, cnt = string.gsub(fn, "%.gz$", "")
+ if cnt == 1 then return fn; end
+ fn, cnt = string.gsub(fn, "%.bz2$", "")
+ if cnt == 1 then return fn; end
+ fn, cnt = string.gsub(fn, "%.xz$", "")
+ if cnt == 1 then return fn; end
+ fn, cnt = string.gsub(fn, "%.zst$", "")
+ return fn
+ end
+ local buildroot = rpm.expand("%buildroot")
+ local modname = rpm.expand("%1")
+ local nosuffix = strip_compress_sfx(modname)
+ local fn = buildroot..".provides"..nosuffix..".ksyms"
+ -- io.stderr:write("TESTING- ",fn,"\\n")
+ local f = io.open(fn)
+ if f then
+ -- io.stderr:write("Found!- ",fn,"\\n")
+ for l in f:lines() do
+ -- io.stderr:write("[KSYM:",l,"]\\n")
+ print(l.."\\n")
+ end
+ f:close()
+ else
+ -- there is no prepared result file: spawn external generator,
+ -- feed it the modname, and use its output
+ if not string.match(modname, "['%%]") then -- ensuring there is no ' % to disrupt quoting / expansion
+ local r = rpm.expand("%(printf '%%s' '"..modname.."' | /usr/lib/rpm/redhat/find-provides.ksyms)")
+ print(r)
+ end
+ end
+}
This ... works, but are we ready to live with such atrocities?
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/2373#issuecomment-1538577443
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/issues/2373/1538577443 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20230508/6530a077/attachment-0001.html>
More information about the Rpm-maint
mailing list