mirror of
https://gitdl.cn/https://github.com/chakralinux/lib32.git
synced 2025-01-26 15:32:16 +08:00
151 lines
4.8 KiB
Bash
151 lines
4.8 KiB
Bash
# maintainer: Manuel Tortosa <manutortoasa@chakra-project.org>
|
|
|
|
# toolchain build order:
|
|
# lib32-glibc > binutils-multilib > gcc-multilib > binutils-multilib > lib32-glibc
|
|
|
|
_pkgbasename=glibc
|
|
pkgname=lib32-$_pkgbasename
|
|
pkgver=2.18
|
|
pkgrel=9
|
|
pkgdesc="GNU C Library for multilib"
|
|
arch=('x86_64')
|
|
url="http://www.gnu.org/software/libc"
|
|
license=('GPL' 'LGPL')
|
|
makedepends=('gcc-multilib>=4.7')
|
|
options=('!strip' '!emptydirs')
|
|
source=(http://ftp.gnu.org/gnu/libc/${_pkgbasename}-${pkgver}.tar.xz{,.sig}
|
|
glibc-2.18-readdir_r-CVE-2013-4237.patch
|
|
glibc-2.18-malloc-corrupt-CVE-2013-4332.patch
|
|
glibc-2.18-strcoll-CVE-2012-4412+4424.patch
|
|
glibc-2.18-ptr-mangle-CVE-2013-4788.patch
|
|
glibc-2.18-strstr-hackfix.patch
|
|
lib32-glibc.conf)
|
|
md5sums=('88fbbceafee809e82efd52efa1e3c58f'
|
|
'SKIP'
|
|
'154da6bf5a5248f42a7bf5bf08e01a47'
|
|
'b79561ab9dce900e9bbeaf0d49927c2b'
|
|
'c7264b99d0f7e51922a4d3126182c40a'
|
|
'9749ba386b08a8fe53e7ecede9bf2dfb'
|
|
'4441f6dfe7d75ced1fa75e54dd21d36e'
|
|
'6e052f1cb693d5d3203f50f9d4e8c33b')
|
|
|
|
prepare() {
|
|
cd ${srcdir}/${_pkgbasename}-${pkgver}
|
|
|
|
# upstream commit 91ce4085
|
|
patch -p1 -i $srcdir/glibc-2.18-readdir_r-CVE-2013-4237.patch
|
|
|
|
# upstream commits 1159a193, 55e17aad and b73ed247
|
|
patch -p1 -i $srcdir/glibc-2.18-malloc-corrupt-CVE-2013-4332.patch
|
|
|
|
# upstream commits 1326ba1a, 141f3a77 and 303e567a
|
|
# https://sourceware.org/ml/libc-alpha/2013-08/msg00394.html
|
|
# https://sourceware.org/ml/libc-alpha/2013-08/msg00462.html
|
|
patch -p1 -i $srcdir/glibc-2.18-strcoll-CVE-2012-4412+4424.patch
|
|
|
|
# upstream commits c61b4d41 and 0b1f8e35
|
|
patch -p1 -i $srcdir/glibc-2.18-ptr-mangle-CVE-2013-4788.patch
|
|
|
|
# hack fix for strstr issues on x86
|
|
patch -p1 -i $srcdir/glibc-2.18-strstr-hackfix.patch
|
|
|
|
mkdir ${srcdir}/glibc-build
|
|
}
|
|
|
|
build() {
|
|
cd ${srcdir}/glibc-build
|
|
|
|
#if [[ ${CARCH} = "i686" ]]; then
|
|
# Hack to fix NPTL issues with Xen, only required on 32bit platforms
|
|
# TODO: make separate glibc-xen package for i686
|
|
export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs"
|
|
#fi
|
|
|
|
echo "slibdir=/usr/lib32" >> configparms
|
|
|
|
export CC="gcc -m32"
|
|
export CXX="g++ -m32"
|
|
|
|
# remove hardening options for building libraries
|
|
CFLAGS=${CFLAGS/-fstack-protector/}
|
|
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
|
|
|
|
${srcdir}/${_pkgbasename}-${pkgver}/configure --prefix=/usr \
|
|
--libdir=/usr/lib32 --libexecdir=/usr/lib32 \
|
|
--with-headers=/usr/include \
|
|
--with-bugurl=https://www.chakralinux.org/bugs/ \
|
|
--enable-add-ons=nptl,libidn \
|
|
--enable-obsolete-rpc \
|
|
--enable-kernel=2.6.32 \
|
|
--enable-bind-now --disable-profile \
|
|
--enable-stackguard-randomization \
|
|
--enable-lock-elision \
|
|
--enable-multi-arch i686-unknown-linux-gnu
|
|
|
|
# build libraries with hardening disabled
|
|
echo "build-programs=no" >> configparms
|
|
make
|
|
|
|
# re-enable hardening for programs
|
|
sed -i "/build-programs=/s#no#yes#" configparms
|
|
echo "CC += -fstack-protector -D_FORTIFY_SOURCE=2" >> configparms
|
|
echo "CXX += -fstack-protector -D_FORTIFY_SOURCE=2" >> configparms
|
|
make
|
|
|
|
# remove harding in preparation to run test-suite
|
|
sed -i '4,6d' configparms
|
|
}
|
|
|
|
check() {
|
|
# bug to file - the linker commands need to be reordered
|
|
LDFLAGS=${LDFLAGS/--as-needed,/}
|
|
|
|
cd ${srcdir}/glibc-build
|
|
make -k check 2>&1 | tee glibc-check-log
|
|
}
|
|
|
|
package() {
|
|
cd ${srcdir}/glibc-build
|
|
make install_root=${pkgdir} install
|
|
|
|
rm -rf ${pkgdir}/{etc,sbin,usr/{bin,sbin,share},var}
|
|
|
|
# We need one 32 bit specific header file
|
|
find ${pkgdir}/usr/include -type f -not -name stubs-32.h -delete
|
|
|
|
|
|
# Dynamic linker
|
|
# install -d -m755 ${pkgdir}/usr/lib
|
|
install -d -m755 ${pkgdir}/lib
|
|
# ln -s ../lib32/ld-linux.so.2 ${pkgdir}/usr/lib/ # no reason yet to install in /usr/lib too, only needed once we also move lib
|
|
ln -s ../usr/lib32/ld-linux.so.2 ${pkgdir}/lib/
|
|
|
|
# Add lib32 paths to the default library search path
|
|
install -Dm644 "$srcdir/lib32-glibc.conf" "$pkgdir/etc/ld.so.conf.d/lib32-glibc.conf"
|
|
|
|
# Symlink /usr/lib32/locale to /usr/lib/locale
|
|
ln -s ../lib/locale "$pkgdir/usr/lib32/locale"
|
|
|
|
# Do not strip the following files for improved debugging support
|
|
# ("improved" as in not breaking gdb and valgrind...):
|
|
# ld-${pkgver}.so
|
|
# libc-${pkgver}.so
|
|
# libpthread-${pkgver}.so
|
|
# libthread_db-1.0.so
|
|
|
|
cd $pkgdir
|
|
strip $STRIP_BINARIES \
|
|
\
|
|
\
|
|
usr/lib32/getconf/*
|
|
|
|
|
|
strip $STRIP_STATIC usr/lib32/*.a
|
|
|
|
strip $STRIP_SHARED usr/lib32/{libanl,libBrokenLocale,libcidn,libcrypt}-*.so \
|
|
usr/lib32/libnss_{compat,db,dns,files,hesiod,nis,nisplus}-*.so \
|
|
usr/lib32/{libdl,libm,libnsl,libresolv,librt,libutil}-*.so \
|
|
usr/lib32/{libmemusage,libpcprofile,libSegFault}.so \
|
|
usr/lib32/{audit,gconv}/*.so
|
|
}
|