# $Id$ PNAME="eglibc" PVER="2.10.0_20091229" PBUILD="r4" PCATEGORIE="sys-libs" STATE="unstable" #DESCRIPTION="Embedded GNU libc6 (also called glibc2) C library with NPTL Threads." HOMEPAGE="http://www.eglibc.org/" #DEPEND="${SDEPEND} # >= sys-libs/libstdc++-4.3 # >= virtual/base-files" # we force headers to one specific version # (for x86_64 2.6.12.0-r2 bi-arch headers are needed!) SDEPEND="== sys-kernel/linux-libc-headers-2.6.31 >= sys-libs/libstdc++-4.3 >= virtual/base-files" #PROVIDE="virtual/glibc" # functions to include in the mage file SPECIAL_FUNCTIONS="fix_db_files" SRCFILE="${PNAME}-${PVER/.0/}.tar.bz2" SRCDIR="${BUILDDIR}/${PNAME}-${PVER/.0/}/libc" sminclude mtools cleanutils SRC_URI=( gnu://${PNAME}/${SRCFILE} mirror://${PNAME}/${SRCFILE} mirror://${PNAME}/nsswitch.conf mirror://${PNAME}/nscd.conf mirror://${PNAME}/eglibc.envd mirror://${PNAME}/locale-gen mirror://${PNAME}/locale.gen ) # glibc don't like strong CFLAGS export CFLAGS="${CFLAGS//-O?} -O2" # glibc -> nptl thread don't like striping NOSTRIP=true # gcc 3.0 - 3.3 needs this: export CFLAGS="${CFLAGS} -finline-limit=2000" export CXXFLAGS="${CFLAGS}" export LDFLAGS="${LDFLAGS//-Wl,--relax}" # hack to fix NPTL issues with xen, only required on 32bit arches if [[ ${ARCH} = i*86 ]] then export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs" fi # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic # first filter -mtune and -march from flags for flag in ${CFLAGS} do case ${flag} in -mtune=*) continue ;; -march=*) continue ;; esac newflags="${newflags} ${flag}" done # than add our defaults for glibc export CFLAGS="${CFLAGS} -march=${ARCH} -mtune=generic" export CXXFLAGS="${CFLAGS}" # use other linux-headers [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include" # kernel support export ENABLE_KERNEL=2.6.18 SPLIT_PACKAGES="eglibc eglibc-dev" split_info_eglibc() { DESCRIPTION="Embedded GNU libc6 (also called glibc2) C library with NPTL Threads." SDEPEND=">= sys-libs/libstdc++-4.3 >= virtual/base-files" PROVIDE="virtual/glibc" preinstall() { # remove libmemusage and libpcprofile as these libs now # resides in /usr/lib and are symlinked to /lib if [[ -f ${MROOT}/$(mlibdir)/libmemusage.so ]] then rm ${MROOT}/$(mlibdir)/libmemusage.so fi if [[ -f ${MROOT}/$(mlibdir)/libpcprofile.so ]] then rm ${MROOT}/$(mlibdir)/libpcprofile.so fi } postinstall() { # first save the old libpthread.so.0; # it will later used to determinate that there are no stale # libpthreads that breaks ldconfig local OLD_PTHREAD OLD_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)" # slackware install method # we cannot easily install the glibc libs, # because our tools for cp etc needs them to run local file echo " Switching to new glibc ..." # swap libraries on the fly: if [ -x /sbin/ldconfig -a -d /$(mlibdir)/incoming ] && [[ -z ${MROOT} ]] then # first create copies of the incoming libraries: cd /$(mlibdir)/incoming for file in $(find /$(mlibdir)/incoming -type f) do if [ ! -r "../$(basename ${file}).incoming" ] then cp -a ${file} ../$(basename ${file}).incoming fi done # then switch to them all at once: /sbin/ldconfig -l /$(mlibdir)/*.incoming 2> /dev/null # finally, rename them and clean up: cd /$(mlibdir) for file in *.incoming do rm -f $(basename ${file} .incoming) cp -a ${file} $(basename ${file} .incoming) /sbin/ldconfig -l $(basename ${file} .incoming) rm -f ${file} done # no ldconfig? # good, it's safe to just jam it on home (and make links below): else ( cd ${MROOT}/$(mlibdir)/incoming for file in * do cp -a ${file} .. done local my_sym local my_dest # rebuild symlinks echo " Recreating Symlinks:" for i in $(find ${MROOT}/$(mlibdir)/incoming -type l) do my_sym="$(readlink ${i})" my_dest="$(basename ${i})" echo " ${my_dest} -> ${my_dest}" # assure to remove the old ones; [ -L ${MROOT}/$(mlibdir)/"${my_dest}" ] && \ rm ${MROOT}/$(mlibdir)/"${my_dest}" ln -snf "${my_sym}" ${MROOT}/$(mlibdir)/"${my_dest}" done ) fi # now, get rid of the temporary directory: rm -rf ${MROOT}/$(mlibdir)/incoming # remove stale nptl libpthread-2.?.?.so, # fix only needed for glibc with linuxthreads; # prevent reloc errors such as: # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory # get our new libpthread.so.0 local NEW_PTHREAD NEW_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)" if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ] then echo " Removing stale libpthread libraries ..." for file in ${MROOT}/$(mlibdir)/libpthread-* do if [ "$(basename ${file})" != "${NEW_PTHREAD}" ] then rm -f ${file} fi done #rm -f /lib/${OLD_PTHREAD} ln -snf ${NEW_PTHREAD} ${MROOT}/$(mlibdir)/libpthread.so.0 fi if [ -x /usr/sbin/iconvconfig ] then # generate fastloading iconv module configuration file. echo " Generate iconv module config ..." /usr/sbin/iconvconfig --prefix=${MROOT}/ fi # not working with busybox if [[ $(basename $(readlink /sbin/init)) != busybox ]] then # reloading init echo " Reloading init ..." [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null fi if [[ -x /usr/sbin/locale-gen ]] && [[ -z ${MROOT} ]] then # generating user def locales echo " Generating user defined locales ..." /usr/sbin/locale-gen fi # now we must fix the mage db files # to stop the annoying errors messages fix_db_files } } split_info_eglibc-dev() { DESCRIPTION="Development files for ${PCATEGORE}/${PNAME}-${PVER}-${PBUILD}." SDEPEND=">= ${PCATEGORIE}/${PNAME}-${PVER}" postinstall() { if [ -x /usr/sbin/iconvconfig ] then # generate fastloading iconv module configuration file. echo " Generate iconv module config ..." /usr/sbin/iconvconfig --prefix=${MROOT}/ fi # not working with busybox if [[ $(basename $(readlink /sbin/init)) != busybox ]] then # reloading init echo " Reloading init ..." [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null fi if [[ -x /usr/sbin/locale-gen ]] && [[ -z ${MROOT} ]] then # generating user def locales echo " Generating user defined locales ..." /usr/sbin/locale-gen fi } } src_prepare() { munpack ${SRCFILE} || die cd ${SRCDIR} # disable binutils -as-needed sed -i 's/^have-as-needed.*/have-as-needed = no/' ${SRCDIR}/config.make.in || die # fix permissions on some of the scripts chmod u+x ${SRCDIR}/scripts/*.sh || die install -d ${SRCDIR}/build || die cd ${SRCDIR}/build if [ ! -f /etc/ld.so.conf ] then touch /etc/ld.so.conf || die fi # disable some eglibc defaults: # no ipv6 support # sed -i "s:^\(OPTION_EGLIBC_ADVANCED_INET6 =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # only some default charsets # sed -i "s:^\(OPTION_EGLIBC_CHARSETS =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # disable support for locales # sed -i "s:^\(OPTION_EGLIBC_CATGETS =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # sed -i "s:^\(OPTION_EGLIBC_LOCALES =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # sed -i "s:^\(OPTION_EGLIBC_LOCALE_CODE =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # disable mail aliases support # sed -i "s:^\(OPTION_EGLIBC_DB_ALIASES =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # # disable nis support # sed -i "s:^\(OPTION_EGLIBC_NIS =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # no remote services via rsh # sed -i "s:^\(OPTION_EGLIBC_RCMD =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # no sunrpc # sed -i "s:^\(OPTION_EGLIBC_SUNRPC =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die # no support for old access of utmp # sed -i "s:^\(OPTION_EGLIBC_UTMP =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die } src_compile() { # fixes some build issues; # -> configure: error: no acceptable grep could be found export ac_cv_path_GREP=/bin/grep # support multilib lib64 dir (x86_64 only) if [[ ${ARCH} = x86_64 ]] then # first build a -m32 version install -d ${SRCDIR}/build-m32 cd ${SRCDIR}/build-m32 CC="gcc -m32" CXX="g++ -m32" \ ../configure \ --build=${CHOST} \ --host=i686-pc-linux-gnu \ --prefix=/usr \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --disable-profile \ --enable-add-ons=nptl \ --with-tls \ --with-__thread \ --enable-kernel=${ENABLE_KERNEL} \ --without-cvs \ --without-gd \ --libdir=/usr/lib \ --libexecdir=/usr/lib/eglibc \ --with-headers=${ALT_HEADERS} \ --disable-nls \ || die make PARALLELMFLAGS="${MAKEOPTS}" || die fi cd ${SRCDIR}/build if [[ ${ARCH} = x86_64 ]]; then # make sure the -m64 libs goes really to /lib64 echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die fi # kernel-2.6 with nptl needs this ../configure \ --build=${CHOST} \ --host=${CHOST} \ --prefix=/usr \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --disable-profile \ --enable-add-ons=nptl \ --with-tls \ --with-__thread \ --enable-kernel=2.6.0 \ --without-cvs \ --without-gd \ --libdir=/usr/$(mlibdir) \ --libexecdir=/usr/$(mlibdir)/eglibc \ --with-headers=${ALT_HEADERS} \ || die make PARALLELMFLAGS="${MAKEOPTS}" || die } src_install_eglibc() { if [[ ${ARCH} = x86_64 ]] then # install -m32 libs cd ${SRCDIR}/build-m32 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die fi cd ${SRCDIR}/build make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die # cleanup zapmost ${BINDIR} $(mlibdir) \ usr/$(mlibdir)/*.so \ $([[ ${ARCH} = x86_64 ]] && echo 'lib usr/lib/*.so') \ sbin/ldconfig \ usr/bin/iconv \ usr/bin/locale \ usr/$(mlibdir)/gconv/ISO8859-1.so \ usr/$(mlibdir)/gconv/UNICODE.so \ usr/$(mlibdir)/gconv/gconv-modules \ $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-1.so') \ $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/UNICODE.so') \ $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/gconv-modules') \ || die # base environment minstallenv eglibc.envd 00eglibc || die if [[ ${ARCH} = x86_64 ]] then echo "LDPATH=\"/usr/local/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00eglibc || die echo "LDPATH=\"/opt/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00eglibc || die fi # move some libs and tools to proper locations # will suppress some ldconfig errors too mv ${BINDIR}/$(mlibdir)/libmemusage.so ${BINDIR}/usr/$(mlibdir) || die mv ${BINDIR}/$(mlibdir)/libpcprofile.so ${BINDIR}/usr/$(mlibdir) || die mlink ../usr/$(mlibdir)/libmemusage.so /$(mlibdir)/libmemusage.so || die mlink ../usr/$(mlibdir)/libpcprofile.so /$(mlibdir)/libpcprofile.so || die # strip all binaries find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die # strip all libraries # want to be safe here; --strip-unneeded seems to cause pthread problems # strip all but libpthread install -d ${BUILDDIR}/thread-backup || die mv ${BINDIR}/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die # now strip find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/$(mlibdir)/ || die # remove stale directory rm -rf ${BUILDDIR}/thread-backup || die # prepare glibc for installation; slackware method minstalldir /incoming || die mv ${BINDIR}/$(mlibdir)/* ${BINDIR}/incoming || die mv ${BINDIR}/incoming ${BINDIR}/$(mlibdir)/incoming || die mv ${BINDIR}/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/$(mlibdir) || die } src_install_eglibc-dev() { if [[ ${ARCH} = x86_64 ]] then # install -m32 libs cd ${SRCDIR}/build-m32 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die fi cd ${SRCDIR}/build make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die # cleanup -> in eglibc rm -r ${BINDIR}/$(mlibdir) || die rm ${BINDIR}/usr/$(mlibdir)/*.so || die rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-1.so || die rm ${BINDIR}/usr/$(mlibdir)/gconv/UNICODE.so || die rm ${BINDIR}/usr/$(mlibdir)/gconv/gconv-modules || die if [[ ${ARCH} = x86_64 ]] then rm -r ${BINDIR}/lib || die rm ${BINDIR}/usr/lib/*.so || die rm ${BINDIR}/usr/lib/gconv/ISO8859-1.so || die rm ${BINDIR}/usr/lib/gconv/UNICODE.so || die rm ${BINDIR}/usr/lib/gconv/gconv-modules || die fi rm ${BINDIR}/sbin/ldconfig || die rm ${BINDIR}/usr/bin/iconv || die rm ${BINDIR}/usr/bin/locale || die # do not generate the locales here, let it the user do with the locale-gen tool # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die # install locales list and generate tools # to generate this listing see the glibc-2.5/localedata/SUPPORTED file minstalletc locale.gen || die minstalldir /usr/sbin || die minstallexec -s locale-gen /usr/sbin || die # nsswitch configuration file minstalletc nsswitch.conf || die # nscd configuration file minstalletc nscd.conf || die # we use Berlin as default cp --remove-destination ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; } [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; } # strip all binaries find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die # strip all libraries find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die } fix_db_files() { local i local DB_ENTRY="${BUILDDIR}/${PKGNAME}" for i in .files .symlinks .dirs do [ ! -f ${DB_ENTRY}/${i} ] && continue [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue echo " fixing /$(mlibdir)/incoming from db-entry '${i}' ..." # /lib/incoming -> empty line; sed2 removes all empty lines #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} # do not simply emtpy the line, but change it the the correct path, # so no stale libs are around if the package gets updated! sed -i -e "s:/$(mlibdir)/incoming:/$(mlibdir):g" \ -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} done }