forked from kata-containers/tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_env_alinux.sh
executable file
·105 lines (85 loc) · 3.19 KB
/
setup_env_alinux.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
#!/bin/bash
#
# Copyright (c) 2022 Ant Group
#
# SPDX-License-Identifier: Apache-2.0
#
set -o errtrace
set -o nounset
set -o pipefail
[ -n "${DEBUG:-}" ] && set -o xtrace
cidir=$(dirname "$0")
source "/etc/os-release" || "source /usr/lib/os-release"
source "${cidir}/lib.sh"
# Obtain AlibabaCloud Linux version
# Either /etc/os-release or /usr/lib/os-release is source´ed
# so that VERSION_ID is already exported.
[ "$VERSION_ID" -ge 3 ] || die "This script is for alinux 3 and above only"
# Send error when a package is not available in the repositories
if [ "$(tail -1 /etc/dnf/dnf.conf | tr -d '\n')" != "skip_missing_names_on_install=0" ]; then
echo "skip_missing_names_on_install=0" | sudo tee -a /etc/dnf/dnf.conf
fi
# Ensure EPEL repository is configured
sudo -E dnf -y install epel-release
# Enable priority to AlibabaCloud Linux Base repo in order to
# avoid perl updating issues
[ -f "/etc/yum.repos.d/AliYun.repo" ] && repo_file="/etc/yum.repos.d/AliYun.repo"
[ -n "${repo_file:-}" ] || die "Unable to find the AlibabaCloud Linux base repository file"
if [ "$(tail -1 ${repo_file} | tr -d '\n')" != "priority=1" ]; then
echo "priority=1" | sudo tee -a "$repo_file"
fi
sudo -E dnf -y clean all
echo "Update repositories"
sudo -E dnf -y --nobest update
echo "Install chronic"
sudo -E dnf -y install moreutils
chronic sudo -E dnf install -y pkgconf-pkg-config
declare -A minimal_packages=( \
[spell-check]="hunspell hunspell-en-GB hunspell-en-US pandoc" \
[xml_validator]="libxml2" \
[yaml_validator]="yamllint" \
)
declare -A packages=( \
[kata_containers_dependencies]="libtool libtool-ltdl-devel device-mapper-persistent-data lvm2 libtool-ltdl" \
[qemu_dependencies]="libcap-devel libcap-ng-devel libattr-devel libcap-ng-devel librbd1-devel flex libfdt-devel libpmem-devel ninja-build" \
[kernel_dependencies]="elfutils-libelf-devel flex pkgconfig patch" \
[crio_dependencies]="glibc-static libseccomp-devel libassuan-devel libgpg-error-devel util-linux libselinux-devel" \
[gperf_dependencies]="gcc-c++" \
[bison_binary]="bison" \
[libgudev1-dev]="libgudev1-devel" \
[general_dependencies]="gpgme-devel glib2-devel glibc-devel bzip2 m4 gettext-devel automake autoconf pixman-devel coreutils expect" \
[build_tools]="python3 pkgconfig zlib-devel" \
[ostree]="ostree-devel" \
[metrics_dependencies]="bc jq" \
[crudini]="crudini" \
[procenv]="procenv" \
[haveged]="haveged" \
[libsystemd]="systemd-devel" \
[redis]="redis" \
[make]="make" \
[agent_shutdown_test]="tmux" \
[virtiofsd_dependencies]="unzip" \
)
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
# On AlibabaCloud Linux:3 container image the installation of coreutils
# conflicts with coreutils-single because they mutually
# exclusive. Let's pass --allowerasing so that coreutils-single
# is replaced.
chronic sudo -E dnf -y install --allowerasing $pkgs_to_install
}
main "$@"