Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package mandoc for openSUSE:Factory checked 
in at 2024-05-14 13:37:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mandoc (Old)
 and      /work/SRC/openSUSE:Factory/.mandoc.new.1880 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "mandoc"

Tue May 14 13:37:26 2024 rev:10 rq:1173641 version:1.14.6

Changes:
--------
--- /work/SRC/openSUSE:Factory/mandoc/mandoc.changes    2023-08-11 
15:55:34.859779776 +0200
+++ /work/SRC/openSUSE:Factory/.mandoc.new.1880/mandoc.changes  2024-05-14 
13:38:11.578217662 +0200
@@ -1,0 +2,8 @@
+Mon May 13 11:37:57 UTC 2024 - Matej Cepl <mc...@cepl.eu>
+
+- Add /usr/lib/rpm/lua/mandoc.lua and use it for processing man
+  pages in the trigger scripts, making processing of packages
+  with many man pages (see OpenSSL for an example) significantly
+  faster.
+
+-------------------------------------------------------------------

New:
----
  mandoc.lua

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ mandoc.spec ++++++
--- /var/tmp/diff_new_pack.lSJhwW/_old  2024-05-14 13:38:12.358246106 +0200
+++ /var/tmp/diff_new_pack.lSJhwW/_new  2024-05-14 13:38:12.358246106 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package mandoc
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -25,6 +25,7 @@
 Group:          Productivity/Publishing/Troff
 URL:            http://mandoc.bsd.lv/
 Source:         http://mandoc.bsd.lv/snapshots/mandoc-%{version}.tar.gz
+Source1:        mandoc.lua
 # PATCH-FIX-UPSTREAM boo1209830-endless-loop.patch bsc#1209830 mc...@suse.com
 # Fix endless loop
 Patch0:         boo1209830-endless-loop.patch
@@ -71,62 +72,43 @@
 %make_install MANDIR=%{_mandir} BINDIR=%{_bindir} SBINDIR=%{_sbindir}
 cp -fv %{buildroot}%{_bindir}/apropos %{_tmppath}/
 mv -fv %{_tmppath}/apropos %{buildroot}%{_sbindir}/makewhatis
+install -D -m 644 %{SOURCE1} %{buildroot}%{_rpmconfigdir}/lua/mandoc.lua
 
 # ghost
 : > %{buildroot}%{_mandir}/mandoc.db
 
-%post
-%{_sbindir}/makewhatis
+%posttrans
+/usr/sbin/makewhatis || :
 
 %filetriggerin -p <lua> -- %{_mandir}
--- no point registering individual files if we can call
--- makewhatis in %%post to catch all if
-if posix.getenv("VERBOSE_FILETRIGGERS") then
-    print("%{nvr}: running file install trigger")
-end
-if posix.access("%{_mandir}/mandoc.db") then
+if not posix.access("/usr/share/man/mandoc.db") then return end
+require("mandoc")
+mandoc.debug = "%{nvr}(fin)"
+file = rpm.next_file()
+while file do
+    mandoc.add(file)
     file = rpm.next_file()
-    while file do
-        if string.match(file, "%{_mandir}/man[^/]+/[^/]+%{?ext_man}$") then
-            if posix.access(file) then
-                if posix.getenv("VERBOSE_FILETRIGGERS") then
-                    print("%{nvr}: adding " .. file)
-                end
-                rpm.execute("%{_sbindir}/makewhatis", "-d", "%{_mandir}", file)
-            else
-                io.stderr:write("%{nvr}: missing " .. file .. "\n")
-            end
-        end
-        file = rpm.next_file()
-    end
-elseif posix.getenv("VERBOSE_FILETRIGGERS") then
-    print("%{nvr}: missing mandoc.db, skipped")
 end
-io.flush()
+
+%transfiletriggerin -p <lua> -- %{_mandir}
+require("mandoc")
+mandoc.debug = "%{nvr}(tfin)"
+mandoc.done()
 
 %filetriggerun -p <lua> -- %{_mandir}
-if posix.getenv("VERBOSE_FILETRIGGERS") then
-    print("%{nvr}: running file remove trigger")
-end
-if posix.access("%{_mandir}/mandoc.db") then
-    file = rpm.next_file()
-    while file do
-        if string.match(file, "%{_mandir}/man[^/]+/[^/]+%{?ext_man}$") then
-            if posix.access(file) then
-                if posix.getenv("VERBOSE_FILETRIGGERS") then
-                    print("%{nvr}: removing " .. file)
-                end
-                rpm.execute("%{_sbindir}/makewhatis", "-u", "%{_mandir}", file)
-            else
-                io.stderr:write("%{nvr}: missing " .. file .. "\n")
-            end
-        end
+if not posix.access("/usr/share/man/mandoc.db") then return end
+require("mandoc")
+mandoc.debug = "%{nvr}(fun)"
+file = rpm.next_file()
+while file do
+    mandoc.remove(file)
         file = rpm.next_file()
-    end
-elseif posix.getenv("VERBOSE_FILETRIGGERS") then
-    print("%{nvr}: missing mandoc.db, skipped")
 end
-io.flush()
+
+%transfiletriggerpostun -p <lua> -- %{_mandir}
+require("mandoc")
+mandoc.debug = "%{nvr}(tfpun)"
+mandoc.done()
 
 %files
 %license LICENSE
@@ -137,6 +119,8 @@
 %{_bindir}/soelim
 %{_bindir}/whatis
 %{_sbindir}/makewhatis
+%dir %{_rpmconfigdir}/lua
+%{_rpmconfigdir}/lua/mandoc.lua
 %{_mandir}/man1/*.1%{?ext_man}
 %{_mandir}/man5/*.5%{?ext_man}
 %{_mandir}/man7/*.7%{?ext_man}

++++++ mandoc.lua ++++++
mandoc = { debug = nil, todo = {}, count = 0, limit = 16 } -- package

function _log(...)
        if mandoc.debug and posix.getenv("VERBOSE_FILETRIGGERS") then
                print(mandoc.debug .. ": ", ...)
        end
end

function mandoc._run(add, file)
        if add then op = "-d" else op = "-u" end
        _log("calling makewhatis " .. op .. " " .. file)
        rpm.execute("/usr/sbin/makewhatis", op, "/usr/share/man", file)
end

function mandoc._handle(add, file)
        if not string.match(file, "/usr/share/man/man[^/]+/[^/]+.gz$") then
                return
        end
        if not posix.access(file) then
                return
        end
--      if mandoc.count < mandoc.limit then
                if add then
                        _log("adding " .. file)
                else
                        _log("removing " .. file)
                end
                mandoc.todo[file] = add
--      elseif mandoc.count == mandoc.limit then
--              _log("too many files, using makewhatis for batch processing")
--      end
        mandoc.count = mandoc.count + 1
end

function mandoc.add(fn)
        mandoc._handle(true, fn)
end

function mandoc.remove(fn)
        mandoc._handle(false, fn)
end

function mandoc.done()
        if mandoc.count < mandoc.limit and 
posix.access("/usr/share/man/mandoc.db") then
                for file, what in pairs(mandoc.todo) do
                        mandoc._run(what, file)
                end
        else
                _log("calling makewhatis")
                rpm.execute("/usr/sbin/makewhatis")
        end
end

Reply via email to