diff options
author | Andreas Grapentin <andreas@grapentin.org> | 2018-02-14 12:28:59 +0100 |
---|---|---|
committer | Andreas Grapentin <andreas@grapentin.org> | 2018-02-14 12:28:59 +0100 |
commit | 7d0766a45e16139d2c88523731287c21d370ad69 (patch) | |
tree | f552b9f1df997d955409ee9aba4823d305d51e0b | |
parent | e973323773123182b6ba135f5c7d5b4490507139 (diff) |
now at glibc
-rwxr-xr-x | create.sh | 1 | ||||
-rwxr-xr-x | src/stage0.sh | 4 | ||||
-rw-r--r-- | src/stage1/build_from_deptree.sh | 10 | ||||
-rw-r--r-- | src/stage1/create_package_tree.sh | 5 | ||||
-rw-r--r-- | src/stage1/patches/glibc.patch | 97 | ||||
-rw-r--r-- | src/stage1/patches/linux-libre-api-headers.patch | 17 | ||||
-rw-r--r-- | src/stage1/patches/npth.patch | 11 |
7 files changed, 139 insertions, 6 deletions
@@ -30,6 +30,7 @@ export _builddir="$_startdir"/build export _srcdir="$_startdir"/src export _target=riscv64-linux-gnu export _arch=${_target%%-*} +export _linux_arch=riscv export _groups="base base-devel" #export _groups="base" diff --git a/src/stage0.sh b/src/stage0.sh index 950f4cf..0179f54 100755 --- a/src/stage0.sh +++ b/src/stage0.sh @@ -21,7 +21,7 @@ set -euo pipefail check_bin() { - echo -n "checking for $1 in \$PATH ... " + echo -n "checking for $1 ... " type -p $1 >/dev/null && echo yes || (echo no && die "missing ${2:-$1} in \$PATH") } @@ -35,3 +35,5 @@ check_bin tput check_bin bsdtar check_bin awk check_bin sudo + +[ "x$_arch" == "x$(uname -m)" ] || check_bin qemu-$_arch-static diff --git a/src/stage1/build_from_deptree.sh b/src/stage1/build_from_deptree.sh index f6bfbf7..75ea28c 100644 --- a/src/stage1/build_from_deptree.sh +++ b/src/stage1/build_from_deptree.sh @@ -20,9 +20,6 @@ set -euo pipefail -# set path to include $_target toolchain -export PATH="/usr/$_target/bin:/usr/$_target/usr/bin:$PATH" - # keep building packages until the deptree is empty while [ -s "$_deptree" ]; do # grab one without unfulfilled dependencies @@ -66,6 +63,11 @@ while [ -s "$_deptree" ]; do [ -f "$_srcdir"/stage1/patches/$_pkgname.patch ] || die "missing package patch" patch -Np1 -i "$_srcdir"/stage1/patches/$_pkgname.patch + # substitute common variables + sed -i "s/@TARGET@/$_target/" PKGBUILD + sed -i "s/@ARCH@/$_arch/" PKGBUILD + sed -i "s/@LINUX_ARCH@/$_linux_arch/" PKGBUILD + # enable the target arch explicitly sed -i "s/arch=([^)]*/& $_arch/" PKGBUILD @@ -73,7 +75,7 @@ while [ -s "$_deptree" ]; do chown -R $SUDO_USER "$_makepkgdir"/$_pkgname sudo -u $SUDO_USER \ "$_makepkgdir"/makepkg-$_arch.sh -C --config "$_makepkgdir"/makepkg-$_arch.conf \ - --skipchecksums --skippgpcheck --nocheck 2>&1 | tee $_pkgname.log + --skipchecksums --skippgpcheck --nocheck --nodeps 2>&1 | tee makepkg.log fi cp -l $_pkgname-$_pkgver-$_pkgarch.pkg.tar.xz "$_makepkgdir"/ diff --git a/src/stage1/create_package_tree.sh b/src/stage1/create_package_tree.sh index 467befd..7e77356 100644 --- a/src/stage1/create_package_tree.sh +++ b/src/stage1/create_package_tree.sh @@ -25,7 +25,10 @@ msg "creating transitive dependency tree for $_groups" if [ ! -f "$_deptree" ]; then declare -A _tree - _frontier=($(pacman -Sg $_groups | awk '{print $2}' )) + # remove a couple things from base we don't need + _frontier=($(pacman -Sg $_groups | awk '{print $2}' \ + | grep -v lvm2)) + while [ ${#_frontier[@]} -gt 0 ]; do # pop pkg from frontier _pkgname=$(echo ${_frontier[0]}) diff --git a/src/stage1/patches/glibc.patch b/src/stage1/patches/glibc.patch new file mode 100644 index 0000000..4239645 --- /dev/null +++ b/src/stage1/patches/glibc.patch @@ -0,0 +1,97 @@ +--- a/PKGBUILD 2018-02-14 10:59:52.990457019 +0100 ++++ b/PKGBUILD 2018-02-14 11:13:29.113515472 +0100 +@@ -6,16 +6,16 @@ + # NOTE: valgrind requires rebuilt with each major glibc version + + pkgbase=glibc +-pkgname=(glibc lib32-glibc) ++pkgname=(glibc) + pkgver=2.26 + pkgrel=11 + arch=(x86_64) + url='http://www.gnu.org/software/libc' + license=(GPL LGPL) +-makedepends=(git gd lib32-gcc-libs) ++makedepends=(git) + options=(!strip staticlibs) +-_commit=de51f431ed6226ec68ca76e578f2cbd55b6262cb +-source=(git+https://sourceware.org/git/glibc.git#commit=${_commit} ++_snapshot=20171231 ++source=(git+https://github.com/riscv/riscv-gnu-toolchain#tag=v${_snapshot} + locale.gen.txt + locale-gen + lib32-glibc.conf +@@ -29,7 +29,14 @@ md5sums=('SKIP' + prepare() { + mkdir -p glibc-build lib32-glibc-build + +- cd glibc ++ cd riscv-gnu-toolchain ++ ++ # fix submodule repo paths ++ sed -i 's#\.\.#git://github.com/riscv#' .gitmodules ++ # update submodule ++ git submodule update --init riscv-glibc ++ ++ cd riscv-glibc + + local i; for i in ${source[@]}; do + case ${i%::*} in +@@ -49,7 +56,7 @@ build() { + --enable-add-ons + --enable-bind-now + --enable-lock-elision +- --enable-multi-arch ++ --disable-multi-arch + --enable-obsolete-nsl + --enable-obsolete-rpc + --enable-stack-protector=strong +@@ -68,7 +75,8 @@ build() { + # remove fortify for building libraries + CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/} + +- "$srcdir/glibc/configure" \ ++ "$srcdir/riscv-gnu-toolchain/riscv-glibc/configure" \ ++ --host=@TARGET@ \ + --libdir=/usr/lib \ + --libexecdir=/usr/lib \ + ${_configure_flags[@]} +@@ -83,38 +91,6 @@ build() { + echo "CC += -D_FORTIFY_SOURCE=2" >> configparms + echo "CXX += -D_FORTIFY_SOURCE=2" >> configparms + make +- +- cd "$srcdir/lib32-glibc-build" +- export CC="gcc -m32 -mstackrealign" +- export CXX="g++ -m32 -mstackrealign" +- +- echo "slibdir=/usr/lib32" >> configparms +- echo "rtlddir=/usr/lib32" >> configparms +- echo "sbindir=/usr/bin" >> configparms +- echo "rootsbindir=/usr/bin" >> configparms +- +- # remove fortify for building libraries +- CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/} +- CFLAGS=${CFLAGS/-fno-plt/} +- CXXFLAGS=${CXXFLAGS/-fno-plt/} +- +- "$srcdir/glibc/configure" \ +- --host=i686-pc-linux-gnu \ +- --libdir=/usr/lib32 \ +- --libexecdir=/usr/lib32 \ +- ${_configure_flags[@]} +- +- # build libraries with fortify disabled +- echo "build-programs=no" >> configparms +- make +- +- # re-enable fortify for programs +- sed -i "/build-programs=/s#no#yes#" configparms +- +- echo "CC += -D_FORTIFY_SOURCE=2" >> configparms +- echo "CXX += -D_FORTIFY_SOURCE=2" >> configparms +- make +- + } + + check() { diff --git a/src/stage1/patches/linux-libre-api-headers.patch b/src/stage1/patches/linux-libre-api-headers.patch new file mode 100644 index 0000000..dbbcbe0 --- /dev/null +++ b/src/stage1/patches/linux-libre-api-headers.patch @@ -0,0 +1,17 @@ +--- a/PKGBUILD 2018-02-12 07:03:31.357350872 +0100 ++++ b/PKGBUILD 2018-02-12 07:09:41.641241382 +0100 +@@ -39,12 +39,12 @@ build() { + cd linux-${_basever} + + make mrproper +- make headers_check ++ make ARCH=@LINUX_ARCH@ CROSS_COMPILE=@TARGET@- headers_check + } + + package() { + cd linux-${_basever} +- make INSTALL_HDR_PATH="$pkgdir/usr" headers_install ++ make INSTALL_HDR_PATH="$pkgdir"/usr ARCH=@LINUX_ARCH@ CROSS_COMPILE=@TARGET@- headers_install + + # use headers from libdrm + rm -r "$pkgdir/usr/include/drm" diff --git a/src/stage1/patches/npth.patch b/src/stage1/patches/npth.patch new file mode 100644 index 0000000..1fba2f1 --- /dev/null +++ b/src/stage1/patches/npth.patch @@ -0,0 +1,11 @@ +--- a/PKGBUILD 2018-02-11 21:35:12.390612022 +0100 ++++ b/PKGBUILD 2018-02-11 21:35:03.423845914 +0100 +@@ -19,7 +19,7 @@ sha256sums=('294a690c1f537b92ed829d867be + + build() { + cd "${srcdir}/${pkgname}-${pkgver}" +- ./configure --prefix=/usr --enable-maintainer-mode ++ ./configure --host=@TARGET@ --prefix=/usr --enable-maintainer-mode + make + } + |