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
151
152
153
154
155
156
157
158
159
160
161
162
|
#!/bin/bash
# NOTE(hwoarang): Most parts of this this file were taken from the
# bifrost repository (scripts/install-deps.sh). This script contains all
# the necessary distro specific code to install ansible and it's dependencies.
set -eu
declare -A PKG_MAP
# workaround: for latest bindep to work, it needs to use en_US local
export LANG=c
CHECK_CMD_PKGS=(
gcc
libffi
libopenssl
lsb-release
make
net-tools
python-devel
python
venv
wget
)
source /etc/os-release || source /usr/lib/os-release
case ${ID,,} in
*suse)
OS_FAMILY="Suse"
INSTALLER_CMD="sudo -H -E zypper install -y --no-recommends"
CHECK_CMD="zypper search --match-exact --installed"
PKG_MAP=(
[gcc]=gcc
[libffi]=libffi-devel
[libopenssl]=libopenssl-devel
[lsb-release]=lsb-release
[make]=make
[net-tools]=net-tools
[python]=python
[python-devel]=python-devel
[venv]=python-virtualenv
[wget]=wget
)
EXTRA_PKG_DEPS=( python-xml )
sudo zypper -n ref
# NOTE (cinerama): we can't install python without removing this package
# if it exists
if $(${CHECK_CMD} patterns-openSUSE-minimal_base-conflicts &> /dev/null); then
sudo -H zypper remove -y patterns-openSUSE-minimal_base-conflicts
fi
;;
ubuntu|debian)
OS_FAMILY="Debian"
export DEBIAN_FRONTEND=noninteractive
INSTALLER_CMD="sudo -H -E apt-get -y install"
CHECK_CMD="dpkg -l"
PKG_MAP=(
[gcc]=gcc
[libffi]=libffi-dev
[libopenssl]=libssl-dev
[lsb-release]=lsb-release
[make]=make
[net-tools]=net-tools
[python]=python-minimal
[python-devel]=libpython-dev
[venv]=python-virtualenv
[wget]=wget
)
EXTRA_PKG_DEPS=()
sudo apt-get update
;;
rhel|fedora|centos)
OS_FAMILY="RedHat"
PKG_MANAGER=$(which dnf || which yum)
INSTALLER_CMD="sudo -H -E ${PKG_MANAGER} -y install"
CHECK_CMD="rpm -q"
PKG_MAP=(
[gcc]=gcc
[libffi]=libffi-devel
[libopenssl]=openssl-devel
[lsb-release]=redhat-lsb
[make]=make
[net-tools]=net-tools
[python]=python
[python-devel]=python-devel
[venv]=python-virtualenv
[wget]=wget
)
sudo yum updateinfo
EXTRA_PKG_DEPS=()
sudo yum update --assumeno
;;
*) echo "ERROR: Supported package manager not found. Supported: apt, dnf, yum, zypper"; exit 1;;
esac
if ! $(python --version &>/dev/null); then
${INSTALLER_CMD} ${PKG_MAP[python]}
fi
if ! $(gcc -v &>/dev/null); then
${INSTALLER_CMD} ${PKG_MAP[gcc]}
fi
if ! $(wget --version &>/dev/null); then
${INSTALLER_CMD} ${PKG_MAP[wget]}
fi
if ! $(python -m virtualenv --version &>/dev/null); then
${INSTALLER_CMD} ${PKG_MAP[venv]}
fi
for pkg in ${CHECK_CMD_PKGS[@]}; do
if ! $(${CHECK_CMD} ${PKG_MAP[$pkg]} &>/dev/null); then
${INSTALLER_CMD} ${PKG_MAP[$pkg]}
fi
done
if [ -n "${EXTRA_PKG_DEPS-}" ]; then
for pkg in ${EXTRA_PKG_DEPS}; do
if ! $(${CHECK_CMD} ${pkg} &>/dev/null); then
${INSTALLER_CMD} ${pkg}
fi
done
fi
# If we're using a venv, we need to work around sudo not
# keeping the path even with -E.
PYTHON=$(which python)
# To install python packages, we need pip.
#
# We can't use the apt packaged version of pip since
# older versions of pip are incompatible with
# requests, one of our indirect dependencies (bug 1459947).
#
# Note(cinerama): We use pip to install an updated pip plus our
# other python requirements. pip breakages can seriously impact us,
# so we've chosen to install/upgrade pip here rather than in
# requirements (which are synced automatically from the global ones)
# so we can quickly and easily adjust version parameters.
# See bug 1536627.
#
# Note(cinerama): If pip is linked to pip3, the rest of the install
# won't work. Remove the alternatives. This is due to ansible's
# python 2.x requirement.
if [[ $(readlink -f /etc/alternatives/pip) =~ "pip3" ]]; then
sudo -H update-alternatives --remove pip $(readlink -f /etc/alternatives/pip)
fi
if ! which pip; then
wget -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py
sudo -H -E ${PYTHON} /tmp/get-pip.py
fi
PIP=$(which pip)
echo "Using pip: $(${PIP} --version)"
sudo -H -E ${PIP} install --upgrade virtualenv
sudo -H -E ${PIP} install --upgrade pip
# upgrade setuptools, as latest version is needed to install some projects
sudo -H -E ${PIP} install --upgrade setuptools
${PIP} install --user --upgrade ansible==$XCI_ANSIBLE_PIP_VERSION
|