-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dockerfile.riscv64: Refactoring with shell scripts
To avoid potential space limitation on the git runners due to running too many separate RUN commands. Signed-off-by: Tan En De <[email protected]>
- Loading branch information
Showing
4 changed files
with
112 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
export ARCH=riscv | ||
export CROSS_COMPILE=riscv64-linux-gnu- | ||
|
||
#-------------------- | ||
# Version tags | ||
#-------------------- | ||
QEMU_TAG=v8.1.2 | ||
OPENSBI_TAG=v1.3.1 | ||
LINUX_TAG=v6.5 | ||
|
||
#-------------------- | ||
# Directory paths | ||
#-------------------- | ||
## Directory path where git clones repos to | ||
DIR_PREFIX=/opt/build | ||
mkdir -p $DIR_PREFIX | ||
## Build output path (to store output of make) | ||
OUTPUT_DIR=/opt/bin | ||
mkdir -p $OUTPUT_DIR | ||
## Build install path (to store output of make install) | ||
INSTALL_DIR=/opt/install | ||
|
||
## Repo paths | ||
QEMU_DIR=$DIR_PREFIX/qemu | ||
OPENSBI_DIR=$DIR_PREFIX/opensbi | ||
LINUX_DIR=$DIR_PREFIX/linux | ||
|
||
#-------------------- | ||
# Prerequisites | ||
#-------------------- | ||
PACKAGE_LIST="git python3 python3-pip build-essential pkg-config libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build gcc-riscv64-linux-gnu libssl-dev wget curl bc flex bison libslirp-dev" | ||
apt-get update | ||
apt-get -y install $PACKAGE_LIST | ||
|
||
cd $DIR_PREFIX | ||
git clone --depth 1 --branch $QEMU_TAG https://gitlab.com/qemu-project/qemu.git | ||
git clone --depth 1 --branch $OPENSBI_TAG https://github.com/riscv-software-src/opensbi.git | ||
git clone --depth 1 --branch $LINUX_TAG https://github.com/torvalds/linux.git | ||
|
||
#-------------------- | ||
# QEMU | ||
#-------------------- | ||
cd $QEMU_DIR | ||
./configure --target-list="riscv64-softmmu" --enable-slirp --prefix=$INSTALL_DIR/usr/local && \ | ||
make -j$(nproc) && \ | ||
make install | ||
|
||
#-------------------- | ||
# OpenSBI | ||
#-------------------- | ||
cd $OPENSBI_DIR | ||
make -j$(nproc) PLATFORM=generic | ||
mv $OPENSBI_DIR/build/platform/generic/firmware/fw_jump.elf $OUTPUT_DIR | ||
|
||
#-------------------- | ||
# Linux | ||
#-------------------- | ||
cd $LINUX_DIR | ||
sed -i "s|^CONFIG_KVM=.*|CONFIG_KVM=y|g" $LINUX_DIR/arch/riscv/configs/defconfig | ||
make defconfig && make -j$(nproc) | ||
mv $LINUX_DIR/arch/riscv/boot/Image $OUTPUT_DIR | ||
|
||
#-------------------- | ||
# Cleanup | ||
#-------------------- | ||
rm -rf $QEMU_DIR | ||
rm -rf $OPENSBI_DIR | ||
rm -rf $LINUX_DIR | ||
apt-get -y remove $PACKAGE_LIST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
#-------------------- | ||
# Version tag | ||
#-------------------- | ||
RUST_TOOLCHAIN="1.72.0" | ||
export PATH="$PATH:/root/.cargo/bin" | ||
|
||
#-------------------- | ||
# Prerequisites | ||
#-------------------- | ||
apt-get update | ||
apt-get -y install curl libglib2.0-dev libfdt-dev libpixman-1-dev libslirp-dev gcc gcc-riscv64-linux-gnu | ||
|
||
curl https://sh.rustup.rs -sSf | sh -s -- \ | ||
-y --default-toolchain "$RUST_TOOLCHAIN" \ | ||
--profile minimal --component clippy,rustfmt | ||
rustup target add riscv64gc-unknown-linux-gnu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
apt-get update | ||
apt-get -y upgrade | ||
apt-get -y install systemd init ifupdown busybox udev |