summaryrefslogtreecommitdiff
path: root/ai-toolset-glibc.spec
blob: 2accdb7d00f5dec37e8706d37d7e09c2a1e59b8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
%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-toolset-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 <example@example.com> - 2.17-1
- Switch sources from RPM files to converted tar.gz payload archives

* Thu May 28 2026 Example Maintainer <example@example.com> - 2.17-1
- Extract EL7 glibc RPM payloads into gcc-toolset-7 sysroot for openEuler 24.03