| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 1 | #!/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 Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 8 | # | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 9 | # - prettytable 0.7.2 permissions are 600 in the package and | 
|  | 10 | #   pip 1.4 doesn't fix it (1.3 did) | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 11 | # | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 12 | # - httplib2 0.8 permissions are 600 in the package and | 
|  | 13 | #   pip 1.4 doesn't fix it (1.3 did) | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 14 | # | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 15 | # - RHEL6: | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 16 | # | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 17 | #   - 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 Spiers | c85ade7 | 2013-10-01 00:35:16 +0100 | [diff] [blame] | 23 | set -o errexit | 
|  | 24 | set -o xtrace | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 25 |  | 
|  | 26 | # Keep track of the current directory | 
|  | 27 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 28 | TOP_DIR=$(cd $TOOLS_DIR/..; pwd) | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 29 |  | 
|  | 30 | # Change dir to top of devstack | 
|  | 31 | cd $TOP_DIR | 
|  | 32 |  | 
|  | 33 | # Import common functions | 
|  | 34 | source $TOP_DIR/functions | 
|  | 35 |  | 
|  | 36 | FILES=$TOP_DIR/files | 
|  | 37 |  | 
| Morgan Fainberg | 6cae83e | 2014-06-12 15:08:48 -0700 | [diff] [blame] | 38 | # 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. | 
|  | 47 | keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358} | 
|  | 48 |  | 
|  | 49 | # Get any currently reserved ports, strip off leading whitespace | 
|  | 50 | reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //') | 
|  | 51 |  | 
|  | 52 | if [[ -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} | 
|  | 55 | else | 
|  | 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} | 
|  | 60 | fi | 
|  | 61 |  | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 62 |  | 
|  | 63 | # Python Packages | 
|  | 64 | # --------------- | 
|  | 65 |  | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 66 | # get_package_path python-package    # in import notation | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 67 | function get_package_path { | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 68 | 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 Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 73 | # Pre-install affected packages so we can fix the permissions | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 74 | # 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 Fazekas | 3a82319 | 2013-11-24 18:53:20 +0100 | [diff] [blame] | 78 | pip_install 'prettytable>0.7' | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 79 | PACKAGE_DIR=$(get_package_path prettytable) | 
|  | 80 | # Only fix version 0.7.2 | 
|  | 81 | dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*) | 
|  | 82 | if [[ -d $dir ]]; then | 
|  | 83 | sudo chmod +r $dir/* | 
|  | 84 | fi | 
|  | 85 |  | 
|  | 86 | # Fix httplib2 0.8 permissions | 
|  | 87 | # Don't specify --upgrade so we use the existing package if present | 
| Aaron Rosen | 1e4551d | 2013-09-16 13:58:08 -0700 | [diff] [blame] | 88 | pip_install httplib2 | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 89 | PACKAGE_DIR=$(get_package_path httplib2) | 
|  | 90 | # Only fix version 0.8 | 
|  | 91 | dir=$(echo $PACKAGE_DIR-0.8*) | 
|  | 92 | if [[ -d $dir ]]; then | 
|  | 93 | sudo chmod +r $dir/* | 
|  | 94 | fi | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 95 |  | 
| Sean Dague | d8416d7 | 2014-01-27 15:36:06 -0500 | [diff] [blame] | 96 | # Ubuntu 12.04 | 
| Dean Troyer | d8864fe | 2014-02-17 11:00:42 -0600 | [diff] [blame] | 97 | # ------------ | 
|  | 98 |  | 
| Sean Dague | d8416d7 | 2014-01-27 15:36:06 -0500 | [diff] [blame] | 99 | # We can regularly get kernel crashes on the 12.04 default kernel, so attempt | 
|  | 100 | # to install a new kernel | 
|  | 101 | if [[ ${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 | 
|  | 111 | fi | 
|  | 112 |  | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 113 |  | 
| Attila Fazekas | d7967a4 | 2014-06-12 11:41:54 +0200 | [diff] [blame] | 114 | if is_fedora; then | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 115 | # Disable selinux to avoid configuring to allow Apache access | 
| Gonéri Le Bouder | 394c11c | 2013-11-05 10:35:55 +0100 | [diff] [blame] | 116 | # to Horizon files (LP#1175444) | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 117 | if selinuxenabled; then | 
|  | 118 | sudo setenforce 0 | 
|  | 119 | fi | 
| Attila Fazekas | d7967a4 | 2014-06-12 11:41:54 +0200 | [diff] [blame] | 120 | fi | 
|  | 121 |  | 
|  | 122 | # RHEL6 | 
|  | 123 | # ----- | 
|  | 124 |  | 
|  | 125 | if [[ $DISTRO =~ (rhel6) ]]; then | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 126 |  | 
|  | 127 | # If the ``dbus`` package was installed by DevStack dependencies the | 
|  | 128 | # uuid may not be generated because the service was never started (PR#598200), | 
|  | 129 | # causing Nova to stop later on complaining that ``/var/lib/dbus/machine-id`` | 
|  | 130 | # does not exist. | 
|  | 131 | sudo service messagebus restart | 
|  | 132 |  | 
|  | 133 | # The following workarounds break xenserver | 
|  | 134 | if [ "$VIRT_DRIVER" != 'xenserver' ]; then | 
|  | 135 | # An old version of ``python-crypto`` (2.0.1) may be installed on a | 
|  | 136 | # fresh system via Anaconda and the dependency chain | 
|  | 137 | # ``cas`` -> ``python-paramiko`` -> ``python-crypto``. | 
|  | 138 | # ``pip uninstall pycrypto`` will remove the packaged ``.egg-info`` | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 139 | # file but leave most of the actual library files behind in | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 140 | # ``/usr/lib64/python2.6/Crypto``. Later ``pip install pycrypto`` | 
|  | 141 | # will install over the packaged files resulting | 
|  | 142 | # in a useless mess of old, rpm-packaged files and pip-installed files. | 
|  | 143 | # Remove the package so that ``pip install python-crypto`` installs | 
|  | 144 | # cleanly. | 
|  | 145 | # Note: other RPM packages may require ``python-crypto`` as well. | 
|  | 146 | # For example, RHEL6 does not install ``python-paramiko packages``. | 
|  | 147 | uninstall_package python-crypto | 
|  | 148 |  | 
|  | 149 | # A similar situation occurs with ``python-lxml``, which is required by | 
|  | 150 | # ``ipa-client``, an auditing package we don't care about.  The | 
|  | 151 | # build-dependencies needed for ``pip install lxml`` (``gcc``, | 
|  | 152 | # ``libxml2-dev`` and ``libxslt-dev``) are present in | 
|  | 153 | # ``files/rpms/general``. | 
|  | 154 | uninstall_package python-lxml | 
|  | 155 | fi | 
|  | 156 |  | 
|  | 157 | # ``setup.py`` contains a ``setup_requires`` package that is supposed | 
|  | 158 | # to be transient.  However, RHEL6 distribute has a bug where | 
|  | 159 | # ``setup_requires`` registers entry points that are not cleaned | 
|  | 160 | # out properly after the setup-phase resulting in installation failures | 
|  | 161 | # (bz#924038).  Pre-install the problem package so the ``setup_requires`` | 
|  | 162 | # dependency is satisfied and it will not be installed transiently. | 
|  | 163 | # Note we do this before the track-depends in ``stack.sh``. | 
|  | 164 | pip_install hgtools | 
|  | 165 |  | 
|  | 166 |  | 
|  | 167 | # RHEL6's version of ``python-nose`` is incompatible with Tempest. | 
|  | 168 | # Install nose 1.1 (Tempest-compatible) from EPEL | 
|  | 169 | install_package python-nose1.1 | 
|  | 170 | # Add a symlink for the new nosetests to allow tox for Tempest to | 
|  | 171 | # work unmolested. | 
|  | 172 | sudo ln -sf /usr/bin/nosetests1.1 /usr/local/bin/nosetests | 
|  | 173 |  | 
| Attila Fazekas | 522cfe0 | 2014-04-11 11:14:07 +0200 | [diff] [blame] | 174 | # workaround for https://code.google.com/p/unittest-ext/issues/detail?id=79 | 
|  | 175 | install_package python-unittest2 patch | 
|  | 176 | pip_install discover | 
|  | 177 | (cd /usr/lib/python2.6/site-packages/; sudo patch <"$FILES/patches/unittest2-discover.patch" || echo 'Assume already applied') | 
|  | 178 | # Make sure the discover.pyc is up to date | 
|  | 179 | sudo rm /usr/lib/python2.6/site-packages/discover.pyc || true | 
|  | 180 | sudo python -c 'import discover' | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 181 | fi |