| 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 |  | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 23 | # If TOP_DIR is set we're being sourced rather than running stand-alone | 
|  | 24 | # or in a sub-shell | 
|  | 25 | if [[ -z "$TOP_DIR" ]]; then | 
|  | 26 | set -o errexit | 
|  | 27 | set -o xtrace | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 28 |  | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 29 | # Keep track of the current directory | 
|  | 30 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) | 
|  | 31 | TOP_DIR=$(cd $TOOLS_DIR/..; pwd) | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 32 |  | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 33 | # Change dir to top of devstack | 
|  | 34 | cd $TOP_DIR | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 35 |  | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 36 | # Import common functions | 
|  | 37 | source $TOP_DIR/functions | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 38 |  | 
| Dean Troyer | 04a3511 | 2014-08-15 14:03:52 -0500 | [diff] [blame] | 39 | FILES=$TOP_DIR/files | 
|  | 40 | fi | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 41 |  | 
| Morgan Fainberg | 6cae83e | 2014-06-12 15:08:48 -0700 | [diff] [blame] | 42 | # Keystone Port Reservation | 
|  | 43 | # ------------------------- | 
|  | 44 | # Reserve and prevent $KEYSTONE_AUTH_PORT and $KEYSTONE_AUTH_PORT_INT from | 
|  | 45 | # being used as ephemeral ports by the system. The default(s) are 35357 and | 
|  | 46 | # 35358 which are in the Linux defined ephemeral port range (in disagreement | 
|  | 47 | # with the IANA ephemeral port range). This is a workaround for bug #1253482 | 
|  | 48 | # where Keystone will try and bind to the port and the port will already be | 
|  | 49 | # in use as an ephemeral port by another process. This places an explicit | 
|  | 50 | # exception into the Kernel for the Keystone AUTH ports. | 
|  | 51 | keystone_ports=${KEYSTONE_AUTH_PORT:-35357},${KEYSTONE_AUTH_PORT_INT:-35358} | 
|  | 52 |  | 
|  | 53 | # Get any currently reserved ports, strip off leading whitespace | 
|  | 54 | reserved_ports=$(sysctl net.ipv4.ip_local_reserved_ports | awk -F'=' '{print $2;}' | sed 's/^ //') | 
|  | 55 |  | 
|  | 56 | if [[ -z "${reserved_ports}" ]]; then | 
|  | 57 | # If there are no currently reserved ports, reserve the keystone ports | 
|  | 58 | sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports} | 
|  | 59 | else | 
|  | 60 | # If there are currently reserved ports, keep those and also reserve the | 
|  | 61 | # keystone specific ports. Duplicate reservations are merged into a single | 
|  | 62 | # reservation (or range) automatically by the kernel. | 
|  | 63 | sudo sysctl -w net.ipv4.ip_local_reserved_ports=${keystone_ports},${reserved_ports} | 
|  | 64 | fi | 
|  | 65 |  | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 66 |  | 
|  | 67 | # Python Packages | 
|  | 68 | # --------------- | 
|  | 69 |  | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 70 | # get_package_path python-package    # in import notation | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 71 | function get_package_path { | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 72 | local package=$1 | 
|  | 73 | echo $(python -c "import os; import $package; print(os.path.split(os.path.realpath($package.__file__))[0])") | 
|  | 74 | } | 
|  | 75 |  | 
|  | 76 |  | 
| Dean Troyer | 9acc12a | 2013-08-09 15:09:31 -0500 | [diff] [blame] | 77 | # Pre-install affected packages so we can fix the permissions | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 78 | # These can go away once we are confident that pip 1.4.1+ is available everywhere | 
|  | 79 |  | 
|  | 80 | # Fix prettytable 0.7.2 permissions | 
|  | 81 | # Don't specify --upgrade so we use the existing package if present | 
| Attila Fazekas | 3a82319 | 2013-11-24 18:53:20 +0100 | [diff] [blame] | 82 | pip_install 'prettytable>0.7' | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 83 | PACKAGE_DIR=$(get_package_path prettytable) | 
|  | 84 | # Only fix version 0.7.2 | 
|  | 85 | dir=$(echo $PACKAGE_DIR/prettytable-0.7.2*) | 
|  | 86 | if [[ -d $dir ]]; then | 
|  | 87 | sudo chmod +r $dir/* | 
|  | 88 | fi | 
|  | 89 |  | 
|  | 90 | # Fix httplib2 0.8 permissions | 
|  | 91 | # Don't specify --upgrade so we use the existing package if present | 
| Aaron Rosen | 1e4551d | 2013-09-16 13:58:08 -0700 | [diff] [blame] | 92 | pip_install httplib2 | 
| Dean Troyer | 65f1af6 | 2013-10-16 12:10:13 -0500 | [diff] [blame] | 93 | PACKAGE_DIR=$(get_package_path httplib2) | 
|  | 94 | # Only fix version 0.8 | 
|  | 95 | dir=$(echo $PACKAGE_DIR-0.8*) | 
|  | 96 | if [[ -d $dir ]]; then | 
|  | 97 | sudo chmod +r $dir/* | 
|  | 98 | fi | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 99 |  | 
| Attila Fazekas | d7967a4 | 2014-06-12 11:41:54 +0200 | [diff] [blame] | 100 | if is_fedora; then | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 101 | # Disable selinux to avoid configuring to allow Apache access | 
| Gonéri Le Bouder | 394c11c | 2013-11-05 10:35:55 +0100 | [diff] [blame] | 102 | # to Horizon files (LP#1175444) | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 103 | if selinuxenabled; then | 
|  | 104 | sudo setenforce 0 | 
|  | 105 | fi | 
| Dean Troyer | 85ebb3a | 2014-08-19 10:54:59 -0500 | [diff] [blame] | 106 |  | 
|  | 107 | FORCE_FIREWALLD=$(trueorfalse False $FORCE_FIREWALLD) | 
|  | 108 | if [[ ${DISTRO} =~ (f19|f20) && $FORCE_FIREWALLD == "False" ]]; then | 
|  | 109 | # On Fedora 19 and 20 firewalld interacts badly with libvirt and | 
|  | 110 | # slows things down significantly.  However, for those cases | 
|  | 111 | # where that combination is desired, allow this fix to be skipped. | 
|  | 112 |  | 
|  | 113 | # There was also an additional issue with firewalld hanging | 
|  | 114 | # after install of libvirt with polkit.  See | 
|  | 115 | # https://bugzilla.redhat.com/show_bug.cgi?id=1099031 | 
|  | 116 | if is_package_installed firewalld; then | 
|  | 117 | uninstall_package firewalld | 
|  | 118 | fi | 
|  | 119 | fi | 
|  | 120 |  | 
| Attila Fazekas | d7967a4 | 2014-06-12 11:41:54 +0200 | [diff] [blame] | 121 | fi | 
|  | 122 |  | 
|  | 123 | # RHEL6 | 
|  | 124 | # ----- | 
|  | 125 |  | 
|  | 126 | if [[ $DISTRO =~ (rhel6) ]]; then | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 127 |  | 
| Ian Wienand | 8fdb42f | 2014-07-30 11:27:54 +1000 | [diff] [blame] | 128 | # install_pip.sh installs the latest setuptools over the packaged | 
|  | 129 | # version.  We can't really uninstall the packaged version if it | 
|  | 130 | # is there, because it may remove other important things like | 
|  | 131 | # cloud-init.  Things work, but there can be an old egg file left | 
|  | 132 | # around from the package that causes some really strange | 
|  | 133 | # setuptools errors.  Remove it, if it is there | 
|  | 134 | sudo rm -f /usr/lib/python2.6/site-packages/setuptools-0.6*.egg-info | 
|  | 135 |  | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 136 | # If the ``dbus`` package was installed by DevStack dependencies the | 
|  | 137 | # uuid may not be generated because the service was never started (PR#598200), | 
|  | 138 | # causing Nova to stop later on complaining that ``/var/lib/dbus/machine-id`` | 
|  | 139 | # does not exist. | 
|  | 140 | sudo service messagebus restart | 
|  | 141 |  | 
|  | 142 | # The following workarounds break xenserver | 
|  | 143 | if [ "$VIRT_DRIVER" != 'xenserver' ]; then | 
|  | 144 | # An old version of ``python-crypto`` (2.0.1) may be installed on a | 
|  | 145 | # fresh system via Anaconda and the dependency chain | 
|  | 146 | # ``cas`` -> ``python-paramiko`` -> ``python-crypto``. | 
|  | 147 | # ``pip uninstall pycrypto`` will remove the packaged ``.egg-info`` | 
| Adam Spiers | cb96159 | 2013-10-05 12:11:07 +0100 | [diff] [blame] | 148 | # file but leave most of the actual library files behind in | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 149 | # ``/usr/lib64/python2.6/Crypto``. Later ``pip install pycrypto`` | 
|  | 150 | # will install over the packaged files resulting | 
|  | 151 | # in a useless mess of old, rpm-packaged files and pip-installed files. | 
|  | 152 | # Remove the package so that ``pip install python-crypto`` installs | 
|  | 153 | # cleanly. | 
|  | 154 | # Note: other RPM packages may require ``python-crypto`` as well. | 
|  | 155 | # For example, RHEL6 does not install ``python-paramiko packages``. | 
|  | 156 | uninstall_package python-crypto | 
|  | 157 |  | 
|  | 158 | # A similar situation occurs with ``python-lxml``, which is required by | 
|  | 159 | # ``ipa-client``, an auditing package we don't care about.  The | 
|  | 160 | # build-dependencies needed for ``pip install lxml`` (``gcc``, | 
|  | 161 | # ``libxml2-dev`` and ``libxslt-dev``) are present in | 
|  | 162 | # ``files/rpms/general``. | 
|  | 163 | uninstall_package python-lxml | 
|  | 164 | fi | 
|  | 165 |  | 
|  | 166 | # ``setup.py`` contains a ``setup_requires`` package that is supposed | 
|  | 167 | # to be transient.  However, RHEL6 distribute has a bug where | 
|  | 168 | # ``setup_requires`` registers entry points that are not cleaned | 
|  | 169 | # out properly after the setup-phase resulting in installation failures | 
|  | 170 | # (bz#924038).  Pre-install the problem package so the ``setup_requires`` | 
|  | 171 | # dependency is satisfied and it will not be installed transiently. | 
|  | 172 | # Note we do this before the track-depends in ``stack.sh``. | 
|  | 173 | pip_install hgtools | 
|  | 174 |  | 
|  | 175 |  | 
|  | 176 | # RHEL6's version of ``python-nose`` is incompatible with Tempest. | 
|  | 177 | # Install nose 1.1 (Tempest-compatible) from EPEL | 
|  | 178 | install_package python-nose1.1 | 
|  | 179 | # Add a symlink for the new nosetests to allow tox for Tempest to | 
|  | 180 | # work unmolested. | 
|  | 181 | sudo ln -sf /usr/bin/nosetests1.1 /usr/local/bin/nosetests | 
|  | 182 |  | 
| Attila Fazekas | 522cfe0 | 2014-04-11 11:14:07 +0200 | [diff] [blame] | 183 | # workaround for https://code.google.com/p/unittest-ext/issues/detail?id=79 | 
|  | 184 | install_package python-unittest2 patch | 
|  | 185 | pip_install discover | 
|  | 186 | (cd /usr/lib/python2.6/site-packages/; sudo patch <"$FILES/patches/unittest2-discover.patch" || echo 'Assume already applied') | 
|  | 187 | # Make sure the discover.pyc is up to date | 
|  | 188 | sudo rm /usr/lib/python2.6/site-packages/discover.pyc || true | 
|  | 189 | sudo python -c 'import discover' | 
| Dean Troyer | 49ba224 | 2013-08-09 19:51:20 -0500 | [diff] [blame] | 190 | fi |