#! /bin/bash

set -e

apt-get update

apt-get install -y \
autoconf \
automake \
autotools-dev \
curl \
libmpc-dev \
libmpfr-dev \
libgmp-dev gawk \
build-essential \
bison \
flex \
texinfo \
gperf \
libtool \
patchutils \
bc \
zlib1g-dev \
libexpat-dev \
realpath \
git 

curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.10/gosu-$(dpkg --print-architecture)"
chmod +x /usr/local/bin/gosu

groupadd -o -g $2 egroup
useradd -o -u $1 -g $2 euser

/usr/local/bin/gosu $1:$2 ./build-riscv-gnu-toolchain work out


