update Dockerfile: ubuntu 18.04-->20.04, QEMU-5.0-->7.0

This commit is contained in:
Yu Chen 2022-07-18 11:23:20 +08:00
parent a03f73d2dd
commit 3cbaae1b29

View File

@ -1,40 +1,85 @@
FROM ubuntu:18.04 # syntax=docker/dockerfile:1
LABEL maintainer="dinghao188" \ # This Dockerfile is adapted from https://github.com/LearningOS/rCore-Tutorial-v3/blob/main/Dockerfile
version="1.1" \ # with the following major updates:
description="ubuntu 18.04 with tools for tsinghua's rCore-Tutorial-V3" # - ubuntu 18.04 -> 20.04
# - qemu 5.0.0 -> 7.0.0
# - Extensive comments linking to relevant documentation
FROM ubuntu:20.04
#install some deps ARG QEMU_VERSION=7.0.0
RUN set -x \ ARG HOME=/root
&& apt-get update \
&& apt-get install -y curl wget autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
gawk build-essential bison flex texinfo gperf libtool patchutils bc xz-utils \
zlib1g-dev libexpat-dev pkg-config libglib2.0-dev libpixman-1-dev git tmux python3
#install rust and qemu # 0. Install general tools
RUN set -x; \ ARG DEBIAN_FRONTEND=noninteractive
RUSTUP='/root/rustup.sh' \ RUN apt-get update && \
&& cd $HOME \ apt-get install -y \
#install rust curl \
&& curl https://sh.rustup.rs -sSf > $RUSTUP && chmod +x $RUSTUP \ git \
&& $RUSTUP -y --default-toolchain nightly --profile minimal \ python3 \
wget
#compile qemu # 1. Set up QEMU RISC-V
&& wget https://ftp.osuosl.org/pub/blfs/conglomeration/qemu/qemu-5.0.0.tar.xz \ # - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
&& tar xvJf qemu-5.0.0.tar.xz \ # - https://www.qemu.org/download/
&& cd qemu-5.0.0 \ # - https://wiki.qemu.org/Documentation/Platforms/RISCV
&& ./configure --target-list=riscv64-softmmu,riscv64-linux-user \ # - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html
&& make -j$(nproc) install \
&& cd $HOME && rm -rf qemu-5.0.0 qemu-5.0.0.tar.xz
#for chinese network # 1.1. Download source
RUN set -x; \ WORKDIR ${HOME}
APT_CONF='/etc/apt/sources.list'; \ RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
CARGO_CONF='/root/.cargo/config'; \ tar xvJf qemu-${QEMU_VERSION}.tar.xz
BASHRC='/root/.bashrc' \
&& echo 'export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static' >> $BASHRC \ # 1.2. Install dependencies
&& echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup' >> $BASHRC \ # - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
&& touch $CARGO_CONF \ RUN apt-get install -y \
&& echo '[source.crates-io]' > $CARGO_CONF \ autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
&& echo "replace-with = 'ustc'" >> $CARGO_CONF \ gawk build-essential bison flex texinfo gperf libtool patchutils bc \
&& echo '[source.ustc]' >> $CARGO_CONF \ zlib1g-dev libexpat-dev git \
&& echo 'registry = "git://mirrors.ustc.edu.cn/crates.io-index"' >> $CARGO_CONF ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev
# 1.3. Build and install from source
WORKDIR ${HOME}/qemu-${QEMU_VERSION}
RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
make -j$(nproc) && \
make install
# 1.4. Clean up
WORKDIR ${HOME}
RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
# 1.5. Sanity checking
RUN qemu-system-riscv64 --version && \
qemu-riscv64 --version
# 2. Set up Rust
# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
# - https://www.rust-lang.org/tools/install
# - https://github.com/rust-lang/docker-rust/blob/master/Dockerfile-debian.template
# 2.1. Install
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=nightly
RUN set -eux; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME;
# 2.2. Sanity checking
RUN rustup --version && \
cargo --version && \
rustc --version
# 3. Build env for labs
# See os1/Makefile `env:` for example.
# This avoids having to wait for these steps each time using a new container.
RUN rustup target add riscv64gc-unknown-none-elf && \
cargo install cargo-binutils --vers ~0.2 && \
rustup component add rust-src && \
rustup component add llvm-tools-preview
# Ready to go
WORKDIR ${HOME}