%global gcc_toolset_base /opt/openEuler/gcc-toolset-7 %global gcc_toolset_root %{gcc_toolset_base}/root %global debug_package %{nil} %ifarch x86_64 %global glibc_tar %{SOURCE0} %global glibc_common_tar %{SOURCE1} %global glibc_devel_tar %{SOURCE2} %global glibc_headers_tar %{SOURCE3} %global arch_asm_dir x86_64-linux-gnu %endif %ifarch aarch64 %global glibc_tar %{SOURCE4} %global glibc_common_tar %{SOURCE5} %global glibc_devel_tar %{SOURCE6} %global glibc_headers_tar %{SOURCE7} %global arch_asm_dir aarch64-linux-gnu %endif Name: ai-builder-glibc Version: 2.17 Release: 1%{?dist} Summary: Extract EL7 glibc runtime and development files for gcc-toolset-7 sysroot License: LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ URL: https://www.gnu.org/software/libc/ # Put these tar.gz files into rpmbuild SOURCES. They are RPM payloads already # converted to archive form, and the package build selects the matching set by # target architecture. Source0: glibc-2.17-326.el7_9.x86_64.tar.gz Source1: glibc-common-2.17-317.el7.x86_64.tar.gz Source2: glibc-devel-2.17-317.el7.x86_64.tar.gz Source3: glibc-headers-2.17-317.el7.x86_64.tar.gz Source4: glibc-2.17-326.el7_9.aarch64.tar.gz Source5: glibc-common-2.17-317.el7.aarch64.tar.gz Source6: glibc-devel-2.17-317.el7.aarch64.tar.gz Source7: glibc-headers-2.17-317.el7.aarch64.tar.gz ExclusiveArch: x86_64 aarch64 BuildRequires: gzip BuildRequires: tar # The extracted EL7 glibc is private to %%{gcc_toolset_root}. Do not let RPM # dependency generators advertise these files as system glibc providers. AutoReqProv: no Provides: bundled(glibc) = %{version} %description This package extracts glibc, glibc-common, glibc-devel and glibc-headers binary RPM payload archives into the private gcc-toolset-7 sysroot layout used on openEuler 24.03. It is intended to provide the libc runtime, crt objects, linker scripts and headers needed by the devtoolset-7 GCC build flow. %prep rm -rf extract-root mkdir -p extract-root cd extract-root for tar_file in \ "%{glibc_tar}" \ "%{glibc_common_tar}" \ "%{glibc_devel_tar}" \ "%{glibc_headers_tar}" do tar --no-same-owner -xzf "${tar_file}" done %build # Nothing to build. This package only repackages glibc files into a private # gcc-toolset-7 sysroot. %install rm -rf %{buildroot} install -d -m 0755 %{buildroot}%{gcc_toolset_root} cp -a extract-root/. %{buildroot}%{gcc_toolset_root}/ # glibc-devel/glibc-headers depend on kernel headers. Keep the same behavior # as build-devtoolset7.sh: use the openEuler 24.03 system kernel headers from # outside the private sysroot. Use relative symlink targets to avoid RPM # absolute-symlink warnings while resolving to the same host headers. install -d -m 0755 %{buildroot}%{gcc_toolset_root}/usr/include rm -rf \ %{buildroot}%{gcc_toolset_root}/usr/include/linux \ %{buildroot}%{gcc_toolset_root}/usr/include/asm-generic \ %{buildroot}%{gcc_toolset_root}/usr/include/asm ln -sfn ../../../../../../usr/include/linux \ %{buildroot}%{gcc_toolset_root}/usr/include/linux ln -sfn ../../../../../../usr/include/asm-generic \ %{buildroot}%{gcc_toolset_root}/usr/include/asm-generic ln -sfn ../../../../../../usr/include/asm \ %{buildroot}%{gcc_toolset_root}/usr/include/asm # Some GCC probes and older build scripts look for the Debian/Ubuntu-style # architecture include directory. Point it at the rpm-style asm headers. install -d -m 0755 %{buildroot}%{gcc_toolset_root}/usr/include/%{arch_asm_dir} rm -rf %{buildroot}%{gcc_toolset_root}/usr/include/%{arch_asm_dir}/asm ln -sfn ../../../../../../../usr/include/asm \ %{buildroot}%{gcc_toolset_root}/usr/include/%{arch_asm_dir}/asm # RPM payloads may contain absolute symlinks such as /lib64/libc-2.17.so. # Inside the private sysroot they should resolve to %%{gcc_toolset_root}/lib64. find %{buildroot}%{gcc_toolset_root} -type l | while read link_path do link_target="$(readlink "${link_path}")" case "${link_target}" in /lib*|/usr/lib*) ln -sfn "%{gcc_toolset_root}${link_target}" "${link_path}" ;; esac done # Convenience environment file matching the new openEuler installation prefix. cat > %{buildroot}%{gcc_toolset_base}/enable <<'EOF' export PATH=/opt/openEuler/gcc-toolset-7/root/usr/bin:${PATH} export CC=/opt/openEuler/gcc-toolset-7/root/usr/bin/gcc export CXX=/opt/openEuler/gcc-toolset-7/root/usr/bin/g++ EOF %files %dir /opt/openEuler %dir %{gcc_toolset_base} %{gcc_toolset_base}/enable %{gcc_toolset_root} %changelog * Tue Jun 09 2026 Example Maintainer - 2.17-1 - Switch sources from RPM files to converted tar.gz payload archives * Thu May 28 2026 Example Maintainer - 2.17-1 - Extract EL7 glibc RPM payloads into gcc-toolset-7 sysroot for openEuler 24.03