forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglibc.spec
272 lines (239 loc) · 9.43 KB
/
glibc.spec
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
Name: %{_cross_os}glibc
Version: 2.38
Release: 1%{?dist}
Summary: The GNU libc libraries
License: LGPL-2.1-or-later AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND GPL-2.0-or-later AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND BSD-3-Clause AND ISC
URL: http://www.gnu.org/software/glibc/
Source0: https://ftp.gnu.org/gnu/glibc/glibc-%{version}.tar.xz
Source1: glibc-tmpfiles.conf
Source2: ld.so.conf
Source3: ldconfig-service.conf
Source4: tz-utc.txt
# We include this patch as a source file to have more control over how it's
# applied and reverted during the build.
Source99: HACK-only-build-and-install-localedef.patch
# Upstream patches from 2.38 release branch:
# ```
# git checkout origin/release/2.38/master
# git format-patch --no-numbered glibc-2.38..
# ```
Patch0001: 0001-stdlib-Improve-tst-realpath-compatibility-with-sourc.patch
Patch0002: 0002-x86-Fix-for-cache-computation-on-AMD-legacy-cpus.patch
Patch0003: 0003-nscd-Do-not-rebuild-getaddrinfo-bug-30709.patch
Patch0004: 0004-x86-Fix-incorrect-scope-of-setting-shared_per_thread.patch
Patch0005: 0005-x86_64-Fix-build-with-disable-multiarch-BZ-30721.patch
Patch0006: 0006-i686-Fix-build-with-disable-multiarch.patch
Patch0007: 0007-malloc-Enable-merging-of-remainders-in-memalign-bug-.patch
Patch0008: 0008-malloc-Remove-bin-scanning-from-memalign-bug-30723.patch
Patch0009: 0009-sysdeps-tst-bz21269-fix-test-parameter.patch
Patch0010: 0010-sysdeps-tst-bz21269-handle-ENOSYS-skip-appropriately.patch
Patch0011: 0011-sysdeps-tst-bz21269-fix-Wreturn-type.patch
Patch0012: 0012-io-Fix-record-locking-contants-for-powerpc64-with-__.patch
Patch0013: 0013-libio-Fix-oversized-__io_vtables.patch
Patch0014: 0014-elf-Do-not-run-constructors-for-proxy-objects.patch
Patch0015: 0015-elf-Always-call-destructors-in-reverse-constructor-o.patch
Patch0016: 0016-elf-Remove-unused-l_text_end-field-from-struct-link_.patch
Patch0017: 0017-elf-Move-l_init_called_next-to-old-place-of-l_text_e.patch
Patch0018: 0018-NEWS-Add-the-2.38.1-bug-list.patch
Patch0019: 0019-CVE-2023-4527-Stack-read-overflow-with-large-TCP-res.patch
Patch0020: 0020-getaddrinfo-Fix-use-after-free-in-getcanonname-CVE-2.patch
Patch0021: 0021-iconv-restore-verbosity-with-unrecognized-encoding-n.patch
Patch0022: 0022-string-Fix-tester-build-with-fortify-enable-with-gcc.patch
Patch0023: 0023-manual-jobs.texi-Add-missing-item-EPERM-for-getpgid.patch
Patch0024: 0024-Fix-leak-in-getaddrinfo-introduced-by-the-fix-for-CV.patch
Patch0025: 0025-Document-CVE-2023-4806-and-CVE-2023-5156-in-NEWS.patch
Patch0026: 0026-Propagate-GLIBC_TUNABLES-in-setxid-binaries.patch
Patch0027: 0027-tunables-Terminate-if-end-of-input-is-reached-CVE-20.patch
# Fedora patches
Patch1001: glibc-cs-path.patch
# Local patches
Patch9001: 9001-move-ldconfig-cache-to-ephemeral-storage.patch
%description
%{summary}.
%package devel
Summary: Files for development using the GNU libc libraries.
Requires: %{name}
%description devel
%{summary}.
%prep
%autosetup -Sgit -n glibc-%{version} -p1
%global glibc_configure %{shrink: \
BUILDFLAGS="-O2 -g -Wp,-D_GLIBCXX_ASSERTIONS -fstack-clash-protection" \
CFLAGS="${BUILDFLAGS}" CPPFLAGS="" CXXFLAGS="${BUILDFLAGS}" \
../configure \
--prefix="%{_cross_prefix}" \
--sysconfdir="%{_cross_sysconfdir}" \
--localstatedir="%{_cross_localstatedir}" \
--enable-bind-now \
--enable-fortify-source \
--enable-multi-arch \
--enable-shared \
--enable-stack-protector=strong \
--disable-build-nscd \
--disable-crypt \
--disable-nscd \
--disable-profile \
--disable-systemtap \
--disable-timezone-tools \
--without-gd \
--without-selinux
%{nil}}
%build
# First build the host tools we need, namely `localedef`. Apply a patch from
# Buildroot that allows us to build just this program and not everything.
patch -p1 < %{S:99}
mkdir build
pushd build
%glibc_configure
make %{?_smp_mflags} -O -r locale/others
mv locale/localedef %{_builddir}/localedef
popd
# Remove the previous build, revert the patch, and verify that the tree is
# clean, since we don't want to contaminate our target build.
rm -rf build
patch -p1 -R < %{S:99}
git diff --quiet
# Now build for the target. This is what will end up in the package, except
# for the C.UTF-8 locale, which we need `localedef` to generate.
mkdir build
pushd build
%glibc_configure \
--target="%{_cross_target}" \
--host="%{_cross_target}" \
--build="%{_build}" \
--with-headers="%{_cross_includedir}" \
--enable-kernel="5.10.0"
make %{?_smp_mflags} -O -r
popd
%install
pushd build
make -j1 install_root=%{buildroot} install
# By default, LOCALEDEF refers to the target binary, and is invoked by the
# dynamic linker that was just built for the target. Neither will run on a
# build host with a different architecture. The locale format is compatible
# across architectures but not across glibc versions, so we can't rely on
# the binary in the SDK and must use the one we built earlier.
make -j1 install_root=%{buildroot} install-files-C.UTF-8/UTF-8 -C ../localedata objdir="$(pwd)" \
LOCALEDEF="I18NPATH=. GCONV_PATH=$(pwd)/../iconvdata LC_ALL=C %{_builddir}/localedef"
popd
install -d %{buildroot}%{_cross_tmpfilesdir}
install -d %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}
install -d %{buildroot}%{_cross_unitdir}/ldconfig.service.d
install -p -m 0644 %{S:1} %{buildroot}%{_cross_tmpfilesdir}/glibc.conf
install -p -m 0644 %{S:2} %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/ld.so.conf
install -p -m 0644 %{S:3} %{buildroot}%{_cross_unitdir}/ldconfig.service.d/ldconfig.conf
truncate -s 0 %{buildroot}%{_cross_libdir}/gconv/gconv-modules
chmod 644 %{buildroot}%{_cross_libdir}/gconv/gconv-modules
truncate -s 0 %{buildroot}%{_cross_libdir}/gconv/gconv-modules.cache
chmod 644 %{buildroot}%{_cross_libdir}/gconv/gconv-modules.cache
truncate -s 0 %{buildroot}%{_cross_datadir}/locale/locale.alias
chmod 644 %{buildroot}%{_cross_datadir}/locale/locale.alias
install -d %{buildroot}%{_cross_datadir}/zoneinfo
base64 --decode %{S:4} > %{buildroot}%{_cross_datadir}/zoneinfo/UTC
%files
%license COPYING COPYING.LIB LICENSES
%{_cross_attribution_file}
%{_cross_tmpfilesdir}/glibc.conf
%exclude %{_cross_sysconfdir}/rpc
%{_cross_bindir}/getconf
%{_cross_bindir}/getent
%exclude %{_cross_bindir}/gencat
%exclude %{_cross_bindir}/iconv
%exclude %{_cross_bindir}/ld.so
%exclude %{_cross_bindir}/ldd
%exclude %{_cross_bindir}/locale
%exclude %{_cross_bindir}/localedef
%exclude %{_cross_bindir}/makedb
%exclude %{_cross_bindir}/mtrace
%exclude %{_cross_bindir}/pldd
%exclude %{_cross_bindir}/pcprofiledump
%exclude %{_cross_bindir}/sotruss
%exclude %{_cross_bindir}/sprof
%exclude %{_cross_bindir}/xtrace
%{_cross_sbindir}/ldconfig
%exclude %{_cross_sbindir}/iconvconfig
%exclude %{_cross_sbindir}/sln
%dir %{_cross_libexecdir}/getconf
%{_cross_libexecdir}/getconf/*
%{_cross_libdir}/ld-linux-*.so.*
%{_cross_libdir}/libBrokenLocale.so.*
%{_cross_libdir}/libanl.so.*
%{_cross_libdir}/libc.so.*
%{_cross_libdir}/libdl.so.*
%{_cross_libdir}/libm.so.*
%{_cross_libdir}/libnss_dns.so.*
%{_cross_libdir}/libnss_files.so.*
%{_cross_libdir}/libpthread.so.*
%{_cross_libdir}/libresolv.so.*
%{_cross_libdir}/librt.so.*
%{_cross_libdir}/libthread_db.so.*
%{_cross_libdir}/libutil.so.*
%{_cross_libdir}/libmvec.so.*
%exclude %{_cross_libdir}/audit/sotruss-lib.so
%exclude %{_cross_libdir}/libc_malloc_debug.so.*
%exclude %{_cross_libdir}/libmemusage.so
%exclude %{_cross_libdir}/libpcprofile.so
%exclude %{_cross_libdir}/libnsl.so.*
%exclude %{_cross_libdir}/libnss_compat.so.*
%exclude %{_cross_libdir}/libnss_db.so.*
%exclude %{_cross_libdir}/libnss_hesiod.so.*
%dir %{_cross_libdir}/gconv
%dir %{_cross_libdir}/gconv/gconv-modules.d
%{_cross_libdir}/gconv/gconv-modules
%{_cross_libdir}/gconv/gconv-modules.cache
%exclude %{_cross_libdir}/gconv/*.so
%exclude %{_cross_libdir}/gconv/gconv-modules.d/*.conf
%dir %{_cross_libdir}/locale
%dir %{_cross_libdir}/locale/C.utf8
%{_cross_libdir}/locale/C.utf8/LC_*
%dir %{_cross_datadir}/i18n
%dir %{_cross_datadir}/i18n/charmaps
%dir %{_cross_datadir}/i18n/locales
%dir %{_cross_datadir}/locale
%{_cross_datadir}/locale/locale.alias
%dir %{_cross_datadir}/zoneinfo
%{_cross_datadir}/zoneinfo/UTC
%exclude %{_cross_datadir}/i18n/charmaps/*
%exclude %{_cross_datadir}/i18n/locales/*
%exclude %{_cross_datadir}/locale/*
%exclude %{_cross_localstatedir}/db/Makefile
%dir %{_cross_factorydir}
%{_cross_factorydir}%{_cross_sysconfdir}/ld.so.conf
%dir %{_cross_unitdir}/ldconfig.service.d
%{_cross_libdir}/systemd/system/ldconfig.service.d/ldconfig.conf
%files devel
%{_cross_libdir}/*.a
%{_cross_libdir}/*.o
%{_cross_libdir}/libBrokenLocale.so
%{_cross_libdir}/libanl.so
%{_cross_libdir}/libc.so
%{_cross_libdir}/libm.so
%{_cross_libdir}/libresolv.so
%{_cross_libdir}/libthread_db.so
%{_cross_libdir}/libmvec.so
%exclude %{_cross_libdir}/libc_malloc_debug.so
%exclude %{_cross_libdir}/libnss_compat.so
%exclude %{_cross_libdir}/libnss_db.so
%exclude %{_cross_libdir}/libnss_hesiod.so
%dir %{_cross_includedir}/arpa
%dir %{_cross_includedir}/bits
%dir %{_cross_includedir}/gnu
%dir %{_cross_includedir}/net
%dir %{_cross_includedir}/netinet
%dir %{_cross_includedir}/netipx
%dir %{_cross_includedir}/netiucv
%dir %{_cross_includedir}/netpacket
%dir %{_cross_includedir}/netrose
%dir %{_cross_includedir}/nfs
%dir %{_cross_includedir}/protocols
%dir %{_cross_includedir}/rpc
%dir %{_cross_includedir}/scsi
%dir %{_cross_includedir}/sys
%dir %{_cross_includedir}/netash
%dir %{_cross_includedir}/netatalk
%dir %{_cross_includedir}/netax25
%dir %{_cross_includedir}/neteconet
%dir %{_cross_includedir}/netrom
%{_cross_includedir}/*.h
%{_cross_includedir}/*/*
%changelog