2 # NOTE(hwoarang): Most parts of this this file were taken from the
3 # bifrost repository (scripts/install-deps.sh). This script contains all
4 # the necessary distro specific code to install ansible and it's dependencies.
17 # Check zypper before apt-get in case zypper-aptitude
19 if [ -x '/usr/bin/zypper' ]; then
21 INSTALLER_CMD="sudo -H -E zypper install -y"
22 CHECK_CMD="zypper search --match-exact --installed"
27 [libopenssl]=libopenssl-devel
30 [python-devel]=python-devel
31 [venv]=python-virtualenv
34 EXTRA_PKG_DEPS=( python-xml )
35 # NOTE (cinerama): we can't install python without removing this package
37 if $(${CHECK_CMD} patterns-openSUSE-minimal_base-conflicts &> /dev/null); then
38 sudo -H zypper remove -y patterns-openSUSE-minimal_base-conflicts
40 elif [ -x '/usr/bin/apt-get' ]; then
42 INSTALLER_CMD="sudo -H -E apt-get -y install"
47 [libopenssl]=libssl-dev
49 [python]=python-minimal
50 [python-devel]=libpython-dev
51 [venv]=python-virtualenv
55 elif [ -x '/usr/bin/dnf' ] || [ -x '/usr/bin/yum' ]; then
57 PKG_MANAGER=$(which dnf || which yum)
58 INSTALLER_CMD="sudo -H -E ${PKG_MANAGER} -y install"
64 [libopenssl]=openssl-devel
67 [python-devel]=python-devel
68 [venv]=python-virtualenv
73 echo "ERROR: Supported package manager not found. Supported: apt,yum,zypper"
76 if ! $(python --version &>/dev/null); then
77 ${INSTALLER_CMD} ${PKG_MAP[python]}
79 if ! $(gcc -v &>/dev/null); then
80 ${INSTALLER_CMD} ${PKG_MAP[gcc]}
82 if ! $(git --version &>/dev/null); then
83 ${INSTALLER_CMD} ${PKG_MAP[git]}
85 if ! $(wget --version &>/dev/null); then
86 ${INSTALLER_CMD} ${PKG_MAP[wget]}
89 for pkg in ${CHECK_CMD_PKGS[@]}; do
90 if ! $(${CHECK_CMD} ${PKG_MAP[$pkg]} &>/dev/null); then
91 ${INSTALLER_CMD} ${PKG_MAP[$pkg]}
95 if [ -n "${EXTRA_PKG_DEPS-}" ]; then
96 for pkg in ${EXTRA_PKG_DEPS}; do
97 if ! $(${CHECK_CMD} ${pkg} &>/dev/null); then
98 ${INSTALLER_CMD} ${pkg}
103 # If we're using a venv, we need to work around sudo not
104 # keeping the path even with -E.
105 PYTHON=$(which python)
107 # To install python packages, we need pip.
109 # We can't use the apt packaged version of pip since
110 # older versions of pip are incompatible with
111 # requests, one of our indirect dependencies (bug 1459947).
113 # Note(cinerama): We use pip to install an updated pip plus our
114 # other python requirements. pip breakages can seriously impact us,
115 # so we've chosen to install/upgrade pip here rather than in
116 # requirements (which are synced automatically from the global ones)
117 # so we can quickly and easily adjust version parameters.
120 # Note(cinerama): If pip is linked to pip3, the rest of the install
121 # won't work. Remove the alternatives. This is due to ansible's
122 # python 2.x requirement.
123 if [[ $(readlink -f /etc/alternatives/pip) =~ "pip3" ]]; then
124 sudo -H update-alternatives --remove pip $(readlink -f /etc/alternatives/pip)
128 wget -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py
129 sudo -H -E ${PYTHON} /tmp/get-pip.py
134 sudo -H -E ${PIP} install "pip>6.0"
136 pip install ansible==$XCI_ANSIBLE_PIP_VERSION