This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
/
setup_env_ubuntu.sh
executable file
·150 lines (123 loc) · 4.61 KB
/
setup_env_ubuntu.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
#
# Copyright (c) 2017-2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
set -e
cidir=$(dirname "$0")
source "/etc/os-release" || source "/usr/lib/os-release"
source "${cidir}/lib.sh"
echo "Update apt repositories"
# FIXME: workaround the case where the runner is pre-configured with a
# broken kubernetes repository.
sudo -E rm -f /etc/apt/sources.list.d/kubernetes.list
sudo -E apt update
# Removing man-db, workflow's kept failing, fixes: #4480
echo "Removing man-db, not needed for CI/CD"
sudo -E apt -y remove --purge man-db
echo "Try to preemptively fix broken dependencies, if any"
sudo -E apt --fix-broken install -y
echo "Install chronic and bc"
sudo -E apt install -y moreutils bc
declare -A minimal_packages=( \
[spell-check]="hunspell hunspell-en-gb hunspell-en-us pandoc" \
[xml_validator]="libxml2-utils" \
[yaml_validator]="yamllint" \
)
declare -A packages=( \
[kata_containers_dependencies]="libtool automake autotools-dev autoconf bc libpixman-1-dev coreutils curl expect" \
[qemu_dependencies]="libcap-dev libattr1-dev libcap-ng-dev librbd-dev ninja-build python python-dev python3-venv" \
[kernel_dependencies]="libelf-dev flex" \
[crio_dependencies]="libglib2.0-dev libseccomp-dev libapparmor-dev libgpgme11-dev thin-provisioning-tools" \
[bison_binary]="bison" \
[libudev-dev]="libudev-dev" \
[build_tools]="build-essential pkg-config zlib1g-dev" \
[crio_dependencies_for_ubuntu]="libdevmapper-dev util-linux" \
[metrics_dependencies]="smem jq" \
[cri-containerd_dependencies]="btrfs-progs libseccomp-dev libapparmor-dev make gcc pkg-config" \
[crudini]="crudini" \
[haveged]="haveged" \
[libsystemd]="libsystemd-dev" \
[redis]="redis-server" \
[agent_shutdown_test]="tmux" \
[virtiofsd_dependencies]="unzip" \
[webhook_dependencies]="openssl" \
)
if [ "${NAME}" == "Ubuntu" ] && [ "$(echo "${VERSION_ID} >= 20.04" | bc -q)" == "1" ]; then
packages[cri-containerd_dependencies]+=" libbtrfs-dev"
# driverctl is unavailable on older Ubuntu like 18.04
packages[vfio_test]="pciutils driverctl"
fi
if [ "${NAME}" == "Ubuntu" ] && [ "$(echo "${VERSION_ID} >= 22.04" | bc -q)" == "1" ]; then
packages[build_tools]+=" python2"
else
packages[build_tools]+=" python"
fi
if [ "$(uname -m)" == "x86_64" ] && [ "${NAME}" == "Ubuntu" ] && [ "$(echo "${VERSION_ID} >= 18.04" | bc -q)" == "1" ]; then
packages[qemu_dependencies]+=" libpmem-dev"
fi
if [ "$(uname -m)" == "s390x" ]; then
packages[kernel_dependencies]+=" libssl-dev"
fi
rust_agent_pkgs=()
rust_agent_pkgs+=("build-essential")
rust_agent_pkgs+=("g++")
rust_agent_pkgs+=("make")
rust_agent_pkgs+=("automake")
rust_agent_pkgs+=("autoconf")
rust_agent_pkgs+=("m4")
rust_agent_pkgs+=("libc6-dev")
rust_agent_pkgs+=("coreutils")
rust_agent_pkgs+=("binutils")
rust_agent_pkgs+=("debianutils")
rust_agent_pkgs+=("gcc")
rust_agent_pkgs+=("git")
if [ "${NAME}" == "Ubuntu" ] && [ "$(echo "${VERSION_ID} >= 22.04" | bc -q)" == "1" ]; then
rust_agent_pkgs+=("libstdc++-10-dev")
else
rust_agent_pkgs+=("libstdc++-8-dev")
fi
# ppc64le and s390x have no musl targets in Rust, hence, do not install musl there
[ "$(arch)" != "ppc64le" ] && [ "$(arch)" != "s390x" ] && rust_agent_pkgs+=("musl" "musl-dev" "musl-tools")
# ppc64le and s390x require a system installation of protobuf-compiler
[ "$(arch)" == "ppc64le" ] || [ "$(arch)" == "s390x" ] && rust_agent_pkgs+=("protobuf-compiler")
main()
{
local setup_type="$1"
[ -z "$setup_type" ] && die "need setup type"
local pkgs_to_install
local pkgs
for pkgs in "${minimal_packages[@]}"; do
info "The following package will be installed: $pkgs"
pkgs_to_install+=" $pkgs"
done
if [ "$setup_type" = "default" ]; then
for pkgs in "${packages[@]}"; do
info "The following package will be installed: $pkgs"
pkgs_to_install+=" $pkgs"
done
fi
# packages for rust agent, build on 18.04 or later
if [[ ! "${VERSION_ID}" < "18.04" ]]; then
pkgs_to_install+=" ${rust_agent_pkgs[@]}"
fi
# The redis-server package fails to install if IPv6 is disabled. Let's
# check if that's the case and then enable it.
if [ $(sudo sysctl -n net.ipv6.conf.all.disable_ipv6) -eq 1 ]; then
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
fi
chronic sudo -E apt -y install $pkgs_to_install
[ "$setup_type" = "minimal" ] && exit 0
if [ "$VERSION_ID" == "16.04" ] && [ "$(arch)" != "ppc64le" ]; then
chronic sudo -E add-apt-repository ppa:alexlarsson/flatpak -y
chronic sudo -E apt update
fi
echo "Install os-tree"
chronic sudo -E apt install -y libostree-dev
if [ "$KATA_KSM_THROTTLER" == "yes" ]; then
echo "Install ${KATA_KSM_THROTTLER_JOB}"
chronic sudo -E apt install -y ${KATA_KSM_THROTTLER_JOB}
fi
}
main "$@"