blob: d3a63602b84b8fab3254843ac2f0377dde5ab31e [file] [log] [blame]
Dean Troyer9acc12a2013-08-09 15:09:31 -05001#!/usr/bin/env bash
2
3# **fixup_stuff.sh**
4
5# fixup_stuff.sh
6#
7# All distro and package specific hacks go in here
Adam Spierscb961592013-10-05 12:11:07 +01008#
Dean Troyer9acc12a2013-08-09 15:09:31 -05009# - prettytable 0.7.2 permissions are 600 in the package and
10# pip 1.4 doesn't fix it (1.3 did)
Adam Spierscb961592013-10-05 12:11:07 +010011#
Dean Troyer9acc12a2013-08-09 15:09:31 -050012# - httplib2 0.8 permissions are 600 in the package and
13# pip 1.4 doesn't fix it (1.3 did)
Adam Spierscb961592013-10-05 12:11:07 +010014#
Dean Troyer49ba2242013-08-09 19:51:20 -050015# - RHEL6:
Adam Spierscb961592013-10-05 12:11:07 +010016#
Dean Troyer49ba2242013-08-09 19:51:20 -050017# - set selinux not enforcing
18# - (re)start messagebus daemon
19# - remove distro packages python-crypto and python-lxml
20# - pre-install hgtools to work around a bug in RHEL6 distribute
21# - install nose 1.1 from EPEL
22
Adam Spiersc85ade72013-10-01 00:35:16 +010023set -o errexit
24set -o xtrace
Dean Troyer9acc12a2013-08-09 15:09:31 -050025
26# Keep track of the current directory
27TOOLS_DIR=$(cd $(dirname "$0") && pwd)
Dean Troyer49ba2242013-08-09 19:51:20 -050028TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
Dean Troyer9acc12a2013-08-09 15:09:31 -050029
30# Change dir to top of devstack
31cd $TOP_DIR
32
33# Import common functions
34source $TOP_DIR/functions
35
36FILES=$TOP_DIR/files
37
Morgan Fainberg6cae83e2014-06-12 15:08:48 -070038# Keystone Port Reservation
39# -------------------------
40# Reserve and prevent $KEYSTONE_AUTH_PORT and $KEYSTONE_AUTH_PORT_INT from
41# being used as ephemeral ports by the system. The default(s) are 35357 and
42# 35358 which are in the Linux defined ephemeral port range (in disagreement
43# with the IANA ephemeral port range). This is a workaround for bug #1253482
44# where Keystone will try and bind to the port and the port will already be
45# in use as an ephemeral port by another process. This places an explicit
46# exception into the Kernel for the Keystone AUTH ports.
47keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358}
48
49# Get any currently reserved ports, strip off leading whitespace
50reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //')
51
52if [[ -z "${reserved_ports}" ]]; then
53 # If there are no currently reserved ports, reserve the keystone ports
54 sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports}
55else
56 # If there are currently reserved ports, keep those and also reserve the
57 # keystone specific ports. Duplicate reservations are merged into a single
58 # reservation (or range) automatically by the kernel.
59 sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports}
60fi
61
Dean Troyer49ba2242013-08-09 19:51:20 -050062
63# Python Packages
64# ---------------
65
Dean Troyer65f1af62013-10-16 12:10:13 -050066# get_package_path python-package # in import notation
Ian Wienandaee18c72014-02-21 15:35:08 +110067function get_package_path {
Dean Troyer65f1af62013-10-16 12:10:13 -050068 local package=$1
69 echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])")
70}
71
72
Dean Troyer9acc12a2013-08-09 15:09:31 -050073# Pre-install affected packages so we can fix the permissions
Dean Troyer65f1af62013-10-16 12:10:13 -050074# These can go away once we are confident that pip 1.4.1+ is available everywhere
75
76# Fix prettytable 0.7.2 permissions
77# Don't specify --upgrade so we use the existing package if present
Attila Fazekas3a823192013-11-24 18:53:20 +010078pip_install 'prettytable>0.7'
Dean Troyer65f1af62013-10-16 12:10:13 -050079PACKAGE_DIR=$(get_package_path prettytable)
80# Only fix version 0.7.2
81dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*)
82if [[ -d $dir ]]; then
83 sudo chmod +r $dir/*
84fi
85
86# Fix httplib2 0.8 permissions
87# Don't specify --upgrade so we use the existing package if present
Aaron Rosen1e4551d2013-09-16 13:58:08 -070088pip_install httplib2
Dean Troyer65f1af62013-10-16 12:10:13 -050089PACKAGE_DIR=$(get_package_path httplib2)
90# Only fix version 0.8
91dir=$(echo $PACKAGE_DIR-0.8*)
92if [[ -d $dir ]]; then
93 sudo chmod +r $dir/*
94fi
Dean Troyer49ba2242013-08-09 19:51:20 -050095
Sean Dagued8416d72014-01-27 15:36:06 -050096# Ubuntu 12.04
Dean Troyerd8864fe2014-02-17 11:00:42 -060097# ------------
98
Sean Dagued8416d72014-01-27 15:36:06 -050099# We can regularly get kernel crashes on the 12.04 default kernel, so attempt
100# to install a new kernel
101if [[ ${DISTRO} =~ (precise) ]]; then
102 # Finally, because we suspect the Precise kernel is problematic, install a new kernel
103 UPGRADE_KERNEL=$(trueorfalse False $UPGRADE_KERNEL)
104 if [[ $UPGRADE_KERNEL == "True" ]]; then
105 if [[ ! `uname -r` =~ (^3\.11) ]]; then
106 apt_get install linux-generic-lts-saucy
107 echo "Installing Saucy LTS kernel, please reboot before proceeding"
108 exit 1
109 fi
110 fi
111fi
112
Dean Troyer49ba2242013-08-09 19:51:20 -0500113
114# RHEL6
115# -----
116
117if [[ $DISTRO =~ (rhel6) ]]; then
118
119 # Disable selinux to avoid configuring to allow Apache access
Gonéri Le Bouder394c11c2013-11-05 10:35:55 +0100120 # to Horizon files (LP#1175444)
Dean Troyer49ba2242013-08-09 19:51:20 -0500121 if selinuxenabled; then
122 sudo setenforce 0
123 fi
124
125 # If the ``dbus`` package was installed by DevStack dependencies the
126 # uuid may not be generated because the service was never started (PR#598200),
127 # causing Nova to stop later on complaining that ``/var/lib/dbus/machine-id``
128 # does not exist.
129 sudo service messagebus restart
130
131 # The following workarounds break xenserver
132 if [ "$VIRT_DRIVER" != 'xenserver' ]; then
133 # An old version of ``python-crypto`` (2.0.1) may be installed on a
134 # fresh system via Anaconda and the dependency chain
135 # ``cas`` -> ``python-paramiko`` -> ``python-crypto``.
136 # ``pip uninstall pycrypto`` will remove the packaged ``.egg-info``
Adam Spierscb961592013-10-05 12:11:07 +0100137 # file but leave most of the actual library files behind in
Dean Troyer49ba2242013-08-09 19:51:20 -0500138 # ``/usr/lib64/python2.6/Crypto``. Later ``pip install pycrypto``
139 # will install over the packaged files resulting
140 # in a useless mess of old, rpm-packaged files and pip-installed files.
141 # Remove the package so that ``pip install python-crypto`` installs
142 # cleanly.
143 # Note: other RPM packages may require ``python-crypto`` as well.
144 # For example, RHEL6 does not install ``python-paramiko packages``.
145 uninstall_package python-crypto
146
147 # A similar situation occurs with ``python-lxml``, which is required by
148 # ``ipa-client``, an auditing package we don't care about. The
149 # build-dependencies needed for ``pip install lxml`` (``gcc``,
150 # ``libxml2-dev`` and ``libxslt-dev``) are present in
151 # ``files/rpms/general``.
152 uninstall_package python-lxml
153 fi
154
155 # ``setup.py`` contains a ``setup_requires`` package that is supposed
156 # to be transient. However, RHEL6 distribute has a bug where
157 # ``setup_requires`` registers entry points that are not cleaned
158 # out properly after the setup-phase resulting in installation failures
159 # (bz#924038). Pre-install the problem package so the ``setup_requires``
160 # dependency is satisfied and it will not be installed transiently.
161 # Note we do this before the track-depends in ``stack.sh``.
162 pip_install hgtools
163
164
165 # RHEL6's version of ``python-nose`` is incompatible with Tempest.
166 # Install nose 1.1 (Tempest-compatible) from EPEL
167 install_package python-nose1.1
168 # Add a symlink for the new nosetests to allow tox for Tempest to
169 # work unmolested.
170 sudo ln -sf /usr/bin/nosetests1.1 /usr/local/bin/nosetests
171
Attila Fazekas522cfe02014-04-11 11:14:07 +0200172 # workaround for https://code.google.com/p/unittest-ext/issues/detail?id=79
173 install_package python-unittest2 patch
174 pip_install discover
175 (cd /usr/lib/python2.6/site-packages/; sudo patch <"$FILES/patches/unittest2-discover.patch" || echo 'Assume already applied')
176 # Make sure the discover.pyc is up to date
177 sudo rm /usr/lib/python2.6/site-packages/discover.pyc || true
178 sudo python -c 'import discover'
Dean Troyer49ba2242013-08-09 19:51:20 -0500179fi