Annotation of /trunk/core/glibc/glibc-2.27-r4.smage2
Parent Directory | Revision Log
Revision 30961 -
(hide annotations)
(download)
Tue May 22 13:58:29 2018 UTC (6 years, 4 months ago) by niro
File size: 12853 byte(s)
Tue May 22 13:58:29 2018 UTC (6 years, 4 months ago) by niro
File size: 12853 byte(s)
-honor newly introduced method of file-5.33 to detect shared libraries as pie executables if the executable bit is set
1 | niro | 30960 | # $Id$ |
2 | |||
3 | PNAME="glibc" | ||
4 | PVER="2.27" | ||
5 | PBUILD="r4" | ||
6 | |||
7 | PCAT="sys-libs" | ||
8 | |||
9 | DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads." | ||
10 | HOMEPAGE="http://www.gnu.org/software/libc/libc.html" | ||
11 | |||
12 | DEPEND=">= sys-apps/base-files-0.7 | ||
13 | >= sys-libs/tzdata-2018" | ||
14 | |||
15 | # we force headers to one specific version | ||
16 | SDEPEND="== sys-kernel/linux-libc-headers-4.16.10" | ||
17 | PROVIDE="virtual/glibc" | ||
18 | |||
19 | # functions to include in the mage file | ||
20 | SPECIAL_FUNCTIONS="fix_db_files" | ||
21 | |||
22 | SRCFILE="glibc-${PVER}.tar.xz" | ||
23 | SRCDIR="${BUILDDIR}/glibc-${PVER}" | ||
24 | |||
25 | ENVD_REV="1.2" | ||
26 | |||
27 | sminclude mtools | ||
28 | |||
29 | SRC_URI=( | ||
30 | ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE} | ||
31 | ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE} | ||
32 | gnu://${PNAME}/${SRCFILE} | ||
33 | mirror://${PNAME}/${SRCFILE} | ||
34 | mirror://${PNAME}/glibc.envd-${ENVD_REV} | ||
35 | mirror://${PNAME}/locale.gen-header | ||
36 | mirror://${PNAME}/locale-gen | ||
37 | mirror://${PNAME}/${PNAME}-2.17-syscalld-infinite-loop.patch | ||
38 | ) | ||
39 | |||
40 | # sed line: on 2 digits add an zero: 2.7 -> 2.7.0 | ||
41 | UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'" | ||
42 | |||
43 | # glibc don't like strong CFLAGS | ||
44 | #export CFLAGS="${CFLAGS//-O?} -O2" | ||
45 | # glibc -> nptl thread don't like striping | ||
46 | msetfeature "!strip" | ||
47 | |||
48 | # hack to fix NPTL issues with xen, only required on 32bit arches | ||
49 | if [[ ${ARCH} = i*86 ]] | ||
50 | then | ||
51 | export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs" | ||
52 | fi | ||
53 | |||
54 | ## glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic | ||
55 | ## first filter -mtune and -march from flags | ||
56 | #for flag in ${CFLAGS} | ||
57 | #do | ||
58 | # case ${flag} in | ||
59 | # -mtune=*) continue ;; | ||
60 | # -march=*) continue ;; | ||
61 | # esac | ||
62 | # newflags="${newflags} ${flag}" | ||
63 | #done | ||
64 | #export CFLAGS="${newflags}" | ||
65 | # | ||
66 | ## than add our defaults for glibc | ||
67 | #[[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86 | ||
68 | #export CFLAGS="${CFLAGS} -mtune=generic" # all arches | ||
69 | #export CXXFLAGS="${CFLAGS}" | ||
70 | |||
71 | # use other linux-headers | ||
72 | [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include" | ||
73 | |||
74 | # kernel support | ||
75 | export ENABLE_KERNEL=2.6.32 | ||
76 | |||
77 | src_prepare() | ||
78 | { | ||
79 | munpack ${SRCFILE} || die | ||
80 | cd ${SRCDIR} | ||
81 | |||
82 | # fix a test case that fails when built using gcc-5.x | ||
83 | sed -i '/tst-audit2-ENV/i CFLAGS-tst-audit2.c += -fno-builtin' elf/Makefile || die | ||
84 | |||
85 | # fixes an infinite loop while syscall.d creation | ||
86 | # see: http://sourceware.org/bugzilla/show_bug.cgi?id=15711 | ||
87 | mpatch ${PNAME}-2.17-syscalld-infinite-loop.patch || die | ||
88 | # use 1.0 second instead of 0.5 (required by arch i686 builds on 64bit machines) | ||
89 | sed -i 's:0.5 seconds ago:1.0 seconds ago:' ${SRCDIR}/Makerules || die | ||
90 | |||
91 | # scripts/test-installation.pl sometime fails | ||
92 | # | ||
93 | # CC="gcc" /usr/bin/perl scripts/test-installation.pl | ||
94 | # /usr/src/glibc-2.16.0.bld/ | ||
95 | # Unmatched ( in regex; marked by <-- HERE in m/$( <-- HERE if $(abi-32-ld-soname),$(abi-32-ld-soname),ld/ at scripts/test-installation.pl line 172, <LDD> | ||
96 | # line 1 | ||
97 | sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die | ||
98 | |||
99 | # binutils patch needs reconf | ||
100 | # autoconf --force || die | ||
101 | |||
102 | # fix permissions on some of the scripts | ||
103 | chmod u+x ${SRCDIR}/scripts/*.sh || die | ||
104 | |||
105 | install -d ${SRCDIR}/build || die | ||
106 | cd ${SRCDIR}/build | ||
107 | |||
108 | if [ ! -f /etc/ld.so.conf ] | ||
109 | then | ||
110 | touch /etc/ld.so.conf || die | ||
111 | fi | ||
112 | } | ||
113 | |||
114 | src_compile() | ||
115 | { | ||
116 | local myopts | ||
117 | |||
118 | # generic pathes | ||
119 | myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info" | ||
120 | myopts+=" --with-headers=/usr/include" | ||
121 | # bugurl | ||
122 | myopts+=" --with-bugurl=http://bugs.magellan-linux.de/" | ||
123 | # disable profiling | ||
124 | myopts+=" --disable-profile" | ||
125 | # enable addons | ||
126 | myopts+=" --enable-add-ons" | ||
127 | # supported kernel-release | ||
128 | myopts+=" --enable-kernel=${ENABLE_KERNEL}" | ||
129 | # disable cvs and gd support | ||
130 | myopts+=" --without-cvs --without-gd" | ||
131 | # enable bindnow | ||
132 | myopts+=" --enable-bind-now" | ||
133 | # enable obsolete rpc implementation | ||
134 | myopts+=" --enable-obsolete-rpc" | ||
135 | # enable obsolete nsl implementation | ||
136 | myopts+=" --enable-obsolete-nsl" | ||
137 | # enable lock elision | ||
138 | myopts+=" --enable-lock-elision" | ||
139 | # disable -werror | ||
140 | myopts+=" --disable-werror" | ||
141 | # enable multi-arch | ||
142 | myopts+=" --enable-multi-arch" | ||
143 | # enable stackguard randomization | ||
144 | myopts+=" --enable-stackguard-randomization" | ||
145 | # enable stack protector | ||
146 | myopts+=" --enable-stack-protector=strong" | ||
147 | |||
148 | # fortify_source not supported | ||
149 | export CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/} | ||
150 | |||
151 | # support multilib lib64 dir (x86_64 only) | ||
152 | if [[ ${ARCH} = x86_64 ]] | ||
153 | then | ||
154 | # first build a -m32 version | ||
155 | install -d ${SRCDIR}/build-m32 | ||
156 | cd ${SRCDIR}/build-m32 | ||
157 | |||
158 | # honor /usr move | ||
159 | echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build-m32/configparms || die | ||
160 | # make sure the -m32 libs goes really to /usr/lib | ||
161 | echo "slibdir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die | ||
162 | echo "rtlddir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die | ||
163 | |||
164 | CC="gcc -m32" CXX="g++ -m32" \ | ||
165 | CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \ | ||
166 | CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \ | ||
167 | ../configure \ | ||
168 | --build=${CHOST} \ | ||
169 | --host=i686-pc-linux-gnu \ | ||
170 | --libdir=/usr/lib \ | ||
171 | --libexecdir=/usr/lib/glibc \ | ||
172 | ${myopts} \ | ||
173 | || die | ||
174 | |||
175 | make PARALLELMFLAGS="${MAKEOPTS}" || die | ||
176 | fi | ||
177 | |||
178 | cd ${SRCDIR}/build | ||
179 | |||
180 | # honor /usr move | ||
181 | echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build/configparms || die | ||
182 | # make sure the -m64 libs goes really to /lib64 | ||
183 | echo "slibdir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die | ||
184 | echo "rtlddir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die | ||
185 | |||
186 | ../configure \ | ||
187 | --build=${CHOST} \ | ||
188 | --host=${CHOST} \ | ||
189 | --libdir=/usr/$(mlibdir) \ | ||
190 | --libexecdir=/usr/$(mlibdir)/glibc \ | ||
191 | ${myopts} \ | ||
192 | || die | ||
193 | |||
194 | make PARALLELMFLAGS="${MAKEOPTS}" || die | ||
195 | } | ||
196 | |||
197 | src_install() | ||
198 | { | ||
199 | if [[ ${ARCH} = x86_64 ]] | ||
200 | then | ||
201 | # install -m32 libs | ||
202 | cd ${SRCDIR}/build-m32 | ||
203 | make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die | ||
204 | fi | ||
205 | |||
206 | cd ${SRCDIR}/build | ||
207 | make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die | ||
208 | |||
209 | # do not generate the locales here, let it the user do with the locale-gen tool | ||
210 | # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die | ||
211 | |||
212 | # install locales list and generate tools | ||
213 | # generate locale.gen file from localedata/SUPPORTED file | ||
214 | minstalletc locale.gen-header locale.gen || die | ||
215 | sed \ | ||
216 | -e 's:/: :g' \ | ||
217 | -e 's:\\: :g' \ | ||
218 | -e 's:SUPPORTED-LOCALES=::' \ | ||
219 | -e 's:\ \ $::g' \ | ||
220 | -e '/^#/d' \ | ||
221 | -e 's:^:#:g' \ | ||
222 | ${SRCDIR}/localedata/SUPPORTED \ | ||
223 | >> ${BINDIR}/etc/locale.gen || die | ||
224 | minstalldir /usr/sbin || die | ||
225 | minstallexec -s locale-gen /usr/sbin || die | ||
226 | |||
227 | # nsswitch configuration file | ||
228 | minstalletc ${SRCDIR}/nss/nsswitch.conf || die | ||
229 | |||
230 | # nscd configuration file | ||
231 | minstalletc ${SRCDIR}/nscd/nscd.conf || die | ||
232 | # systemd services, but do not include systemd.sminc to have a hard depend on systemd | ||
233 | minstalldir /usr/lib/systemd/system || die | ||
234 | minstallfile ${SRCDIR}/nscd/nscd.service /usr/lib/systemd/system || die | ||
235 | minstalldir /etc/tmpfiles.d || die | ||
236 | minstallfile ${SRCDIR}/nscd/nscd.tmpfiles /etc/tmpfiles.d/nscd.conf || die | ||
237 | |||
238 | # gai configuration file | ||
239 | minstalletc ${SRCDIR}/posix/gai.conf || die | ||
240 | |||
241 | # now in tzdata | ||
242 | ## we use Berlin as default | ||
243 | ## busybox compat | ||
244 | #local args | ||
245 | #if need_busybox_support /bin/cp | ||
246 | #then | ||
247 | # args="-f" | ||
248 | #else | ||
249 | # args="--remove-destination" | ||
250 | #fi | ||
251 | #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die | ||
252 | [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; } | ||
253 | [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; } | ||
254 | |||
255 | # base environment | ||
256 | minstallenv glibc.envd-${ENVD_REV} 00glibc || die | ||
257 | if [[ ${ARCH} = x86_64 ]] | ||
258 | then | ||
259 | MCONFIG="/etc/env.d/00glibc" | ||
260 | maddconfig "LDPATH=\"/$(mlibdir)\"" || die | ||
261 | maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die | ||
262 | maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die | ||
263 | maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die | ||
264 | fi | ||
265 | |||
266 | # strip all binaries | ||
267 | niro | 30961 | find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep -v "pie executable" | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-unneeded || die |
268 | niro | 30960 | |
269 | # strip all libraries | ||
270 | # want to be safe here; --strip-unneeded seems to cause pthread problems | ||
271 | # strip all but libpthread | ||
272 | install -d ${BUILDDIR}/thread-backup || die | ||
273 | mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die | ||
274 | |||
275 | # now strip but only debuging symbols | ||
276 | niro | 30961 | find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep "[shared object|pie executable]" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-debug || die |
277 | find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-debug || die | ||
278 | niro | 30960 | mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die |
279 | # remove stale directory | ||
280 | rm -rf ${BUILDDIR}/thread-backup || die | ||
281 | |||
282 | # prepare glibc for installation; slackware method | ||
283 | minstalldir /incoming || die | ||
284 | mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die | ||
285 | mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die | ||
286 | mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die | ||
287 | mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die | ||
288 | } | ||
289 | |||
290 | fix_db_files() | ||
291 | { | ||
292 | local i | ||
293 | local DB_ENTRY="${BUILDDIR}/${PKGNAME}" | ||
294 | |||
295 | for i in .files .symlinks .dirs | ||
296 | do | ||
297 | [ ! -f ${DB_ENTRY}/${i} ] && continue | ||
298 | [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue | ||
299 | |||
300 | echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..." | ||
301 | |||
302 | # /usr/lib/incoming -> empty line; sed2 removes all empty lines | ||
303 | #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} | ||
304 | # do not simply emtpy the line, but change it the the correct path, | ||
305 | # so no stale libs are around if the package gets updated! | ||
306 | sed -i \ | ||
307 | -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \ | ||
308 | -e "s:/usr/$(mlibdir)/incoming.*::g" \ | ||
309 | -e '/^$/d' ${DB_ENTRY}/${i} | ||
310 | done | ||
311 | } | ||
312 | |||
313 | postinstall() | ||
314 | { | ||
315 | # first save the old libpthread.so.0; | ||
316 | # it will later used to determinate that there are no stale | ||
317 | # libpthreads that breaks ldconfig | ||
318 | local OLD_PTHREAD | ||
319 | OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)" | ||
320 | |||
321 | # slackware install method | ||
322 | |||
323 | # we cannot easily install the glibc libs, | ||
324 | # because our tools for cp etc needs them to run | ||
325 | |||
326 | local file | ||
327 | |||
328 | echo " Switching to new glibc ..." | ||
329 | # swap libraries on the fly: | ||
330 | if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]] | ||
331 | then | ||
332 | # first create copies of the incoming libraries: | ||
333 | cd /usr/$(mlibdir)/incoming | ||
334 | for file in $(find /usr/$(mlibdir)/incoming -type f) | ||
335 | do | ||
336 | if [ ! -r "../$(basename ${file}).incoming" ] | ||
337 | then | ||
338 | cp -a ${file} ../$(basename ${file}).incoming | ||
339 | fi | ||
340 | done | ||
341 | |||
342 | # then switch to them all at once: | ||
343 | /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null | ||
344 | |||
345 | # finally, rename them and clean up: | ||
346 | cd /usr/$(mlibdir) | ||
347 | for file in *.incoming | ||
348 | do | ||
349 | rm -f $(basename ${file} .incoming) | ||
350 | cp -a ${file} $(basename ${file} .incoming) | ||
351 | /usr/sbin/ldconfig -l $(basename ${file} .incoming) | ||
352 | rm -f ${file} | ||
353 | done | ||
354 | |||
355 | # no ldconfig? | ||
356 | # good, it's safe to just jam it on home (and make links below): | ||
357 | else | ||
358 | ( | ||
359 | cd ${MROOT}/usr/$(mlibdir)/incoming | ||
360 | for file in * | ||
361 | do | ||
362 | cp -a ${file} .. | ||
363 | done | ||
364 | |||
365 | local my_sym | ||
366 | local my_dest | ||
367 | |||
368 | # rebuild symlinks | ||
369 | echo " Recreating Symlinks:" | ||
370 | for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l) | ||
371 | do | ||
372 | my_sym="$(readlink ${i})" | ||
373 | my_dest="$(basename ${i})" | ||
374 | |||
375 | echo " ${my_dest} -> ${my_dest}" | ||
376 | |||
377 | # assure to remove the old ones; | ||
378 | [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \ | ||
379 | rm ${MROOT}/usr/$(mlibdir)/"${my_dest}" | ||
380 | |||
381 | ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}" | ||
382 | done | ||
383 | ) | ||
384 | fi | ||
385 | |||
386 | # now, get rid of the temporary directory: | ||
387 | rm -rf ${MROOT}/usr/$(mlibdir)/incoming | ||
388 | |||
389 | # remove stale nptl libpthread-2.?.?.so, | ||
390 | # fix only needed for glibc with linuxthreads; | ||
391 | # prevent reloc errors such as: | ||
392 | # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory | ||
393 | |||
394 | # get our new libpthread.so.0 | ||
395 | local NEW_PTHREAD | ||
396 | NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)" | ||
397 | |||
398 | if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ] | ||
399 | then | ||
400 | echo " Removing stale libpthread libraries ..." | ||
401 | for file in ${MROOT}/usr/$(mlibdir)/libpthread-* | ||
402 | do | ||
403 | if [ "$(basename ${file})" != "${NEW_PTHREAD}" ] | ||
404 | then | ||
405 | rm -f ${file} | ||
406 | fi | ||
407 | done | ||
408 | |||
409 | #rm -f /lib/${OLD_PTHREAD} | ||
410 | |||
411 | ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0 | ||
412 | fi | ||
413 | |||
414 | if [ -x /usr/sbin/iconvconfig ] | ||
415 | then | ||
416 | # generate fastloading iconv module configuration file. | ||
417 | echo " Generate iconv module config ..." | ||
418 | /usr/sbin/iconvconfig --prefix=${MROOT}/ | ||
419 | fi | ||
420 | |||
421 | # not working with busybox | ||
422 | if ! need_busybox_support /sbin/telinit | ||
423 | then | ||
424 | # reloading init | ||
425 | echo " Reloading init ..." | ||
426 | [[ -z ${MROOT} ]] && /sbin/telinit U &> /dev/null | ||
427 | fi | ||
428 | |||
429 | # generating user def locales | ||
430 | echo " Generating user defined locales ..." | ||
431 | [[ -z ${MROOT} ]] && /usr/sbin/locale-gen | ||
432 | |||
433 | # now we must fix the mage db files | ||
434 | # to stop the annoying errors messages | ||
435 | fix_db_files | ||
436 | } |