-
Notifications
You must be signed in to change notification settings - Fork 3
/
prepare-ubuntu20.sh
78 lines (61 loc) · 2.29 KB
/
prepare-ubuntu20.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
if [ $UID -ne 0 ]; then
echo Please run as root
exit
fi
HCDIR=$(dirname $(readlink -f "$0"))
export GIT_SSL_NO_VERIFY=true
apt update
apt -y upgrade
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
pkgs="autoconf \
bison \
flex \
build-essential \
git \
libtool \
make \
pkg-config \
libprotobuf-dev \
protobuf-compiler \
git \
wget \
openjdk-8-jdk \
python3 \
libnl-route-3-dev \
nodejs"
apt install --assume-yes $pkgs
export RUSTUP_DIST_SERVER=https://mirror.sjtu.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirror.sjtu.edu.cn/rust-static/rustup
curl https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh -sSf | sh -s -- --profile default -y && source ~/.cargo/env
echo '# 放到 `$HOME/.cargo/config` 文件中
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 替换成你偏好的镜像源
replace-with = "sjtu"
# replace-with = "ustc"
# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# 中国科学技术大学
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc 社区
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
' >~/.cargo/config
source /etc/profile
npm install -g npm --registry=https://registry.npm.taobao.org
npm i -g cnpm --registry=https://registry.npm.taobao.org && source /etc/profile
git clone -b v0.4.0 --depth=1 --single-branch https://github.com.cnpmjs.org/ThinkSpiritLab/ojcmp.git ~/ojcmp &&
cd ~/ojcmp && cargo build --release && cp target/release/ojcmp /usr/bin
git clone --depth=1 --single-branch https://github.com.cnpmjs.org/google/nsjail.git ~/nsjail &&
sed -i '/ .set_tid = 0,\| .set_tid_size = 0,\| .cgroup = 0,/d' ~/nsjail/subproc.cc &&
cd ~/nsjail && make && cp ~/nsjail/nsjail /usr/bin/nsjail
git clone --depth=1 --single-branch https://github.com.cnpmjs.org/ThinkSpiritLab/Heng-Core.git ~/Heng-Core &&
cd ~/Heng-Core && make && cp ~/Heng-Core/hc /usr/bin/hc && cd ~
cp -r ~/.rustup/toolchains/$(ls ~/.rustup/toolchains/ | grep "stable") /usr/local/rustup && ln -s /usr/local/rustup/bin/rustc /usr/bin/rustc
cp $HCDIR/Tools/testlib.h /testlib.h
cd $HCDIR && cnpm install && npm run build