packaging: fix rpmbuild errors
[platform/upstream/glibc.git] / packaging / glibc.spec
1 #
2 # spec file for package glibc
3 #
4 # Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
5 # Copyright (c) 2021 Samsung Electronics Co. Ltd.
6 #
7 # All modifications and additions to the file contributed by third parties
8 # remain the property of their copyright owners, unless otherwise agreed
9 # upon. The license for this file, and modifications and additions to the
10 # file, is the same license as for the pristine package itself (unless the
11 # license for the pristine package is not an Open Source License, in which
12 # case the license is the MIT License). An "Open Source License" is a
13 # license that conforms to the Open Source Definition (Version 1.9)
14 # published by the Open Source Initiative.
15
16 %if 0%{?run_tests}
17 %define glibc_run_tests 1
18 %endif
19
20 # Enable this when testing on device to:
21 # 1. Enable macro to turn on testsuite building ('glibc_run_tests 1')
22 # 2. Keep 'build/' folder in build stage as we do not want to rebuild all
23 # glibc again on device after invoking rpmbuild --short-circuit -bc ...
24 # 3. Skip configure and make commands and go directly to 'make check'
25 %if 0%{?run_tests_on_device}
26 %define glibc_run_tests 1
27 %define glibc_keep_build_dir 1
28 %define glibc_skip_configure 1
29 %define glibc_skip_make 1
30 %endif
31
32 # Exit right after 'make ..' step to keep all object files produced by glibc build
33 %if 0%{?exit_on_make_finish}
34 %define glibc_exit_on_make_finish 1
35 %endif
36
37 %if 0%{?dump_configure}
38 %define glibc_dump_configure 1
39 %endif
40
41 # This will avoid building some parts of glibc
42 %define asan_arch x86_64 armv7l aarch64
43 %define hwasan_arch aarch64
44 %bcond_with    fast_build
45 Name:           glibc
46 Summary:        Standard Shared Libraries (from the GNU C Library)
47 License:        LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
48 Group:          Base/Libraries
49 BuildRequires:  fdupes
50 BuildRequires:  makeinfo
51 BuildRequires:  xz
52 BuildRequires:  gcc-c++
53 BuildRequires:  gettext-tools
54 BuildRequires:  libstdc++-devel
55 BuildRequires:  bison
56 BuildRequires:  python3-base
57 %{?asan:
58 %ifarch %asan_arch
59 #BuildRequires:  python
60 BuildRequires:  glibc-devel-static
61 %endif
62 }
63 %if 0%{?glibc_dump_configure}
64 BuildRequires: configure-dumper
65 %endif
66 #BuildRequires:  pkgconfig(systemd)
67 %define _filter_GLIBC_PRIVATE 1
68 %if %_target_cpu == "i686"
69 # For i686 let's only build what's different from i586, so
70 # no need to build documentation
71 %define build_profile 1
72 %define build_locales 0
73 %define build_html 0
74 %else
75 %if %{with fast_build}
76 %define build_profile 0
77 %define build_locales 0
78 %define build_html 0
79 %else
80 # Default:
81 %define build_profile 1
82 %define build_locales 0
83 %define build_html 1
84 %endif
85 %endif
86
87 %define disable_assert 0
88 %define enable_stackguard_randomization 1
89 %define multiarcharches %{ix86} x86_64
90
91 %ifarch x86_64
92 %define enablekernel 2.6.16
93 %else
94 %define enablekernel 2.6.16
95 %endif
96 Conflicts:      kernel < %{enablekernel}
97 %ifarch armv7l armv7hl
98 # The old runtime linker link gets not provided by rpm find.provides, but it exists
99 Provides:       ld-linux.so.3
100 Provides:       ld-linux.so.3(GLIBC_2.4)
101 %endif
102 Version:        2.30
103 Release:        0
104 %define glibc_major_version %{version}
105 %define git_id 0a8262a1b2
106
107 Url:            http://www.gnu.org/software/libc/libc.html
108 Source:         glibc-%{version}.tar.xz
109 Source7:        bindresvport.blacklist
110 Source8:        glibc_post_upgrade.c
111 Source9:        glibc.rpmlintrc
112 Source10:       baselibs.conf
113 # For systemd
114 Source1001:     glibc.manifest
115
116 Requires(pre):  filesystem
117 Provides:       rtld(GNU_HASH)
118
119 %description
120 The GNU C Library provides the most important standard libraries used
121 by nearly all programs: the standard C library, the standard math
122 library, and the POSIX thread library. A system is not functional
123 without these libraries.
124
125 %package info
126 Summary:        Info Files for the GNU C Library
127 License:        GFDL-1.1
128 Group:          Documentation
129 BuildArch:      noarch
130
131 %description info
132 This package contains the documentation for the GNU C library stored as
133 info files. Due to a lack of resources, this documentation is not
134 complete and is partially out of date.
135
136 %package html
137 Summary:        HTML Documentation for the GNU C Library
138 License:        GFDL-1.1
139 Group:          Documentation
140 BuildArch:      noarch
141
142 %description html
143 This package contains the HTML documentation for the GNU C library. Due
144 to a lack of resources, this documentation is not complete and is
145 partially out of date.
146
147 %package i18ndata
148 Summary:        Database Sources for 'locale'
149 License:        GPL-2.0+ and MIT
150 Group:          Base/Libraries
151 BuildArch:      noarch
152
153 %description i18ndata
154 This package contains the data needed to build the locale data files to
155 use the internationalization features of the GNU libc. It is normally
156 not necessary to install this packages, the data files are already
157 created.
158
159 %package locale
160 Summary:        Locale Data for Localized Programs
161 License:        GPL-2.0+ and MIT and LGPL-2.1+
162 Requires(post): /usr/bin/cat
163 Requires:       glibc = %{version}
164 %description locale
165 Locale data for the internationalisation features of the GNU C library.
166
167 %package profile
168 Summary:        Libc Profiling and Debugging Versions
169 License:        LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
170 Group:          Base/Utilities
171 Requires:       glibc = %{version}
172
173 %description profile
174 This package contains special versions of the GNU C library which are
175 necessary for profiling and debugging.
176
177 %package devel
178 Summary:        Include Files and Libraries Mandatory for Development
179 License:        BSD-3-Clause and LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
180 Requires:       glibc = %{version}
181 Requires:       linux-kernel-headers
182
183 %description devel
184 These libraries are needed to develop programs which use the standard C
185 library.
186
187 %package devel-static
188 Summary:        C library static libraries for -static linking
189 License:        BSD-3-Clause and LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
190 Requires:       %{name}-devel = %{version}
191 # Provide Fedora name for package to make packaging easier
192 Provides:       %{name}-static = %version
193
194 %description devel-static
195 The glibc-devel-static package contains the C library static libraries
196 for -static linking.  You don't need these, unless you link statically,
197 which is highly discouraged.
198
199 %package devel-utils
200 Summary:        Development utilities from GNU C library
201 License:        LGPL-2.1+
202 Requires:       glibc = %{version}
203
204 %description devel-utils
205 The glibc-devel-utils package contains various binaries which can be helpful during program
206 debugging.
207
208 If you are unsure if you need this, don't install this package.
209
210 %package extra
211 Summary:        Extra binaries from GNU C Library
212 License:        LGPL-2.1+
213 Requires:       glibc = %{version}
214
215 %description extra
216 The glibc-extra package contains some extra binaries for glibc that
217 are not essential but recommend to use.
218
219 makedb: A program to create a database for nss
220
221 %package obsolete
222 Summary:        Obsolete Shared Libraries from the GNU C Library
223 License:        LGPL-2.0+
224 Requires:       glibc = %{version}
225
226 %description obsolete
227 This package provides some old libraries from the GNU C Library which
228 are no longer supported. Additional it provides a compatibility library
229 for old binaries linked against glibc 2.0.
230
231 Install this package if you need one of this libraries to get old
232 binaries working, but since this libraries are not supported and there
233 is no gurantee that they work for you, you should try to get newer
234 versions of your software.
235
236 %package testresults
237 Summary:       Testsuite results
238 License:       LGPL-2.1+
239 Group:         Development/Languages
240 %description testresults
241 Results from running the glibc testsuites.
242
243 %{?asan:
244 %ifarch %asan_arch
245 %package asan
246 Summary:     glibc with ASan instrumentation
247 License:     LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
248 Requires:    glibc = %{version}
249 Requires:    rpm
250
251 %description asan
252 This package provides glibc with ASan instrumentation
253
254 %post asan
255 ln -s --force /%{_lib}/libc-%{version}-asan.so /%{_lib}/libc.so.6
256
257 %preun asan
258 ln -s --force /%{_lib}/libc-%{version}.so /%{_lib}/libc.so.6
259
260 %endif
261 }
262
263 %{?hwasan:
264 %ifarch %hwasan_arch
265 %package hwasan
266 Summary:     glibc with Hwasan instrumentation
267 License:     LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
268 Requires:    glibc = %{version}
269 Requires:    rpm
270
271 %description hwasan
272 This package provides glibc with Hwasan instrumentation
273
274 %post hwasan
275 ln -s --force /%{_lib}/libc-%{version}-hwasan.so /%{_lib}/libc.so.6
276
277 %preun hwasan
278 ln -s --force /%{_lib}/libc-%{version}.so /%{_lib}/libc.so.6
279
280 %endif
281 }
282
283
284 %{?glibc_dump_configure:
285 %package configure-dump
286 Summary:       GNU Glibc configure dump
287 License:       GPL-3.0+
288 Group:         Development/Languages
289 %description configure-dump
290 This package contains dump of configure variables of Glibc
291 }
292
293 %prep
294 %setup -n glibc-%{version} -q
295 cp %{SOURCE1001} .
296
297 %build
298 %{?asan:%gcc_unforce_options}
299 %{?hwasan:%gcc_unforce_options}
300 if [ -x /bin/uname.bin ]; then
301         /bin/uname.bin -a
302 else
303         uname -a
304 fi
305 uptime || :
306 ulimit -a
307 nice
308 # We do not want configure to figure out the system its building one
309 # to support a common ground and thus set build and host to the
310 # target_cpu.
311 %ifarch %arm
312 %define target %{_target_cpu}-tizen-linux-gnueabi
313 %else
314 %define target %{_target_cpu}-tizen-linux
315 %endif
316 # Don't use as-needed, it breaks glibc assumptions
317 # Before enabling it, run the testsuite and verify that it
318 # passes completely
319 export LD_AS_NEEDED=0
320 # Adjust glibc version.h
321 echo "#define CONFHOST \"%{target}\"" >> version.h
322 echo "#define GITID \"%{git_id}\"" >> version.h
323 #
324 # Default CFLAGS and Compiler
325 #
326 BuildFlags=$(echo %{optflags} | sed -e "s/-Wp,-D_FORTIFY_SOURCE=2//g" | sed -e "s/-ffast-math//" | sed -e "s/atom/i686/g" | sed -e "s/-fexceptions//" | sed -e "s/-fno-omit-frame-pointer//" )
327 BuildFlags="$BuildFlags -O2 -g -U_FORTIFY_SOURCE"
328 BuildFlags="$(echo $BuildFlags | sed -e 's#-ffortify=[0-9]*##')"
329 BuildFlags="$(echo $BuildFlags | sed -e 's#-fstack-protector-strong##')"
330 BuildFlags="$(echo $BuildFlags | sed -e 's#-fstack-protector##')"
331 BuildFlags="$(echo $BuildFlags | sed -e 's/-Wa,-mimplicit-it=thumb\(-interwork\)\?//g' | sed -e 's/-mthumb\(-interwork\)\?//g')"
332 # Turn off all -Wformat enable flags as there are glibc tests that explicitly
333 # append -Wno-format and with enabled Wformat options that produced warnings
334 # that turns into errors. Remove -Wformat=1|2 or -Wformat-..-arg
335 BuildFlags="$(echo $BuildFlags | sed -re 's/-Wformat((=[1-2])|((-\w+)+))?(\s|$)//g')"
336
337 %ifarch %arm
338 # Support DA build with armv8 cpu in 32bit mode: prevent Werror on sqrt function
339 (echo ${BuildFlags} | grep '\-march=armv8') && BuildFlags="${BuildFlags} -Wno-error=unused-variable"
340 %endif
341
342 BuildCC="%__cc"
343 BuildCCplus="%__cxx"
344 add_ons=",libidn"
345
346 BuildFlags="$BuildFlags -g"
347
348 %ifarch %arm aarch64
349 # Glibc must have both functions' implementations
350 BuildFlags="$BuildFlags -U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
351 %endif
352 %if %{disable_assert}
353         BuildFlags="$BuildFlags -DNDEBUG=1"
354 %endif
355 %ifarch %ix86
356         add_ons=$add_ons
357 %endif
358 %ifarch %arm aarch64
359         add_ons=$add_ons
360 %endif
361 %ifarch mipsel
362         # fails to build otherwise - need to recheck and fix
363         %define enable_stackguard_randomization 0
364 %endif
365
366 #
367 # Build glibc
368 #
369 %{!?glibc_keep_build_dir:
370   rm -rf "build"
371   mkdir "build"
372   pushd "build"
373  }
374
375 conf_cflags="$BuildFlags -funwind-tables -fPIC"
376 %{?asan: conf_cflags="$conf_cflags -DASAN_INIT_FIRST"}
377 %{?hwasan: conf_cflags="$conf_cflags -DASAN_INIT_FIRST -Wno-error=pragmas"}
378 profile="--disable-profile"
379 %{?build_profile:profile="--enable-profile"}
380 %{?glibc_dump_configure:patch_configure.pl ..}
381
382 %{!?glibc_skip_configure:
383   CFLAGS="$conf_cflags" BUILD_CFLAGS="$conf_cflags" \
384   CC="$BuildCC" CXX="$BuildCCplus" \
385   ../configure \
386   --prefix=%{_prefix} \
387   --libexecdir=%{_libexecdir} --infodir=%{_infodir} \
388   --enable-add-ons=$add_ons \
389   $profile \
390   --enable-kernel=%{enablekernel} \
391   --enable-bind-now \
392   --enable-obsolete-rpc \
393   --disable-nscd \
394   --disable-experimental-malloc \
395   libc_cv_cc_pie_default=yes \
396 %if %{enable_stackguard_randomization}
397   --enable-stackguard-randomization \
398 %endif
399   --build=%{target} --host=%{target} \
400 %ifnarch %{multiarcharches}
401   --disable-multi-arch \
402 %endif
403 %ifarch %{ix86} x86_64
404   --disable-mathvec \
405 %endif
406 %if 0%{?enable_static_pie}
407   --enable-static-pie \
408 %endif
409  }
410
411 %{!?glibc_skip_make:
412   make %{?_smp_mflags}
413 %{?glibc_dump_configure:
414     dump_configure.pl .. . \
415     --project glibc \
416     --project-version %{version} \
417     --out_db glibc-%{version}-%{release}-%_project-%_repository.db
418  }
419
420 #
421 # Build glibc_post_upgrade binary
422 #
423 $BuildCC \
424     -static %{optflags} -Os \
425     $RPM_SOURCE_DIR/glibc_post_upgrade.c -o glibc_post_upgrade \
426     -L. -Bcsu \
427     '-DREMOVE_TLS_DIRS' '-DREMOVE_PPC_OPTIMIZE_POWER5' \
428     '-DLIBDIR="/%{_lib}"' '-DGCONV_MODULES_DIR="%{_libdir}/gconv"'
429
430 %{!?glibc_keep_build_dir:
431   popd
432  }
433 #
434 # Build html documentation
435 #
436 %if %{build_html}
437 make %{?_smp_mflags} -C "build" html
438 %endif
439
440 #
441 # Build ASan version of glibc
442 #
443 %{?asan:
444 %ifarch %{asan_arch}
445 configure_flags="--prefix=/usr --without-cvs --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --disable-mathvec"
446 configure_flags="$configure_flags --disable-sanity-checks"
447
448 HERE=%{_builddir}/%{name}-%{version}
449 J=${J:-32}
450 GLIBC=$HERE
451 ASAN_BUILD=$HERE/asan-build
452 unset CXXFLAGS
453 unset CFLAGS
454 unset LDFLAGS
455 %ifarch %{arm} aarch64
456 # Glibc must have both functions' implementations
457 CPPFLAGS="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
458 %endif
459 CPPFLAGS+=" -DASAN_INIT_FIRST"
460
461 # chmod +x $HERE/asan-glibc-gcc-wrapper.py
462 # build static wrapper, because we don't want asan to intercept allocators
463 g++ -o gcc-wrapper gcc-wrapper.cc -O3 -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -static
464
465 rm -rf $ASAN_BUILD
466 mkdir -p $ASAN_BUILD
467 pushd $ASAN_BUILD
468 # Legacy python wrapper call was:
469 #   CC=$HERE/asan-glibc-gcc-wrapper.py $GLIBC/configure $configure_flags
470 CPPFLAGS=$CPPFLAGS \
471         CC=$HERE/gcc-wrapper $GLIBC/configure $configure_flags
472
473 # Quick build - builds only libraries, but does not create symlinks.
474 make -r -j $J -C $GLIBC objdir=`pwd` subdir_lib
475 # make -r -j $J -C $GLIBC objdir=`pwd` install_root=$ASAN_INST install-lib
476 popd
477 %endif
478 }
479
480 %{?hwasan:
481 %ifarch %{hwasan_arch}
482 configure_flags="--prefix=/usr --without-cvs --without-selinux --enable-stackguard-randomization --enable-obsolete-rpc --disable-mathvec"
483 configure_flags="$configure_flags --disable-sanity-checks"
484
485 HERE=%{_builddir}/%{name}-%{version}
486 J=${J:-32}
487 GLIBC=$HERE
488 ASAN_BUILD=$HERE/hwasan-build
489 unset CXXFLAGS
490 unset CFLAGS
491 unset LDFLAGS
492 %ifarch %arm aarch64
493 # Glibc must have both functions' implementations
494 CPPFLAGS="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
495 %endif
496 CPPFLAGS+=" -DASAN_INIT_FIRST"
497
498 # chmod +x $HERE/asan-glibc-gcc-wrapper.py
499 # build static wrapper, because we don't want asan to intercept allocators
500 g++ -o gcc-wrapper gcc-wrapper.cc -O3 -funroll-loops -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-exceptions -static -DHWASAN_BUILD
501
502 rm -rf $ASAN_BUILD
503 mkdir -p $ASAN_BUILD
504 pushd $ASAN_BUILD
505 # Legacy python wrapper call was:
506 #   CC=$HERE/asan-glibc-gcc-wrapper.py $GLIBC/configure $configure_flags
507 CPPFLAGS=$CPPFLAGS \
508         CC=$HERE/gcc-wrapper $GLIBC/configure $configure_flags
509
510 # Quick build - builds only libraries, but does not create symlinks.
511 make -r -j $J -C $GLIBC objdir=`pwd` subdir_lib
512 # make -r -j $J -C $GLIBC objdir=`pwd` install_root=$ASAN_INST install-lib
513 popd
514 %endif
515 }
516
517
518 %{?glibc_exit_on_make_finish:
519   echo "Glibc build is complete and environment is ready, exiting"
520   exit 1
521  }
522
523  }
524
525 #
526 # Build testsuite
527 #
528 # #check sections could be redefined/disabled, so keep this inside #build
529
530 %{?glibc_run_tests:
531   export LD_AS_NEEDED=0
532   (make %{?_smp_mflags} -k -C build check || true) 2>&1 | tee check.log
533  }
534
535 #######################################################################
536 ###
537 ### CHECK
538 ###
539 #######################################################################
540
541 %check
542 # The testsuite will fail if asneeded is used
543 export LD_AS_NEEDED=0
544 # This has to pass on all platforms!
545 # Exceptions:
546 # None!
547 make %{?_smp_mflags} -k -C build check-abi
548
549 #######################################################################
550 ###
551 ### INSTALL
552 ###
553 #######################################################################
554
555 %install
556 # We don't want to strip the .symtab from our libraries in find-debuginfo.sh,
557 # certainly not from libpthread.so.* because it is used by libthread_db to find
558 # some non-exported symbols in order to detect if threading support
559 # should be enabled.  These symbols are _not_ exported, and we can't easily
560 # export them retroactively without changing the ABI.  So we have to
561 # continue to "export" them via .symtab, instead of .dynsym :-(
562 # But we also want to keep .symtab and .strtab of other libraries since some
563 # debugging tools currently require these sections directly inside the main
564 # files - specifically valgrind and PurifyPlus.
565 export STRIP_KEEP_SYMTAB=*.so*
566
567 # Make sure we will create the gconv-modules.cache
568 mkdir -p %{buildroot}%{_libdir}/gconv
569 touch %{buildroot}%{_libdir}/gconv/gconv-modules.cache
570
571 # Install base glibc
572 make %{?_smp_mflags} install_root=%{buildroot} install -C build
573
574 %{?glibc_dump_configure:
575   install -D -m 0644 build/glibc-%{version}-%{release}-%_project-%_repository.db %{buildroot}%{_datadir}/glibc-%{version}-%{release}-%_project-%_repository.db
576 }
577
578 # Install locales
579 %if %{build_locales}
580 # XXX Do not install locales in parallel!
581 pushd build
582 # localedef creates hardlinks to other locales if possible
583 # this will not work if we generate them in parallel.
584 # thus we need to run fdupes on  /usr/lib/locale/
585 # Still, on my system this is a speed advantage:
586 # non-parallel build for install-locales: 9:34mins
587 # parallel build with fdupes: 7:08mins
588 make %{?_smp_mflags} install_root=%{buildroot} localedata/install-locales
589 %fdupes %{buildroot}/usr/lib/locale
590 popd
591 %endif
592
593 # Create file list for glibc-locale package
594 %{find_lang} libc
595
596 # Prepare obsolete/, used only on some architectures:
597 export RPM_BUILD_ROOT
598 %ifarch %ix86
599 mkdir -p %{buildroot}/%{_lib}/obsolete
600 %endif
601
602 # Miscelanna:
603
604 install -m 0700 build/glibc_post_upgrade %{buildroot}%{_sbindir}
605
606 install -m 644 %{SOURCE7} %{buildroot}/etc
607 install -m 644 posix/gai.conf %{buildroot}/etc
608
609 mkdir -p %{buildroot}/etc/default
610
611 mkdir -p %{buildroot}%{_includedir}/resolv
612 install -m 0644 resolv/mapv4v6addr.h %{buildroot}%{_includedir}/resolv/
613 install -m 0644 resolv/mapv4v6hostent.h %{buildroot}%{_includedir}/resolv/
614
615 %if %{build_html}
616 mkdir -p %{buildroot}%{_datadir}/doc/glibc
617 cp -p build/manual/libc/*.html %{buildroot}%{_datadir}/doc/glibc
618 %endif
619
620 #
621 # Create ld.so.conf
622 #
623 cat > %{buildroot}/etc/ld.so.conf <<EOF
624 %if "%{_lib}" == "lib64"
625 /usr/local/lib64
626 %endif
627 /usr/local/lib
628 include /etc/ld.so.conf.d/*.conf
629 # /lib64, /lib, /usr/lib64 and /usr/lib gets added
630 # automatically by ldconfig after parsing this file.
631 # So, they do not need to be listed.
632 EOF
633 # Add ldconfig cache directory for directory ownership
634 mkdir -p %{buildroot}/var/cache/ldconfig
635 # Empty the ld.so.cache:
636 rm -f %{buildroot}/etc/ld.so.cache
637 touch %{buildroot}/etc/ld.so.cache
638
639 # Don't look at ldd! We don't wish a /bin/sh requires
640 chmod 644 %{buildroot}%{_bindir}/ldd
641
642 # Remove timezone data, now coming in standalone package:
643 for i in sbin/sln usr/bin/tzselect usr/sbin/zic usr/sbin/zdump etc/localtime; do
644         rm -f %{buildroot}/$i
645 done
646 rm -rf %{buildroot}%{_datadir}/zoneinfo
647
648 %ifarch armv7hl
649 # Provide compatibility link
650 ln -s ld-linux-armhf.so.3 %{buildroot}/lib/ld-linux.so.3
651 %endif
652
653 # Move getconf to %{_libexecdir}/getconf/ to avoid cross device link
654 mv %{buildroot}%{_bindir}/getconf %{buildroot}%{_libexecdir}/getconf/getconf
655 ln -s %{_libexecdir}/getconf/getconf %{buildroot}%{_bindir}/getconf
656
657 #######################################################################
658 ###
659 ### ...
660 ###
661 #######################################################################
662
663 %{?asan:
664 %ifarch %{asan_arch}
665 HERE=%{_builddir}/%{name}-%{version}
666 GLIBC=$HERE
667 ASAN_BUILD=$HERE/asan-build
668 cp $ASAN_BUILD/libc.so %{buildroot}/%{_lib}/libc-%{version}-asan.so
669 %endif
670 }
671
672 %{?hwasan:
673 %ifarch %{hwasan_arch}
674 HERE=%{_builddir}/%{name}-%{version}
675 GLIBC=$HERE
676 ASAN_BUILD=$HERE/hwasan-build
677 cp $ASAN_BUILD/libc.so %{buildroot}/%{_lib}/libc-%{version}-hwasan.so
678 %endif
679 }
680
681 %{?glibc_run_tests:
682   mkdir testresults
683   find build \
684        \( -name "*tests.sum" -o -name "*.out" -o -name "*.test-result" \) \
685        -exec cp --parents {} testresults/ \;
686   find testresults/ -type f -exec chmod 644 {} \;
687   cp check.log testresults/
688 }
689
690 %post -p %{_sbindir}/glibc_post_upgrade
691
692 %postun -p /sbin/ldconfig
693
694 %post locale
695 for l in /usr/share/locale/locale.alias %{_libdir}/gconv/gconv-modules; do
696         [ -d "$l.d" ] || continue
697         echo "###X# The following is autogenerated from extra files in the .d directory:" >>"$l"
698         cat "$l.d"/* >>"$l"
699 done
700 /usr/sbin/iconvconfig
701
702 %post info
703 %install_info --info-dir=%{_infodir} %{_infodir}/libc.info.gz
704
705 %postun info
706 %install_info_delete --info-dir=%{_infodir} %{_infodir}/libc.info.gz
707
708 %files
709 %manifest %{name}.manifest
710 # glibc
711 %defattr(-,root,root)
712 %license LICENSES COPYING COPYING.LIB
713 %config(noreplace) /etc/bindresvport.blacklist
714 %config /etc/ld.so.conf
715 %attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache
716 %config(noreplace) /etc/rpc
717 %verify(not md5 size mtime) %config(noreplace) /etc/gai.conf
718
719 # Each architecture has a different name for the dynamic linker:
720 %ifarch %arm
721 %ifarch armv7hl
722 /lib/ld-linux-armhf.so.3
723 %endif
724 # Keep as compatibility link for armv7lh
725 /lib/ld-linux.so.3
726 %endif
727 %ifarch x86_64
728 /lib64/ld-linux-x86-64.so.2
729 %endif
730 %ifarch %ix86 %sparc
731 /lib/ld-linux.so.2
732 %endif
733 %ifarch aarch64
734 /lib/ld-linux-aarch64.so.1
735 %endif
736
737 /%{_lib}/libanl.so.1
738 /%{_lib}/libc.so.6*
739 /%{_lib}/libcrypt.so.1
740 /%{_lib}/libdl.so.2*
741 /%{_lib}/libm.so.6*
742 /%{_lib}/libnsl.so.1
743 /%{_lib}/libnss_compat.so.2
744 /%{_lib}/libnss_db.so.2
745 /%{_lib}/libnss_dns.so.2
746 /%{_lib}/libnss_files.so.2
747 /%{_lib}/libnss_optfiles.so.2
748 /%{_lib}/libnss_hesiod.so.2
749 /%{_lib}/libpthread.so.0
750 /%{_lib}/libthread_db.so.1
751 /%{_lib}/libresolv.so.2
752 /%{_lib}/librt.so.1
753 /%{_lib}/libutil.so.1
754 %define optimized_libs() \
755         %dir %attr(0755,root,root) /%{_lib}/%1\
756         /%{_lib}/%1/libc.so.6*\
757         /%{_lib}/%1/libm.so.6*\
758         /%{_lib}/%1/libpthread.so.0\
759         /%{_lib}/%1/librt.so.1\
760         /%{_lib}/%1/libthread_db.so.1
761
762 %dir %attr(0700,root,root) /var/cache/ldconfig
763 /sbin/ldconfig
764 %{_bindir}/gencat
765 %{_bindir}/getconf
766 %{_bindir}/getent
767 %{_bindir}/iconv
768 %attr(755,root,root) %{_bindir}/ldd
769 %ifarch %ix86 sparc sparcv9
770         %{_bindir}/lddlibc4
771 %endif
772 %{_bindir}/locale
773 %{_bindir}/localedef
774 %dir %attr(0755,root,root) %{_libexecdir}/getconf
775 %{_libexecdir}/getconf/*
776 %{_sbindir}/glibc_post_upgrade
777 %{_sbindir}/iconvconfig
778 /%{_lib}/libBrokenLocale.so.1
779
780 %ifarch %ix86
781
782 %files obsolete
783 %manifest %{name}.manifest
784 %license COPYING.LIB
785 %defattr (755,root,root,755)
786 %dir /%{_lib}/obsolete/
787         # %dir /{_lib}/obsolete/noversion
788         # /{_lib}/obsolete/noversion/libNoVersion.so.1
789 %endif
790
791 %files locale -f libc.lang
792 %manifest %{name}.manifest
793 %license COPYING COPYING.LIB
794 %defattr(-,root,root)
795 %{_datadir}/locale/locale.alias
796 %if %{build_locales}
797 /usr/lib/locale/*
798 %endif
799 %{_libdir}/gconv
800
801 %{?asan:
802 %ifarch %{asan_arch}
803 %files asan
804 %manifest %{name}.manifest
805 /%{_lib}/libc-%{version}-asan.so
806 %endif
807 }
808
809 %{?hwasan:
810 %ifarch %{hwasan_arch}
811 %files hwasan
812 %manifest %{name}.manifest
813 /%{_lib}/libc-%{version}-hwasan.so
814 %endif
815 }
816
817 %files devel
818 %manifest %{name}.manifest
819 %defattr(-,root,root)
820 %license COPYING COPYING.LIB
821 %doc NEWS README
822 %{_bindir}/rpcgen
823 %{_includedir}/*
824 %{_libdir}/*.o
825 %{_libdir}/*.so
826 # These static libraries are needed even for shared builds
827 %{_libdir}/libc_nonshared.a
828 %{_libdir}/libg.a
829 %ifarch ppc ppc64 s390 s390x sparc sparcv8 sparcv9 sparcv9v
830 # This is not built on sparc64.
831         %{_libdir}/libnldbl_nonshared.a
832 %endif
833 %{_libdir}/libmcheck.a
834 %{_libdir}/librpcsvc.a
835
836 %files devel-static
837 %manifest %{name}.manifest
838 %defattr(-,root,root)
839 %{_libdir}/libBrokenLocale.a
840 %{_libdir}/libanl.a
841 %{_libdir}/libc.a
842 %{_libdir}/libcrypt.a
843 %{_libdir}/libdl.a
844 %{_libdir}/libm.a
845 %{_libdir}/libpthread.a
846 %{_libdir}/libresolv.a
847 %{_libdir}/librt.a
848 %{_libdir}/libutil.a
849
850 %files info
851 %manifest %{name}.manifest
852 %defattr(-,root,root)
853 %doc %{_infodir}/libc.info.gz
854 %doc %{_infodir}/libc.info-?.gz
855 %doc %{_infodir}/libc.info-??.gz
856
857 %if %{build_html}
858 %files html
859 %manifest %{name}.manifest
860 %defattr(-,root,root)
861 %doc %{_prefix}/share/doc/glibc
862 %endif
863
864 %files i18ndata
865 %manifest %{name}.manifest
866 %defattr(-,root,root)
867 %{_prefix}/share/i18n
868
869 %if %{build_profile}
870 %files profile
871 %manifest %{name}.manifest
872 %license COPYING COPYING.LIB
873 %defattr(-,root,root)
874 %{_libdir}/libc_p.a
875 %{_libdir}/libBrokenLocale_p.a
876 %{_libdir}/libanl_p.a
877 %{_libdir}/libm_p.a
878 %{_libdir}/libcrypt_p.a
879 %{_libdir}/libpthread_p.a
880 %{_libdir}/libresolv_p.a
881 %{_libdir}/librt_p.a
882 %{_libdir}/librpcsvc_p.a
883 %{_libdir}/libutil_p.a
884 %{_libdir}/libdl_p.a
885 %endif
886
887 %files devel-utils
888 %manifest %{name}.manifest
889 %defattr(-,root,root)
890 /%{_lib}/libmemusage.so
891 /%{_lib}/libpcprofile.so
892 /%{_libdir}/libBrokenLocale.so
893 /%{_lib}/libSegFault.so
894 /%{_lib}/libthread_db.so.1
895 /%{_libdir}/libthread_db.so
896 %dir /%{_libdir}/audit
897 /%{_libdir}/audit/sotruss-lib.so
898 # These need gd-devel for building
899 # %%{_bindir}/memusage
900 # %%{_bindir}/memusagestat
901 %{_bindir}/mtrace
902 %{_bindir}/pcprofiledump
903 %{_bindir}/sotruss
904 %{_bindir}/xtrace
905 %{_bindir}/pldd
906 %{_bindir}/catchsegv
907 %{_bindir}/sprof
908
909 %files extra
910 %manifest %{name}.manifest
911 %license COPYING.LIB
912 %defattr(-,root,root)
913 %{_bindir}/makedb
914 /var/db/Makefile
915
916 %{?glibc_run_tests:
917 %files testresults
918 %defattr(-,root,root)
919 %doc testresults/check.log
920 %doc testresults/*
921 }
922
923 %{?glibc_dump_configure:
924 %files configure-dump
925 %manifest glibc.manifest
926 %{_datadir}/glibc-%{version}-%{release}-%_project-%_repository.db
927 }
928
929 %docs_package