move locale.gen configuration from glibc to glibc-utils to fix some upgrade failures cases [release 2.40-4mamba;Sun Oct 13 2024]

This commit is contained in:
Silvan Calarco 2024-10-13 21:07:39 +02:00
parent a6c28131e0
commit 57c9221784

View File

@ -87,7 +87,7 @@
Name: glibc Name: glibc
Version: 2.40 Version: 2.40
Release: 3mamba Release: 4mamba
Summary: The GNU libc libraries Summary: The GNU libc libraries
Group: System/Libraries Group: System/Libraries
Vendor: openmamba Vendor: openmamba
@ -104,12 +104,6 @@ Patch5: glibc-2.16.0-localedata_openmamba.patch
Patch17: glibc-2.21-prevent-ehaustion-of-tls-slots.patch Patch17: glibc-2.21-prevent-ehaustion-of-tls-slots.patch
License: LGPL License: LGPL
## AUTOBUILDREQ-BEGIN ## AUTOBUILDREQ-BEGIN
BuildRequires: libaudit-devel
BuildRequires: libcap-devel
BuildRequires: libgd-devel
BuildRequires: libpng-devel
BuildRequires: libselinux-devel
BuildRequires: libz-devel
## AUTOBUILDREQ-END ## AUTOBUILDREQ-END
BuildRequires: libidn-devel BuildRequires: libidn-devel
BuildRequires: binutils >= 2.13 BuildRequires: binutils >= 2.13
@ -135,9 +129,9 @@ BuildRequires: kernelsanitisedheaders
BuildRequires: libpython3-devel BuildRequires: libpython3-devel
BuildRequires: elfutils BuildRequires: elfutils
%endif %endif
Requires(post): ldconfig = %{?epoch:%epoch:}%{version}-%{release} Requires: ldconfig = %{?epoch:%epoch:}%{version}-%{release}
Requires(post): glibc-utils = %{?epoch:%epoch:}%{version}-%{release} Requires: glibc-common = %{?epoch:%epoch:}%{version}-%{release}
Requires(post): glibc-common = %{?epoch:%epoch:}%{version}-%{release} Requires: glibc-utils = %{?epoch:%epoch:}%{version}-%{release}
Requires(pre): libxcrypt Requires(pre): libxcrypt
%systemd_requires %systemd_requires
@ -222,7 +216,8 @@ Pregenerated locales for the GNU C Library.
%package utils %package utils
Summary: Development utilities from GNU C library Summary: Development utilities from GNU C library
Group: Development/Tools Group: Development/Tools
Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release} Requires(post): %{name} = %{?epoch:%epoch:}%{version}-%{release}
Requires(post): glibc-common = %{?epoch:%epoch:}%{version}-%{release}
%description utils %description utils
The glibc-utils package contains memusage, a memory usage profiler, mtrace, a memory leak tracer and, a function call tracer which can be helpful during program debugging. The glibc-utils package contains memusage, a memory usage profiler, mtrace, a memory leak tracer and, a function call tracer which can be helpful during program debugging.
@ -409,9 +404,9 @@ _configure_flags=(
#:<< __EOF #:<< __EOF
# Build # Build
rm -rf ../glibc-build rm -rf ../glibc-build-%{_target_platform}
mkdir ../glibc-build mkdir ../glibc-build-%{_target_platform}
cd ../glibc-build cd ../glibc-build-%{_target_platform}
export CFLAGS="$buildflags" export CFLAGS="$buildflags"
export CXXFLAGS="$buildflags" export CXXFLAGS="$buildflags"
@ -460,9 +455,9 @@ make pdf html
%if "%{?stage1}" != "1" %if "%{?stage1}" != "1"
%if "%{?stage2}" != "1" %if "%{?stage2}" != "1"
# Multilib # Multilib
rm -rf ../glibc-multilib-build rm -rf ../glibc-multilib-build-%{_target_platform}
mkdir ../glibc-multilib-build mkdir ../glibc-multilib-build-%{_target_platform}
cd ../glibc-multilib-build cd ../glibc-multilib-build-%{_target_platform}
export CC="gcc -m32 -mstackrealign" export CC="gcc -m32 -mstackrealign"
export CXX="g++ -m32 -mstackrealign" export CXX="g++ -m32 -mstackrealign"
@ -502,7 +497,7 @@ _EOF
%if "%{_target_platform}" == "%{_host}" %if "%{_target_platform}" == "%{_host}"
# Multilib # Multilib
%ifarch x86_64 %ifarch x86_64
%makeinstall -C ../glibc-multilib-build %makeinstall -C ../glibc-multilib-build-%{_target_platform}
cat > %{buildroot}%{_sysconfdir}/ld.so.conf.d/lib32-glibc.conf << _EOF cat > %{buildroot}%{_sysconfdir}/ld.so.conf.d/lib32-glibc.conf << _EOF
/usr/lib32 /usr/lib32
_EOF _EOF
@ -511,7 +506,7 @@ ln -s ../lib/locale %{buildroot}/usr/lib32/locale
%endif %endif
%endif %endif
%makeinstall -C ../glibc-build %makeinstall -C ../glibc-build-%{_target_platform}
%if "%{_target_platform}" == "%{_build}" %if "%{_target_platform}" == "%{_build}"
%ifarch aarch64 %ifarch aarch64
@ -526,12 +521,12 @@ ln -s ../lib/locale %{buildroot}/usr/lib32/locale
sed -e '1,3d' -e 's|/| |g' -e 's| \\||g' -e 's|^|#|g' \ sed -e '1,3d' -e 's|/| |g' -e 's| \\||g' -e 's|^|#|g' \
localedata/SUPPORTED >> %{buildroot}%{_sysconfdir}/locale.gen localedata/SUPPORTED >> %{buildroot}%{_sysconfdir}/locale.gen
sed -i '/#C\.UTF-8 /d' %{buildroot}%{_sysconfdir}/locale.gen sed -i '/#C\.UTF-8 /d' %{buildroot}%{_sysconfdir}/locale.gen
make localedata/install-locale-files -C ../glibc-build install_root=%{buildroot} make localedata/install-locale-files -C ../glibc-build-%{_target_platform} install_root=%{buildroot}
%else %else
# WORKAROUND: worked up to 2.21 # WORKAROUND: worked up to 2.21
mkdir -p %{buildroot}%{_prefix}/lib/locale mkdir -p %{buildroot}%{_prefix}/lib/locale
make LOCALEDEF="I18NPATH=. LC_ALL=C localedef" localedata/install-locale-files -C ../glibc-build install_root=%{buildroot} make LOCALEDEF="I18NPATH=. LC_ALL=C localedef" localedata/install-locale-files -C ../glibc-build-%{_target_platform} install_root=%{buildroot}
install -d -m0755 %{buildroot}%{glibc_prefix}/lib/locale/ install -d -m0755 %{buildroot}%{glibc_prefix}/lib/locale/
mv %{buildroot}%{_prefix}/lib/locale/* %{buildroot}%{glibc_prefix}/lib/locale/ mv %{buildroot}%{_prefix}/lib/locale/* %{buildroot}%{glibc_prefix}/lib/locale/
%endif %endif
@ -549,7 +544,7 @@ ln -s ../lib/locale %{buildroot}/usr/lib32/locale
[-e %{buildroot}%{glibc_libdir}/libbsd-compat.a ] && ln -sf libbsd-compat.a %{buildroot}%{glibc_libdir}/libbsd.a [-e %{buildroot}%{glibc_libdir}/libbsd-compat.a ] && ln -sf libbsd-compat.a %{buildroot}%{glibc_libdir}/libbsd.a
%else %else
# stage 1 # stage 1
make -C ../glibc-build install-headers install_root=%{buildroot} cross-compiling=yes make -C ../glibc-build-%{_target_platform} install-headers install_root=%{buildroot} cross-compiling=yes
# the following files are generated during the glibc build. # the following files are generated during the glibc build.
# Fortunately, it is sufficient to substitute empty files for a first stage gcc build # Fortunately, it is sufficient to substitute empty files for a first stage gcc build
touch %{buildroot}%{glibc_includedir}/gnu/stubs.h touch %{buildroot}%{glibc_includedir}/gnu/stubs.h
@ -623,8 +618,8 @@ ln -s locale.h %{buildroot}%{_includedir}/xlocale.h
#install api documentation #install api documentation
%if %{build_doc} %if %{build_doc}
install -d %{buildroot}%{_docdir}/libc/html install -d %{buildroot}%{_docdir}/libc/html
cp -a ../glibc-build/manual/libc/* %{buildroot}%{_docdir}/libc/html/ cp -a ../glibc-build-%{_target_platform}/manual/libc/* %{buildroot}%{_docdir}/libc/html/
cp -a ../glibc-build/manual/libc.pdf %{buildroot}%{_docdir}/libc/ cp -a ../glibc-build-%{_target_platform}/manual/libc.pdf %{buildroot}%{_docdir}/libc/
%endif %endif
%endif %endif
@ -638,123 +633,24 @@ rm -rf %{buildroot}%{glibc_datadir}/zoneinfo
%clean %clean
[ "%{buildroot}" != / ] && rm -rf %{buildroot} [ "%{buildroot}" != / ] && rm -rf %{buildroot}
%post %post utils
if [ $1 -ge 1 ]; then if [ $1 -ge 1 ]; then
cat > /tmp/migrate-libdirs.sh << _EOF # update locale.gen to make sure current LANG locale is enabled
#!/bin/bash LOCALES=(`grep ${LANG/utf*/UTF-8} %{glibc_datadir}/i18n/SUPPORTED | awk '{ print $1 }'`);
d=\$1 for l in ${LOCALES[*]/\/*/}; do
echo "Migrating /\$d.notmigrated/* to /usr/\$d..." sed -i "s|#${l}|${l}|" %{_sysconfdir}/locale.gen
for f in \${d}.notmigrated/*; do done
dest=/usr\${f/.notmigrated} # update locale-archive according to locale.gen
if [ -e \$dest ]; then locale-gen
#echo "\$f exists as \$dest"
if [ -L \$f ]; then
linkdest=\`readlink \$f\`
#echo "\$f is a symlink to \$linkdest"
/usr/bin/rm -f \$f
elif [ -L \$dest ]; then
linkdest=\`readlink \$dest\`
#echo "\$dest is a symlink to \$linkdest"
/usr/bin/rm -f \$dest && mv \$f \$dest
else
#echo "\$f exists as a file also as \$linkdest"
if [ -d \${f} ]; then
# second level
for f1 in \${f}/*; do
dest=/usr\${f1/.notmigrated}
if [ -e \$dest ]; then
#echo "$f1 exists as $dest"
if [ -L \$f1 ]; then
linkdest=\`readlink \$f1\`
#echo "$f1 is a symlink to $linkdest"
/usr/bin/rm -f \$f1
elif [ -L \$dest ]; then
linkdest=\`readlink \$dest\`
#echo "$dest is a symlink to $linkdest"
/usr/bin/rm -f \$dest && mv \$f1 \$dest
else
/usr/bin/rm -f \$f1
fi
else
if [ -L \$f1 ]; then
linkdest=\`readlink \$f1\`
if [ "\${linkdest:0:3}" = "../" ]; then
fulllinkdest=\`readlink -f \$f1\`
#echo "$f1 is a symlink pointing to ../ -> fixing"
/usr/bin/ln -s \$fulllinkdest \$dest
/usr/bin/rm -f \$f1
else
/usr/bin/mv \$f1 \$dest
fi
else
/usr/bin/mv \$f1 \$dest
fi
fi
[ -d \${f1} ] && /usr/bin/rmdir \${f1}
done
/usr/bin/rmdir \${f}
else
/usr/bin/rm -f \$f
fi
fi
else
if [ -L \$f ]; then
linkdest=\`readlink \$f\`
if [ "\${linkdest:0:3}" = "../" ]; then
fulllinkdest=\`readlink -f \$f\`
#echo "\$f is a symlink pointing to ../ -> fixing"
/usr/bin/ln -s \$fulllinkdest \$dest
/usr/bin/rm -f \$f
else
/usr/bin/mv \$f \$dest
fi
else
/usr/bin/mv \$f \$dest
fi
fi
done
/usr/bin/rmdir \${d}.notmigrated
_EOF
chmod +x /tmp/migrate-libdirs.sh
fi fi
# update locale.gen to make sure current LANG locale is enabled
LOCALES=(`grep ${LANG/utf*/UTF-8} %{glibc_datadir}/i18n/SUPPORTED | awk '{ print $1 }'`);
for l in ${LOCALES[*]/\/*/}; do
sed -i "s|#${l}|${l}|" %{_sysconfdir}/locale.gen
done
# update locale-archive according to locale.gen
locale-gen
: :
# Restore ld-linux loader after removing from /lib[64] to fix /usr/lib[64] migration %posttrans utils
%triggerpostun -p <lua> -- glibc < 2.34-4mamba if [ $1 -ge 1 ]; then
local libdirs = { # Regenerated locale-archive if it has been deleted by a old glibc
[1] = "/lib64", [ -e /usr/lib/locale/locale-archive ] || locale-gen
[2] = "/lib", fi
} :
for i, l in ipairs(libdirs) do
stat_libdir = posix.stat(l)
if stat_libdir ~= nil then
if stat_libdir.mode ~= "rwxrwxrwx" then
-- lib dir exists and is not already a symlink
-- Check that old glibc has been cleaned in this dir (or fails on multilib glibc on x86_64)
stat_check_cleaned = posix.stat(l .. "/libc.so.6")
if stat_check_cleaned == nil then
-- All seems ok to migrate
print("Migrating " .. l .. " to /usr" .. l .. "..")
os.rename(l, l .. ".notmigrated")
posix.symlink("usr" .. l,l)
local pid = posix.fork()
if pid == 0 then
posix.exec("/tmp/migrate-libdirs.sh", l)
elseif pid > 0 then
posix.wait(pid)
end
end
end
end
end
%ifarch x86_64 %ifarch x86_64
%transfiletriggerin -n ldconfig -P 2000000 -- %{_libdir} %{_prefix}/lib %transfiletriggerin -n ldconfig -P 2000000 -- %{_libdir} %{_prefix}/lib
@ -967,6 +863,9 @@ fi
%endif %endif
%changelog %changelog
* Sun Oct 13 2024 Silvan Calarco <silvan.calarco@mambasoft.it> 2.40-4mamba
- move locale.gen configuration from glibc to glibc-utils to fix some upgrade failures cases
* Fri Oct 11 2024 Silvan Calarco <silvan.calarco@mambasoft.it> 2.40-3mamba * Fri Oct 11 2024 Silvan Calarco <silvan.calarco@mambasoft.it> 2.40-3mamba
- provide locale-gen and /etc/locale.gen mechanism to generate /usr/lib/locale-archive - provide locale-gen and /etc/locale.gen mechanism to generate /usr/lib/locale-archive
- provide C.utf8 as always preinstalled locale - provide C.utf8 as always preinstalled locale