Skip to content

Commit

Permalink
Update to Ubuntu 22.04
Browse files Browse the repository at this point in the history
  • Loading branch information
Menci committed Jul 24, 2022
1 parent f5cb737 commit 047410b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 21 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Sandbox RootFS
This is the sandbox's rootfs used by [lyrio-judge](https://github.com/lyrio-dev/judge). It's based on Ubuntu 20.04 and contains compilers (and interpreters) below:
This is the sandbox's rootfs used by [lyrio-judge](https://github.com/lyrio-dev/judge). It's based on Ubuntu 22.04 and contains compilers (and interpreters) below:

* GCC 10
* Clang 11 (from [LLVM](https://apt.llvm.org/))
* OpenJDK 11
* GCC 12
* Clang 14 (from [LLVM](https://apt.llvm.org/))
* OpenJDK 17
* Kotlin (from [SDKMAN!](https://kotlinlang.org/docs/tutorials/command-line.html))
* Free Pascal 3
* Python 2.7 (from [PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa))
* Python 3.6
* Python 3.9 (from [PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa))
* Python 2.7
* Python 3.6 (with [Pyenv](https://github.com/pyenv/pyenv), built from source)
* Python 3.9
* Python 3.10
* Swift (from [Swift.org](https://swift.org/))
* Rust (from [Rustup](https://rustup.rs/))
* Go (from [PPA](https://launchpad.net/~longsleep/+archive/ubuntu/golang-backports))
* GHC (from [PPA](https://launchpad.net/~hvr/+archive/ubuntu/ghc))
* GHC 9.0.1 (from [PPA](https://launchpad.net/~hvr/+archive/ubuntu/ghc))
* C# (from [Mono](https://www.mono-project.com/download/stable/))
* F# (from [Mono](https://www.mono-project.com/download/stable/))

Expand All @@ -25,7 +26,7 @@ You'll need:

* A Linux box with root privilege
* `arch-chroot` (usually in the package `arch-install-scripts`)
* `debootstrap` (some old version of Debian's `debootstrap` couldn't bootstrap Ubuntu 20.04)
* `debootstrap` (some old version of Debian's `debootstrap` couldn't bootstrap Ubuntu 22.04)

First, clone this repo:

Expand Down
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi

rm -rf "$ROOTFS_PATH"
mkdir -p "$ROOTFS_PATH"
debootstrap --components=main,universe focal "$ROOTFS_PATH" "$MIRROR"
debootstrap --components=main,universe jammy "$ROOTFS_PATH" "$MIRROR"

cp "$INSTALL_SCRIPT" "$ROOTFS_PATH/root"
arch-chroot "$ROOTFS_PATH" "/root/$INSTALL_SCRIPT"
Expand Down
54 changes: 43 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash -e

GCC_VERSION="12"
LLVM_VERSION="14"
OPENJDK_VERSION="17"
GHC_VERSION="9.0.1"

UBUNTU_CODENAME="$(source /etc/os-release && echo "$UBUNTU_CODENAME")"
UBUNTU_VERSION="$(source /etc/os-release && echo "$VERSION_ID")"

# Fix PATH environment variable
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Expand All @@ -13,9 +21,9 @@ echo 'LC_ALL=en_US.UTF-8' > /etc/default/locale
useradd -r sandbox -d /sandbox -m
mkdir -p /sandbox/{binary,source,working}

# Add focal-updates source
# Add ubuntu-updates source
ORIGINAL_SOURCE=$(head -n 1 /etc/apt/sources.list)
sed 's/focal/focal-updates/' <<< "$ORIGINAL_SOURCE" >> /etc/apt/sources.list
sed "s/$UBUNTU_CODENAME/$UBUNTU_CODENAME-updates/" <<< "$ORIGINAL_SOURCE" >> /etc/apt/sources.list

# Install dependencies
apt-get update
Expand All @@ -34,15 +42,39 @@ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys FF3AEACEF6F882
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

# Add sources
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main" > /etc/apt/sources.list.d/llvm.list
echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main" > /etc/apt/sources.list.d/python.list
echo "deb http://ppa.launchpad.net/longsleep/golang-backports/ubuntu focal main" > /etc/apt/sources.list.d/go.list
echo "deb http://apt.llvm.org/$UBUNTU_CODENAME/ llvm-toolchain-$UBUNTU_CODENAME-$LLVM_VERSION main" > /etc/apt/sources.list.d/llvm.list
echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu $UBUNTU_CODENAME main" > /etc/apt/sources.list.d/python.list
echo "deb http://ppa.launchpad.net/longsleep/golang-backports/ubuntu $UBUNTU_CODENAME main" > /etc/apt/sources.list.d/go.list
echo "deb http://ppa.launchpad.net/hvr/ghc/ubuntu focal main" > /etc/apt/sources.list.d/haskell.list
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" > /etc/apt/sources.list.d/mono.list

# Install some language support via APT
apt-get update
apt-get install -y g++-10-multilib gcc-10-multilib clang-11 libc++-11-dev libc++abi-11-dev openjdk-11-jdk fpc python2.7 python3.6 python3.9 golang-go ghc mono-devel fsharp
apt-get install -y g++-$GCC_VERSION-multilib \
gcc-$GCC_VERSION-multilib \
clang-$LLVM_VERSION \
libc++-$LLVM_VERSION-dev \
libc++abi-$LLVM_VERSION-dev \
openjdk-$OPENJDK_VERSION-jdk \
fpc \
python2.7 \
python3.9 \
python3.10 \
golang-go \
ghc-$GHC_VERSION \
mono-devel \
fsharp

# Install Python 3.6 via Pyenv
su sandbox -c 'curl https://pyenv.run | bash'
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev libgdbm-dev libnss3-dev libedit-dev libc6-dev
function install_python_pyenv() {
FULL_VERSION="$(su sandbox -c "/sandbox/.pyenv/bin/pyenv install --list" | sed -nE "s/^ ($(echo "$1" | sed 's/\./\\./')\.[0-9]+)$/\1/p" | tail -n 1)"
su sandbox -c "/sandbox/.pyenv/bin/pyenv install $FULL_VERSION"
ln -sf "/sandbox/.pyenv/versions/$FULL_VERSION/bin/python" "/usr/local/bin/python$1"
}
install_python_pyenv 3.6

# Install Rust via Rustup
su sandbox -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"
Expand All @@ -52,16 +84,16 @@ su sandbox -c "curl -s https://get.sdkman.io | bash"
su sandbox -s /bin/bash -c "source ~/.sdkman/bin/sdkman-init.sh && sdk install kotlin"

# Install Swift
SWIFT_URL_QUOTED="$(curl https://www.swift.org/download/ --compressed | grep -P '"([^"]+ubuntu20.04.tar.gz)"' -o | head -n 1)"
SWIFT_URL_QUOTED="$(curl https://www.swift.org/download/ --compressed | grep -P "\"([^\"]+ubuntu$UBUNTU_VERSION.tar.gz)\"" -o | head -n 1)"
SWIFT_URL="$(eval "echo $SWIFT_URL_QUOTED")"
wget -O - "$SWIFT_URL" | tar -xzf - -C /opt
mv /opt/swift* /opt/swift

# Create symlinks for compilers and interpreters with non-common names and locations
ln -s /usr/bin/g++-10 /usr/local/bin/g++
ln -s /usr/bin/gcc-10 /usr/local/bin/gcc
ln -s /usr/bin/clang-11 /usr/local/bin/clang
ln -s /usr/bin/clang++-11 /usr/local/bin/clang++
ln -s /usr/bin/g++-$GCC_VERSION /usr/local/bin/g++
ln -s /usr/bin/gcc-$GCC_VERSION /usr/local/bin/gcc
ln -s /usr/bin/clang-$LLVM_VERSION /usr/local/bin/clang
ln -s /usr/bin/clang++-$LLVM_VERSION /usr/local/bin/clang++
ln -s /sandbox/.sdkman/candidates/kotlin/current/bin/kotlin /usr/local/bin/kotlin
ln -s /sandbox/.sdkman/candidates/kotlin/current/bin/kotlinc /usr/local/bin/kotlinc
ln -s /sandbox/.cargo/bin/rustc /usr/local/bin/rustc
Expand Down

0 comments on commit 047410b

Please sign in to comment.