"Carlos O'Donell" <carlos(a)redhat.com> writes:
v2
- Fixed SOURCE0 reference in comment.
- Fixed iconvconfig inclusion in glibc.filelist.
- Fixed iconvconfig removal from common.filelist.
- Created post_exec function to run execs with asserts to check for errors.
- Switched step 1 to use tighter regexps.
- Switched step 1 to use %{_libdir} where possible.
- Fixed step 2 to use io.lines and simplify.
- Always run ldconfig in step 3 using post_exec
- Step 4 uses post_exec also.
diff --git a/glibc-post_upgrade.patch b/glibc-post_upgrade.patch
deleted file mode 100644
index a64adfc..0000000
--- a/glibc-post_upgrade.patch
+++ /dev/null
Deletes unneeded patch. OK.
-Release: 21%{?dist}
+Release: 22%{?dist}
Ok
-Patch1: glibc-post_upgrade.patch
Removes unneeded patch. Ok.
-# We need to run ldconfig manually because ldconfig cannot handle
the
-# relative include path in the /etc/ld.so.conf file we gneerate.
+# We need to run ldconfig manually because __brp_ldconfig assumes that
+# glibc itself is always installed in $RPM_BUILD_ROOT, but with sysroots
+# we may be installed into a subdirectory of that path. Therefore we
+# unset __brp_ldconfig and run ldconfig by hand with the sysroots path
+# passed to -r.
Ok.
-# Install the upgrade program
-install -m 700 build-%{target}/elf/glibc_post_upgrade \
- %{glibc_sysroot}%{_prefix}/sbin/glibc_post_upgrade.%{_target_cpu}
-
Don't install the program we no longer need. OK.
-# which is to at least keep the timestamp consistent. The choice of
using
-# glibc_post_upgrade.c is arbitrary.
+# which is to at least keep the timestamp consistent. The choice of using
+# SOURCE0 is arbitrary.
Ok.
-# - The use of [^gi] is meant to exclude all files except
glibc_post_upgrade,
-# and iconvconfig, which we want in the main packages.
+# - We want iconvconfig in the main package and we do this by using
+# a double negation of -v and [^i] so it removes all files in
+# sbin *but* iconvconfig.
Ok. Possibly TMI but ok. It's a weird thing it's doing, hard to
document...
- -e '%{_prefix}/sbin/[^gi]' \
+ -e '%{_prefix}/sbin/[^i]' \
Take out reference to program we no longer have, leave the rest alone.
Ok.
-# glibc_post_upgrade.* and iconvconfig which need to go in glibc.
Likewise
-# nscd is excluded because it goes in nscd.
+# iconvconfig which needs to go in glibc. Likewise nscd is excluded because
+# it goes in nscd.
Ok.
-grep '%{_prefix}/sbin/[^gi]' master.filelist \
+grep '%{_prefix}/sbin' master.filelist \
+ | grep -v '%{_prefix}/sbin/iconvconfig' \
Net result - everything in sbin except iconconfig, both ways. Ok.
-%post -p %{_prefix}/sbin/glibc_post_upgrade.%{_target_cpu}
+%post -p <lua>
+-- We use lua's posix.exec because there may be no shell that we can
+-- run during glibc upgrade.
+function post_exec (program, ...)
+ local pid = posix.fork ()
+ if pid == 0 then
+ assert (posix.exec (program, ...))
+ elseif pid > 0 then
+ posix.wait (pid)
+ end
+end
Ok.
+
+-- (1) Remove multilib libraries from previous installs.
+-- In order to support in-place upgrades, we must immediately remove
+-- obsolete platform directories after installing a new glibc
+-- version. RPM only deletes files removed by updates near the end
+-- of the transaction. If we did not remove the obsolete platform
+-- directories here, they may be preferred by the dynamic linker
+-- during the execution of subsequent RPM scriptlets, likely
+-- resulting in process startup failures.
+
+-- We are going to remove these libraries. Generally speaking we remove
+-- all core libraries in the multilib directory.
+-- We employ a tight match on libc-X.Y.so where X > 2 and Y > 2?, and
+-- related libraries so we would match "libc-2.20.so" and higher.
+remove_regexps = { "libc%%-[2-9][0-9]*%%.[2-9][0-9]+%%.so",
+ "libm%%-[2-9][0-9]*%%.[2-9][0-9]+%%.so",
+ "librt%%-[2-9][0-9]*%%.[2-9][0-9]+%%.so",
+ "libpthread%%-[2-9][0-9]*%%.[2-9][0-9]+%%.so",
+ "librtkaio%%-[2-9][0-9]*%%.[2-9][0-9]+%%.so",
+ "libthread_db%%-[1-9][0-9]*%%.[0-9]+%%.so" }
+
Noted that libthread_db is exception. Will not match libc-3.10.
+-- We are going to search these directories.
+local remove_dirs = { "%{_libdir}/i686",
+ "%{_libdir}/i686/nosegneg",
+ "%{_libdir}/power6",
+ "%{_libdir}/power7",
+ "%{_libdir}/power8" }
+
List of obsolete multilibs, ok.
+-- Walk all the directories with files we need to remove...
+for _, rdir in ipairs (remove_dirs) do
+ if posix.access (rdir) then
+ -- If the directory exists we look at all the files...
+ local remove_files = posix.files (rdir)
+ for rfile in remove_files do
+ for _, rregexp in ipairs (remove_regexps) do
+ -- Does it match the regexp?
+ local dso = string.match (rfile, rregexp)
+ if (dso ~= nil) then
+ -- Removing file...
+ os.remove (rdir .. '/' .. rfile)
+ end
+ end
+ end
+ end
+end
+
Ok.
+-- (2) Update /etc/ld.so.conf
+-- Next we update /etc/ld.so.conf to ensure that it starts with
+-- a literal "include ld.so.conf.d/*.conf".
+
+local ldsoconf = "/etc/ld.so.conf"
+local ldsoconf_tmp = "/etc/glibc_post_upgrade.ld.so.conf"
+
+if posix.access (ldsoconf) then
+
+ -- We must have a "include ld.so.conf.d/*.conf" line.
+ local have_include = false
+ for line in io.lines (ldsoconf) do
+ -- This must match, and we don't ignore whitespace.
+ if string.match (line, "^include ld.so.conf.d/%*%.conf$") ~= nil then
+ have_include = true
+ end
+ end
+
+ if not have_include then
+ -- Insert "include ld.so.conf.d/*.conf" line at the start of the
+ -- file. We only support one of these post upgrades running at
+ -- a time (temporary file name is fixed).
+ local tmp_fd = io.open (ldsoconf_tmp, "w")
+ if tmp_fd ~= nil then
+ tmp_fd:write ("include ld.so.conf.d/*.conf\n")
+ for line in io.lines (ldsoconf) do
+ tmp_fd:write (line .. "\n")
+ end
+ tmp_fd:close ()
+ local res = os.rename (ldsoconf_tmp, ldsoconf)
+ if res == nil then
+ io.stdout:write ("Error: Unable to update configuration file
(rename).\n")
+ end
+ else
+ io.stdout:write ("Error: Unable to update configuration file
(open).\n")
+ end
+ end
+end
Ok.
+-- (3) Rebuild ld.so.cache early.
+-- If the format of the cache changes then we need to rebuild
+-- 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")
Ok.
+-- (4) Update gconv modules cache.
+-- If the /usr/lib/gconv/gconv-modules.cache exists, then update it
+-- with the latest set of modules that were just installed.
+-- We assume that the cache is in _libdir/gconv and called
+-- "gconv-modules.cache".
+
+local iconv_dir = "%{_libdir}/gconv"
+local iconv_cache = iconv_dir .. "/gconv-modules.cache"
+if (posix.utime (iconv_cache) == 0) then
+ post_exec ("%{_prefix}/sbin/iconvconfig",
+ "-o", iconv_cache,
+ "--nostdlib",
+ iconv_dir)
+else
+ io.stdout:write ("Error: Missing " .. iconv_cache .. " file.\n")
+end
Ok.
diff --git a/glibc_post_upgrade.c b/glibc_post_upgrade.c
deleted file mode 100644
index 9014857..0000000
--- a/glibc_post_upgrade.c
+++ /dev/null
Deleting unneeded file, ok.