blob: 354917ba9ff4c766ca36d351dd70df67bc997e7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/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 $CARCH librechroot"
# create directories
mkdir -p "$_pkgdest" "$_logdest"
# initialize [native] repo
echo -n "checking for $CARCH [native] repo ... "
[ -e "$_pkgdest"/native.db ] && _have_native=yes || _have_native=no
echo $_have_native
if [ "x$_have_native" == "xno" ]; then
tar -czf "$_pkgdest"/native.db.tar.gz -T /dev/null
tar -czf "$_pkgdest"/native.files.tar.gz -T /dev/null
ln -s native.db.tar.gz "$_pkgdest"/native.db
ln -s native.files.tar.gz "$_pkgdest"/native.files
fi
# create configurations
mkdir -p "$_builddir"/config
cat > "$_builddir"/config/pacman.conf << EOF
[options]
Architecture = $CARCH
[native]
Server = file://$topbuilddir/stage3/packages/\$arch
[cross]
Server = file://$topbuilddir/stage2/packages/\$arch
EOF
cat "$_srcdir"/makepkg.conf.in > "$_builddir"/config/makepkg.conf
cat >> "$_builddir"/config/makepkg.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"
MAKEFLAGS="-j$(($(nproc) + 1))"
EOF
# initialize the chroot using the cross-compiled packages
rm -rf /var/cache/pacman/pkg-$CARCH/*
librechroot \
-n "$CHOST-stage3" \
-C "$_builddir"/config/pacman.conf \
-M "$_builddir"/config/makepkg.conf \
make
set +o pipefail
export _chrootdir="$(librechroot -n "$CHOST-stage3" 2>&1 | grep copydir.*: | awk '{print $3}')"
set -o pipefail
for repo in native cross; do
mkdir -p "$_chrootdir"/$repo/$CARCH
if mount | grep -q "$_chrootdir"/$repo/$CARCH; then umount "$_chrootdir"/$repo/$CARCH; fi
done
mount -o bind "$_pkgdest" "$_chrootdir"/native/$CARCH
mount -o bind "${_pkgdest//stage3/stage2}" "$_chrootdir"/cross/$CARCH
cat > "$_builddir"/config/pacman.conf << EOF
[options]
Architecture = $CARCH
[native]
Server = file:///native/\$arch
[cross]
Server = file:///cross/\$arch
EOF
librechroot \
-n "$CHOST-stage3" \
-C "$_builddir"/config/pacman.conf \
-M "$_builddir"/config/makepkg.conf \
update
# produce a patched libremakepkg to update config.sub/config.guess where needed
cat $(which libremakepkg) > "$_builddir"/libremakepkg-$CARCH.sh
sed -i '/Boring\/mundane/i \
update_config_fragments() {\
local url="https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain"\
find $1/build -iname config.sub -print -exec curl "$url;f=config.sub;hb=HEAD" -o {} \\;\
find $1/build -iname config.guess -print -exec curl "$url;f=config.guess;hb=HEAD" -o {} \\;\
}\
hook_pre_build+=(update_config_fragments)' "$_builddir"/libremakepkg-$CARCH.sh
|