[wiki] Update toolchain description
MODIFY
.gitignore
.gitignore
@@ -70,3 +70,6 @@ sysroot
# pcap files
*.pcap
+
+# python env
+mimiker-env/

MODIFY
Dockerfile
Dockerfile
@@ -2,28 +2,20 @@ FROM debian:bullseye-backports
WORKDIR /root
-RUN apt-get -q update && apt-get upgrade -y
-RUN apt-get install -y --no-install-recommends -t bullseye-backports \
- git make ccache cpio curl gnupg universal-ctags cscope socat patch \
- gperf quilt bmake byacc python3-pip device-tree-compiler tmux \
- libmpfr6 libfdt1 libpython3.9 libsdl2-2.0-0 libglib2.0-0 libpixman-1-0
-RUN apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key
-RUN echo "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-14 main" > \
- /etc/apt/sources.list.d/llvm-14.list && apt-get update
-RUN apt-get install -y --no-install-recommends -t bullseye-backports \
+COPY packages.txt .
+RUN apt-get -q update && apt-get upgrade -y && \
+ apt-get install -y --no-install-recommends -t bullseye-backports $(cat packages.txt) && \
+ apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key && \
+ echo "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-14 main" > \
+ /etc/apt/sources.list.d/llvm-14.list && apt-get update && \
+ apt-get install -y --no-install-recommends -t bullseye-backports \
clang-14 clang-format-14 llvm-14 lld-14
-# patch & quilt required by lua and programs in contrib/
-# gperf required by libterminfo
-# socat & tmux required by launch
+
COPY requirements.txt .
-RUN pip3 install setuptools wheel && pip3 install -r requirements.txt
-RUN curl -O https://mimiker.ii.uni.wroc.pl/download/mipsel-mimiker-elf_latest_amd64.deb && \
- dpkg -i mipsel-mimiker-elf_latest_amd64.deb && rm -f mipsel-mimiker-elf_latest_amd64.deb
-RUN curl -O https://mimiker.ii.uni.wroc.pl/download/aarch64-mimiker-elf_latest_amd64.deb && \
- dpkg -i aarch64-mimiker-elf_latest_amd64.deb && rm -f aarch64-mimiker-elf_latest_amd64.deb
-RUN curl -O https://mimiker.ii.uni.wroc.pl/download/riscv32-mimiker-elf_latest_amd64.deb && \
- dpkg -i riscv32-mimiker-elf_latest_amd64.deb && rm -f riscv32-mimiker-elf_latest_amd64.deb
-RUN curl -O https://mimiker.ii.uni.wroc.pl/download/riscv64-mimiker-elf_latest_amd64.deb && \
- dpkg -i riscv64-mimiker-elf_latest_amd64.deb && rm -f riscv64-mimiker-elf_latest_amd64.deb
-RUN curl -O https://mimiker.ii.uni.wroc.pl/download/qemu-mimiker_latest_amd64.deb && \
- dpkg -i qemu-mimiker_latest_amd64.deb && rm -f qemu-mimiker_latest_amd64.deb
+RUN pip3 install setuptools wheel && pip3 install -r requirements.txt && \
+ curl -O https://mimiker.ii.uni.wroc.pl/download/mipsel-mimiker-elf_latest_amd64.deb && \
+ curl -O https://mimiker.ii.uni.wroc.pl/download/aarch64-mimiker-elf_latest_amd64.deb && \
+ curl -O https://mimiker.ii.uni.wroc.pl/download/riscv32-mimiker-elf_latest_amd64.deb && \
+ curl -O https://mimiker.ii.uni.wroc.pl/download/riscv64-mimiker-elf_latest_amd64.deb && \
+ curl -O https://mimiker.ii.uni.wroc.pl/download/qemu-mimiker_latest_amd64.deb && \
+ apt-get install -y ./*.deb && rm -f *.deb

ADD
install-tools.sh
+#!/bin/bash
+nocolor='\033[0m'
+col_red='\033[0;31m'
+col_orange='\033[0;33m'
+col_blue='\033[0;34m'
+
+function fatal() {
+ echo -e "${col_red}ERROR${nocolor}: "$1
+ exit 1
+}
+
+function warn() {
+ echo -e "${col_orange}WARN${nocolor}: "$1
+}
+
+function info() {
+ echo -e "${col_blue}INFO${nocolor}: "$1
+}
+
+function ask() {
+ read -p "Do you want to proceed? (Y/n) " choice
+ case $choice in
+ [yY] ) return;;
+ [nN] ) echo exiting...;
+ exit 1;;
+ * ) echo invalid response. Assuming NO.;
+ exit 1;;
+ esac
+}
+
+# all checks before script is run
+[ "`id -u`" -eq 0 ] && fatal "You are running as root... it is not supported"
+[ -f /etc/apt/sources.list.d/llvm.list ] && warn 'You already have llvm sources.list. The script will override it.' && ask
+[ -f requirements.txt ] || fatal 'Python requirements not found. Are you in the Mimiker directory?'
+[ -f /usr/bin/apt ] || fatal '/usr/bin/apt is missing; is your distro debian based?'
+[ -f /usr/bin/sudo ] || fatal 'sudo is missing; (run `su -c "apt install sudo"`)'
+
+DEBS=packages.txt
+
+info "Install required packages"
+info "Upgrade privileges to root user"
+info "Install packages from base repository"
+
+sudo -u root sh -c "apt-get update -q && apt install $(< ${DEBS})"
+
+info "Drop privileges to $USER"
+
+read -p "Do you want to create python virtual env for Mimiker? (Y/n) " choice
+case $choice in
+ [yY] )
+ python3 -m venv mimiker-env
+ source mimiker-env/bin/activate
+ info "Python venv 'mimiker-env' created"
+ ;;
+esac
+
+info "Install python dependencies"
+pip3 install -r requirements.txt
+
+CODENAME=$(lsb_release -sc 2>/dev/null)
+
+if ! [ "$CODENAME" == "bullseye" ]; then
+ fatal "Your distribution '$CODENAME' is not supported"
+fi
+
+LLVM_VERSION=14
+DEBS_LLVM="clang-${LLVM_VERSION} clang-format-${LLVM_VERSION} llvm-${LLVM_VERSION} lld-${LLVM_VERSION}"
+
+info "Prepare sources.list for llvm && install llvm-${LLVM_VERSION}"
+LLVM_REPO="deb http://apt.llvm.org/${CODENAME}/ llvm-toolchain-${CODENAME}-${LLVM_VERSION} main"
+sudo -u root sh -c "apt-key adv --fetch-keys https://apt.llvm.org/llvm-snapshot.gpg.key && echo ${LLVM_REPO} > /etc/apt/sources.list.d/llvm.list && apt-get update -q && apt-get install ${DEBS_LLVM}"
+
+WORKDIR=$(mktemp -d)
+info "${WORKDIR} created"
+info "Download prebuild toolchain"
+
+curl -o $WORKDIR/mipsel-mimiker-elf_latest_amd64.deb https://mimiker.ii.uni.wroc.pl/download/mipsel-mimiker-elf_latest_amd64.deb
+curl -o $WORKDIR/aarch64-mimiker-elf_latest_amd64.deb https://mimiker.ii.uni.wroc.pl/download/aarch64-mimiker-elf_latest_amd64.deb
+curl -o $WORKDIR/riscv32-mimiker-elf_latest_amd64.deb https://mimiker.ii.uni.wroc.pl/download/riscv32-mimiker-elf_latest_amd64.deb
+curl -o $WORKDIR/riscv64-mimiker-elf_latest_amd64.deb https://mimiker.ii.uni.wroc.pl/download/riscv64-mimiker-elf_latest_amd64.deb
+curl -o $WORKDIR/qemu-mimiker_latest_amd64.deb https://mimiker.ii.uni.wroc.pl/download/qemu-mimiker_latest_amd64.deb
+
+info "Install toolchain"
+sudo -u root sh -c "apt-get install $WORKDIR/*.deb"
+
+info "Cleanup $WORKDIR"
+rm -r $WORKDIR
+
+exit 0

ADD
packages.txt
+git make ccache cpio curl gnupg universal-ctags cscope socat patch gperf quilt byacc python3 python3-pip python3-virtualenv device-tree-compiler tmux lsb-release

MODIFY
wiki/docs/building.md
wiki/docs/building.md
@@ -22,4 +22,7 @@ they are run, add `VERBOSE=1` to the command line.
**Important!** It's recommended to issue `make distclean` command after each
modification to `config.mk` file.
+**Important!** Before building Mimker for different board you have to run
+`make distclean` with `BOARD` argument set to previous board.
+
[1]: toolchain.md

[wiki] Update toolchain description (#1343)