Skip to content

Commit 4e0223b

Browse files
committed
beware of the monster - this commit unifies the separate porting efforts into one source tree
1 parent c9d45d2 commit 4e0223b

File tree

337 files changed

+2975
-1191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+2975
-1191
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
# build dirs
33
build/
4+
sources/
45

56
# built packages and signatures
67
*.pkg.tar.xz

README

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,28 @@ parabola-riscv64-bootstrap
99
---------------
1010

1111
This project is an attempt to bootstrap a self-contained parabola
12-
GNU/Linux-libre system for the riscv64 architecture. The scripts are created
13-
with the goal to be as architectur agnostic as possible, to make future porting
14-
efforts easier.
12+
GNU/Linux-libre system for the following architectures:
13+
14+
- riscv64 (HiFive)
15+
- riscv32 (PULP)
16+
- sparc (OpenSparc)
17+
- powerpc64le (TalosII)
18+
19+
The scripts are created with the goal to be as architecture agnostic as
20+
possible, to make future porting efforts easier.
1521

1622
The build process is split into four stages, the rationale of which is outlined
1723
in section 2 below.
1824

1925
To initiate a complete build of all stages, run:
20-
$> sudo ./create
26+
$> sudo ./create [CARCH]
2127

2228
The builds can be configured to keep going if the build of a single package
2329
fails, by creating the file `build/.KEEP_GOING`. Otherwise, the build will stop
2430
once an error is encountered. This is useful for getting as much work done as
2531
possible unattended, but will make debugging harder in the later stages,
26-
because temporary build fragments and filesystem trees will be overwritten by
27-
the next package.
32+
because temporary build fragments and filesystem trees in the build chroots
33+
will be overwritten by the next package.
2834

2935
The complete console output of a package build process can be found in the
3036
corresponding .MAKEPKGLOG file in the build directory of that package.
@@ -62,9 +68,9 @@ can email me at <[email protected]>, or find me as <oaken-source> in
6268
1.3. Current state of the project
6369
---------------------------------
6470

65-
All four stages are complete and this repository is now closed. A pointer where
66-
to find future development efforts for the parabola RISC-V port will be added
67-
here in due time.
71+
All four stages of the riscv64 bootstrap are complete, and efforts to add
72+
additional architectures has begun. A pointer where to find future development
73+
efforts for the parabola RISC-V port will be added here in due time.
6874

6975
2. Build Stages
7076
---------------

config/config.powerpc64le.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
2020
##############################################################################
2121

22+
# this configuration targets the TalosII systems
23+
2224
# the target host triplet
2325
export CARCH=powerpc64le
2426
export CHOST="$CARCH-unknown-linux-gnu"
@@ -39,9 +41,9 @@ export GCC_CONFIG_FLAGS=("--with-long-double-128" "--enable-vsx")
3941
#export PLATFORM32_CFLAGS=()
4042

4143
# configure build directories
42-
export TOPBUILDDIR="$startdir/build/$CHOST"
44+
export TOPBUILDDIR="$startdir/build/$CARCH"
4345
export TOPSRCDIR="$startdir"/src
44-
export SRCDEST="$startdir"/build/sources
46+
export SRCDEST="$startdir"/sources
4547

4648
# build options
4749
export REGEN_CONFIG_FRAGMENTS=yes

config/config.riscv32.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
##############################################################################
3+
# parabola-riscv64-bootstrap #
4+
# #
5+
# Copyright (C) 2018 Andreas Grapentin #
6+
# #
7+
# This program is free software: you can redistribute it and/or modify #
8+
# it under the terms of the GNU General Public License as published by #
9+
# the Free Software Foundation, either version 3 of the License, or #
10+
# (at your option) any later version. #
11+
# #
12+
# This program is distributed in the hope that it will be useful, #
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15+
# GNU General Public License for more details. #
16+
# #
17+
# You should have received a copy of the GNU General Public License #
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19+
##############################################################################
20+
21+
# this configuration targets the PULP platform
22+
23+
# the target host triplet
24+
export CARCH=riscv32
25+
export CHOST="$CARCH-unknown-linux-gnu"
26+
27+
# the equivalent architecture name used by the linux kernel
28+
export LINUX_ARCH=riscv
29+
30+
# flags added to the default CFLAGS in makepkg.conf
31+
export PLATFORM_CFLAGS=("-march=rv32g" "-mabi=ilp32d")
32+
33+
# flags added to the gcc PKGBUILD configure call
34+
export GCC_CONFIG_FLAGS=("--with-arch=rv32g" "--with-abi=ilp32d")
35+
36+
# multilib configuration, uncomment if applicable
37+
#export MULTILIB=enable
38+
#export CARCH32=""
39+
#export CHOST32=""
40+
#export PLATFORM32_CFLAGS=()
41+
42+
# configure build directories
43+
export TOPBUILDDIR="$startdir/build/$CARCH"
44+
export SRCDEST="$startdir"/sources
45+
46+
# regenerate config.sub / config.guess during builds
47+
export REGEN_CONFIG_FRAGMENTS=yes
48+

config/config.riscv64.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
1919
##############################################################################
2020

21+
# this configuration targets the HiFive boards
22+
2123
# the target host triplet
2224
export CARCH=riscv64
2325
export CHOST="$CARCH-unknown-linux-gnu"
@@ -38,9 +40,9 @@ export GCC_CONFIG_FLAGS=("--with-arch=rv64gc" "--with-abi=lp64d")
3840
#export PLATFORM32_CFLAGS=()
3941

4042
# configure build directories
41-
export TOPBUILDDIR="$startdir/build/$CHOST"
43+
export TOPBUILDDIR="$startdir/build/$CARCH"
4244
export TOPSRCDIR="$startdir"/src
43-
export SRCDEST="$startdir"/build/sources
45+
export SRCDEST="$startdir"/sources
4446

4547
# build options
4648
export REGEN_CONFIG_FRAGMENTS=yes

config/config.sparc.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
##############################################################################
3+
# parabola-riscv64-bootstrap #
4+
# #
5+
# Copyright (C) 2018 Andreas Grapentin #
6+
# #
7+
# This program is free software: you can redistribute it and/or modify #
8+
# it under the terms of the GNU General Public License as published by #
9+
# the Free Software Foundation, either version 3 of the License, or #
10+
# (at your option) any later version. #
11+
# #
12+
# This program is distributed in the hope that it will be useful, #
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15+
# GNU General Public License for more details. #
16+
# #
17+
# You should have received a copy of the GNU General Public License #
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19+
##############################################################################
20+
21+
# this configuration targets the OpenSPARC platform
22+
23+
# the target host triplet
24+
export CARCH=sparc
25+
export CHOST="$CARCH-unknown-linux-gnu"
26+
27+
# the equivalent architecture name used by the linux kernel
28+
export LINUX_ARCH=sparc
29+
30+
# flags added to the default CFLAGS in makepkg.conf
31+
export PLATFORM_CFLAGS=("-mcpu=v9")
32+
33+
# flags added to the gcc PKGBUILD configure call
34+
export GCC_CONFIG_FLAGS=("--with-cpu=v9")
35+
36+
# multilib configuration, uncomment if applicable
37+
#export MULTILIB=enable
38+
#export CARCH32=""
39+
#export CHOST32=""
40+
#export PLATFORM32_CFLAGS=()
41+
42+
# configure build directories
43+
export TOPBUILDDIR="$startdir/build/$CARCH"
44+
export SRCDEST="$startdir"/sources
45+
46+
# regenerate config.sub / config.guess during builds
47+
export REGEN_CONFIG_FRAGMENTS=yes
48+

config/config.template.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export GCC_CONFIG_FLAGS=()
3838
#export PLATFORM32_CFLAGS=()
3939

4040
# configure build directories
41-
export TOPBUILDDIR="$startdir/build/$CHOST"
42-
export SRCDEST="$startdir"/build/sources
41+
export TOPBUILDDIR="$startdir/build/$CARCH"
42+
export SRCDEST="$startdir"/sources
4343

4444
# regenerate config.sub / config.guess during builds
4545
export REGEN_CONFIG_FRAGMENTS=yes

create.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ if [ -z "${SUDO_USER:-}" ]; then
3838
fi
3939

4040
# shellcheck source=config/config.template.sh
41-
. "$CONFIGDIR/config.$1.sh" || die -e "$ERROR_INVOCATION" "usage: $0 CARCH (see config/config.*.sh)"
41+
. "$CONFIGDIR/config.$1.sh" || die -e "$ERROR_INVOCATION" \
42+
"usage: $0 CARCH (see config/config.*.sh)"
4243

4344
mkdir -p "$TOPBUILDDIR" "$SRCDEST"
4445
chown "$SUDO_USER" "$TOPBUILDDIR"

src/shared/deptree.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ build_deptree() {
3737
# add the packages listed in the given groups
3838
local g p r
3939
for g in "$@"; do
40-
for p in $(pacman -Sg "$g" | awk '{print $2}'); do
41-
r=$(make_realpkg "$p") || return "$ERROR_MISSING"
42-
deptree_add_entry "$r" "$g"
43-
done
40+
if pacman -Si "$g" &>/dev/null; then
41+
deptree_add_entry "$g" "<immediate>"
42+
else
43+
for p in $(pacman -Sg "$g" | awk '{print $2}'); do
44+
r=$(make_realpkg "$p") || return "$ERROR_MISSING"
45+
deptree_add_entry "$r" "$g"
46+
done
47+
fi
4448
done
4549

4650
return 0
@@ -107,15 +111,15 @@ deptree_check_depend() {
107111
}
108112

109113
deptree_add_entry() {
110-
local r="${2:-<cmdline>}"
114+
local r="${2:-<immediate>}"
111115

112116
if grep -q "^$1 :" "$DEPTREE".FULL; then
113117
# if pkg is in deptree, append requestee to list
114118
sed -i "/#.* $r\\(\$\\|[ ,]\\)/! s/^$1 : \\[.*/&, $r/" "$DEPTREE"*
115119
elif grep -q "^$r :" "$DEPTREE".FULL; then
116120
# elif requestee is in deptree, insert after requestee
117121
sed -i "/^$r :/a $1 : [ ] # $r" "$DEPTREE"*
118-
elif [ "x$r" == "x<cmdline>" ]; then
122+
elif [ "x$r" == "x<immediate>" ]; then
119123
# elif requested directly, add to top of file
120124
sed -i "1i $1 : [ ] # $r" "$DEPTREE"*
121125
else

src/shared/feedback.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ export ERROR_KEYFAIL=5
2727

2828
# messaging functions
2929
notify() {
30-
# useful if running notify_telegram
31-
local recipient=-211578786
3230
if type -p notify-send >/dev/null; then
3331
machinectl -q shell --uid="$SUDO_USER" .host \
34-
"$(which notify-send)" -h string:recipient:$recipient "$@" >/dev/null
32+
"$(which notify-send)" "$@" >/dev/null
3533
fi
3634
}
3735

src/shared/package.sh

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ package_has_patch() {
120120
done
121121
shift $((OPTIND-1))
122122

123-
local pkgbase
123+
local pkgbase pkgname
124124
pkgbase=$(srcinfo_pkgbase) || return
125+
pkgname=$(srcinfo_pkgname) || return
125126

126-
local patch="$SRCDIR/patches/$pkgbase$p".patch
127+
local patch="$SRCDIR/patches/$CARCH/$pkgbase$p.$pkgname".patch
128+
[ -f "$patch" ] || patch="$SRCDIR/patches/$CARCH/$pkgbase$p".patch
129+
[ -f "$patch" ] || patch="$SRCDIR/patches/generic/$pkgbase$p.$pkgname".patch
130+
[ -f "$patch" ] || patch="$SRCDIR/patches/generic/$pkgbase$p".patch
127131
[ -f "$patch" ] || return "$ERROR_MISSING"
128132
}
129133

@@ -138,26 +142,51 @@ package_patch() {
138142
done
139143
shift $((OPTIND-1))
140144

141-
local pkgbase
145+
local pkgbase pkgname
142146
pkgbase=$(srcinfo_pkgbase) || return
147+
pkgname=$(srcinfo_pkgname) || return
143148

144-
local patch="$SRCDIR/patches/$pkgbase$p".patch
145-
local badpatch="$SRCDIR/patches/$pkgname$p".patch
146-
147-
ln -s "$patch" .PATCH
148-
149-
echo -n "checking for $(basename "$patch") ... "
149+
local patch="$SRCDIR/patches/$CARCH/$pkgbase$p.$pkgname".patch
150+
echo -n "checking for $CARCH/$(basename "$patch") ... "
150151
local have_patch=yes
151152
if [ ! -f "$patch" ]; then
152153
have_patch=no
153-
if [ -f "$badpatch" ]; then
154-
have_patch="$(basename "$badpatch") (renaming...)"
155-
mv "$badpatch" "$patch" || return
156-
fi
157154
fi
158155
echo "$have_patch (needed: $r)"
159156

160-
[ "x$r" == "xyes" ] && [ ! -e "$patch" ] && return "$ERROR_MISSING"
157+
if [ "x$have_patch" == "xno" ]; then
158+
patch="$SRCDIR/patches/$CARCH/$pkgbase$p".patch
159+
echo -n "checking for $CARCH/$(basename "$patch") ... "
160+
have_patch=yes
161+
if [ ! -f "$patch" ]; then
162+
have_patch=no
163+
fi
164+
echo "$have_patch (needed: $r)"
165+
fi
166+
167+
if [ "x$have_patch" == "xno" ]; then
168+
patch="$SRCDIR/patches/generic/$pkgbase$p.$pkgname".patch
169+
echo -n "checking for generic/$(basename "$patch") ... "
170+
have_patch=yes
171+
if [ ! -f "$patch" ]; then
172+
have_patch=no
173+
fi
174+
echo "$have_patch (needed: $r)"
175+
fi
176+
177+
if [ "x$have_patch" == "xno" ]; then
178+
patch="$SRCDIR/patches/generic/$pkgbase$p".patch
179+
echo -n "checking for generic/$(basename "$patch") ... "
180+
have_patch=yes
181+
if [ ! -f "$patch" ]; then
182+
have_patch=no
183+
fi
184+
echo "$have_patch (needed: $r)"
185+
fi
186+
187+
ln -s "$patch" .PATCH
188+
189+
[ "x$r" == "xyes" ] && [ "x$have_patch" == "xno" ] && return "$ERROR_MISSING"
161190

162191
cp PKGBUILD{,.orig}
163192
[ ! -e "$patch" ] || patch -Np1 -i "$patch" || return

src/shared/srcinfo.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ srcinfo_pkgbase() {
3434
grep '^pkgbase =' .SRCINFO | awk '{print $3}'
3535
}
3636

37+
srcinfo_pkgname() {
38+
$(basename $(pwd))
39+
}
40+
3741
srcinfo_builddeps() {
3842
local OPTIND o n='check\|' m='make\|'
3943
while getopts "nm" o; do

src/stage1/stage1.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,13 @@ stage1_makepkg() {
5252
for f in "$SRCDIR"/toolchain-pkgbuilds/$1/*.in; do
5353
sed "s#@CHOST@#$CHOST#g; \
5454
s#@CARCH@#$CARCH#g; \
55+
s#@PLATFORM_CFLAGS@#${PLATFORM_CFLAGS[*]}#g; \
5556
s#@LINUX_ARCH@#$LINUX_ARCH#g; \
56-
s#@GCC_MARCH@#${GCC_MARCH:-}#g; \
57-
s#@GCC_MABI@#${GCC_MABI:-}#g; \
57+
s#@GCC_CONFIG_FLAGS@#${GCC_CONFIG_FLAGS[*]}#g; \
5858
s#@MULTILIB@#${MULTILIB:-disable}#g; \
59-
s#@GCC_32_MARCH@#${GCC_32_MARCH:-}#g; \
60-
s#@GCC_32_MABI@#${GCC_32_MABI:-}#g; \
6159
s#@CARCH32@#${CARCH32:-}#g; \
62-
s#@CHOST32@#${CHOST32:-}#g" \
60+
s#@CHOST32@#${CHOST32:-}#g; \
61+
s#@PLATFORM32_CFLAGS@#${PLATFORM32_CFLAGS[*]}#g" \
6362
"$f" > ./"$(basename "${f%.in}")"
6463
done
6564

@@ -118,6 +117,8 @@ EOF
118117
yes | pacman -U "$PKGDEST/$pkgfile"
119118
done
120119

121-
# final sanity check
120+
# final sanity checks
122121
check_cross_toolchain || die -e "$ERROR_MISSING" "toolchain build incomplete"
122+
[ ! -e "/usr/$CHOST/lib64" ] || die \
123+
"toolchain installs libraries in lib64. this WILL cause problems. fix pure64.patch!"
123124
}

src/stage1/toolchain-pkgbuilds/gcc-bootstrap/0001-pthread-reentrant.patch.in

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)