Merge "Install from bindep.txt in plugins"

This commit is contained in:
Zuul 2019-06-21 08:04:35 +00:00 committed by Gerrit Code Review
commit 5e09df086c
3 changed files with 80 additions and 7 deletions

View File

@ -222,14 +222,20 @@ dependency mechanism is beyond the scope of the current work.
System Packages
===============
Devstack provides a framework for getting packages installed at an early
phase of its execution. These packages may be defined in a plugin as files
that contain new-line separated lists of packages required by the plugin
Supported packaging systems include apt and yum across multiple distributions.
To enable a plugin to hook into this and install package dependencies, packages
may be listed at the following locations in the top-level of the plugin
repository:
Devstack based
--------------
Devstack provides a custom framework for getting packages installed at
an early phase of its execution. These packages may be defined in a
plugin as files that contain new-line separated lists of packages
required by the plugin
Supported packaging systems include apt and yum across multiple
distributions. To enable a plugin to hook into this and install
package dependencies, packages may be listed at the following
locations in the top-level of the plugin repository:
- ``./devstack/files/debs/$plugin_name`` - Packages to install when running
on Ubuntu, Debian or Linux Mint.
@ -240,6 +246,42 @@ repository:
- ``./devstack/files/rpms-suse/$plugin_name`` - Packages to install when
running on SUSE Linux or openSUSE.
Although there a no plans to remove this method of installing
packages, plugins should consider it deprecated for ``bindep`` support
described below.
bindep
------
The `bindep <https://docs.openstack.org/infra/bindep>`__ project has
become the defacto standard for OpenStack projects to specify binary
dependencies.
A plugin may provide a ``./devstack/files/bindep.txt`` file, which
will be called with the *default* profile to install packages. For
details on the syntax, etc. see the bindep documentation.
It is also possible to use the ``bindep.txt`` of projects that are
being installed from source with the ``-bindep`` flag available in
install functions. For example
.. code-block:: bash
if use_library_from_git "diskimage-builder"; then
GITREPO["diskimage-builder"]=$DISKIMAGE_BUILDER_REPO_URL
GITDIR["diskimage-builder"]=$DEST/diskimage-builder
GITBRANCH["diskimage-builder"]=$DISKIMAGE_BUILDER_REPO_REF
git_clone_by_name "diskimage-builder"
setup_dev_lib -bindep "diskimage-builder"
fi
will result in any packages required by the ``bindep.txt`` of the
``diskimage-builder`` project being installed. Note however that jobs
that switch projects between source and released/pypi installs
(e.g. with a ``foo-dsvm`` and a ``foo-dsvm-src`` test to cover both
released dependencies and master versions) will have to deal with
``bindep.txt`` being unavailable without the source directory.
Using Plugins in the OpenStack Gate
===================================

View File

@ -1275,6 +1275,30 @@ function get_plugin_packages {
$xtrace
}
# Search plugins for a bindep.txt file
#
# Uses globals ``BINDEP_CMD``, ``GITDIR``, ``DEVSTACK_PLUGINS``
#
# Note this is only valid after BINDEP_CMD is setup in stack.sh, and
# is thus not really intended to be called externally.
function _get_plugin_bindep_packages {
local xtrace
xtrace=$(set +o | grep xtrace)
set +o xtrace
local bindep_file
local packages
for plugin in ${DEVSTACK_PLUGINS//,/ }; do
bindep_file=${GITDIR[$plugin]}/devstack/files/bindep.txt
if [[ -f ${bindep_file} ]]; then
packages+=$($BINDEP_CMD -b --file ${bindep_file} || true)
fi
done
echo "${packages}"
$xtrace
}
# Distro-agnostic package installer
# Uses globals ``NO_UPDATE_REPOS``, ``REPOS_UPDATED``, ``RETRY_UPDATE``
# install_package package [package ...]

View File

@ -809,6 +809,13 @@ install_infra
$VIRTUALENV_CMD $DEST/bindep-venv
# TODO(ianw) : optionally install from zuul checkout?
$DEST/bindep-venv/bin/pip install bindep
export BINDEP_CMD=${DEST}/bindep-venv/bin/bindep
# Install packages as defined in plugin bindep.txt files
pkgs="$( _get_plugin_bindep_packages )"
if [[ -n "${pkgs}" ]]; then
install_package ${pkgs}
fi
# Extras Pre-install
# ------------------