├── .github └── workflows │ └── build.yaml ├── LICENSE ├── README.md ├── bootstrap.sh └── install.sh /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | workflow_dispatch: 6 | schedule: 7 | - cron: '0 9 * * *' 8 | 9 | env: 10 | TZ: Asia/Shanghai 11 | 12 | jobs: 13 | build_deploy: 14 | name: Build 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v2 19 | - name: Install dependencies 20 | run: | 21 | sudo apt-get install -y arch-install-scripts debootstrap 22 | - name: Build 23 | run: | 24 | export ROOTFS_PATH="$(pwd)/rootfs" 25 | export MIRROR="http://azure.archive.ubuntu.com/ubuntu" 26 | sudo --preserve-env ./bootstrap.sh 27 | - name: Compress with XZ 28 | run: | 29 | sudo tar -cJvf rootfs.tar.xz rootfs 30 | sudo chmod 777 rootfs.tar.xz 31 | - uses: actions/upload-artifact@v3 32 | with: 33 | name: rootfs 34 | path: rootfs.tar.xz 35 | 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sandbox RootFS 2 | 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: 3 | 4 | * GCC 12 5 | * Clang 14 (from [LLVM](https://apt.llvm.org/)) 6 | * OpenJDK 17 7 | * Kotlin (from [SDKMAN!](https://kotlinlang.org/docs/tutorials/command-line.html)) 8 | * Free Pascal 3 9 | * Python 2.7 10 | * Python 3.9 11 | * Python 3.10 12 | * Swift (from [Swift.org](https://swift.org/)) 13 | * Rust (from [Rustup](https://rustup.rs/)) 14 | * Go (from [PPA](https://launchpad.net/~longsleep/+archive/ubuntu/golang-backports)) 15 | * GHC 9.0.1 (from [PPA](https://launchpad.net/~hvr/+archive/ubuntu/ghc)) 16 | * C# (from [Mono](https://www.mono-project.com/download/stable/)) 17 | * F# (from [Mono](https://www.mono-project.com/download/stable/)) 18 | 19 | Each compiler (or interpreter) is available in `$PATH`. It also contains [`testlib.h`](https://github.com/MikeMirzayanov/testlib) in `/usr/include`. 20 | 21 | You can download it from [release](https://github.com/lyrio-dev/sandbox-rootfs/releases) or bootstrap by yourself. 22 | 23 | # Bootstrapping 24 | You'll need: 25 | 26 | * A Linux box with root privilege 27 | * `arch-chroot` (usually in the package `arch-install-scripts`) 28 | * `debootstrap` (some old version of Debian's `debootstrap` couldn't bootstrap Ubuntu 22.04) 29 | 30 | First, clone this repo: 31 | 32 | ```bash 33 | git clone git@github.com:lyrio-dev/sandbox-rootfs.git 34 | cd sandbox-rootfs 35 | ``` 36 | 37 | Set the path to bootstrap rootfs. If there're anything inside it, it'll be `rm -rf`-ed. If the path doesn't exist, it'll be `mkdir -p`-ed. 38 | 39 | ```bash 40 | export ROOTFS_PATH=/rootfs 41 | ``` 42 | 43 | If you're root, just run the `bootstrap.sh` script: 44 | 45 | ```bash 46 | ./bootstrap.sh 47 | ``` 48 | 49 | Or if you use `sudo`, remember to preserve the `ROOTFS_PATH` environment variable with `-E` option: 50 | 51 | ```bash 52 | sudo -E ./bootstrap.sh 53 | ``` 54 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INSTALL_SCRIPT="install.sh" 4 | 5 | cd "$(dirname "$0")" 6 | 7 | set -e 8 | 9 | if [[ "$UID" != "0" ]]; then 10 | echo This script must be run with root privileges. 11 | exit 1 12 | fi 13 | 14 | if ! arch-chroot -h >/dev/null 2>&1; then 15 | echo "You need arch-chroot to run this script." 16 | echo "Usually it's in the package "'"'"arch-install-scripts"'".' 17 | exit 1 18 | fi 19 | 20 | if ! debootstrap --version >/dev/null 2>&1; then 21 | echo "You need debootstrap to run this script." 22 | exit 1 23 | fi 24 | 25 | if [[ "$ROOTFS_PATH" == "" ]]; then 26 | echo "Please specify the path to put rootfs on with ROOTFS_PATH." 27 | exit 1 28 | fi 29 | 30 | if [[ "$MIRROR" == "" ]]; then 31 | MIRROR="http://mirrors.tuna.tsinghua.edu.cn/ubuntu" 32 | fi 33 | 34 | rm -rf "$ROOTFS_PATH" 35 | mkdir -p "$ROOTFS_PATH" 36 | debootstrap --components=main,universe jammy "$ROOTFS_PATH" "$MIRROR" 37 | 38 | cp "$INSTALL_SCRIPT" "$ROOTFS_PATH/root" 39 | arch-chroot "$ROOTFS_PATH" "/root/$INSTALL_SCRIPT" 40 | rm "$ROOTFS_PATH/root/$INSTALL_SCRIPT" 41 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | GCC_VERSION="12" 4 | LLVM_VERSION="14" 5 | OPENJDK_VERSION="17" 6 | GHC_VERSION="9.0.1" 7 | 8 | UBUNTU_CODENAME="$(source /etc/os-release && echo "$UBUNTU_CODENAME")" 9 | UBUNTU_VERSION="$(source /etc/os-release && echo "$VERSION_ID")" 10 | 11 | # Fix PATH environment variable 12 | export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 13 | 14 | # Set Locale 15 | sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen 16 | locale-gen 17 | export LC_ALL=en_US.UTF-8 18 | echo 'LC_ALL=en_US.UTF-8' > /etc/default/locale 19 | 20 | # Create sandbox user and directories 21 | useradd -r sandbox -d /sandbox -m 22 | mkdir -p /sandbox/{binary,source,working} 23 | 24 | # Add ubuntu-updates source 25 | ORIGINAL_SOURCE=$(head -n 1 /etc/apt/sources.list) 26 | sed "s/$UBUNTU_CODENAME/$UBUNTU_CODENAME-updates/" <<< "$ORIGINAL_SOURCE" >> /etc/apt/sources.list 27 | 28 | # Install dependencies 29 | apt-get update 30 | apt-get dist-upgrade -y 31 | apt-get install -y gnupg ca-certificates curl wget locales unzip zip git 32 | 33 | # Key: LLVM repo 34 | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 35 | # Key: Python repo 36 | apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BA6932366A755776 37 | # Key: Go repo 38 | apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys F6BC817356A3D45E 39 | # Key: Haskell repo 40 | apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys FF3AEACEF6F88286 41 | # Key: Mono repo 42 | apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF 43 | 44 | # Add sources 45 | echo "deb http://apt.llvm.org/$UBUNTU_CODENAME/ llvm-toolchain-$UBUNTU_CODENAME-$LLVM_VERSION main" > /etc/apt/sources.list.d/llvm.list 46 | echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu $UBUNTU_CODENAME main" > /etc/apt/sources.list.d/python.list 47 | echo "deb http://ppa.launchpad.net/longsleep/golang-backports/ubuntu $UBUNTU_CODENAME main" > /etc/apt/sources.list.d/go.list 48 | echo "deb http://ppa.launchpad.net/hvr/ghc/ubuntu focal main" > /etc/apt/sources.list.d/haskell.list 49 | echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" > /etc/apt/sources.list.d/mono.list 50 | 51 | # Install some language support via APT 52 | apt-get update 53 | apt-get install -y g++-$GCC_VERSION-multilib \ 54 | gcc-$GCC_VERSION-multilib \ 55 | clang-$LLVM_VERSION \ 56 | libc++-$LLVM_VERSION-dev \ 57 | libc++abi-$LLVM_VERSION-dev \ 58 | openjdk-$OPENJDK_VERSION-jdk \ 59 | fpc \ 60 | python2.7 \ 61 | python3.9 \ 62 | python3.10 \ 63 | golang-go \ 64 | ghc-$GHC_VERSION \ 65 | mono-devel \ 66 | fsharp 67 | 68 | # Install Rust via Rustup 69 | su sandbox -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y" 70 | 71 | # Install Kotlin via SDKMAN! 72 | su sandbox -c "curl -s https://get.sdkman.io | bash" 73 | su sandbox -s /bin/bash -c "source ~/.sdkman/bin/sdkman-init.sh && sdk install kotlin" 74 | 75 | # Install Swift 76 | SWIFT_URL_QUOTED="$(curl https://www.swift.org/download/ --compressed | grep -P "\"([^\"]+ubuntu$UBUNTU_VERSION.tar.gz)\"" -o | head -n 1)" 77 | SWIFT_URL="$(eval "echo $SWIFT_URL_QUOTED")" 78 | wget -O - "$SWIFT_URL" | tar -xzf - -C /opt 79 | mv /opt/swift* /opt/swift 80 | 81 | # Create symlinks for compilers and interpreters with non-common names and locations 82 | ln -s /usr/bin/g++-$GCC_VERSION /usr/local/bin/g++ 83 | ln -s /usr/bin/gcc-$GCC_VERSION /usr/local/bin/gcc 84 | ln -s /usr/bin/clang-$LLVM_VERSION /usr/local/bin/clang 85 | ln -s /usr/bin/clang++-$LLVM_VERSION /usr/local/bin/clang++ 86 | ln -s /sandbox/.sdkman/candidates/kotlin/current/bin/kotlin /usr/local/bin/kotlin 87 | ln -s /sandbox/.sdkman/candidates/kotlin/current/bin/kotlinc /usr/local/bin/kotlinc 88 | ln -s /sandbox/.cargo/bin/rustc /usr/local/bin/rustc 89 | ln -s /opt/swift/usr/bin/swiftc /usr/local/bin/swiftc 90 | 91 | # Create wrapper for GHC 92 | cat > /usr/local/bin/ghc <