Use rpm.execute() instead of an open-coded variant
See https://rpm-software-management.github.io/rpm/manual/lua.html and
298bb60a9f/rpmio/rpmlua.c (L806-L829)
assert() is not used because it seems better to ignore the error. The
old code would assert on exec(), but not on fork(), and it would not
check the return value either. But if the call fails (for any reason),
an error is printed. At least iconvconfig just seems to fail quietly
in case of a problem.
This commit is contained in:
parent
4f7d89c5d3
commit
f6ed6cf018
40
glibc.spec
40
glibc.spec
@ -111,21 +111,19 @@
|
||||
# any lua %pre, %post, %postun, etc. sections to have them expand into
|
||||
# those scripts. It only works in lua sections and not anywhere else.
|
||||
%global glibc_post_funcs %{expand:
|
||||
-- We use lua posix.exec because there may be no shell that we can run
|
||||
-- during glibc upgrade. We used to implement much of %%post as a C
|
||||
-- program, but from an overall maintenance perspective the lua in the
|
||||
-- spec file was simpler and safer given the operations required.
|
||||
-- We use lua because there may be no shell that we can run during
|
||||
-- glibc upgrade. We used to implement much of %%post as a C program,
|
||||
-- but from an overall maintenance perspective the lua in the spec
|
||||
-- file was simpler and safer given the operations required.
|
||||
-- All lua code will be ignored by rpm-ostree; see:
|
||||
-- https://github.com/projectatomic/rpm-ostree/pull/1869
|
||||
-- If we add new lua actions to the %%post code we should coordinate
|
||||
-- with rpm-ostree and ensure that their glibc install is functional.
|
||||
function post_exec (program, ...)
|
||||
local pid = posix.fork ()
|
||||
if pid == 0 then
|
||||
posix.exec (program, ...)
|
||||
assert (nil)
|
||||
elseif pid > 0 then
|
||||
posix.wait (pid)
|
||||
--
|
||||
-- Note: We use _prefix because Fedora's UsrMove says so.
|
||||
function call_ldconfig ()
|
||||
if not rpm.execute("%{_prefix}/sbin/ldconfig") then
|
||||
io.stdout:write ("Error: call to %{_prefix}/sbin/ldconfig failed.\n")
|
||||
end
|
||||
end
|
||||
|
||||
@ -133,12 +131,15 @@ function update_gconv_modules_cache ()
|
||||
local iconv_dir = "%{_libdir}/gconv"
|
||||
local iconv_cache = iconv_dir .. "/gconv-modules.cache"
|
||||
local iconv_modules = iconv_dir .. "/gconv-modules"
|
||||
if (posix.utime (iconv_modules) == 0) then
|
||||
if (posix.utime (iconv_cache) == 0) then
|
||||
post_exec ("%{_prefix}/sbin/iconvconfig",
|
||||
"-o", iconv_cache,
|
||||
"--nostdlib",
|
||||
iconv_dir)
|
||||
if posix.utime(iconv_modules) == 0 then
|
||||
if posix.utime (iconv_cache) == 0 then
|
||||
if not rpm.execute("%{_prefix}/sbin/iconvconfig",
|
||||
"-o", iconv_cache,
|
||||
"--nostdlib",
|
||||
iconv_dir)
|
||||
then
|
||||
io.stdout:write ("Error: call to %{_prefix}/sbin/iconvconfig failed.\n")
|
||||
end
|
||||
else
|
||||
io.stdout:write ("Error: Missing " .. iconv_cache .. " file.\n")
|
||||
end
|
||||
@ -2047,8 +2048,7 @@ end
|
||||
-- the cache early to avoid any problems running binaries with
|
||||
-- the new glibc.
|
||||
|
||||
-- Note: We use _prefix because Fedora's UsrMove says so.
|
||||
post_exec ("%{_prefix}/sbin/ldconfig")
|
||||
call_ldconfig()
|
||||
|
||||
-- (4) Update gconv modules cache.
|
||||
-- If the /usr/lib/gconv/gconv-modules.cache exists, then update it
|
||||
@ -2060,7 +2060,7 @@ update_gconv_modules_cache()
|
||||
|
||||
-- (5) On upgrades, restart systemd if installed. "systemctl -q" does
|
||||
-- not suppress the error message (which is common in chroots), so
|
||||
-- open-code post_exec with standard error suppressed.
|
||||
-- open-code rpm.execute with standard error suppressed.
|
||||
if tonumber(arg[2]) >= 2
|
||||
and posix.access("%{_prefix}/bin/systemctl", "x")
|
||||
then
|
||||
|
Loading…
Reference in New Issue
Block a user