Debian Codegraph @

hack/github-actions-setup

raw ◀ ▶
1 Debian patch touch this file
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 declare -A VERSIONS=(
5 ["cni-plugins"]=v1.3.0
6 ["runc"]=v1.1.14
7 ["crun"]=1.17
8 ["bats"]=v1.9.0
9 )
10
11 main() {
12 set -x
13 prepare_system
14
15 install_packages
16 install_conmon
17 install_bats
18 install_critools
19 install_runc
20 install_crun
21 install_cni_plugins
22 install_testdeps
23 setup_etc_subid
24 }
25
26 prepare_system() {
27 sudo systemctl stop docker
28 sudo ufw disable
29
30 # enable necessary kernel modules
31 sudo ip6tables --list >/dev/null
32
33 # enable necessary sysctls
34 sudo sysctl -w net.ipv4.conf.all.route_localnet=1
35 sudo sysctl -w net.ipv4.ip_forward=1
36 # needed for crictl test
37 sudo sysctl -w net.bridge.bridge-nf-call-iptables=1
38 sudo iptables -t nat -I POSTROUTING -s 127.0.0.0/8 ! -d 127.0.0.0/8 -j MASQUERADE
39 }
40
41 remove_packages() {
42 sudo apt-get remove \
43 conmon \
44 containernetworking-plugins
45 }
46
47 install_packages() {
48 . /etc/os-release
49 CRIU_REPO="https://download.opensuse.org/repositories/devel:/tools:/criu/xUbuntu_$VERSION_ID"
50
•51 curl -fSsL $CRIU_REPO/Release.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/criu.gpg
52 echo "deb $CRIU_REPO/ /" | sudo tee /etc/apt/sources.list.d/criu.list
53
54 sudo apt update
55 sudo apt install -y \
56 autoconf \
57 automake \
58 conntrack \
59 criu \
60 libaio-dev \
61 libapparmor-dev \
62 libbtrfs-dev \
63 libcap-dev \
64 libdevmapper-dev \
65 libfuse-dev \
66 libgpgme11-dev \
67 libglib2.0-dev \
68 libnet1-dev \
69 libnl-3-dev \
70 libprotobuf-c-dev \
71 libprotobuf-dev \
72 libseccomp-dev \
73 libsystemd-dev \
74 libtool \
75 libudev-dev \
76 libyajl-dev \
77 sed \
78 socat \
79 uuid-dev
80 }
81
82 install_conmon() {
83 sudo make install
84 conmon --version
85 }
86
87 install_bats() {
88 git clone https://github.com/bats-core/bats-core
89 pushd bats-core
90 git checkout "${VERSIONS["bats"]}"
91 sudo ./install.sh /usr/local
92 popd
93 rm -rf bats-core
94 mkdir -p ~/.parallel
95 touch ~/.parallel/will-cite
96 }
97
98 install_critools() {
99 URL=https://github.com/kubernetes-sigs/cri-tools
100
101 git clone $URL
102 pushd cri-tools
103 sudo -E PATH="$PATH" make BINDIR=/usr/bin install
104 popd
105 sudo rm -rf cri-tools
106 sudo critest --version
107 sudo crictl --version
108 }
109
110 install_cni_plugins() {
111 URL=https://github.com/containernetworking/plugins/releases/download
112 TARBALL=cni-plugins-linux-amd64-${VERSIONS["cni-plugins"]}.tgz
113 CNI_DIR=/opt/cni/bin
114 sudo mkdir -p "$CNI_DIR"
115 wget -O "$TARBALL" $URL/"${VERSIONS["cni-plugins"]}"/"$TARBALL"
116 sudo tar xf "$TARBALL" -C "$CNI_DIR"
117 rm "$TARBALL"
118 ls -lah "$CNI_DIR"
119 }
120
121 install_runc() {
122 URL=https://github.com/opencontainers/runc/releases/download/"${VERSIONS["runc"]}"
123 BINARY=/usr/sbin/runc
124 sudo wget -O "$BINARY" "$URL"/runc.amd64
125 sudo chmod +x "$BINARY"
126
127 # Verify the SHA256
128 SUMFILE=runc.sha256sum
129 wget "$URL"/$SUMFILE
130 grep -qw "$(sha256sum "$BINARY" | awk '{ print $1 }')" $SUMFILE
131 rm $SUMFILE
132
133 runc --version
134 }
135
136 install_crun() {
137 URL=https://github.com/containers/crun/releases/download/"${VERSIONS["crun"]}"/crun-"${VERSIONS["crun"]}"-linux-amd64
138
139 BINARY=/usr/bin/crun
140 sudo wget -O "$BINARY" "$URL"
141 sudo chmod +x "$BINARY"
142
143 crun --version
144 }
145
146 install_testdeps() {
147 CLONE_PATH=$(go env GOPATH)/src/github.com/cri-o
148 mkdir -p "$CLONE_PATH"
149 pushd "$CLONE_PATH"
150
151 URL=https://github.com/cri-o/cri-o
152 git clone $URL
153 pushd cri-o
154 make "$(pwd)"/build/bin/ginkgo
155 sudo cp build/bin/ginkgo /usr/bin
156 ginkgo version
157
158 sudo mkdir -p /etc/containers/registries.d
159 sudo cp test/policy.json /etc/containers
160 sudo cp test/redhat_sigstore.yaml /etc/containers/registries.d/registry.access.redhat.com.yaml
161 sudo cp test/registries.conf /etc/containers/registries.conf
162 popd
163 popd
164 }
165
166 setup_etc_subid() {
167 echo "containers:200000:65536" | sudo tee -a /etc/subuid
168 echo "containers:200000:65536" | sudo tee -a /etc/subgid
169
170 }
171
172 main "$@"