summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Grapentin <andreas@grapentin.org>2018-03-29 23:33:02 +0200
committerAndreas Grapentin <andreas@grapentin.org>2018-03-29 23:33:02 +0200
commitc1fced40c2f37f844eb810216eb0a1da1a436aa8 (patch)
tree205d4971dd3e2498d8c78b42ff1320f3603957e5
parent0cdff36d43aea7dc5415e6a4d58d1e10c68e2965 (diff)
major restructure, builds ok up to end of stage2
-rwxr-xr-xcreate.sh60
-rw-r--r--src/shared/checks.sh153
-rw-r--r--src/shared/common.sh127
-rw-r--r--src/shared/deptree.sh103
-rw-r--r--src/shared/feedback.sh76
-rw-r--r--src/shared/pacman.sh81
-rw-r--r--src/shared/srcinfo.sh (renamed from src/stage2/prepare_chroot.sh)77
-rw-r--r--src/shared/upstream.sh93
-rw-r--r--src/stage1/makepkg.conf.in6
-rwxr-xr-xsrc/stage1/stage1.sh193
-rw-r--r--src/stage1/toolchain-pkgbuilds/gcc-bootstrap/0001-pthread-reentrant.patch.in11
-rw-r--r--src/stage1/toolchain-pkgbuilds/gcc-bootstrap/PKGBUILD.in38
-rw-r--r--src/stage1/toolchain-pkgbuilds/gcc/0001-pthread-reentrant.patch.in11
-rw-r--r--src/stage1/toolchain-pkgbuilds/gcc/PKGBUILD.in48
-rw-r--r--src/stage2/chroot.sh78
-rw-r--r--src/stage2/makepkg.conf.in1
-rw-r--r--src/stage2/makepkg.sh (renamed from src/stage2/prepare_makepkg.sh)65
-rw-r--r--src/stage2/patches/binutils.patch20
-rw-r--r--src/stage2/patches/cryptsetup.patch9
-rw-r--r--src/stage2/patches/elfutils.patch (renamed from src/stage2/patches/libelf.patch)0
-rw-r--r--src/stage2/patches/expat.patch6
l---------src/stage2/patches/gcc-libs.patch1
-rw-r--r--src/stage2/patches/gcc.patch94
-rw-r--r--src/stage2/patches/glib2.patch10
-rw-r--r--src/stage2/patches/libcap-ng.patch15
-rw-r--r--src/stage2/patches/libcap.patch21
-rw-r--r--src/stage2/patches/libgpg-error.patch2
-rw-r--r--src/stage2/patches/libpsl.patch14
l---------src/stage2/patches/libsystemd-standalone.patch1
l---------src/stage2/patches/libsystemd.patch1
l---------src/stage2/patches/libudev.patch1
l---------src/stage2/patches/libutil-linux.patch1
-rw-r--r--src/stage2/patches/lvm2.patch (renamed from src/stage2/patches/device-mapper.patch)0
l---------src/stage2/patches/nss-myhostname.patch1
l---------src/stage2/patches/nss-mymachines.patch1
l---------src/stage2/patches/nss-resolve.patch1
l---------src/stage2/patches/nss-systemd.patch1
-rw-r--r--src/stage2/patches/openssl.patch11
-rw-r--r--src/stage2/patches/sqlite.patch18
-rw-r--r--src/stage2/patches/systemd.patch46
-rw-r--r--src/stage2/patches/tcl.patch8
-rw-r--r--src/stage2/patches/util-linux.patch16
-rw-r--r--src/stage2/prepare_deptree.sh106
-rwxr-xr-xsrc/stage2/stage2.sh337
-rw-r--r--src/stage3/libretools.patch52
45 files changed, 1252 insertions, 763 deletions
diff --git a/create.sh b/create.sh
index 8ab271a..92c7728 100755
--- a/create.sh
+++ b/create.sh
@@ -18,9 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -euo pipefail
-
-# target options
+# target platform
export CARCH=riscv64
export CHOST=riscv64-unknown-linux-gnu
export LINUX_ARCH=riscv
@@ -30,37 +28,45 @@ export GCC_MABI=lp64d
#export GCC32_MARCH=rv32gc
#export GCC32_MABI=ilp32d
#export CARCH32=riscv32
-#export CHOST32=riscv32-linux-gnu
-export REGEN_CONFIG_FRAGMENTS=yes
+#export CHOST32=riscv32-pc-linux-gnu
# common directories
-export startdir="$(pwd)"
-export topbuilddir="$startdir"/build
-export topsrcdir="$startdir"/src
+startdir="$(pwd)"
+export TOPBUILDDIR="$startdir"/build
+export TOPSRCDIR="$startdir"/src
+export SRCDEST="$TOPBUILDDIR"/sources
+mkdir -p "$TOPBUILDDIR" "$SRCDEST"
+chown "$SUDO_USER" "$TOPBUILDDIR"
# options
export KEEP_GOING=${KEEP_GOING:-no}
+export REGEN_CONFIG_FRAGMENTS=${REGEN_CONFIG_FRAGMENTS:-yes}
-. "$topsrcdir"/shared/feedback.sh
-. "$topsrcdir"/shared/common.sh
-
-[ $(id -u) -ne 0 ] && die "must be root"
-[ -z "${SUDO_USER:-}" ] && die "SUDO_USER must be set in environment"
-
-mkdir -p "$topbuilddir"
-chown $SUDO_USER "$topbuilddir"
-
-# Stage 1: prepare cross toolchain
-. "$topsrcdir"/stage1/stage1.sh
+# shellcheck source=src/shared/common.sh
+. "$TOPSRCDIR"/shared/common.sh
-# Stage 2: cross-compile base-devel
-. "$topsrcdir"/stage2/stage2.sh
+# sanity checks
+if [ "$(id -u)" -ne 0 ]; then
+ die -e "$ERROR_INVOCATION" "must be root"
+fi
+if [ -z "${SUDO_USER:-}" ]; then
+ die -e "$ERROR_INVOCATION" "SUDO_USER must be set in environment"
+fi
-# Stage 3: libremakepkg native base-devel
-. "$topsrcdir"/stage3/stage3.sh
+# import stages
+# shellcheck source=src/stage1/stage1.sh
+. "$TOPSRCDIR"/stage1/stage1.sh
+# shellcheck source=src/stage2/stage2.sh
+. "$TOPSRCDIR"/stage2/stage2.sh
+# shellcheck source=src/stage3/stage3.sh
+. "$TOPSRCDIR"/stage3/stage3.sh
+# shellcheck source=src/stage4/stage4.sh
+#. "$TOPSRCDIR"/stage4/stage4.sh
-# Stage 4: libremakepkg full native base & base-devel
-. "$topsrcdir"/stage4/stage4.sh
+# run stages
+stage1 || die -e "$ERROR_BUILDFAIL" "Stage 1 failed. Exiting..."
+stage2 || die -e "$ERROR_BUILDFAIL" "Stage 2 failed. Exiting..."
+stage3 || die -e "$ERROR_BUILDFAIL" "Stage 3 failed. Exiting..."
+#stage4
-msg "all done."
-notify "*Bootstrap Finished*"
+msg -n "all done."
diff --git a/src/shared/checks.sh b/src/shared/checks.sh
new file mode 100644
index 0000000..57bb646
--- /dev/null
+++ b/src/shared/checks.sh
@@ -0,0 +1,153 @@
+#!/bin/bash
+ ##############################################################################
+ # parabola-riscv64-bootstrap #
+ # #
+ # Copyright (C) 2018 Andreas Grapentin #
+ # #
+ # This program is free software: you can redistribute it and/or modify #
+ # it under the terms of the GNU General Public License as published by #
+ # the Free Software Foundation, either version 3 of the License, or #
+ # (at your option) any later version. #
+ # #
+ # This program is distributed in the hope that it will be useful, #
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of #
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+ # GNU General Public License for more details. #
+ # #
+ # You should have received a copy of the GNU General Public License #
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
+ ##############################################################################
+
+check_exe() {
+ local OPTIND o r=
+ while getopts "r" o; do
+ case "$o" in
+ r) r=yes ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-r] program ..." ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ local v res=0
+ for v in "$@"; do
+ echo -n "checking for $v in \$PATH ... "
+
+ local have_exe=yes
+ type -p "$v" >/dev/null || have_exe=no
+ echo $have_exe
+
+ if [ "x$have_exe" != "xyes" ]; then
+ [ "x$r" == "xyes" ] && die -e "$ERROR_MISSING" "missing $v in \$PATH"
+ res="$ERROR_MISSING"
+ fi
+ done
+
+ return "$res"
+}
+
+check_file() {
+ local OPTIND o r=
+ while getopts "r" o; do
+ case "$o" in
+ r) r=yes ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-r] file ..." ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ local v res=0
+ for v in "$@"; do
+ echo -n "checking for $v ... "
+
+ local have_file=yes
+ [ -f "$v" ] || have_file=no
+ echo $have_file
+
+ if [ "x$have_file" != "xyes" ]; then
+ [ "x$r" == "xyes" ] && die -e "$ERROR_MISSING" "missing $v in filesystem"
+ res="$ERROR_MISSING"
+ fi
+ done
+
+ return "$res"
+}
+
+check_gpgkey() {
+ local OPTIND o r=
+ while getopts "r" o; do
+ case "$o" in
+ r) r=yes ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-r] key" ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ local v res=0
+ for v in "$@"; do
+ echo -n "checking for key $v ... "
+
+ local have_key=yes
+ sudo -u "$SUDO_USER" gpg --list-keys "$v" &>/dev/null || have_key=no
+ echo $have_key
+
+ if [ "x$have_key" != "xyes" ]; then
+ [ "x$r" == "xyes" ] && die -e "$ERROR_MISSING" "missing $v in keyring"
+ res="$ERROR_MISSING"
+ fi
+ done
+
+ return "$res"
+}
+
+check_pkgfile() {
+ local OPTIND o r=
+ while getopts "r" o; do
+ case "$o" in
+ r) r=yes ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-r] key" ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ echo -n "checking for built package $2 ... "
+
+ local pkgfile have_pkgfile=yes
+ pkgfile=$(find "$1" -regex "^.*/$2-[^-]*-[^-]*-[^-]*\\.pkg\\.tar\\.xz\$")
+ [ -n "$pkgfile" ] || have_pkgfile=no
+ echo $have_pkgfile
+
+ if [ "x$have_pkgfile" != "xyes" ]; then
+ [ "x$r" == "xyes" ] && die -e "$ERROR_MISSING" "missing package $2 in $1"
+ return "$ERROR_MISSING"
+ fi
+}
+
+check_repo() {
+ local OPTIND o r=
+ while getopts "r" o; do
+ case "$o" in
+ r) r=yes ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-r] repo ..." ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ local path="$1"
+ shift
+
+ local v res=0
+ for v in "$@"; do
+ echo -n "checking for repo $v ... "
+
+ local have_repo=yes
+ [ -e "$path/$v.db" ] || have_repo=no
+ echo $have_repo
+
+ if [ "x$have_repo" != "xyes" ]; then
+ [ "x$r" == "xyes" ] && die -e "$ERROR_MISSING" "missing [$v] in $path"
+ res="$ERROR_MISSING"
+ fi
+ done
+
+ return "$res"
+}
diff --git a/src/shared/common.sh b/src/shared/common.sh
index 46ba6ca..0a11251 100644
--- a/src/shared/common.sh
+++ b/src/shared/common.sh
@@ -18,90 +18,75 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -euo pipefail
+# shellcheck source=src/shared/feedback.sh
+. "$TOPSRCDIR"/shared/feedback.sh
+# shellcheck source=src/shared/checks.sh
+. "$TOPSRCDIR"/shared/checks.sh
+# shellcheck source=src/shared/srcinfo.sh
+. "$TOPSRCDIR"/shared/srcinfo.sh
+# shellcheck source=src/shared/pacman.sh
+. "$TOPSRCDIR"/shared/pacman.sh
+# shellcheck source=src/shared/upstream.sh
+. "$TOPSRCDIR"/shared/upstream.sh
+# shellcheck source=src/shared/deptree.sh
+. "$TOPSRCDIR"/shared/deptree.sh
retry() {
- for i in $(seq $(expr $1 - 1)); do
- "${@:3}" && return 0 || sleep $2;
+ local OPTIND o n=5 s=60
+ while getopts "n:s:" o; do
+ case "$o" in
+ n) n="$OPTARG" ;;
+ s) s="$OPTARG" ;;
+ *) die -e $ERROR_INVOCATION "Usage: ${FUNCNAME[0]} [-n tries] [-s delay] cmd ..." ;;
+ esac
done
- "${@:3}" || return;
-}
-
-import_keys() {
- local keys="$(source ${1:-PKGBUILD} && echo "${validpgpkeys[@]}")"
- if [ -n "$keys" ]; then
- local key
- for key in $keys; do
- echo -n "checking for key $key ... "
- sudo -u $SUDO_USER gpg --list-keys $key &>/dev/null && _have_key=yes || _have_key=no
- echo $_have_key
- if [ "x$_have_key" == "xno" ]; then
- retry 5 60 sudo -u $SUDO_USER gpg --recv-keys $key \
- || die "failed to import key $key"
- fi
- done
- fi
-}
+ shift $((OPTIND-1))
-_fetch_pkgfiles_from() {
- curl -sL $url | grep -iq 'not found' && return 1
- local src=$(curl -sL $url | grep -i 'source files' | cut -d'"' -f2 | sed 's#/tree/#/plain/#')
- for link in $(curl -sL $src | grep '^ <li><a href' | cut -d"'" -f2 \
- | sed "s#^#$(echo $src | awk -F/ '{print $3}')#"); do
- wget -q $link -O $(basename ${link%\?*});
+ for _ in $(seq "$((n - 1))"); do
+ "$@" && return 0
+ sleep "$s"
done
- [ -f PKGBUILD ] || return 1
+ "$@" || return
}
-fetch_pkgfiles() {
- # acquire the pkgbuild and auxiliary files
- local url=https://www.parabola.nu/packages/libre/x86_64/$1/
- _fetch_pkgfiles_from $url && echo "libre" > .REPO && return
+prepare_makepkgdir() {
+ rm -rf "$1"
+ mkdir -p "$1"
+ chown -R "$SUDO_USER" "$1"
- local repo
- for repo in core extra community; do
- url=https://www.archlinux.org/packages/$repo/x86_64/$1/
- _fetch_pkgfiles_from $url && echo "$repo" > .REPO && return
- done
- die "$1: failed to fetch pkgfiles"
+ pushd "$1" >/dev/null || return 1
}
-prepare_makepkgdir() {
- rm -rf "$_makepkgdir"/$_pkgname
- mkdir -p "$_makepkgdir"/$_pkgname
- pushd "$_makepkgdir"/$_pkgname >/dev/null
- chown -R $SUDO_USER "$_makepkgdir"/$_pkgname
+find_lastlog() {
+ local log
+ # shellcheck disable=SC2010
+ log=$(ls -t "$1" | grep -P "^$2(-[^-]*){3}-(pkgver|prepare|build|package)" | head -n1)
+ [ -n "$log" ] && echo "$log"
}
-failed_build() {
- _log=$(find "$_logdest" -type f -iname "$1-*" -printf "%T@ %p\n" \
- | sort -n | tail -n1 | cut -d' ' -f2-)
- set +o pipefail
- _phase=""
- [ -z "$_log" ] || _phase=$(cat $_log | grep '==>.*occurred in' \
- | awk '{print $7}' | sed 's/().*//')
- set -o pipefail
- if [ -n "${_phase:-}" ]; then
- notify -c error "$_pkgname: error in $_phase()" -h string:document:"$_log"
- else
- notify -c error "$_pkgname: error in makepkg"
- fi
- [ "x$KEEP_GOING" == "xyes" ] || die "error building $_pkgname"
- _build_failed=yes
+binfmt_enable() {
+ echo 1 > /proc/sys/fs/binfmt_misc/status
}
-make_realdep() {
- local dep
-
- dep="$1"
- _realdep=$(pacman --noconfirm -Sddw "$dep" \
- | grep '^Packages' | awk '{print $3}')
- [ -n "$_realdep" ] && _realdep="${_realdep%-*-*}" && return 0
+binfmt_disable() {
+ echo 0 > /proc/sys/fs/binfmt_misc/status
+}
- dep="$(echo "$dep" | sed 's/[<>=].*//')"
- _realdep=$(pacman --noconfirm -Sddw "$dep" \
- | grep '^Packages' | awk '{print $3}')
- [ -n "$_realdep" ] && _realdep="${_realdep%-*-*}" && return 0
+#failed_build() {
+# # FIXME
+# _log=$(find "$_logdest" -type f -iname "$1-*" -printf "%T@ %p\n" \
+# | sort -n | tail -n1 | cut -d' ' -f2-)
+# set +o pipefail
+# _phase=""
+# [ -z "$_log" ] || _phase=$(cat $_log | grep '==>.*occurred in' \
+# | awk '{print $7}' | sed 's/().*//')
+# set -o pipefail
+# if [ -n "${_phase:-}" ]; then
+# notify -c error "$_pkgname: error in $_phase()" -h string:document:"$_log"
+# else
+# notify -c error "$_pkgname: error in makepkg"
+# fi
+# [ "x$KEEP_GOING" == "xyes" ] || die "error building $_pkgname"
+# _build_failed=yes
+#}
- return 0
-}
diff --git a/src/shared/deptree.sh b/src/shared/deptree.sh
new file mode 100644
index 0000000..ffc0af8
--- /dev/null
+++ b/src/shared/deptree.sh
@@ -0,0 +1,103 @@
+#!/bin/bash
+ ##############################################################################
+ # parabola-riscv64-bootstrap #
+ # #
+ # Copyright (C) 2018 Andreas Grapentin #
+ # #
+ # This program is free software: you can redistribute it and/or modify #
+ # it under the terms of the GNU General Public License as published by #
+ # the Free Software Foundation, either version 3 of the License, or #
+ # (at your option) any later version. #
+ # #
+ # This program is distributed in the hope that it will be useful, #
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of #
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+ # GNU General Public License for more details. #
+ # #
+ # You should have received a copy of the GNU General Public License #
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
+ ##############################################################################
+
+check_deptree() {
+ echo -n "checking for complete deptree ... "
+
+ local have_deptree=yes
+ [ -f "$DEPTREE".FULL ] || have_deptree=no
+ echo $have_deptree
+
+ [ "x$have_deptree" == "xyes" ] || return "$ERROR_MISSING"
+}
+
+build_deptree() {
+ check_exe ed pacman sed || return
+
+ # create empty deptree
+ truncate -s0 "$DEPTREE".FULL
+
+ # add the packages listed in the given groups
+ local g p r
+ for g in "$@"; do
+ for p in $(pacman -Sg "$g" | awk '{print $2}'); do
+ r=$(make_realpkg "$p") || return "$ERROR_MISSING"
+
+ if ! grep -q "^$r :" "$DEPTREE".FULL; then
+ echo "$r : [ ] # $g" >> "$DEPTREE".FULL
+ else
+ sed -i "s/^$r : \\[.*/&, $g/" "$DEPTREE".FULL
+ fi
+ done
+ done
+}
+
+prepare_deptree() {
+ check_deptree || build_deptree "$@" || return
+
+ [ -f "$DEPTREE" ] || cp "$DEPTREE"{.FULL,}
+ chown "$SUDO_USER" "$DEPTREE"{,.FULL}
+}
+
+deptree_next() {
+ local pkg
+ pkg=$(grep '\[ *\]' "$DEPTREE" | tail -n1 | awk '{print $1}')
+ [ -n "$pkg" ] || return "$ERROR_MISSING"
+ echo "$pkg"
+}
+
+deptree_remove() {
+ sed -i "/^$1 :/d; s/ / /g; s/ $1 / /g; s/ */ /g" "$DEPTREE"
+}
+
+deptree_check_depends() {
+ local OPTIND o needed=yes
+ while getopts "n" o; do
+ case "$o" in
+ n) needed=no ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-p] deptree pkgname depend" ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ local pkg="$1"
+ shift
+
+ local dep r res=0
+ # shellcheck disable=SC2068
+ for dep in $@; do
+ r=$(make_realpkg "$dep") || { res="$ERROR_MISSING"; continue; }
+
+ local have_pkg=yes
+ check_pkgfile "$PKGDEST" "$r" || have_pkg=no
+
+ if ! grep -q "^$r :" "$DEPTREE".FULL; then
+ echo "$r : [ ] # $pkg" >> "$DEPTREE".FULL
+ echo "$r : [ ] # $pkg" >> "$DEPTREE"
+ else
+ sed -i "/#.* $pkg\\(\\$\\|[ ,]\\)/! s/^$r : \\[.*/&, $pkg/" "$DEPTREE"{,.FULL}
+ fi
+ if [ "x$needed" == "xyes" ] && [ "x$have_pkg" == "xno" ]; then
+ sed -i "s/^$pkg : \\[/& $r/" "$DEPTREE"{,.FULL}
+ fi
+ done
+
+ return "$res"
+}
diff --git a/src/shared/feedback.sh b/src/shared/feedback.sh
index 6b766ff..39e0a0c 100644
--- a/src/shared/feedback.sh
+++ b/src/shared/feedback.sh
@@ -18,45 +18,67 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -euo pipefail
-
-# output formatting
-export BO=$(tput bold)
-export NO=$(tput sgr0)
-export RE=$(tput setf 4)
-export GR=$(tput setf 2)
-export WH=$(tput setf 7)
+# error codes
+export ERROR_UNSPECIFIED=1
+export ERROR_INVOCATION=2
+export ERROR_MISSING=3
+export ERROR_BUILDFAIL=4
+export ERROR_KEYFAIL=5
# messaging functions
notify() {
# useful if running notify_telegram
- local recipient=-211578786
+ local recipient=260151125
+ #local recipient=-211578786
if type -p notify-send >/dev/null; then
- machinectl -q shell --uid=$SUDO_USER .host \
- $(which notify-send) -h string:recipient:$recipient "$@" >/dev/null
+ machinectl -q shell --uid="$SUDO_USER" .host \
+ "$(which notify-send)" -h string:recipient:$recipient "$@" >/dev/null
fi
}
-die() {
- echo "$BO$RE==> ERROR:$WH $*$NO" 1>&2
- notify -c error *Error:* "$(caller): $*"
- trap - ERR
- exit 1;
-}
-
msg() {
- echo "$BO$GR==>$WH $*$NO";
+ local OPTIND o n='' d=()
+ while getopts "d:n" o; do
+ case "$o" in
+ n) n=yes ;;
+ d) d=(-h string:document:"$OPTARG") ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-n] [-d file] msg ..." ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ [ "x$n" == "xyes" ] && notify "${d[@]}" "$*"
+ echo "$(tput bold)$(tput setf 2)==>$(tput setf 7) $*$(tput sgr0)";
}
-trap "die unknown error" ERR
+error() {
+ local OPTIND o n='' d=()
+ while getopts "d:n" o; do
+ case "$o" in
+ n) n=yes ;;
+ d) d=(-h string:document:"$OPTARG") ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-n] [-d file] msg ..." ;;
+ esac
+ done
+ shift $((OPTIND-1))
-# host system check helpers
-check_exe() {
- echo -n "checking for $1 ... "
- type -p $1 >/dev/null && echo yes || (echo no && die "missing ${2:-$1} in \$PATH")
+ [ "x$n" == "xyes" ] && notify -c error "${d[@]}" "$*"
+ echo "$(tput bold)$(tput setf 4)==> ERROR:$(tput setf 7) $*$(tput sgr0)" 1>&2
}
-check_file() {
- echo -n "checking for $1 ... "
- [ -f "$1" ] && echo yes || (echo no && die "missing ${2:-$1} in filesystem")
+die() {
+ local OPTIND o e="$ERROR_UNSPECIFIED" d=()
+ while getopts "e:d:" o; do
+ case "$o" in
+ e) e="$OPTARG" ;;
+ d) d=(-d "$OPTARG") ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-e status] [-d file] msg ..." ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ error -n "${d[@]}" "$*"
+ trap - ERR
+ exit "$e"
}
+trap 'die "unknown error"' ERR
diff --git a/src/shared/pacman.sh b/src/shared/pacman.sh
new file mode 100644
index 0000000..fde78e7
--- /dev/null
+++ b/src/shared/pacman.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+ ##############################################################################
+ # parabola-riscv64-bootstrap #
+ # #
+ # Copyright (C) 2018 Andreas Grapentin #
+ # #
+ # This program is free software: you can redistribute it and/or modify #
+ # it under the terms of the GNU General Public License as published by #
+ # the Free Software Foundation, either version 3 of the License, or #
+ # (at your option) any later version. #
+ # #
+ # This program is distributed in the hope that it will be useful, #
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of #
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+ # GNU General Public License for more details. #
+ # #
+ # You should have received a copy of the GNU General Public License #
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
+ ##############################################################################
+
+import_keys() {
+ local keys k
+ keys="$(srcinfo_validpgpkeys)"
+ for k in $keys; do
+ check_gpgkey "$k" && continue
+ if ! retry -n 5 -s 60 sudo -u "$SUDO_USER" gpg --recv-keys "$k"; then
+ error -n "failed to import key '$k'"
+ return "$ERROR_KEYFAIL"
+ fi
+ done
+}
+
+pkgdeps() {
+ pacman -Si "$1" | grep '^Depends' | cut -d':' -f2 | sed 's/None//'
+}
+
+pkgarch() {
+ local pkgarch
+ pkgarch=$(pacman -Si "$1" | grep '^Architecture' | awk '{print $3}') || return
+ [ -n "$pkgarch" ] || return
+
+ # set arch to $CARCH, unless it is any
+ [ "x$pkgarch" == "xany" ] || pkgarch="$CARCH"
+ echo "$pkgarch"
+}
+
+pkgver() {
+ local pkgver
+ pkgver=$(pacman -Si "$1" | grep '^Version' | awk '{print $3}') || return
+ [ -n "$pkgver" ] || return
+ echo "$pkgver"
+}
+
+make_realpkg() {
+ local dep realpkg
+
+ dep="$1"
+ realpkg=$(pacman --noconfirm -Sddw "$dep" | grep '^Packages' | awk '{print $3}')
+ [ -n "$realpkg" ] && echo "${realpkg%-*-*}" && return 0
+
+ dep="$(sed 's/[<>=].*//' <<< "$dep")"
+ realpkg=$(pacman --noconfirm -Sddw "$dep" | grep '^Packages' | awk '{print $3}')
+ [ -n "$realpkg" ] && echo "${realpkg%-*-*}" && return 0
+
+ return "$ERROR_MISSING"
+}
+
+make_repo() {
+ local path=$1
+ shift
+
+ mkdir -p "$path" || return
+
+ local v
+ for v in "$@"; do
+ tar -czf "$path"/"$v".db.tar.gz -T /dev/null
+ tar -czf "$path"/"$v".files.tar.gz -T /dev/null
+ ln -s "$v".db.tar.gz "$path"/"$v".db
+ ln -s "$v".files.tar.gz "$path"/"$v".files
+ done
+}
diff --git a/src/stage2/prepare_chroot.sh b/src/shared/srcinfo.sh
index 4eb2162..906ce9d 100644
--- a/src/stage2/prepare_chroot.sh
+++ b/src/shared/srcinfo.sh
@@ -18,43 +18,40 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -euo pipefail
-
-msg "preparing a $CARCH skeleton chroot"
-
-echo -n "checking for $CARCH skeleton chroot ... "
-[ -e $_chrootdir ] && _have_chroot=yes || _have_chroot=no
-echo $_have_chroot
-
-if [ "x$_have_chroot" == "xno" ]; then
- # create required directories
- mkdir -pv "$_chrootdir"/etc/pacman.d/{gnupg,hooks} \
- "$_chrootdir"/var/{lib/pacman,cache/pacman/pkg,log} \
- | sed "s#$_chrootdir#\$_chrootdir#"
-
- # copy sysroot /usr to chroot
- cp -ar "$_sysroot"/usr "$_chrootdir"/
-
- # create pacman.conf
- cat > "$_chrootdir"/etc/pacman.conf << EOF
-[options]
-RootDir = $_chrootdir
-DBPath = $_chrootdir/var/cache/pacman/
-CacheDir = $_chrootdir/var/cache/pacman/pkg/
-LogFile = $_chrootdir/var/log/pacman.log
-GPGDir = $_chrootdir/etc/pacman.d/gnupg
-HookDir = $_chrootdir/etc/pacman.d/hooks
-Architecture = $CARCH
-
-[cross]
-SigLevel = Never
-Server = file://${_pkgdest%/$CARCH}/\$arch
-EOF
-
- # test and initialize ALPM library
- pacman --config "$_chrootdir"/etc/pacman.conf -r "$_chrootdir" -Syyu
-fi
-
-# mount chroot /usr to sysroot
-if mount | grep -q "$_sysroot/usr"; then umount "$_sysroot"/usr; fi
-mount -o bind "$_chrootdir"/usr "$_sysroot"/usr
+makesrcinfo() {
+ if [ ! -f .SRCINFO ] || [ .SRCINFO -ot PKGBUILD ]; then
+ (sudo -u "$SUDO_USER" makepkg --printsrcinfo) > .SRCINFO
+ fi
+}
+
+srcinfo_validpgpkeys() {
+ makesrcinfo
+ grep 'validpgpkeys =' .SRCINFO | awk '{print $3}'
+}
+
+srcinfo_pkgbase() {
+ makesrcinfo
+ grep '^pkgbase =' .SRCINFO | awk '{print $3}'
+}
+
+srcinfo_builddeps() {
+ local OPTIND o n='check\|' m='make\|'
+ while getopts "nm" o; do
+ case "$o" in
+ n) n='' ;;
+ m) m='' ;;
+ *) die -e "$ERROR_INVOCATION" "Usage: ${FUNCNAME[0]} [-n]" ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ makesrcinfo
+ awk '/^pkgbase = /,/^$/{print}' < .SRCINFO \
+ | grep " \\($m$n\\)depends =" | awk '{print $3}'
+}
+
+srcinfo_rundeps() {
+ makesrcinfo
+ awk '/^pkgname = '"$1"'$/,/^$/{print}' < .SRCINFO \
+ | grep ' depends =' | awk '{print $3}'
+}
diff --git a/src/shared/upstream.sh b/src/shared/upstream.sh
new file mode 100644
index 0000000..d310be7
--- /dev/null
+++ b/src/shared/upstream.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+ ##############################################################################
+ # parabola-riscv64-bootstrap #
+ # #
+ # Copyright (C) 2018 Andreas Grapentin #
+ # #
+ # This program is free software: you can redistribute it and/or modify #
+ # it under the terms of the GNU General Public License as published by #
+ # the Free Software Foundation, either version 3 of the License, or #
+ # (at your option) any later version. #
+ # #
+ # This program is distributed in the hope that it will be useful, #
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of #
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+ # GNU General Public License for more details. #
+ # #
+ # You should have received a copy of the GNU General Public License #
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
+ ##############################################################################
+
+package_get_upstream_repo() {
+ local repo url response target=
+ for repo in core extra community; do
+ url=https://www.archlinux.org/packages/$repo/x86_64/$1/
+ response=$(retry -n 5 -s 60 curl -sL "$url") || die "failed to retrieve url $url"
+ grep -iq "Arch Linux - $1" <<< "$response" || continue
+
+ target=$repo
+ break
+ done
+ [ -z "$target" ] || target=libre
+ echo $target
+}
+
+package_fetch_upstream_pkgfiles() {
+ # fetch upstream pkgbuilds from arch
+ local repo repoinfo pkgbase
+ repoinfo=$(asp list-repos "$1") || repoinfo=""
+ repo=$(grep -P '^(core|extra|community)' <<< "$repoinfo" | head -n1)
+ pkgbase=$(grep -o 'part of package .*' <<< "$repoinfo" | awk '{print $4}')
+
+ [ -z "$repo" ] && repo=libre
+ [ -z "$pkgbase" ] && pkgbase="$1"
+
+ mkdir -p .arch
+ asp export "$repo/$1" >/dev/null
+ mv "$pkgbase"/* .arch/
+ rm -rf "$pkgbase"
+
+ # fetch upstream pkgbuilds from parabola
+ mkdir -p .parabola
+ local src url=https://www.parabola.nu/packages/libre/x86_64/$1/
+ if ! curl -sL "$url" | grep -iq 'not found'; then
+ src=$(curl -sL "$url" | grep -i 'source files' | cut -d'"' -f2 | sed 's#/tree/#/plain/#')
+ for link in $(curl -sL "$src" | grep '^ <li><a href' | cut -d"'" -f2 \
+ | sed "s#^#$(echo "$src" | awk -F/ '{print $3}')#"); do
+ wget -q "$link" -O .parabola/"$(basename "${link%\?*}")";
+ done
+ fi
+
+ if [ -f .parabola/PKGBUILD ]; then
+ cp -v .parabola/* .
+ elif [ -f .arch/PKGBUILD ]; then
+ cp -v .arch/* .
+ else
+ return "$ERROR_MISSING"
+ fi
+}
+
+#package_fetch_upstream_pkgfiles() {
+# FIXME
+# # acquire the pkgbuild and auxiliary files
+# local url=https://www.parabola.nu/packages/libre/x86_64/$1/
+# _fetch_pkgfiles_from $url && echo "libre" > .REPO && return
+#
+# local repo
+# for repo in core extra community; do
+# url=https://www.archlinux.org/packages/$repo/x86_64/$1/
+# _fetch_pkgfiles_from $url && echo "$repo" > .REPO && return
+# done
+# die "$1: failed to fetch pkgfiles"
+#}
+#
+#_fetch_pkgfiles_from() {
+# curl -sL $url | grep -iq 'not found' && return 1
+# local src=$(curl -sL $url | grep -i 'source files' | cut -d'"' -f2 | sed 's#/tree/#/plain/#')
+# for link in $(curl -sL $src | grep '^ <li><a href' | cut -d"'" -f2 \
+# | sed "s#^#$(echo $src | awk -F/ '{print $3}')#"); do
+# wget -q $link -O $(basename ${link%\?*});
+# done
+# [ -f PKGBUILD ] || return 1
+#}
+
diff --git a/src/stage1/makepkg.conf.in b/src/stage1/makepkg.conf.in
index ca3a250..270774b 100644
--- a/src/stage1/makepkg.conf.in
+++ b/src/stage1/makepkg.conf.in
@@ -10,6 +10,12 @@ VCSCLIENTS=('bzr::bzr'
BUILDENV=(!distcc color !ccache check !sign)
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !optipng !upx !debug)
INTEGRITY_CHECK=(md5)
+CARCH="x86_64"
+CHOST="x86_64-pc-linux-gnu"
+CPPFLAGS="-D_FORTIFY_SOURCE=2"
+CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt"
+CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt"
+LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
STRIP_BINARIES="--strip-all"
STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug"
diff --git a/src/stage1/stage1.sh b/src/stage1/stage1.sh
index a1d2ee4..0715724 100755
--- a/src/stage1/stage1.sh
+++ b/src/stage1/stage1.sh
@@ -18,119 +18,106 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -euo pipefail
-
-msg "Entering Stage 1"
-notify "*Bootstrap Entering Stage 1*"
-
-# set a bunch of convenience variables
-_builddir="$topbuilddir"/stage1
-_srcdir="$topsrcdir"/stage1
-_pkgdest="$_builddir"/packages
-_logdest="$_builddir"/makepkglogs
-_makepkgdir="$_builddir"
-
-function check_toolchain() {
+check_cross_toolchain() {
echo -n "checking for $CHOST binutils ... "
- local _have_binutils
- type -p $CHOST-ar >/dev/null && _have_binutils=yes || _have_binutils=no
- echo $_have_binutils
- [ "x$_have_binutils" == "xyes" ] || return 1
+ local have_binutils=yes
+ type -p "$CHOST-ar" >/dev/null || have_binutils=no
+ echo $have_binutils
+ [ "x$have_binutils" == "xyes" ] || return 1
echo -n "checking for $CHOST gcc ... "
- local _have_gcc
- type -p $CHOST-g++ >/dev/null && _have_gcc=yes || _have_gcc=no
- echo $_have_gcc
- [ "x$_have_gcc" == "xyes" ] || return 1
+ local have_gcc=yes
+ type -p "$CHOST-g++" >/dev/null || have_gcc=no
+ echo $have_gcc
+ [ "x$have_gcc" == "xyes" ] || return 1
- local _sysroot=$($CHOST-gcc --print-sysroot)
+ local sysroot
+ sysroot=$("$CHOST-gcc" --print-sysroot) || die "failed to produce $CHOST-gcc sysroot"
echo -n "checking for $CHOST linux api headers ... "
- local _have_headers
- [ -e "$_sysroot"/include/linux/kernel.h ] && _have_headers=yes || _have_headers=no
- echo $_have_headers
- [ "x$_have_headers" == "xyes" ] || return 1
+ local have_headers=yes
+ [ -e "$sysroot"/include/linux/kernel.h ] || have_headers=no
+ echo $have_headers
+ [ "x$have_headers" == "xyes" ] || return 1
echo -n "checking for $CHOST glibc ... "
- local _have_glibc
- [ -e "$_sysroot"/usr/lib/libc.so.6 ] && _have_glibc=yes || _have_glibc=no
- echo $_have_glibc
- [ "x$_have_glibc" == "xyes" ] || return 1
+ local have_glibc=yes
+ [ -e "$sysroot"/usr/lib/libc.so.6 ] || have_glibc=no
+ echo $have_glibc
+ [ "x$have_glibc" == "xyes" ] || return 1
}
-# simply return if the toolchain is already there
-if check_toolchain; then return 0; fi
-
-# check for required programs in $PATH to build the toolchain
-check_exe makepkg
-check_exe pacman
-check_exe sed
-check_exe sudo
-
-# create required directories
-mkdir -p "$_logdest" "$_pkgdest"
-chown $SUDO_USER "$_logdest" "$_pkgdest"
-
-# create a sane makepkg.conf
-cat "$_srcdir"/makepkg.conf.in > "$_builddir"/makepkg.conf
-cat >> "$_builddir"/makepkg.conf << EOF
-CARCH="$(source /etc/makepkg.conf && echo $CARCH)"
-CHOST="$(source /etc/makepkg.conf && echo $CHOST)"
-CPPFLAGS="$(source /etc/makepkg.conf && echo $CPPFLAGS)"
-CFLAGS="$(source /etc/makepkg.conf && echo $CFLAGS)"
-CXXFLAGS="$(source /etc/makepkg.conf && echo $CXXFLAGS)"
-LDFLAGS="$(source /etc/makepkg.conf && echo $LDFLAGS)"
-LOGDEST="$_logdest"
-PKGDEST="$_pkgdest"
+stage1() {
+ msg -n "Entering Stage 1"
+
+ export BUILDDIR="$TOPBUILDDIR"/stage1
+ export SRCDIR="$TOPSRCDIR"/stage1
+ export PKGDEST="$BUILDDIR"/packages
+ export LOGDEST="$BUILDDIR"/makepkglogs
+ export MAKEPKGDIR="$BUILDDIR"
+
+ check_cross_toolchain && return
+
+ check_exe gpg makepkg pacman sed sudo || return
+
+ # create required directories
+ mkdir -p "$LOGDEST" "$PKGDEST" "$SRCDEST"
+ chown "$SUDO_USER" "$LOGDEST" "$PKGDEST" "$SRCDEST"
+
+ # create a sane makepkg.conf
+ cat "$SRCDIR"/makepkg.conf.in > "$BUILDDIR"/makepkg.conf
+ cat >> "$BUILDDIR"/makepkg.conf << EOF
+LOGDEST="$LOGDEST"
+PKGDEST="$PKGDEST"
+SRCDEST="$SRCDEST"
MAKEFLAGS="-j$(($(nproc) + 1))"
EOF
-_srcdest="$(source /etc/makepkg.conf && echo $SRCDEST || true)"
-[ -z "$_srcdest" ] || echo "SRCDEST=\"$_srcdest\"" >> "$_builddir"/makepkg.conf
-
-# build and install the toolchain packages
-for pkg in binutils linux-libre-api-headers gcc-bootstrap glibc gcc; do
- _pkgname=$CHOST-$pkg
- echo -n "checking for $_pkgname ... "
- _pkgfile=$(find $_pkgdest -regex "^.*/$_pkgname-[^-]*-[^-]*-[^-]*\.pkg\.tar\.xz\$")
- [ -n "$_pkgfile" ] && _have_pkg=yes || _have_pkg=no
- echo $_have_pkg
-
- if [ "x$_have_pkg" == "xno" ]; then
- msg "makepkg: $_pkgname"
- prepare_makepkgdir
-
- cp "$_srcdir"/toolchain-pkgbuilds/$pkg/PKGBUILD.in .
-
- import_keys
-
- # substitute architecture variables
- sed -i "s#@CHOST@#$CHOST#g; \
- s#@CARCH@#$CARCH#g; \
- s#@LINUX_ARCH@#$LINUX_ARCH#g; \
- s#@GCC_MARCH@#${GCC_MARCH:-}#g; \
- s#@GCC_MABI@#${GCC_MABI:-}#g; \
- s#@MULTILIB@#${MULTILIB:-disable}#g; \
- s#@GCC_32_MARCH@#${GCC_32_MARCH:-}#g; \
- s#@GCC_32_MABI@#${GCC_32_MABI:-}#g; \
- s#@CARCH32@#${CARCH32:-}#g; \
- s#@CHOST32@#${CHOST32:-}#g" \
- PKGBUILD
-
- # build the package
- chown -R $SUDO_USER .
- sudo -u $SUDO_USER makepkg -LC --config "$_builddir"/makepkg.conf || failed_build
-
- popd >/dev/null
- notify -c success -u low "$_pkgname"
- fi
-
- # install the package
- set +o pipefail
- _pkgfile=$(find $_pkgdest -regex "^.*/$_pkgname-[^-]*-[^-]*-[^-]*\.pkg\.tar\.xz\$" | head -n1)
- yes | pacman -U "$_pkgfile"
- set -o pipefail
-done
-
-# final sanity check
-check_toolchain || die "toolchain build incomplete"
+ # build and install the toolchain packages
+ for pkg in binutils linux-libre-api-headers gcc-bootstrap glibc gcc; do
+ msg "makepkg: $CHOST-$pkg"
+
+ if ! check_pkgfile "$PKGDEST" "$CHOST-$pkg"; then
+ prepare_makepkgdir "$MAKEPKGDIR/$CHOST-$pkg" || return
+
+ # produce pkgfiles
+ for f in "$SRCDIR"/toolchain-pkgbuilds/$pkg/*.in; do cp "$f" "$(basename "${f%.in}")"; done
+ sed -i "s#@CHOST@#$CHOST#g; \
+ s#@CARCH@#$CARCH#g; \
+ s#@LINUX_ARCH@#$LINUX_ARCH#g; \
+ s#@GCC_MARCH@#${GCC_MARCH:-}#g; \
+ s#@GCC_MABI@#${GCC_MABI:-}#g; \
+ s#@MULTILIB@#${MULTILIB:-disable}#g; \
+ s#@GCC_32_MARCH@#${GCC_32_MARCH:-}#g; \
+ s#@GCC_32_MABI@#${GCC_32_MABI:-}#g; \
+ s#@CARCH32@#${CARCH32:-}#g; \
+ s#@CHOST32@#${CHOST32:-}#g" \
+ PKGBUILD
+
+ import_keys || return
+
+ if ! sudo -u "$SUDO_USER" makepkg -LC --config "$BUILDDIR"/makepkg.conf; then
+ local log phase
+ log=$(find_lastlog "$LOGDEST" "$CHOST-$pkg")
+ if [ -z "$log" ]; then
+ error -n "$CHOST-$pkg: error in makepkg"
+ else
+ phase=$(sed 's/.*\(pkgver\|prepare\|build\|package\).*/\1/' <<< "$log")
+ error -n -d "$log" "$CHOST-$pkg: error in $phase"
+ fi
+ return "$ERROR_BUILDFAIL"
+ fi
+
+ popd >/dev/null || return
+ notify -c success -u low "$CHOST-$pkg"
+ fi
+
+ # install the package
+ # shellcheck disable=SC2010
+ pkgfile=$(ls -t "$PKGDEST" | grep -P "^$CHOST-$pkg(-[^-]*){3}\\.pkg" | head -n1)
+ yes | pacman -U "$PKGDEST/$pkgfile"
+ done
+
+ # final sanity check
+ check_cross_toolchain || die -e "$ERROR_MISSING" "toolchain build incomplete"
+}
diff --git a/src/stage1/toolchain-pkgbuilds/gcc-bootstrap/0001-pthread-reentrant.patch.in b/src/stage1/toolchain-pkgbuilds/gcc-bootstrap/0001-pthread-reentrant.patch.in
new file mode 100644
index 0000000..36342ef
--- /dev/null
+++ b/src/stage1/toolchain-pkgbuilds/gcc-bootstrap/0001-pthread-reentrant.patch.in
@@ -0,0 +1,11 @@
+--- trunk/gcc/config/riscv/linux.h 2018/01/03 10:03:58 256169
++++ trunk/gcc/config/riscv/linux.h 2018/02/13 11:21:01 257621
+@@ -47,6 +47,8 @@
+
+ #define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
+
++#define CPP_SPEC "%{pthread:-D_REENTRANT}"
++
+ #define LINK_SPEC "\
+ -melf" XLEN_SPEC "lriscv \
+ %{shared} \
diff --git a/src/stage1/toolchain-pkgbuilds/gcc-bootstrap/PKGBUILD.in b/src/stage1/toolchain-pkgbuilds/gcc-bootstrap/PKGBUILD.in
index 25dc331..02f51ee 100644
--- a/src/stage1/toolchain-pkgbuilds/gcc-bootstrap/PKGBUILD.in
+++ b/src/stage1/toolchain-pkgbuilds/gcc-bootstrap/PKGBUILD.in
@@ -2,7 +2,7 @@
_target=@CHOST@
pkgname=$_target-gcc-bootstrap
-pkgver=7.3.1
+pkgver=7.3.1+20180312
_islver=0.18
pkgrel=1
pkgdesc='The GNU Compiler Collection - cross compiler for @CARCH@ target - bootstrap version. only used to build initial glibc and compiler'
@@ -14,35 +14,33 @@ makedepends=(gmp mpfr)
options=(!emptydirs !strip)
provides=(${pkgname%-bootstrap})
conflicts=(${pkgname%-bootstrap})
-_snapshot=7-20180215
-source=(#ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-$pkgver.tar.xz
- ftp://gcc.gnu.org/pub/gcc/snapshots/$_snapshot/gcc-$_snapshot.tar.xz
- http://isl.gforge.inria.fr/isl-$_islver.tar.bz2)
-sha256sums=('bb276f6fce4822fc0806d1e87d21245854d1e41f2a7027c7288375084176c679'
- '6b8b0fd7f81d0a957beb3679c81bbb34ccc7568d5682844d8924424a0dadcb1b')
-
-if [ -n "$_snapshot" ]; then
- _basedir=gcc-$_snapshot
-else
- _basedir=gcc-$pkgver
-fi
+source=(https://sources.archlinux.org/other/gcc/gcc-${pkgver/+/-}.tar.xz{,.sig}
+ http://isl.gforge.inria.fr/isl-$_islver.tar.bz2
+ 0001-pthread-reentrant.patch)
+validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
+ 13975A70E63C361C73AE69EF6EEB81F8981C74C7) # richard.guenther@gmail.com
+sha256sums=('c52618f656f2102b3544419e7d0a8a4f4e6ff052783865202be73edf1a40e28b'
+ 'SKIP'
+ '6b8b0fd7f81d0a957beb3679c81bbb34ccc7568d5682844d8924424a0dadcb1b'
+ 'fc9c6f0edd615f2b39deff28b9626a08fd98ef8ce19f7e34281c0a5bd653ac3b')
prepare() {
- cd $_basedir
+ [[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
+ cd gcc
# link isl for in-tree builds
ln -sf ../isl-$_islver isl
- echo $pkgver > gcc/BASE-VER
-
# Do not run fixincludes
sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
- sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" "$srcdir"/$_basedir/{libiberty,gcc}/configure
+ sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" "$srcdir"/gcc/{libiberty,gcc}/configure
+
+ # fix -pthreads behavior on risc-v
+ patch -Np1 -i "$srcdir/0001-pthread-reentrant.patch"
- rm -rf $srcdir/gcc-build
- mkdir $srcdir/gcc-build
+ mkdir -p "$srcdir/gcc-build"
}
build() {
@@ -53,7 +51,7 @@ build() {
CFLAGS=${CFLAGS/-pipe/}
CXXFLAGS=${CXXFLAGS/-pipe/}
- $srcdir/$_basedir/configure \
+ $srcdir/gcc/configure \
--target=$_target \
--prefix=/usr \
--libdir=/usr/lib \
diff --git a/src/stage1/toolchain-pkgbuilds/gcc/0001-pthread-reentrant.patch.in b/src/stage1/toolchain-pkgbuilds/gcc/0001-pthread-reentrant.patch.in
new file mode 100644
index 0000000..36342ef
--- /dev/null
+++ b/src/stage1/toolchain-pkgbuilds/gcc/0001-pthread-reentrant.patch.in
@@ -0,0 +1,11 @@
+--- trunk/gcc/config/riscv/linux.h 2018/01/03 10:03:58 256169
++++ trunk/gcc/config/riscv/linux.h 2018/02/13 11:21:01 257621
+@@ -47,6 +47,8 @@
+
+ #define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
+
++#define CPP_SPEC "%{pthread:-D_REENTRANT}"
++
+ #define LINK_SPEC "\
+ -melf" XLEN_SPEC "lriscv \
+ %{shared} \
diff --git a/src/stage1/toolchain-pkgbuilds/gcc/PKGBUILD.in b/src/stage1/toolchain-pkgbuilds/gcc/PKGBUILD.in
index 4ba85e8..2863cad 100644
--- a/src/stage1/toolchain-pkgbuilds/gcc/PKGBUILD.in
+++ b/src/stage1/toolchain-pkgbuilds/gcc/PKGBUILD.in
@@ -2,7 +2,7 @@
_target=@CHOST@
pkgname=$_target-gcc
-pkgver=7.3.1
+pkgver=7.3.1+20180312
_islver=0.18
pkgrel=1
pkgdesc='The GNU Compiler Collection - cross compiler for @CARCH@ target'
@@ -14,35 +14,33 @@ makedepends=(gmp mpfr)
options=(!emptydirs !strip staticlibs)
conflicts=($pkgname-bootstrap)
replaces=($pkgname-bootstrap)
-_snapshot=7-20180215
-source=(#ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-$pkgver.tar.xz
- ftp://gcc.gnu.org/pub/gcc/snapshots/$_snapshot/gcc-$_snapshot.tar.xz
- http://isl.gforge.inria.fr/isl-$_islver.tar.bz2)
-sha256sums=('bb276f6fce4822fc0806d1e87d21245854d1e41f2a7027c7288375084176c679'
- '6b8b0fd7f81d0a957beb3679c81bbb34ccc7568d5682844d8924424a0dadcb1b')
-
-if [ -n "$_snapshot" ]; then
- _basedir=gcc-$_snapshot
-else
- _basedir=gcc-$pkgver
-fi
+source=(https://sources.archlinux.org/other/gcc/gcc-${pkgver/+/-}.tar.xz{,.sig}
+ http://isl.gforge.inria.fr/isl-$_islver.tar.bz2
+ 0001-pthread-reentrant.patch)
+validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
+ 13975A70E63C361C73AE69EF6EEB81F8981C74C7) # richard.guenther@gmail.com
+sha256sums=('c52618f656f2102b3544419e7d0a8a4f4e6ff052783865202be73edf1a40e28b'
+ 'SKIP'
+ '6b8b0fd7f81d0a957beb3679c81bbb34ccc7568d5682844d8924424a0dadcb1b'
+ 'fc9c6f0edd615f2b39deff28b9626a08fd98ef8ce19f7e34281c0a5bd653ac3b')
prepare() {
- cd $_basedir
+ [[ ! -d gcc ]] && ln -s gcc-${pkgver/+/-} gcc
+ cd gcc
# link isl for in-tree builds
ln -sf ../isl-$_islver isl
- echo $pkgver > gcc/BASE-VER
-
# Do not run fixincludes
sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
- sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" "$srcdir"/$_basedir/{libiberty,gcc}/configure
+ sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" "$srcdir"/gcc/{libiberty,gcc}/configure
+
+ # fix -pthreads behavior on risc-v
+ patch -Np1 -i "$srcdir/0001-pthread-reentrant.patch"
- rm -rf $srcdir/gcc-build
- mkdir $srcdir/gcc-build
+ mkdir -p "$srcdir/gcc-build"
}
build() {
@@ -53,7 +51,7 @@ build() {
CFLAGS=${CFLAGS/-pipe/}
CXXFLAGS=${CXXFLAGS/-pipe/}
- $srcdir/$_basedir/configure \
+ $srcdir/gcc/configure \
--target=$_target \
--prefix=/usr \
--libdir=/usr/lib \
@@ -62,19 +60,19 @@ build() {
--with-local-prefix=/usr/$_target \
--with-build-sysroot=/usr/$_target \
--with-sysroot=/usr/$_target \
- --with-system-zlib \
--enable-shared \
+ --with-system-zlib \
--enable-tls \
--enable-languages=c,c++,fortran \
--disable-libmudflap \
--disable-libssp \
--disable-libquadmath \
--disable-nls \
- --disable-bootstrap \
- --enable-checking=release \
--@MULTILIB@-multilib \
--with-abi=@GCC_MABI@ \
- --with-arch=@GCC_MARCH@
+ --with-arch=@GCC_MARCH@ \
+ --disable-bootstrap \
+ --enable-checking=release
make
}
@@ -94,5 +92,5 @@ package() {
rm -r "$pkgdir"/usr/lib/libcc1.so{,.0,.0.0.0}
rm -r "$pkgdir"/usr/share/man/man7
rm -r "$pkgdir"/usr/share/info
- rm -r "$pkgdir"/usr/share/gcc-$pkgver
+ rm -r "$pkgdir"/usr/share/gcc-*
}
diff --git a/src/stage2/chroot.sh b/src/stage2/chroot.sh
new file mode 100644
index 0000000..9a1384f
--- /dev/null
+++ b/src/stage2/chroot.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+ ##############################################################################
+ # parabola-riscv64-bootstrap #
+ # #
+ # Copyright (C) 2018 Andreas Grapentin #
+ # #
+ # This program is free software: you can redistribute it and/or modify #
+ # it under the terms of the GNU General Public License as published by #
+ # the Free Software Foundation, either version 3 of the License, or #
+ # (at your option) any later version. #
+ # #
+ # This program is distributed in the hope that it will be useful, #
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of #
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+ # GNU General Public License for more details. #
+ # #
+ # You should have received a copy of the GNU General Public License #
+ # along with this program. If not, see <http://www.gnu.org/licenses/>. #
+ ##############################################################################
+
+check_chroot() {
+ echo -n "checking for functional $CARCH skeleton chroot ... "
+
+ local pacman_works=yes
+ pacman --config "$CHROOTDIR"/etc/pacman.conf -r "$CHROOTDIR" -Syyu &>/dev/null || pacman_works=no
+ echo $pacman_works
+
+ [ "x$pacman_works" == "xyes" ] || return "$ERROR_MISSING"
+}
+
+build_chroot() {
+ # create directories
+ rm -rf "$CHROOTDIR"
+ mkdir -pv "$CHROOTDIR"/etc/pacman.d/{gnupg,hooks} \
+ "$CHROOTDIR"/var/{lib/pacman,cache/pacman/pkg,log} \
+ | sed "s#$CHROOTDIR#\$CHROOTDIR#"
+
+ # create sane pacman config
+ cat > "$CHROOTDIR"/etc/pacman.conf << EOF
+[options]
+RootDir = $CHROOTDIR
+DBPath = $CHROOTDIR/var/cache/pacman/
+CacheDir = $CHROOTDIR/var/cache/pacman/pkg/
+LogFile = $CHROOTDIR/var/log/pacman.log
+GPGDir = $CHROOTDIR/etc/pacman.d/gnupg
+HookDir = $CHROOTDIR/etc/pacman.d/hooks
+Architecture = $CARCH
+
+[cross]
+SigLevel = Never
+Server = file://${PKGDEST%/$CARCH}/\$arch
+EOF
+
+ # copy toolchain sysroot to chroot
+ cp -ar "$SYSROOT"/usr "$CHROOTDIR"/
+
+ # final sanity check
+ check_chroot || return
+}
+
+umount_chrootdir() {
+ umount "$SYSROOT"/usr
+
+ trap - INT TERM EXIT
+}
+
+mount_chrootdir() {
+ if mount | grep -q "$SYSROOT/usr"; then umount_chrootdir; fi
+ mount -o bind "$CHROOTDIR"/usr "$SYSROOT"/usr
+
+ trap 'umount_chrootdir' INT TERM EXIT
+}
+
+prepare_chroot() {
+ check_chroot || build_chroot || return
+
+ mount_chrootdir
+}
diff --git a/src/stage2/makepkg.conf.in b/src/stage2/makepkg.conf.in
index 60666fd..bb6dfce 100644
--- a/src/stage2/makepkg.conf.in
+++ b/src/stage2/makepkg.conf.in
@@ -7,7 +7,6 @@ VCSCLIENTS=('bzr::bzr'
'git::git'
'hg::mercurial'
'svn::subversion')
-CPPFLAGS="-D_FORTIFY_SOURCE=2"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
DEBUG_CFLAGS="-g -fvar-tracking-assignments"
DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"
diff --git a/src/stage2/prepare_makepkg.sh b/src/stage2/makepkg.sh
index 82dac20..fd3a4f7 100644
--- a/src/stage2/prepare_makepkg.sh
+++ b/src/stage2/makepkg.sh
@@ -18,59 +18,50 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -euo pipefail
+check_makepkg() {
+ echo -n "checking for makepkg-$CARCH.sh ... "
-msg "preparing a $CARCH cross makepkg environment"
+ local have_makepkg=yes
+ [ -f "$BUILDDIR"/makepkg-"$CARCH".sh ] || have_makepkg=no
+ echo $have_makepkg
-echo -n "checking for makepkg-$CARCH.sh ... "
-[ -f "$_builddir"/makepkg-$CARCH.sh ] && _have_makepkg=yes || _have_makepkg=no
-echo $_have_makepkg
+ [ "x$have_makepkg" == "xyes" ] || return "$ERROR_MISSING"
+}
-if [ "x$_have_makepkg" == "xno" ]; then
- rm -rf "$_makepkgdir"/makepkg-$CARCH
- mkdir -p "$_makepkgdir"/makepkg-$CARCH
- pushd "$_makepkgdir"/makepkg-$CARCH >/dev/null
+build_makepkg() {
+ check_exe bsdtar pacman || return
+
+ prepare_makepkgdir "$MAKEPKGDIR/makepkg-$CARCH" || return
# fetch pacman package to excract makepkg
pacman -Sw --noconfirm --cachedir . pacman
mkdir tmp && bsdtar -C tmp -xf pacman-*.pkg.tar.xz
# install makepkg
- cp -Lv tmp/usr/bin/makepkg "$_builddir"/makepkg-$CARCH.sh
+ cp -Lv tmp/usr/bin/makepkg "$BUILDDIR"/makepkg-"$CARCH".sh
# patch run_pacman in makepkg, we cannot pass the pacman root to it as parameter ATM
- sed -i "s#\"\$PACMAN_PATH\"#& --config $_chrootdir/etc/pacman.conf -r $_chrootdir#" \
- "$_builddir"/makepkg-$CARCH.sh
- popd >/dev/null
-fi
+ sed -i "s#\"\$PACMAN_PATH\"#& --config $CHROOTDIR/etc/pacman.conf -r $CHROOTDIR#" \
+ "$BUILDDIR"/makepkg-"$CARCH".sh
+
+ popd >/dev/null || return
+}
+
+prepare_makepkg() {
+ check_makepkg || build_makepkg || return
-# create a sane makepkg.conf
-cat "$_srcdir"/makepkg.conf.in > "$_builddir"/makepkg-$CARCH.conf
-cat >> "$_builddir"/makepkg-$CARCH.conf << EOF
+ # create a sane makepkg.conf
+ cat "$SRCDIR"/makepkg.conf.in > "$BUILDDIR"/makepkg-"$CARCH".conf
+ cat >> "$BUILDDIR"/makepkg-"$CARCH".conf << EOF
CARCH="$CARCH"
CHOST="$CHOST"
CFLAGS="-march=$GCC_MARCH -mabi=$GCC_MABI -O2 -pipe -fstack-protector-strong -fno-plt"
CXXFLAGS="-march=$GCC_MARCH -mabi=$GCC_MABI -O2 -pipe -fstack-protector-strong -fno-plt"
-PKGDEST="$_pkgdest"
-LOGDEST="$_logdest"
+LOGDEST="$LOGDEST"
+PKGDEST="$PKGDEST"
+SRCDEST="$SRCDEST"
MAKEFLAGS="-j$(($(nproc) + 1))"
EOF
-_srcdest="$(source /etc/makepkg.conf && echo $SRCDEST || true)"
-[ -z "$_srcdest" ] || echo "SRCDEST=\"$_srcdest\"" >> "$_builddir"/makepkg-$CARCH.conf
-
-# create build artefact directories
-mkdir -p "$_logdest" "$_pkgdest"
-chown $SUDO_USER "$_logdest" "$_pkgdest"
-
-# initialize [cross] repo
-echo -n "checking for $CARCH [cross] repo ... "
-[ -e "$_pkgdest"/cross.db ] && _have_cross=yes || _have_cross=no
-echo $_have_cross
-
-if [ "x$_have_cross" == "xno" ]; then
- tar -czf "$_pkgdest"/cross.db.tar.gz -T /dev/null
- tar -czf "$_pkgdest"/cross.files.tar.gz -T /dev/null
- ln -s cross.db.tar.gz "$_pkgdest"/cross.db
- ln -s cross.files.tar.gz "$_pkgdest"/cross.files
-fi
+ check_repo "$PKGDEST" cross || make_repo "$PKGDEST" cross
+}
diff --git a/src/stage2/patches/binutils.patch b/src/stage2/patches/binutils.patch
index 19ee5e6..c5dfe64 100644
--- a/src/stage2/patches/binutils.patch
+++ b/src/stage2/patches/binutils.patch
@@ -1,26 +1,26 @@
---- a/PKGBUILD 2018-03-05 08:54:51.864853816 +0100
-+++ b/PKGBUILD 2018-03-05 08:54:51.864853816 +0100
+--- a/PKGBUILD 2018-03-29 08:30:40.025895502 +0200
++++ b/PKGBUILD 2018-03-29 08:58:13.640738777 +0200
@@ -4,8 +4,8 @@
# toolchain build order: linux-api-headers->glibc->binutils->gcc->binutils->glibc
pkgname=binutils
-pkgver=2.29.1
--pkgrel=2
+-pkgrel=3
+pkgver=2.30
+pkgrel=1
pkgdesc='A set of programs to assemble and manipulate binary and object files'
arch=(x86_64)
url='http://www.gnu.org/software/binutils/'
-@@ -22,7 +22,7 @@ options=(staticlibs !distcc !ccache)
- source=(https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz{,.sig}
- 0001-x86-64_Dont_pass_output_bfd_to_info-callbacks-minfo.patch)
+@@ -24,7 +24,7 @@ source=(https://ftp.gnu.org/gnu/binutils
+ 0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch
+ 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch)
validpgpkeys=(3A24BC1E8FB409FA9F14371813FCEF89DD9E3C4F)
-md5sums=('acc9cd826edb9954ac7cecb81c727793'
+md5sums=('ffc476dd46c96f932875d1b2e27e929f'
'SKIP'
- 'e4be936139ef46122cb3841881c432b2')
-
-@@ -43,6 +43,7 @@ build() {
+ 'e4be936139ef46122cb3841881c432b2'
+ '469164f3c93a0e92a697537b60c9806c'
+@@ -53,6 +53,7 @@ build() {
cd binutils-build
"$srcdir/binutils-$pkgver/configure" \
@@ -28,7 +28,7 @@
--prefix=/usr \
--with-lib-path=/usr/lib:/usr/local/lib \
--with-bugurl=https://bugs.archlinux.org/ \
-@@ -56,7 +57,7 @@ build() {
+@@ -66,7 +67,7 @@ build() {
--with-pic \
--disable-werror \
--disable-gdb \
diff --git a/src/stage2/patches/cryptsetup.patch b/src/stage2/patches/cryptsetup.patch
index 0494127..af4cab2 100644
--- a/src/stage2/patches/cryptsetup.patch
+++ b/src/stage2/patches/cryptsetup.patch
@@ -1,5 +1,14 @@
--- a/PKGBUILD 2018-02-21 21:02:19.655165323 +0100
+++ b/PKGBUILD 2018-02-21 21:03:34.912657502 +0100
+@@ -10,7 +10,7 @@ arch=(x86_64)
+ license=('GPL')
+ url='https://gitlab.com/cryptsetup/cryptsetup/'
+ groups=('base')
+-depends=('device-mapper' 'libgcrypt' 'popt' 'libutil-linux' 'json-c' 'argon2')
++depends=('device-mapper' 'libgcrypt' 'popt' 'libutil-linux' 'json-c' 'argon2' 'fakeroot')
+ makedepends=('util-linux')
+ options=('!emptydirs')
+ validpgpkeys=('2A2918243FDE46648D0686F9D9B0577BD93E98FC') # Milan Broz <gmazyland@gmail.com>
@@ -28,6 +28,7 @@ build() {
cd "${srcdir}"/$pkgname-${pkgver}
diff --git a/src/stage2/patches/libelf.patch b/src/stage2/patches/elfutils.patch
index fa7705b..fa7705b 100644
--- a/src/stage2/patches/libelf.patch
+++ b/src/stage2/patches/elfutils.patch
diff --git a/src/stage2/patches/expat.patch b/src/stage2/patches/expat.patch
index 9e7107f..cb1d8a7 100644
--- a/src/stage2/patches/expat.patch
+++ b/src/stage2/patches/expat.patch
@@ -1,11 +1,11 @@
--- a/PKGBUILD 2018-02-16 13:14:29.306245879 +0100
+++ b/PKGBUILD 2018-02-16 13:16:11.093974920 +0100
-@@ -16,7 +16,7 @@ sha256sums=('d9dc32efba7e74f788fcc4f212a
+@@ -16,7 +16,7 @@ md5sums=('789e297f547980fc9ecc036f9a070d
build() {
cd $pkgname-$pkgver
-- ./configure --prefix=/usr --disable-static
-+ ./configure --host=@CHOST@ --build=@BUILDHOST@ --prefix=/usr --disable-static
+- ./configure --prefix=/usr
++ ./configure --host=@CHOST@ --build=@BUILDHOST@ --prefix=/usr
make
}
diff --git a/src/stage2/patches/gcc-libs.patch b/src/stage2/patches/gcc-libs.patch
deleted file mode 120000
index 741beb3..0000000
--- a/src/stage2/patches/gcc-libs.patch
+++ /dev/null
@@ -1 +0,0 @@
-gcc.patch \ No newline at end of file
diff --git a/src/stage2/patches/gcc.patch b/src/stage2/patches/gcc.patch
index 8e5f443..ddb9c63 100644
--- a/src/stage2/patches/gcc.patch
+++ b/src/stage2/patches/gcc.patch
@@ -1,45 +1,54 @@
---- a/PKGBUILD 2018-03-05 14:47:11.525693335 +0100
-+++ b/PKGBUILD 2018-03-07 05:34:24.951028232 +0100
-@@ -5,8 +5,9 @@
+--- a/PKGBUILD 2018-03-29 08:30:53.138894260 +0200
++++ b/PKGBUILD 2018-03-29 09:01:36.169719582 +0200
+@@ -5,7 +5,8 @@
# toolchain build order: linux-api-headers->glibc->binutils->gcc->binutils->glibc
# NOTE: libtool requires rebuilt with each new gcc version
-pkgname=(gcc gcc-libs gcc-fortran gcc-objc gcc-ada gcc-go lib32-gcc-libs)
--pkgver=7.3.0
+pkgname=(gcc gcc-libs gcc-fortran)
+[ "x@MULTILIB@" == "xdisable" ] || pkgname+=(lib32-gcc-libs)
-+pkgver=7.3.1
+ pkgver=7.3.1+20180312
_majorver=${pkgver:0:1}
_islver=0.18
- pkgrel=1
-@@ -17,14 +18,14 @@ url='http://gcc.gnu.org'
- makedepends=(binutils libmpc gcc-ada doxygen lib32-glibc lib32-gcc-libs)
+@@ -14,6 +15,7 @@ pkgdesc='The GNU Compiler Collection'
+ arch=(x86_64)
+ license=(GPL LGPL FDL custom)
+ url='http://gcc.gnu.org'
++depends=(zlib)
+ makedepends=(binutils libmpc gcc-ada doxygen lib32-glibc lib32-gcc-libs python)
checkdepends=(dejagnu inetutils)
options=(!emptydirs)
-+_snapshot=7-20180215
- #source=(https://sources.archlinux.org/other/gcc/gcc-${pkgver/+/-}.tar.xz{,.sig}
--source=(https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz{,.sig}
-+source=(ftp://gcc.gnu.org/pub/gcc/snapshots/$_snapshot/gcc-$_snapshot.tar.xz
+@@ -21,7 +23,8 @@ source=(https://sources.archlinux.org/ot
+ #source=(https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz{,.sig}
http://isl.gforge.inria.fr/isl-${_islver}.tar.bz2
- c89 c99)
+ c89 c99
+- bz84080.patch)
++ bz84080.patch
++ 0001-pthread-reentrant.patch)
validpgpkeys=(F3691687D867B81B51CE07D9BBE43771487328A9 # bpiotrowski@archlinux.org
13975A70E63C361C73AE69EF6EEB81F8981C74C7) # richard.guenther@gmail.com
--sha256sums=('832ca6ae04636adbb430e865a1451adf6979ab44ca1c8374f61fba65645ce15c'
-- 'SKIP'
-+sha256sums=('bb276f6fce4822fc0806d1e87d21245854d1e41f2a7027c7288375084176c679'
+ sha256sums=('c52618f656f2102b3544419e7d0a8a4f4e6ff052783865202be73edf1a40e28b'
+@@ -29,7 +32,8 @@ sha256sums=('c52618f656f2102b3544419e7d0
'6b8b0fd7f81d0a957beb3679c81bbb34ccc7568d5682844d8924424a0dadcb1b'
'de48736f6e4153f03d0a5d38ceb6c6fdb7f054e8f47ddd6af0a3dbf14f27b931'
- '2513c6d9984dd0a2058557bf00f06d8d5181734e41dcfe07be7ed86f2959622a')
-@@ -51,7 +52,7 @@ snapshot() {
+ '2513c6d9984dd0a2058557bf00f06d8d5181734e41dcfe07be7ed86f2959622a'
+- 'bce05807443558db55f0d6b4dae37a678ea1bb3388b541c876fe3d110e3717e7')
++ 'bce05807443558db55f0d6b4dae37a678ea1bb3388b541c876fe3d110e3717e7'
++ 'fc9c6f0edd615f2b39deff28b9626a08fd98ef8ce19f7e34281c0a5bd653ac3b')
+
+ _svnrev=258469
+ _svnurl=svn://gcc.gnu.org/svn/gcc/branches/gcc-${_majorver}-branch
+@@ -71,6 +75,9 @@ prepare() {
+ # hack! - some configure tests for header files using "$CPP $CPPFLAGS"
+ sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {libiberty,gcc}/configure
+
++ # fix -pthreads behavior on risc-v
++ patch -Np1 -i "$srcdir/0001-pthread-reentrant.patch"
++
+ mkdir -p "$srcdir/gcc-build"
}
- prepare() {
-- ln -s gcc-${pkgver/+/-} gcc
-+ ln -s gcc-$_snapshot gcc
- cd gcc
-
- # link isl for in-tree build
-@@ -77,16 +78,24 @@ build() {
+@@ -82,16 +89,24 @@ build() {
CFLAGS=${CFLAGS/-pipe/}
CXXFLAGS=${CXXFLAGS/-pipe/}
@@ -67,7 +76,7 @@
--with-system-zlib \
--with-isl \
--enable-__cxa_atexit \
-@@ -101,16 +110,13 @@ build() {
+@@ -106,16 +121,13 @@ build() {
--enable-install-libiberty \
--with-linker-hash-style=gnu \
--enable-gnu-indirect-function \
@@ -85,7 +94,16 @@
}
check() {
-@@ -134,25 +140,17 @@ package_gcc-libs() {
+@@ -129,7 +141,7 @@ check() {
+ package_gcc-libs() {
+ pkgdesc='Runtime libraries shipped by GCC'
+ groups=(base)
+- depends=('glibc>=2.26')
++ depends=('glibc>=2.26' libmpc)
+ options+=(!strip)
+ provides=($pkgname-multilib libgo.so libgfortran.so)
+ replaces=($pkgname-multilib)
+@@ -139,25 +151,17 @@ package_gcc-libs() {
rm -f "$pkgdir/$_libdir/libgcc_eh.a"
for lib in libatomic \
@@ -112,7 +130,7 @@
libquadmath; do
make -C $CHOST/$lib DESTDIR="$pkgdir" install-info
done
-@@ -183,22 +181,22 @@ package_gcc() {
+@@ -188,22 +192,22 @@ package_gcc() {
install -m755 -t "$pkgdir/${_libdir}/" gcc/{cc1,cc1plus,collect2,lto1}
make -C $CHOST/libgcc DESTDIR="$pkgdir" install
@@ -140,7 +158,7 @@
make DESTDIR="$pkgdir" install-fixincludes
make -C gcc DESTDIR="$pkgdir" install-mkheaders
-@@ -208,26 +206,16 @@ package_gcc() {
+@@ -213,26 +217,16 @@ package_gcc() {
ln -s /${_libdir}/liblto_plugin.so \
"$pkgdir/usr/lib/bfd-plugins/"
@@ -170,7 +188,7 @@
make -C libcpp DESTDIR="$pkgdir" install
make -C gcc DESTDIR="$pkgdir" install-po
-@@ -239,9 +227,6 @@ package_gcc() {
+@@ -244,9 +238,6 @@ package_gcc() {
install -Dm755 "$srcdir/c89" "$pkgdir/usr/bin/c89"
install -Dm755 "$srcdir/c99" "$pkgdir/usr/bin/c99"
@@ -180,7 +198,7 @@
# remove files provided by lib32-gcc-libs
rm -f "$pkgdir"/usr/lib32/lib{stdc++,gcc_s}.so
-@@ -260,7 +245,7 @@ package_gcc-fortran() {
+@@ -269,7 +260,7 @@ package_gcc-fortran() {
cd gcc-build
make -C $CHOST/libgfortran DESTDIR="$pkgdir" install-cafexeclibLTLIBRARIES \
install-{toolexeclibDATA,nodist_fincludeHEADERS}
@@ -189,3 +207,17 @@
install-{toolexeclibDATA,nodist_fincludeHEADERS}
make -C $CHOST/libgomp DESTDIR="$pkgdir" install-nodist_fincludeHEADERS
make -C gcc DESTDIR="$pkgdir" fortran.install-{common,man,info}
+--- /dev/null 2018-03-20 11:36:27.102196685 +0100
++++ b/0001-pthread-reentrant.patch 2018-03-29 09:01:25.248720617 +0200
+@@ -0,0 +1,11 @@
++--- trunk/gcc/config/riscv/linux.h 2018/01/03 10:03:58 256169
+++++ trunk/gcc/config/riscv/linux.h 2018/02/13 11:21:01 257621
++@@ -47,6 +47,8 @@
++
++ #define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
++
+++#define CPP_SPEC "%{pthread:-D_REENTRANT}"
+++
++ #define LINK_SPEC "\
++ -melf" XLEN_SPEC "lriscv \
++ %{shared} \
diff --git a/src/stage2/patches/glib2.patch b/src/stage2/patches/glib2.patch
index ca4e630..d10b45b 100644
--- a/src/stage2/patches/glib2.patch
+++ b/src/stage2/patches/glib2.patch
@@ -6,12 +6,12 @@
pkgbase=glib2
-pkgname=(glib2 glib2-docs)
+pkgname=(glib2)
- pkgver=2.55.1+240+g5d93dd63e
+ pkgver=2.56.0+7+g66948ae23
pkgrel=1
pkgdesc="Low level core library"
-@@ -40,13 +40,18 @@ prepare() {
+@@ -43,13 +43,18 @@ build() {
+ check_option debug n && debug=yes
- build() {
cd glib
+ cat > config.cache << EOF
+glib_cv_stack_grows=no
@@ -24,12 +24,12 @@
--libdir=/usr/lib \
--sysconfdir=/etc \
--with-pcre=system \
- --enable-debug=yes \
+ --enable-debug=$debug \
- --enable-gtk-doc \
--disable-fam
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
-@@ -60,7 +65,6 @@ check() {
+@@ -63,7 +68,6 @@ check() {
package_glib2() {
cd glib
make DESTDIR="$pkgdir" install
diff --git a/src/stage2/patches/libcap-ng.patch b/src/stage2/patches/libcap-ng.patch
index 58c5bb0..e2e6e72 100644
--- a/src/stage2/patches/libcap-ng.patch
+++ b/src/stage2/patches/libcap-ng.patch
@@ -1,11 +1,10 @@
--- a/PKGBUILD 2018-02-14 21:40:20.315697551 +0100
+++ b/PKGBUILD 2018-02-14 21:41:14.872805361 +0100
-@@ -16,7 +16,7 @@ md5sums=('0dece96644bd798020e170fbf76638
+@@ -21,6 +21,7 @@ prepare() {
build() {
- cd $pkgname-$pkgver
-
-- ./configure --prefix=/usr --enable-static=no --with-python=no
-+ ./configure --host=@CHOST@ --build=@BUILDHOST@ --prefix=/usr --enable-static=no --with-python=no
- make
- }
-
+ cd ${pkgname}-${pkgver}
+ ./configure \
++ --host=@CHOST@ --build=@BUILDHOST@ \
+ --prefix=/usr \
+ --enable-static=no \
+ -with-python=no
diff --git a/src/stage2/patches/libcap.patch b/src/stage2/patches/libcap.patch
index 8556745..2399e50 100644
--- a/src/stage2/patches/libcap.patch
+++ b/src/stage2/patches/libcap.patch
@@ -1,14 +1,17 @@
--- a/PKGBUILD 2018-02-16 19:41:56.996792407 +0100
+++ b/PKGBUILD 2018-02-16 20:17:25.900329276 +0100
-@@ -13,16 +13,20 @@ license=('GPL2')
- depends=('glibc' 'attr')
+@@ -10,18 +10,22 @@ pkgdesc='POSIX 1003.1e capabilities'
+ arch=('i686' 'x86_64')
+ url='http://sites.google.com/site/fullycapable/'
+ license=('GPL2')
+-depends=('glibc' 'attr')
++depends=('glibc' 'attr' 'pam' 'unixodbc' 'linux-api-headers')
makedepends=('linux-api-headers')
- validpgpkeys=('38A644698C69787344E954CE29EE848AE2CCF3F4') # Andrew G. Morgan <morgan@kernel.org>
--source=(https://kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-$pkgver.tar.{xz,sign})
--md5sums=('6666b839e5d46c2ad33fc8aa2ceb5f77' 'SKIP')
-+source=(https://kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-$pkgver.tar.{xz,sign}
+-source=(https://kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-$pkgver.tar.xz)
+-md5sums=('6666b839e5d46c2ad33fc8aa2ceb5f77')
++source=(https://kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-$pkgver.tar.xz
+ libcap-2.25-gperf.patch)
-+md5sums=('6666b839e5d46c2ad33fc8aa2ceb5f77' 'SKIP'
++md5sums=('6666b839e5d46c2ad33fc8aa2ceb5f77'
+ '03198e18adb059f9d666d2069ff9e9a7')
prepare() {
@@ -19,8 +22,8 @@
build() {
- make -C $pkgname-$pkgver KERNEL_HEADERS=/usr/include
-+ make -C $pkgname-$pkgver KERNEL_HEADERS=/usr/include \
-+ BUILD_CC=gcc CC=@CHOST@-gcc AR=@CHOST@-ar RANLIB=@CHOST@-ranlib
++ make -C $pkgname-$pkgver KERNEL_HEADERS=@SYSROOT@/usr/include \
++ BUILD_CC=gcc BUILD_CFLAGS="" CC=@CHOST@-gcc AR=@CHOST@-ar RANLIB=@CHOST@-ranlib
}
package() {
diff --git a/src/stage2/patches/libgpg-error.patch b/src/stage2/patches/libgpg-error.patch
index 8fa2e6a..39267ba 100644
--- a/src/stage2/patches/libgpg-error.patch
+++ b/src/stage2/patches/libgpg-error.patch
@@ -9,7 +9,7 @@
+ lock-obj-pub.riscv64-unknown-linux-gnu.h)
#ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/libgpg-error/${pkgname}-${pkgver}.tar.bz2)
# https://www.gnupg.org/download/integrity_check.html
- sha1sums=('a428758999ff573e62d06892e3d2c0b0f335787c'
+ sha1sums=('2b9baae264f3e82ebe00dcd10bae3f2d64232c10'
- 'SKIP')
+ 'SKIP'
+ 'e7a718fdcca098d2ae5331313aef59b2d3031929')
diff --git a/src/stage2/patches/libpsl.patch b/src/stage2/patches/libpsl.patch
index 8c3355b..5491547 100644
--- a/src/stage2/patches/libpsl.patch
+++ b/src/stage2/patches/libpsl.patch
@@ -1,6 +1,15 @@
--- a/PKGBUILD 2018-02-16 14:38:32.235244930 +0100
+++ b/PKGBUILD 2018-02-16 14:41:16.650413298 +0100
-@@ -22,14 +22,15 @@ prepare() {
+@@ -8,7 +8,7 @@ pkgdesc='Public Suffix List library'
+ url='https://github.com/rockdaboot/libpsl'
+ arch=('x86_64')
+ license=('MIT')
+-depends=('libidn2' 'libunistring')
++depends=('libidn2' 'libunistring' 'publicsuffix-list')
+ makedepends=('libxslt' 'python' 'publicsuffix-list' 'gtk-doc')
+ provides=('libpsl.so')
+ source=(https://github.com/rockdaboot/libpsl/releases/download/${pkgname}-${pkgver}/${pkgname}-${pkgver}.tar.gz)
+@@ -23,14 +23,13 @@ prepare() {
build() {
cd ${pkgname}-${pkgver}
./configure \
@@ -8,9 +17,8 @@
--prefix=/usr \
--disable-static \
--disable-dependency-tracking \
- --enable-man \
+- --enable-man \
- --enable-gtk-doc \
-+ --disable-gtk-doc \
--enable-{builtin,runtime}=libidn2 \
- --with-psl-file=/usr/share/publicsuffix/effective_tld_names.dat \
- --with-psl-testfile=/usr/share/publicsuffix/test_psl.txt
diff --git a/src/stage2/patches/libsystemd-standalone.patch b/src/stage2/patches/libsystemd-standalone.patch
deleted file mode 120000
index fc81fda..0000000
--- a/src/stage2/patches/libsystemd-standalone.patch
+++ /dev/null
@@ -1 +0,0 @@
-systemd.patch \ No newline at end of file
diff --git a/src/stage2/patches/libsystemd.patch b/src/stage2/patches/libsystemd.patch
deleted file mode 120000
index fc81fda..0000000
--- a/src/stage2/patches/libsystemd.patch
+++ /dev/null
@@ -1 +0,0 @@
-systemd.patch \ No newline at end of file
diff --git a/src/stage2/patches/libudev.patch b/src/stage2/patches/libudev.patch
deleted file mode 120000
index fc81fda..0000000
--- a/src/stage2/patches/libudev.patch
+++ /dev/null
@@ -1 +0,0 @@
-systemd.patch \ No newline at end of file
diff --git a/src/stage2/patches/libutil-linux.patch b/src/stage2/patches/libutil-linux.patch
deleted file mode 120000
index 70ec2ed..0000000
--- a/src/stage2/patches/libutil-linux.patch
+++ /dev/null
@@ -1 +0,0 @@
-util-linux.patch \ No newline at end of file
diff --git a/src/stage2/patches/device-mapper.patch b/src/stage2/patches/lvm2.patch
index 229c789..229c789 100644
--- a/src/stage2/patches/device-mapper.patch
+++ b/src/stage2/patches/lvm2.patch
diff --git a/src/stage2/patches/nss-myhostname.patch b/src/stage2/patches/nss-myhostname.patch
deleted file mode 120000
index fc81fda..0000000
--- a/src/stage2/patches/nss-myhostname.patch
+++ /dev/null
@@ -1 +0,0 @@
-systemd.patch \ No newline at end of file
diff --git a/src/stage2/patches/nss-mymachines.patch b/src/stage2/patches/nss-mymachines.patch
deleted file mode 120000
index fc81fda..0000000
--- a/src/stage2/patches/nss-mymachines.patch
+++ /dev/null
@@ -1 +0,0 @@
-systemd.patch \ No newline at end of file
diff --git a/src/stage2/patches/nss-resolve.patch b/src/stage2/patches/nss-resolve.patch
deleted file mode 120000
index fc81fda..0000000
--- a/src/stage2/patches/nss-resolve.patch
+++ /dev/null
@@ -1 +0,0 @@
-systemd.patch \ No newline at end of file
diff --git a/src/stage2/patches/nss-systemd.patch b/src/stage2/patches/nss-systemd.patch
deleted file mode 120000
index fc81fda..0000000
--- a/src/stage2/patches/nss-systemd.patch
+++ /dev/null
@@ -1 +0,0 @@
-systemd.patch \ No newline at end of file
diff --git a/src/stage2/patches/openssl.patch b/src/stage2/patches/openssl.patch
index 5404139..cc70009 100644
--- a/src/stage2/patches/openssl.patch
+++ b/src/stage2/patches/openssl.patch
@@ -1,5 +1,16 @@
--- a/PKGBUILD 2018-02-20 18:48:24.326408636 +0100
+++ b/PKGBUILD 2018-02-20 18:54:14.080912013 +0100
+@@ -14,8 +14,8 @@ license=('custom:BSD')
+ depends=('perl')
+ optdepends=('ca-certificates')
+ backup=('etc/ssl/openssl.cnf')
+-source=("https://www.openssl.org/source/${pkgname}-${_ver}.tar.gz"
+- "https://www.openssl.org/source/${pkgname}-${_ver}.tar.gz.asc"
++source=("https://www.openssl.org/source/old/1.1.0/${pkgname}-${_ver}.tar.gz"
++ "https://www.openssl.org/source/old/1.1.0/${pkgname}-${_ver}.tar.gz.asc"
+ 'ca-dir.patch')
+ sha256sums=('de4d501267da39310905cb6dc8c6121f7a2cad45a7707f76df828fe1b85073af'
+ 'SKIP'
@@ -39,9 +39,11 @@ build() {
openssltarget='linux-elf'
optflags=''
diff --git a/src/stage2/patches/sqlite.patch b/src/stage2/patches/sqlite.patch
index 768f0fb..d187d58 100644
--- a/src/stage2/patches/sqlite.patch
+++ b/src/stage2/patches/sqlite.patch
@@ -1,6 +1,14 @@
--- a/PKGBUILD 2018-02-20 14:26:45.612481607 +0100
+++ b/PKGBUILD 2018-02-20 14:28:37.776428772 +0100
-@@ -38,7 +38,7 @@ build() {
+@@ -13,6 +13,7 @@ pkgdesc="A C library that implements an
+ arch=('x86_64')
+ license=('custom:Public Domain')
+ url="http://www.sqlite.org/"
++depends=('tcl')
+ makedepends=('tcl' 'readline' 'zlib')
+ source=(https://www.sqlite.org/2018/sqlite-src-${_srcver}.zip
+ https://www.sqlite.org/2018/sqlite-doc-${_docver}.zip
+@@ -38,7 +39,7 @@ build() {
# build sqlite
cd sqlite-src-$_srcver
@@ -9,3 +17,11 @@
--disable-static \
--disable-amalgamation \
--enable-fts3 \
+@@ -47,6 +48,7 @@ build() {
+ --enable-rtree \
+ --enable-json1 \
+ TCLLIBDIR=/usr/lib/sqlite$pkgver
++ sed -i '/+= -I\/usr\/include/d' Makefile
+ make
+ # build additional tools
+ make showdb showjournal showstat4 showwal sqldiff sqlite3_analyzer
diff --git a/src/stage2/patches/systemd.patch b/src/stage2/patches/systemd.patch
index e8c6241..09c622d 100644
--- a/src/stage2/patches/systemd.patch
+++ b/src/stage2/patches/systemd.patch
@@ -1,14 +1,24 @@
---- a/PKGBUILD 2018-03-05 11:20:19.665799440 +0100
-+++ b/PKGBUILD 2018-03-05 11:20:19.664799432 +0100
-@@ -26,7 +26,6 @@ makedepends=('acl' 'cryptsetup' 'docbook
+--- a/PKGBUILD 2018-03-29 08:40:33.725839233 +0200
++++ b/PKGBUILD 2018-03-29 08:47:05.303802120 +0200
+@@ -24,7 +24,7 @@ makedepends=('acl' 'cryptsetup' 'docbook
'meson' 'libseccomp' 'pcre2')
makedepends_i686=('gnu-efi-libs')
makedepends_x86_64=('gnu-efi-libs')
-options=('strip')
- validpgpkeys=('63CDA1E5D3FC22B998D20DD6327F26951A015CC4') # Lennart Poettering <lennart@poettering.net>
- source=('git://github.com/systemd/systemd-stable.git'
- 'git://github.com/systemd/systemd.git' # pull in for tags, backports & reverts
-@@ -146,10 +145,30 @@ build() {
++depends=('libutil-linux' 'pcre2')
+ validpgpkeys=('63CDA1E5D3FC22B998D20DD6327F26951A015CC4' # Lennart Poettering <lennart@poettering.net>
+ '5C251B5FC54EB2F80F407AAAC54CA336CFEB557E') # Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
+ source=('git+https://github.com/systemd/systemd-stable'
+@@ -85,6 +85,8 @@ sha512sums=('SKIP'
+ _backports=(
+ # core: do not free heap-allocated strings (#8391) (FS#57741)
+ '5cbaad2f6795088db56063d20695c6444595822f'
++ # basic/macros: rename noreturn into _noreturn_ (#8456)
++ '848e863acc51ecfb0f3955c498874588201d9130'
+ )
+
+ _reverts=(
+@@ -163,10 +165,30 @@ build() {
CXXFLAGS+=" -fno-lto"
fi
@@ -39,7 +49,7 @@
-Ddbuspolicydir=/usr/share/dbus-1/system.d
-Ddefault-dnssec=no
-@@ -166,7 +185,7 @@ build() {
+@@ -183,7 +205,7 @@ build() {
meson_options+=(-Dgnuefi=true)
fi
@@ -48,7 +58,7 @@
ninja -C build
-@@ -181,28 +202,21 @@ build() {
+@@ -198,28 +220,21 @@ build() {
mv -T "$srcdir/dest"/{systemd,libsystemd}/usr/include/systemd
mv -T "$srcdir/dest"/{systemd,libsystemd}/usr/lib/pkgconfig/libsystemd.pc
mv "$srcdir/dest"/systemd/usr/lib/libsystemd.so* -t "$srcdir/dest"/libsystemd/usr/lib/
@@ -70,20 +80,20 @@
done
install -dm755 "$srcdir/dest/systemd-sysvcompat"/usr/share/man/man8
-- mv "$srcdir/dest/systemd"/usr/share/man/man8/{telinit,halt,reboot,poweroff,runlevel,shutdown}.8 \
+- mv "$srcdir/dest/systemd"/usr/share/man/man8/{halt,poweroff,reboot,runlevel,shutdown,telinit}.8 \
- -t "$srcdir/dest/systemd-sysvcompat"/usr/share/man/man8
- rmdir "$srcdir/dest"/systemd/usr/{share/man/man3,lib/pkgconfig,include}
-+ rmdir "$srcdir/dest"/systemd/usr/{share/man/man3,lib/pkgconfig,include} || true
++ rm -rf "$srcdir/dest"/systemd/usr/{share/man/man3,lib/pkgconfig,include}
}
- package_systemd() {
-@@ -267,7 +281,7 @@ package_systemd() {
- chmod 0750 "$pkgdir"/usr/share/polkit-1/rules.d
+ check() {
+@@ -261,7 +276,7 @@ package_systemd() {
+ rm -rv "$pkgdir"/etc/systemd/system/*
# we'll create this on installation
-- rmdir "$pkgdir/var/log/journal/remote"
-+ rmdir "$pkgdir/var/log/journal/remote" || true
+- rmdir "$pkgdir"/var/log/journal/remote
++ rm -rf "$pkgdir"/var/log/journal/remote
- # ship default policy to leave services disabled
- echo 'disable *' >"$pkgdir"/usr/lib/systemd/system-preset/99-default.preset
+ # executable (symlinks) shipped with systemd-sysvcompat
+ rm "$pkgdir"/usr/bin/{halt,init,poweroff,reboot,runlevel,shutdown,telinit}
diff --git a/src/stage2/patches/tcl.patch b/src/stage2/patches/tcl.patch
index f1a5473..ff62673 100644
--- a/src/stage2/patches/tcl.patch
+++ b/src/stage2/patches/tcl.patch
@@ -1,14 +1,14 @@
--- a/PKGBUILD 2018-02-20 14:57:44.236937412 +0100
+++ b/PKGBUILD 2018-02-20 15:09:43.351455663 +0100
-@@ -22,7 +22,10 @@ prepare() {
+@@ -21,7 +21,10 @@ prepare() {
+
build() {
cd tcl${pkgver}/unix
- [[ $CARCH == "x86_64" ]] && BIT="--enable-64bit"
-- ./configure --prefix=/usr --mandir=/usr/share/man --enable-threads $BIT
+- ./configure --prefix=/usr --mandir=/usr/share/man --enable-threads --enable-64bit
+ export CC=@CHOST@-gcc
+ export ac_cv_func_strtod=yes
+ export tcl_cv_strtod_buggy=1
-+ ./configure --host=@CHOST@ --build=@BUILDHOST@ --prefix=/usr --mandir=/usr/share/man --enable-threads $BIT
++ ./configure --host=@CHOST@ --build=@BUILDHOST@ --prefix=/usr --mandir=/usr/share/man --enable-threads
make
}
diff --git a/src/stage2/patches/util-linux.patch b/src/stage2/patches/util-linux.patch
index a7a8ee4..12ae122 100644
--- a/src/stage2/patches/util-linux.patch
+++ b/src/stage2/patches/util-linux.patch
@@ -8,8 +8,8 @@
+options=('debug')
validpgpkeys=('B0C64D14301CC6EFAEDF60E4E4B71D5EEC39C284') # Karel Zak
source=("https://www.kernel.org/pub/linux/utils/util-linux/v$_pkgmajor/$pkgbase-$pkgver.tar."{xz,sign}
- pam-{login,common,su}
-@@ -35,6 +35,8 @@ build() {
+ '0001-fstrim-cleanup-uncludes.patch'
+@@ -46,6 +46,8 @@ build() {
cd "$pkgbase-$pkgver"
./configure --prefix=/usr \
@@ -18,7 +18,7 @@
--libdir=/usr/lib \
--bindir=/usr/bin \
--localstatedir=/run \
-@@ -45,7 +47,7 @@ build() {
+@@ -56,7 +58,7 @@ build() {
--enable-chfn-chsh \
--enable-write \
--enable-mesg \
@@ -27,7 +27,7 @@
make
}
-@@ -78,7 +80,6 @@ package_util-linux() {
+@@ -89,7 +91,6 @@ package_util-linux() {
install -m644 "$srcdir/pam-su" "$pkgdir/etc/pam.d/su-l"
# TODO(dreisner): offer this upstream?
@@ -35,3 +35,11 @@
# adjust for usrmove
# TODO(dreisner): fix configure.ac upstream so that this isn't needed
+@@ -115,6 +116,7 @@ package_util-linux() {
+
+ package_libutil-linux() {
+ pkgdesc="util-linux runtime libraries"
++ depends=(pam shadow coreutils libcap-ng)
+ provides=('libblkid.so' 'libfdisk.so' 'libmount.so' 'libsmartcols.so' 'libuuid.so')
+
+ make -C "$pkgbase-$pkgver" DESTDIR="$pkgdir" install-usrlib_execLTLIBRARIES
diff --git a/src/stage2/prepare_deptree.sh b/src/stage2/prepare_deptree.sh
deleted file mode 100644
index fa32846..0000000
--- a/src/stage2/prepare_deptree.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/bash
- ##############################################################################
- # parabola-riscv64-bootstrap #
- # #
- # Copyright (C) 2018 Andreas Grapentin #
- # #
- # This program is free software: you can redistribute it and/or modify #
- # it under the terms of the GNU General Public License as published by #
- # the Free Software Foundation, either version 3 of the License, or #
- # (at your option) any later version. #
- # #
- # This program is distributed in the hope that it will be useful, #
- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
- # GNU General Public License for more details. #
- # #
- # You should have received a copy of the GNU General Public License #
- # along with this program. If not, see <http://www.gnu.org/licenses/>. #
- ##############################################################################
-
-set -euo pipefail
-
-msg "preparing transitive dependency tree for $_groups (Stage 2)"
-
-echo -n "checking for complete deptree ... "
-[ -f "$_deptree".FULL ] && _have_deptree=yes || _have_deptree=no
-echo $_have_deptree
-
-if [ "x$_have_deptree" == "xno" ]; then
- declare -A _tree
- _frontier=($(pacman -Sg $_groups | awk '{print $2}'))
-
- while [ ${#_frontier[@]} -gt 0 ]; do
- # pop pkg from frontier
- _pkgname=$(echo ${_frontier[0]})
- _frontier=("${_frontier[@]:1}")
-
- # if seen before, skip, otherwise create entry in dependency tree
- [[ -v _tree[$_pkgname] ]] && continue
- _tree[$_pkgname]=""
-
- echo -en "\r pkges: ${#_tree[@]} "
-
- _pkgdeps=$(pacman -Si $_pkgname | grep '^Depends' | cut -d':' -f2 | sed 's/None//')
-
- # tweak some build-time dependencies
- case $_pkgname in
- curl)
- _pkgdeps="${_pkgdeps/krb5}" ;;
- gcc-libs)
- _pkgdeps+=" libmpc mpfr gmp" ;;
- gmp)
- _pkgdeps="${_pkgdeps/gcc-libs}"
- _pkgdeps="${_pkgdeps/bash}" ;;
- iptables)
- _pkgdeps+=" libnfnetlink libnetfilter_conntrack" ;;
- libcap)
- _pkgdeps+=" pam unixodbc" ;;
- libpsl)
- _pkgdeps+=" publicsuffix-list" ;;
- libtirpc)
- _pkgdeps="${_pkgdeps/krb5}" ;;
- libutil-linux)
- _pkgdeps+=" pam shadow coreutils libcap-ng" ;;
- make)
- _pkgdeps="${_pkgdeps/guile}" ;;
- nss-*|libudev|libsystemd*)
- _pkgdeps+=" libutil-linux pcre2" ;;
- pinentry)
- _pkgdeps="${_pkgdeps/libsecret}" ;;
- sqlite)
- _pkgdeps+=" tcl" ;;
- suda)
- _pkgdeps="${_pkgdeps/libldap}" ;;
- util-linux)
- _pkgdeps="${_pkgdeps/libsystemd}" ;;
- esac
-
- # iterate dependencies for pkg
- for _dep in $_pkgdeps; do
- # translate dependency string to actual package
- realdep=$(pacman --noconfirm -Sw "$_dep" | grep '^Packages' | awk '{print $3}')
- realdep=${realdep%-*-*}
- # add dependency to tree and frontier
- _tree[$_pkgname]="${_tree[$_pkgname]} $realdep"
- _frontier+=($realdep)
- done
- done
-
- echo -en "\r"
-
- # write package dependency tree
- truncate -s0 "$_deptree".FULL
- for i in "${!_tree[@]}"; do
- echo "${i} : [${_tree[$i]} ]" >> "$_deptree".FULL
- done
-
- # pull filesystem to the front, for directories and symlinks
- sed -i "/^filesystem/d; 1ifilesystem : [${_tree[filesystem]} ]" "$_deptree".FULL
-fi
-
-[ -f "$_deptree" ] || cp "$_deptree"{.FULL,}
-chown $SUDO_USER "$_deptree"
-
-echo " total pkges: $(cat "$_deptree".FULL | wc -l)"
-echo " remaining pkges: $(cat "$_deptree" | wc -l)"
diff --git a/src/stage2/stage2.sh b/src/stage2/stage2.sh
index 2296fd8..ecd0340 100755
--- a/src/stage2/stage2.sh
+++ b/src/stage2/stage2.sh
@@ -18,163 +18,204 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
-set -euo pipefail
-
-msg "Entering Stage 2"
-notify "*Bootstrap Entering Stage 2*"
-
-# set a bunch of convenience variables
-_builddir="$topbuilddir"/stage2
-_srcdir="$topsrcdir"/stage2
-_chrootdir="$_builddir"/$CARCH-root
-_makepkgdir="$_builddir"/$CARCH-makepkg
-_deptree="$_builddir"/DEPTREE
-_sysroot="$($CHOST-gcc --print-sysroot)"
-_buildhost="$(gcc -dumpmachine)"
-_groups="base-devel"
-_pkgdest="$_builddir"/packages/$CARCH
-_logdest="$_builddir"/makepkglogs
-
-# check for required programs
-check_exe awk
-check_exe bsdtar
-check_exe git
-check_exe pacman
-check_exe sed
-check_exe tar
-
-# required for dbus
-check_file /usr/share/aclocal/ax_append_flag.m4
-
-# make sure that binfmt is *disabled* for stage2 build
-echo 0 > /proc/sys/fs/binfmt_misc/status
-
-# prepare for the build
-. "$_srcdir"/prepare_makepkg.sh
-. "$_srcdir"/prepare_chroot.sh
-. "$_srcdir"/prepare_deptree.sh
-
-msg "starting $CARCH cross-build"
-
-# keep building packages until the deptree is empty
-while [ -s "$_deptree" ]; do
- # grab one without unfulfilled dependencies
- _pkgname=$(grep '\[ *\]' "$_deptree" | head -n1 | awk '{print $1}') || true
- [ -n "$_pkgname" ] || die "could not resolve dependencies. exiting."
-
- _pkgarch=$(pacman -Si $_pkgname | grep '^Architecture' | awk '{print $3}')
-
- # set arch to $CARCH, unless it is any
- [ "x$_pkgarch" == "xany" ] || _pkgarch=$CARCH
-
- msg "makepkg: $_pkgname"
- msg " remaining packages: $(cat "$_deptree" | wc -l)"
-
- echo -n "checking for built $_pkgname package ... "
- pacman --config "$_chrootdir"/etc/pacman.conf -r "$_chrootdir" -Syyi $_pkgname &>/dev/null \
- && _have_pkg=yes || _have_pkg=no
- echo $_have_pkg
-
- if [ "x$_have_pkg" == "xno" ]; then
- prepare_makepkgdir
-
- _pkgdir="$_makepkgdir"/$_pkgname/pkg/$_pkgname
-
- if [ "x$_pkgarch" == "xany" ]; then
- # repackage arch=(any) packages
- _pkgver=$(pacman -Si $_pkgname | grep '^Version' | awk '{print $3}')
- pacman -Sddw --noconfirm --cachedir "$_pkgdest" $_pkgname
- elif [ "x$_pkgname" == "xca-certificates-mozilla" ]; then
- # repackage ca-certificates-mozilla to avoid building nss
- _pkgver=$(pacman -Si $_pkgname | grep '^Version' | awk '{print $3}')
- pacman -Sw --noconfirm --cachedir . $_pkgname
- mkdir tmp && bsdtar -C tmp -xf $_pkgname-$_pkgver-*.pkg.tar.xz
- mkdir -p "$_pkgdir"/usr/share/
- cp -rv tmp/usr/share/ca-certificates/ "$_pkgdir"/usr/share/
- cat > "$_pkgdir"/.PKGINFO << EOF
-pkgname = $_pkgname
-pkgver = $_pkgver
+# shellcheck source=src/stage2/makepkg.sh
+. "$TOPSRCDIR"/stage2/makepkg.sh
+# shellcheck source=src/stage2/chroot.sh
+. "$TOPSRCDIR"/stage2/chroot.sh
+
+build_pkg_any() {
+ local dep
+ for dep in $(pkgdeps "$pkgname"); do
+ deptree_check_depends "$pkgname" "$dep" || return
+ done
+ [ "x$(deptree_next)" != "x$pkgname" ] && return
+
+ check_pkgfile "$PKGDEST" "$pkgname" && return
+
+ pacman -Sddw --noconfirm --cachedir "$PKGDEST" "$pkgname" || return
+}
+
+build_pkg_ca-certificates-mozilla() {
+ # repackage ca-certificates-mozilla to avoid building nss
+ local dep
+ for dep in $(pkgdeps "$pkgname"); do
+ deptree_check_depends "$pkgname" "$dep" || return
+ done
+ [ "x$(deptree_next)" != "x$pkgname" ] && return
+
+ check_pkgfile "$PKGDEST" "$pkgname" && return
+
+ local pkgver pkgdir="$MAKEPKGDIR"/$pkgname/pkg/$pkgname
+ pkgver=$(pkgver "$pkgname") || return
+ pacman -Sddw --noconfirm --cachedir . "$pkgname" || return
+ mkdir tmp && bsdtar -C tmp -xf "$pkgname"-*.pkg.tar.xz || return
+ mkdir -p "$pkgdir"/usr/share/
+ cp -rv tmp/usr/share/ca-certificates/ "$pkgdir"/usr/share/
+ cat > "$pkgdir"/.PKGINFO << EOF
+pkgname = $pkgname
+pkgver = $pkgver
pkgdesc = Mozilla's set of trusted CA certificates
url = https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS
builddate = $(date '+%s')
size = 0
-arch = $_pkgarch
+arch = $pkgarch
EOF
- cd "$_pkgdir"
- env LANG=C bsdtar -czf .MTREE \
- --format=mtree \
- --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
- .PKGINFO *
- env LANG=C bsdtar -cf - .MTREE .PKGINFO * | xz -c -z - > \
- "$_pkgdest"/$_pkgname-$_pkgver-$_pkgarch.pkg.tar.xz
- else
- fetch_pkgfiles $_pkgname
- import_keys
-
- # patch for cross-compiling
- [ -f "$_srcdir"/patches/$_pkgname.patch ] || die "missing package patch"
- cp PKGBUILD{,.old}
- patch -Np1 -i "$_srcdir"/patches/$_pkgname.patch || die "patch does not apply"
- cp PKGBUILD{,.in}
-
- # substitute common variables
- sed -i
- "s#@CARCH@#$CARCH#g; \
- s#@CHOST@#$CHOST#g; \
- s#@GCC_MARCH@#$GCC_MARCH#g; \
- s#@GCC_MABI@#$GCC_MABI#g; \
- s#@CARCH32@#${CARCH32:-}#g; \
- s#@CHOST32@#${CHOST32:-}#g; \
- s#@GCC32_MARCH@#${GCC32_MARCH:-}#g; \
- s#@GCC32_MABI@#${GCC32_MABI:-}#g; \
- s#@BUILDHOST@#$_buildhost#g; \
- s#@SYSROOT@#$_sysroot#g; \
- s#@LINUX_ARCH@#$LINUX_ARCH#g; \
- s#@MULTILIB@#${MULTILIB:-disable}#g;" \
- PKGBUILD
-
- # enable the target CARCH in arch array
- sed -i "s/arch=([^)]*/& $CARCH/" PKGBUILD
-
- # build the package
- chown -R $SUDO_USER "$_makepkgdir"/$_pkgname
- sudo -u $SUDO_USER \
- "$_builddir"/makepkg-$CARCH.sh -fLC --config "$_builddir"/makepkg-$CARCH.conf \
- --nocheck --nodeps --nobuild || failed_build
-
- if [ "x${REGEN_CONFIG_FRAGMENTS:-no}" == "xyes" ]; then
- url="https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain"
- find src -iname config.sub -print -exec curl "$url;f=config.sub;hb=HEAD" -o {} \;
- fi
-
- sudo -u $SUDO_USER \
- "$_builddir"/makepkg-$CARCH.sh -fLC --config "$_builddir"/makepkg-$CARCH.conf \
- --nocheck --nodeps --noprepare || failed_build
- fi
-
- popd >/dev/null
+ cd "$pkgdir" || return
+ env LANG=C bsdtar -czf .MTREE \
+ --format=mtree \
+ --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
+ .PKGINFO ./* || return
+ env LANG=C bsdtar -cf - .MTREE .PKGINFO ./* | xz -c -z - > \
+ "$PKGDEST/$pkgname-$pkgver-$pkgarch.pkg.tar.xz" || return
+}
+
+build_stage2_pkg() {
+ package_fetch_upstream_pkgfiles "$pkgname" || return
+ import_keys || return
+
+ local pkgbase
+ pkgbase=$(srcinfo_pkgbase) || return
+
+ # patch for cross-compiling
+ cp PKGBUILD{,.old}
+ patch -Np1 -i "$SRCDIR"/patches/"$pkgbase".patch || return
+ cp PKGBUILD{,.in}
+
+ # substitute common variables
+ sed -i \
+ "s#@CARCH@#$CARCH#g; \
+ s#@CHOST@#$CHOST#g; \
+ s#@GCC_MARCH@#$GCC_MARCH#g; \
+ s#@GCC_MABI@#$GCC_MABI#g; \
+ s#@CARCH32@#${CARCH32:-}#g; \
+ s#@CHOST32@#${CHOST32:-}#g; \
+ s#@GCC32_MARCH@#${GCC32_MARCH:-}#g; \
+ s#@GCC32_MABI@#${GCC32_MABI:-}#g; \
+ s#@BUILDHOST@#$BUILDHOST#g; \
+ s#@SYSROOT@#$SYSROOT#g; \
+ s#@LINUX_ARCH@#$LINUX_ARCH#g; \
+ s#@MULTILIB@#${MULTILIB:-disable}#g;" \
+ PKGBUILD
+
+ # enable the target CARCH in arch array
+ sed -i "s/arch=([^)]*/& $CARCH/" PKGBUILD
+
+ # force regeneration of .SRCINFO
+ rm .SRCINFO
+
+ # check built dependencies
+ local dep
+ for dep in $(srcinfo_builddeps -nm); do
+ deptree_check_depends "$pkgname" "$dep" || return
+ done
+ for dep in $(srcinfo_rundeps "$pkgname"); do
+ deptree_check_depends "$pkgname" "$dep" || return
+ done
+
+ # postpone build if necessary
+ [ "x$(deptree_next)" != "x$pkgname" ] && return
+
+ # don't rebuild if already exists
+ check_pkgfile "$PKGDEST" "$pkgname" && return
+
+ # build the package
+ sudo -u "$SUDO_USER" \
+ "$BUILDDIR"/makepkg-"$CARCH".sh -fLC --config "$BUILDDIR"/makepkg-"$CARCH".conf \
+ --nocheck --nodeps --nobuild --noconfirm || return
+
+ if [ "x${REGEN_CONFIG_FRAGMENTS:-no}" == "xyes" ]; then
+ url="https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain"
+ find src -iname config.sub -print -exec curl "$url;f=config.sub;hb=HEAD" -o {} \; || return
+ fi
- # update pacman cache
- rm -rf "$_chrootdir"/var/cache/pacman/pkg/*
- rm -rf "$_pkgdest"/cross.{db,files}*
- repo-add -q -R "$_pkgdest"/{cross.db.tar.gz,*.pkg.tar.xz}
+ sudo -u "$SUDO_USER" \
+ "$BUILDDIR"/makepkg-"$CARCH".sh -efL --config "$BUILDDIR"/makepkg-"$CARCH".conf \
+ --nocheck --nodeps --noprepare --noconfirm || return
+}
+
+build_pkg() {
+ local pkgname="$1"
+ pkgarch=$(pkgarch "$pkgname") || return
+
+ if [ "x$pkgarch" == "xany" ]; then
+ build_pkg_any "$1" || return
+ elif [ "x$pkgname" == "xca-certificates-mozilla" ]; then
+ build_pkg_ca-certificates-mozilla "$1" || return
+ else
+ build_stage2_pkg "$1" || return
fi
- # install in chroot
- set +o pipefail
- yes | pacman --noscriptlet --force --config "$_chrootdir"/etc/pacman.conf \
- -r "$_chrootdir" -Syydd $_pkgname
- set -o pipefail
+ # postpone on unmet dependencies
+ [ "x$(deptree_next)" != "x$pkgname" ] && return
+
+ # update pacman cache
+ rm -rf "$CHROOTDIR"/var/cache/pacman/pkg/*
+ rm -rf "$PKGDEST"/cross.{db,files}*
+ repo-add -q -R "$PKGDEST"/{cross.db.tar.gz,*.pkg.tar.xz}
+}
+
+stage2() {
+ msg -n "Entering Stage 2"
+
+ local sysroot
+ sysroot="$("$CHOST"-gcc --print-sysroot)"
+
+ export BUILDDIR="$TOPBUILDDIR"/stage2
+ export SRCDIR="$TOPSRCDIR"/stage2
+ export CHROOTDIR="$BUILDDIR"/$CARCH-root
+ export MAKEPKGDIR="$BUILDDIR"/$CARCH-makepkg
+ export DEPTREE="$BUILDDIR"/DEPTREE
+ export SYSROOT="$sysroot"
+ export BUILDHOST="x86_64-pc-linux-gnu"
+ export PKGDEST="$BUILDDIR"/packages/$CARCH
+ export LOGDEST="$BUILDDIR"/makepkglogs
+
+ mkdir -p "$PKGDEST" "$LOGDEST"
+ chown "$SUDO_USER" "$PKGDEST" "$LOGDEST"
+
+ binfmt_disable
+
+ prepare_makepkg || die -e "$ERROR_BUILDFAIL" "failed to prepare $CARCH makepkg"
+ prepare_chroot || die -e "$ERROR_BUILDFAIL" "failed to prepare $CARCH chroot"
+ prepare_deptree base-devel || die -e "$ERROR_BUILDFAIL" "failed to prepare DEPTREE"
+
+ echo "remaining pkges: $(wc -l < "$DEPTREE") / $(wc -l < "$DEPTREE".FULL)"
+ [ -s "$DEPTREE" ] || return 0
+
+ # pull in various tools required to run the scripts or build the packages
+ check_exe -r arch-meson asp awk bsdtar git gperf help2man pacman sed svn tar tclsh
+
+ while [ -s "$DEPTREE" ]; do
+ local pkgname pkgarch
+ pkgname=$(deptree_next) \
+ || die -e "$ERROR_MISSING" "could not resolve dependencies"
+
+ msg "makepkg: $pkgname"
+ msg " remaining packages: $(wc -l < "$DEPTREE")"
+
+ prepare_makepkgdir "$MAKEPKGDIR/$pkgname" || return
+
+ build_pkg "$pkgname" 2>&1 | tee .MAKEPKGLOG
+ if [ "${PIPESTATUS[0]}" -ne 0 ]; then
+ notify -c error "$pkgname" -h string:document:.MAKEPKGLOG
+ [ "x$KEEP_GOING" == "xyes" ] || return
+ sed -i "s/^$pkgname : \\[/& FIXME/" "$DEPTREE"
+ fi
+
+ popd >/dev/null || return
+
+ [ "x$(deptree_next)" != "x$pkgname" ] && continue
- # remove pkg from deptree
- sed -i "/^$_pkgname :/d; s/ / /g; s/ $_pkgname / /g; s/ */ /g" "$_deptree"
+ # install in chroot
+ yes | pacman --noscriptlet --force --config "$CHROOTDIR"/etc/pacman.conf \
+ -r "$CHROOTDIR" -Syydd "$pkgname" || die -e "$ERROR_BUILDFAIL" "failed to install pkg"
- full=$(cat "$_deptree".FULL | wc -l)
- curr=$(expr $full - $(cat "$_deptree" | wc -l))
- notify -c success -u low "*$curr/$full* $_pkgname"
-done
+ deptree_remove "$pkgname"
-echo "all packages built."
+ full=$(wc -l < "$DEPTREE".FULL)
+ curr=$((full - $(wc -l < "$DEPTREE")))
+ notify -c success -u low "*$curr/$full* $pkgname"
+ done
-# unmount sysroot
-umount "$_sysroot"/usr
+ umount_chrootdir
+}
diff --git a/src/stage3/libretools.patch b/src/stage3/libretools.patch
deleted file mode 100644
index ac8cd4e..0000000
--- a/src/stage3/libretools.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-diff -rupN a/usr/bin/librechroot b/usr/bin/librechroot
---- a/usr/bin/librechroot 2018-01-03 23:05:52.000000000 +0100
-+++ b/usr/bin/librechroot 2018-02-26 09:14:42.813251799 +0100
-@@ -69,32 +69,36 @@ hack_arch_nspawn_flags() {
- CARCH="$(uname -m)"
- fi
-
-- if [[ "$CARCH" == armv7h ]] && ! setarch armv7l /bin/true 2>/dev/null; then
-- # We're running an ARM chroot on a non-ARM processor
-+ case $CARCH in
-+ armv7h) _setarch=armv7l ; _qemuarch=arm ;;
-+ *) _setarch=$CARCH ; _qemuarch=$CARCH ;;
-+ esac
-+ if ! setarch $_setarch /bin/true 2>/dev/null; then
-+ # We're running a cross-arch chroot
-
- # Make sure that qemu-static is set up with binfmt_misc
- if [[ -z $(grep -l -xF \
-- -e 'interpreter /usr/bin/qemu-arm-static' \
-- -r -- /proc/sys/fs/binfmt_misc 2>/dev/null \
-- | xargs -r grep -xF 'enabled') ]]
-+ -e "interpreter /usr/bin/qemu-$_qemuarch-static" \
-+ -r -- /proc/sys/fs/binfmt_misc 2>/dev/null \
-+ | xargs -r grep -xF 'enabled') ]]
- then
-- error 'Cannot cross-compile for ARM on x86'
-- plain 'This requires a binfmt_misc entry for qemu-arm-static.'
-+ error "Cannot cross-compile for $CARCH on $(uname -m)"
-+ plain "This requires a binfmt_misc entry for qemu-$_qemuarch-static."
- prose 'Such a binfmt_misc entry is provided by the %s
-- package. If you have it installed, but still see
-- this message, you may need to restart %s.' \
-+ package. If you have it installed, but still see
-+ this message, you may need to restart %s.' \
- qemu-user-static-binfmt systemd-binfmt.service
- return $EXIT_NOTINSTALLED
- fi
-
- # Let qemu/binfmt_misc do its thing
-- arch_nspawn_flags+=(-f /usr/bin/qemu-arm-static -s)
-+ arch_nspawn_flags+=(-f /usr/bin/qemu-$_qemuarch-static -s)
-
- # The -any packages are built separately for ARM from
- # x86, so if we use the same CacheDir as the x86 host,
- # then there will be PGP errors.
-- mkdir -p /var/cache/pacman/pkg-arm
-- arch_nspawn_flags+=(-c /var/cache/pacman/pkg-arm)
-+ mkdir -p /var/cache/pacman/pkg-$CARCH
-+ arch_nspawn_flags+=(-c /var/cache/pacman/pkg-$CARCH)
- fi
- }
-