[Bindep]Use bindep lib to install system packages
1.Fix install_rally.sh.Move all system packages from install_rally.sh script to separate file bindep.txt add call to bindep from install_rally.sh script 2.Add bindep command to tox.ini, we can use "tox -e bindep" to check the required system packages which is missing. 3.Install bindep when running Dockerfile Change-Id: If4568c22d3b4f1c393c217d935cda233bd41d45e
This commit is contained in:
parent
8f83ee724a
commit
8fab84b3cb
@ -2,7 +2,7 @@ FROM ubuntu:16.04
|
||||
MAINTAINER Sergey Skripnick <sskripnick@mirantis.com>
|
||||
|
||||
# install prereqs
|
||||
RUN apt-get update && apt-get install --yes wget python vim bash-completion gcc
|
||||
RUN apt-get update && apt-get install --yes wget python vim bash-completion gcc lsb-release
|
||||
|
||||
# ubuntu's pip is too old to work with the version of requests we
|
||||
# require, so get pip with get-pip.py
|
||||
@ -10,6 +10,9 @@ RUN wget https://bootstrap.pypa.io/get-pip.py && \
|
||||
python get-pip.py && \
|
||||
rm -f get-pip.py
|
||||
|
||||
# install bindep
|
||||
RUN pip install bindep
|
||||
|
||||
# create rally user
|
||||
RUN apt-get install sudo && \
|
||||
useradd -u 65500 -m rally && \
|
||||
|
23
bindep.txt
Normal file
23
bindep.txt
Normal file
@ -0,0 +1,23 @@
|
||||
# This is a cross-platform list tracking distribution packages needed by tests;
|
||||
# see http://docs.openstack.org/infra/bindep/ for additional information.
|
||||
|
||||
build-essential [platform:dpkg]
|
||||
gcc [platform:rpm]
|
||||
git
|
||||
gmp-devel [platform:rpm]
|
||||
libffi-dev [platform:dpkg]
|
||||
libffi-devel [platform:rpm !platform:opensuse]
|
||||
libffi48-devel [platform:opensuse]
|
||||
libpq-dev [platform:dpkg]
|
||||
libssl-dev [platform:dpkg]
|
||||
libxml2-dev [platform:dpkg]
|
||||
libxml2-devel [platform:rpm]
|
||||
libxslt1-dev [platform:dpkg]
|
||||
libxslt-devel [platform:rpm]
|
||||
openssl-devel [platform:rpm]
|
||||
postgresql-devel [platform:rpm !platform:opensuse]
|
||||
postgresql93-devel [platform:opensuse]
|
||||
python-dev [platform:dpkg]
|
||||
python-devel [platform:rpm]
|
||||
redhat-rpm-config [platform:rpm]
|
||||
wget
|
@ -22,6 +22,7 @@ ASKCONFIRMATION=1
|
||||
RECREATEDEST="ask"
|
||||
USEVIRTUALENV="yes"
|
||||
DEVELOPMENT_MODE="false"
|
||||
SKIP_SW_CHECK=0
|
||||
|
||||
# ansi colors for formatting heredoc
|
||||
ESC=$(printf "\e")
|
||||
@ -246,26 +247,21 @@ __EOF__
|
||||
fi
|
||||
}
|
||||
|
||||
have_sw_package () {
|
||||
# instead of guessing which distribution this is, we check for the
|
||||
# package manager name as it basically identifies the distro
|
||||
if have_command dpkg; then
|
||||
(dpkg -l "$1" | egrep -q ^i ) >/dev/null 2>/dev/null
|
||||
elif have_command rpm; then
|
||||
rpm -q "$1" >/dev/null 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
which_missing_packages () {
|
||||
local missing=''
|
||||
for pkgname in "$@"; do
|
||||
if have_sw_package "$pkgname"; then
|
||||
continue;
|
||||
else
|
||||
missing="$missing $pkgname"
|
||||
if have_command bindep; then
|
||||
if ! missing="$(bindep -b)"; then
|
||||
if [ -z "$missing" ]; then
|
||||
abort $EX_PROTOCOL "Error While running bindep command. Please ensure that required command lsb_release is available."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$missing"
|
||||
else
|
||||
missing="bindep"
|
||||
fi
|
||||
if ! have_command pip; then
|
||||
missing="$missing python-pip"
|
||||
fi
|
||||
echo $missing
|
||||
}
|
||||
|
||||
# Download command
|
||||
@ -273,14 +269,9 @@ download() {
|
||||
wget -nv $VERBOSE --no-check-certificate -O "$@";
|
||||
}
|
||||
|
||||
install_required_sw () {
|
||||
# instead of guessing which distribution this is, we check for the
|
||||
# package manager name as it basically identifies the distro
|
||||
local missing pkg_manager
|
||||
get_pkg_manager () {
|
||||
if have_command apt-get; then
|
||||
# Debian/Ubuntu
|
||||
missing=$(which_missing_packages build-essential libssl-dev libffi-dev python-dev libxml2-dev libxslt1-dev libpq-dev git wget)
|
||||
|
||||
if [ "$ASKCONFIRMATION" -eq 0 ]; then
|
||||
pkg_manager="apt-get install --yes"
|
||||
else
|
||||
@ -288,8 +279,6 @@ install_required_sw () {
|
||||
fi
|
||||
elif have_command dnf; then
|
||||
# dnf based RHEL/CentOS/Fedora
|
||||
missing=$(which_missing_packages gcc libffi-devel python-devel openssl-devel gmp-devel libxml2-devel libxslt-devel postgresql-devel redhat-rpm-config git wget)
|
||||
|
||||
if [ "$ASKCONFIRMATION" -eq 0 ]; then
|
||||
pkg_manager="dnf install -y"
|
||||
else
|
||||
@ -297,8 +286,6 @@ install_required_sw () {
|
||||
fi
|
||||
elif have_command yum; then
|
||||
# yum based RHEL/CentOS/Fedora
|
||||
missing=$(which_missing_packages gcc libffi-devel python-devel openssl-devel gmp-devel libxml2-devel libxslt-devel postgresql-devel redhat-rpm-config git wget)
|
||||
|
||||
if [ "$ASKCONFIRMATION" -eq 0 ]; then
|
||||
pkg_manager="yum install -y"
|
||||
else
|
||||
@ -306,8 +293,6 @@ install_required_sw () {
|
||||
fi
|
||||
elif have_command zypper; then
|
||||
# SuSE
|
||||
missing=$(which_missing_packages gcc libffi48-devel python-devel openssl-devel gmp-devel libxml2-devel libxslt-devel postgresql93-devel git wget)
|
||||
|
||||
if [ "$ASKCONFIRMATION" -eq 0 ]; then
|
||||
pkg_manager="zypper -n --no-gpg-checks --non-interactive install --auto-agree-with-licenses"
|
||||
else
|
||||
@ -317,9 +302,15 @@ install_required_sw () {
|
||||
# MacOSX maybe?
|
||||
echo "Cannot determine what package manager this system has, so I cannot check if requisite software is installed. I'm proceeding anyway, but you may run into errors later."
|
||||
fi
|
||||
if ! have_command pip; then
|
||||
missing="$missing python-pip"
|
||||
fi
|
||||
echo $pkg_manager
|
||||
}
|
||||
|
||||
install_required_sw () {
|
||||
# instead of guessing which distribution this is, we check for the
|
||||
# package manager name as it basically identifies the distro
|
||||
local missing pkg_manager
|
||||
missing=$1
|
||||
pkg_manager=$(get_pkg_manager)
|
||||
|
||||
if [ -n "$missing" ]; then
|
||||
cat <<__EOF__
|
||||
@ -334,7 +325,8 @@ __EOF__
|
||||
In order to install the required software you would need to run as
|
||||
'root' the following command:
|
||||
$GREEN
|
||||
$pkg_manager $missing
|
||||
$(if [[ "$missing" != "bindep" ]]; then echo "$pkg_manager ${missing//bindep/}"; fi)
|
||||
$(if [[ "$missing" == *bindep* ]]; then echo "pip install bindep"; fi)
|
||||
$NO_COLOR
|
||||
__EOF__
|
||||
# ask if we have to install it
|
||||
@ -356,7 +348,14 @@ __EOF__
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if ! $pkg_manager $missing; then
|
||||
if [[ "$missing" == *bindep* ]]; then
|
||||
missing=${missing//bindep/}
|
||||
if ! pip install bindep; then
|
||||
abort $EX_PROTOCOL "Error while installing bindep."
|
||||
fi
|
||||
fi
|
||||
missing=$(echo $missing) # If missing=' ', we must remove the space.
|
||||
if [ -n "$missing" ] && ! $pkg_manager $missing; then
|
||||
abort $EX_UNAVAILABLE "Error while installing $missing"
|
||||
fi
|
||||
# installation successful
|
||||
@ -377,6 +376,7 @@ likely to fail!
|
||||
__EOF__
|
||||
if ask_yn "Proceed with installation anyway?"
|
||||
then
|
||||
SKIP_SW_CHECK=1
|
||||
echo "Proceeding with installation at your request... keep fingers crossed!"
|
||||
else
|
||||
die $EX_UNAVAILABLE "missing software prerequisites" <<__EOF__
|
||||
@ -384,7 +384,8 @@ Please ask your system administrator to install the missing packages,
|
||||
or, if you have root access, you can do that by running the following
|
||||
command from the 'root' account:
|
||||
$GREEN
|
||||
$pkg_manager $missing
|
||||
$(if [[ "$missing" != "bindep" ]]; then echo "$pkg_manager ${missing//bindep/}"; fi)
|
||||
$(if [[ "$missing" == *bindep* ]]; then echo "pip install bindep"; fi)
|
||||
$NO_COLOR
|
||||
__EOF__
|
||||
fi
|
||||
@ -637,7 +638,16 @@ __EOF__
|
||||
fi
|
||||
|
||||
# check and install prerequisites
|
||||
install_required_sw
|
||||
while true; do
|
||||
if [ $SKIP_SW_CHECK -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
missing=$(which_missing_packages)
|
||||
if [ -z "$missing" ]; then
|
||||
break
|
||||
fi
|
||||
install_required_sw "$missing"
|
||||
done
|
||||
require_python
|
||||
|
||||
|
||||
|
8
tox.ini
8
tox.ini
@ -83,3 +83,11 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools,build,setup.py
|
||||
[hacking]
|
||||
import_exceptions = rally.common.i18n
|
||||
local-check-factory = tests.hacking.checks.factory
|
||||
|
||||
[testenv:bindep]
|
||||
# Do not install any requirements. We want this to be fast and work even if
|
||||
# system dependencies are missing, since it's used to tell you what system
|
||||
# dependencies are missing! This also means that bindep must be installed
|
||||
# separately, outside of the requirements files.
|
||||
deps = bindep
|
||||
commands = bindep
|
||||
|
Loading…
Reference in New Issue
Block a user