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
34
glibc.spec
34
glibc.spec
@ -111,21 +111,19 @@
|
|||||||
# any lua %pre, %post, %postun, etc. sections to have them expand into
|
# any lua %pre, %post, %postun, etc. sections to have them expand into
|
||||||
# those scripts. It only works in lua sections and not anywhere else.
|
# those scripts. It only works in lua sections and not anywhere else.
|
||||||
%global glibc_post_funcs %{expand:
|
%global glibc_post_funcs %{expand:
|
||||||
-- We use lua posix.exec because there may be no shell that we can run
|
-- We use lua because there may be no shell that we can run during
|
||||||
-- during glibc upgrade. We used to implement much of %%post as a C
|
-- glibc upgrade. We used to implement much of %%post as a C program,
|
||||||
-- program, but from an overall maintenance perspective the lua in the
|
-- but from an overall maintenance perspective the lua in the spec
|
||||||
-- spec file was simpler and safer given the operations required.
|
-- file was simpler and safer given the operations required.
|
||||||
-- All lua code will be ignored by rpm-ostree; see:
|
-- All lua code will be ignored by rpm-ostree; see:
|
||||||
-- https://github.com/projectatomic/rpm-ostree/pull/1869
|
-- https://github.com/projectatomic/rpm-ostree/pull/1869
|
||||||
-- If we add new lua actions to the %%post code we should coordinate
|
-- If we add new lua actions to the %%post code we should coordinate
|
||||||
-- with rpm-ostree and ensure that their glibc install is functional.
|
-- with rpm-ostree and ensure that their glibc install is functional.
|
||||||
function post_exec (program, ...)
|
--
|
||||||
local pid = posix.fork ()
|
-- Note: We use _prefix because Fedora's UsrMove says so.
|
||||||
if pid == 0 then
|
function call_ldconfig ()
|
||||||
posix.exec (program, ...)
|
if not rpm.execute("%{_prefix}/sbin/ldconfig") then
|
||||||
assert (nil)
|
io.stdout:write ("Error: call to %{_prefix}/sbin/ldconfig failed.\n")
|
||||||
elseif pid > 0 then
|
|
||||||
posix.wait (pid)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -133,12 +131,15 @@ function update_gconv_modules_cache ()
|
|||||||
local iconv_dir = "%{_libdir}/gconv"
|
local iconv_dir = "%{_libdir}/gconv"
|
||||||
local iconv_cache = iconv_dir .. "/gconv-modules.cache"
|
local iconv_cache = iconv_dir .. "/gconv-modules.cache"
|
||||||
local iconv_modules = iconv_dir .. "/gconv-modules"
|
local iconv_modules = iconv_dir .. "/gconv-modules"
|
||||||
if (posix.utime (iconv_modules) == 0) then
|
if posix.utime(iconv_modules) == 0 then
|
||||||
if (posix.utime (iconv_cache) == 0) then
|
if posix.utime (iconv_cache) == 0 then
|
||||||
post_exec ("%{_prefix}/sbin/iconvconfig",
|
if not rpm.execute("%{_prefix}/sbin/iconvconfig",
|
||||||
"-o", iconv_cache,
|
"-o", iconv_cache,
|
||||||
"--nostdlib",
|
"--nostdlib",
|
||||||
iconv_dir)
|
iconv_dir)
|
||||||
|
then
|
||||||
|
io.stdout:write ("Error: call to %{_prefix}/sbin/iconvconfig failed.\n")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
io.stdout:write ("Error: Missing " .. iconv_cache .. " file.\n")
|
io.stdout:write ("Error: Missing " .. iconv_cache .. " file.\n")
|
||||||
end
|
end
|
||||||
@ -2047,8 +2048,7 @@ end
|
|||||||
-- the cache early to avoid any problems running binaries with
|
-- the cache early to avoid any problems running binaries with
|
||||||
-- the new glibc.
|
-- the new glibc.
|
||||||
|
|
||||||
-- Note: We use _prefix because Fedora's UsrMove says so.
|
call_ldconfig()
|
||||||
post_exec ("%{_prefix}/sbin/ldconfig")
|
|
||||||
|
|
||||||
-- (4) Update gconv modules cache.
|
-- (4) Update gconv modules cache.
|
||||||
-- If the /usr/lib/gconv/gconv-modules.cache exists, then update it
|
-- 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
|
-- (5) On upgrades, restart systemd if installed. "systemctl -q" does
|
||||||
-- not suppress the error message (which is common in chroots), so
|
-- 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
|
if tonumber(arg[2]) >= 2
|
||||||
and posix.access("%{_prefix}/bin/systemctl", "x")
|
and posix.access("%{_prefix}/bin/systemctl", "x")
|
||||||
then
|
then
|
||||||
|
Loading…
Reference in New Issue
Block a user