66206d0b27
This change does the following: - Removes the centos7 job, it uses python2 even though python2 was dropped from IPA in 2019. (see Ifd0e0b99bb82a7d7e82d6c14309468196f5734fc) - Allow 60-ironic-python-agent-ramdisk-install to assume python3 and the venv module, the remaining centos7-python3 job will also test this - Replaces the pip-and-virtualenv element with ensure-venv. pip-and-virtualenv exists to install virtualenv for python2 environments, and it is unmaintained and mostly technical debt. Change-Id: I9b6e03f50a4eb2484a04748e51d7348401b6ca04
76 lines
2.6 KiB
Bash
Executable File
76 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
SCRIPTDIR=$(dirname $0)
|
|
IPADIR=/tmp/ironic-python-agent
|
|
IRLIBDIR=/tmp/ironic-lib
|
|
UPPER_CONSTRAINTS=/tmp/requirements/upper-constraints.txt
|
|
VENVDIR=/opt/ironic-python-agent
|
|
|
|
# create the virtual environment using the default python
|
|
python3 -m venv $VENVDIR
|
|
REQUIRED_PIP_STR="21.3.1"
|
|
REQUIRED_PIP_TUPLE="(21, 3, 1)"
|
|
|
|
HAS_PIP=$($VENVDIR/bin/python -c \
|
|
"import pip; print(tuple(map(int, pip.__version__.split('.'))) >= $REQUIRED_PIP_TUPLE)")
|
|
if [ $HAS_PIP == "False" ]; then
|
|
# NOTE(dtantsur): use a fixed version to avoid breakages
|
|
$VENVDIR/bin/pip install "pip==$REQUIRED_PIP_STR"
|
|
fi
|
|
|
|
# Upgrade setuptools package for openSuse and in virtualenvs using Python 2.x
|
|
# NOTE(rpittau): if we want to keep compatibility with Python 2.x, we need to
|
|
# upgrade setuptools in the virtualenv as the default installed has issues
|
|
# when parsing requirements.
|
|
if [ "$DISTRO_NAME" == "opensuse" ]; then
|
|
$VENVDIR/bin/pip install -U setuptools
|
|
fi
|
|
|
|
# For aarch64 platform, it seems it always tries to build wheels first for
|
|
# python packages which have no wheels in PyPi. Although it will install the
|
|
# source packages successfully at last.
|
|
if [[ "$ARCH" =~ (arm64|aarch64) ]]; then
|
|
$VENVDIR/bin/pip install wheel
|
|
fi
|
|
|
|
# install IPA inside the virtual environment
|
|
$VENVDIR/bin/pip install -c $UPPER_CONSTRAINTS $IPADIR
|
|
ln -s $VENVDIR/bin/ironic-python-agent /usr/local/bin/
|
|
ln -s $VENVDIR/bin/ironic-collect-introspection-data /usr/local/bin/
|
|
|
|
# install ironic-lib from source if requested
|
|
if [ ${IRONIC_LIB_FROM_SOURCE:-false} == "true" ]; then
|
|
$VENVDIR/bin/pip install -c $UPPER_CONSTRAINTS -r $IRLIBDIR/requirements.txt
|
|
$VENVDIR/bin/pip install $IRLIBDIR
|
|
fi
|
|
|
|
case "$DIB_INIT_SYSTEM" in
|
|
upstart)
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.conf /etc/init/ironic-python-agent.conf
|
|
;;
|
|
systemd)
|
|
install -D -g root -o root -m 0644 ${SCRIPTDIR}/ironic-python-agent.service /usr/lib/systemd/system/ironic-python-agent.service
|
|
;;
|
|
sysv)
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.init /etc/init.d/ironic-python-agent.init
|
|
update-rc.d ironic-python-agent.init defaults
|
|
;;
|
|
*)
|
|
echo "Unsupported init system"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Copying the self signed certificate for request library
|
|
if [ -f /tmp/in_target.d/ipa-trusted-cert.pem ]; then
|
|
cat /tmp/in_target.d/ipa-trusted-cert.pem >> $($VENVDIR/bin/python -c "import requests; print(requests.certs.where())")
|
|
fi
|