Export the packages anvil requires.

Export and ensure that we don't remove the
dependencies that anvil and openstack source
directories requires to operate.

- d2to1 is required to even run setup.py
- setuptools-git (the same)
- pbr (the same)

Fixes bug: #1189707

Change-Id: I099856eba07784afa2b65c3e4ebf6c0abcaab4bd
This commit is contained in:
Joshua Harlow 2013-06-10 18:07:27 -07:00
parent 8d8da96137
commit 74127fc2a1
4 changed files with 65 additions and 20 deletions

View File

@ -77,7 +77,6 @@ class DependencyHandler(object):
self.distro = distro
self.root_dir = root_dir
self.instances = instances
self.deps_dir = sh.joinpths(self.root_dir, "deps")
self.download_dir = sh.joinpths(self.deps_dir, "download")
self.log_dir = sh.joinpths(self.deps_dir, "output")
@ -88,10 +87,17 @@ class DependencyHandler(object):
self.pip_executable = str(self.distro.get_command_config('pip'))
self.pips_to_install = []
self.forced_packages = []
# these packages conflict with our deps and must be removed
# These packages conflict with our deps and must be removed
self.nopackages = []
self.package_dirs = self._get_package_dirs(instances)
self.python_names = self._get_python_names(self.package_dirs)
# Instantiate this as late as we can.
self._python_names = None
@property
def python_names(self):
if self._python_names is None:
self._python_names = self._get_python_names(self.package_dirs)
return self._python_names
@staticmethod
def _get_package_dirs(instances):

View File

@ -21,6 +21,7 @@ import sys
from datetime import datetime
from anvil import colorizer
from anvil import env
from anvil import log as logging
from anvil.packaging import base
from anvil.packaging.helpers import pip_helper
@ -412,11 +413,17 @@ BuildArch: noarch
sh.unlink(self.tracereader.filename())
self.tracereader = None
# Don't take out packages that anvil requires to run...
no_remove = os.env.get_key('REQUIRED_PACKAGES', '').split()
no_remove = sorted(set(no_remove))
rpm_names = []
for name in self._convert_names_python2rpm(self.python_names):
if self.helper.is_installed(name):
if self.helper.is_installed(name) and name not in no_remove:
rpm_names.append(name)
if rpm_names:
cmdline = ["yum", "remove", "--remove-leaves", "-y"] + rpm_names
cmdline = ["yum", "remove", "--remove-leaves", "-y"]
for p in no_remove:
cmdline.append("--exclude=%s" % (p))
cmdline.extend(rpm_names)
sh.execute(cmdline, stdout_fh=sys.stdout, stderr_fh=sys.stderr)

46
smithy
View File

@ -13,6 +13,9 @@ PIP_CMD=""
PIP_OPTS=""
RPM_OPTS=""
CURL_OPTS=""
PACKAGES=""
PACKAGE_NAMES=""
CONFLICTS=""
if [ "$VERBOSE" == "0" ]; then
YUM_OPTS="$YUM_OPTS -q"
@ -39,8 +42,22 @@ if [ -z "$BOOT_FILES" ]; then
fi
conflicts() {
echo "Removing conflicting packages $(echo $@)"
yum erase $YUM_OPTS $@
local rpm_name=$1
if [ -n "$rpm_name" ]; then
CONFLICTS="$CONFLICTS $rpm_name"
fi
}
remove_conflicts() {
if [ -z "$CONFLICTS" ]; then
return 0
fi
echo "Removing conflicting packages: $CONFLICTS"
for rpm_name in $CONFLICTS; do
if [ -n $rpm_name ]; then
yum erase $YUM_OPTS $rpm_name
fi
done
}
find_pip()
@ -107,7 +124,8 @@ install_rpm()
{
local rpm_path=$1
local py_name=$2
if [ -n "$rpm_path" ]; then
local always_build=$3
if [ -n "$rpm_path" -a -z "$always_build" ]; then
yum_install "$rpm_path"
if rpm_is_installed "$rpm_path"; then
return 0
@ -154,7 +172,8 @@ bootstrap_packages()
for pkg in $PACKAGES; do
local rpm_name=$(echo $pkg | cut -d: -f1)
local py_name=$(echo $pkg | cut -d: -f2)
install_rpm "$rpm_name" "$py_name"
local always_build=$(echo $pkg | cut -d: -f3)
install_rpm "$rpm_name" "$py_name" "$always_build"
install_status=$?
if [ "$install_status" != 0 ]; then
echo "Error: Installation of package '$rpm_name' failed!"
@ -167,11 +186,13 @@ require()
{
local rpm_name=$1
local py_name=$2
local always_build=$3
if [ -z "$rpm_name" -a -z "$py_name" ]; then
echo "Please specify at RPM or Python package name"
exit 1
fi
PACKAGES="$PACKAGES $rpm_name:$py_name"
PACKAGES="$PACKAGES $rpm_name:$py_name:$always_build"
PACKAGE_NAMES="$PACKAGE_NAMES $rpm_name"
}
needs_bootstrap()
@ -241,6 +262,15 @@ fi
ARGS=""
BOOTSTRAP=false
if [ -f "$BSCONF_FILE" ]; then
source $BSCONF_FILE
fi
# Export these immediatly so that anvil can know about them and it will
# avoid removing them.
export REQUIRED_PACKAGES="$PACKAGE_NAMES"
export CONFLICTING_PACKAGES="$CONFLICTS"
# Ad-hoc getopt to handle long opts.
#
# Smithy opts are consumed while those to anvil are copied through.
@ -274,13 +304,11 @@ if [ "$(id -u)" != "0" ]; then
echo "You must run '$SMITHY_NAME --bootstrap' with root privileges!" >&2
exit 1
fi
if [ ! -f $BSCONF_FILE ]; then
if [ ! -f "$BSCONF_FILE" ]; then
echo "Anvil has not been tested on distribution '$OSNAME'" >&2
puke
fi
echo "Sourcing $BSCONF_FILE"
source $BSCONF_FILE
MIN_RELEASE=${MIN_RELEASE:?"Error: MIN_RELEASE is undefined!"}
SHORTNAME=${SHORTNAME:?"Error: SHORTNAME is undefined!"}
@ -292,6 +320,8 @@ fi
echo "Bootstrapping $SHORTNAME $RELEASE"
echo "Please wait..."
remove_conflicts
for step in ${STEPS:?"Error: STEPS is undefined!"}; do
bootstrap_${step}
if [ $? != 0 ]; then

View File

@ -3,12 +3,13 @@ STEPS="epel packages"
EPEL_RPM_URL="http://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm"
## Bootstrap for Red Hat based distros
conflicts 'python-paste-deploy1.5
python-nose1.1
python-routes1.12
python-sphinx10
python-webob1.0
Django14'
conflicts python-paste-deploy1.5
conflicts python-nose1.1
conflicts python-routes1.12
conflicts python-sphinx10
conflicts python-webob1.0
conflicts Django14
## Package Requirements (Order matters!)
require PyYAML
require gcc
@ -49,4 +50,5 @@ require python-setuptools-git setuptools-git
# This one requires a newer version and the
# current EPEL rpm doesn't provide a version
# that will satisify the desired versions in OpenStack.
require "" d2to1
require python-d2to1 d2to1 true
require python-pbr pbr