blob: 750849db68cceda94358b7e23179aea5521b1ca8 [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
Attila Fazekas1f316be2015-01-26 16:39:57 +01008
Dean Troyer49ba2242013-08-09 19:51:20 -05009
Dean Troyerdc97cb72015-03-28 08:20:50 -050010# If ``TOP_DIR`` is set we're being sourced rather than running stand-alone
Dean Troyer04a35112014-08-15 14:03:52 -050011# or in a sub-shell
12if [[ -z "$TOP_DIR" ]]; then
13 set -o errexit
14 set -o xtrace
Dean Troyer9acc12a2013-08-09 15:09:31 -050015
Dean Troyer04a35112014-08-15 14:03:52 -050016 # Keep track of the current directory
17 TOOLS_DIR=$(cd $(dirname "$0") && pwd)
18 TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
Dean Troyer9acc12a2013-08-09 15:09:31 -050019
Dean Troyerdc97cb72015-03-28 08:20:50 -050020 # Change dir to top of DevStack
Dean Troyer04a35112014-08-15 14:03:52 -050021 cd $TOP_DIR
Dean Troyer9acc12a2013-08-09 15:09:31 -050022
Dean Troyer04a35112014-08-15 14:03:52 -050023 # Import common functions
24 source $TOP_DIR/functions
Dean Troyer9acc12a2013-08-09 15:09:31 -050025
Dean Troyer04a35112014-08-15 14:03:52 -050026 FILES=$TOP_DIR/files
27fi
Dean Troyer9acc12a2013-08-09 15:09:31 -050028
Dean Troyer49ba2242013-08-09 19:51:20 -050029# Python Packages
30# ---------------
31
IWAMOTO Toshihiro4d835e32018-02-05 16:57:41 +090032function fixup_fedora {
33 if ! is_fedora; then
34 return
35 fi
Dean Troyer49ba2242013-08-09 19:51:20 -050036 # Disable selinux to avoid configuring to allow Apache access
Gonéri Le Bouder394c11c2013-11-05 10:35:55 +010037 # to Horizon files (LP#1175444)
Dean Troyer49ba2242013-08-09 19:51:20 -050038 if selinuxenabled; then
39 sudo setenforce 0
40 fi
Dean Troyer85ebb3a2014-08-19 10:54:59 -050041
Ian Wienande82bac02015-08-25 14:29:08 +100042 FORCE_FIREWALLD=$(trueorfalse False FORCE_FIREWALLD)
Ian Wienand3380a162015-05-15 13:12:02 +100043 if [[ $FORCE_FIREWALLD == "False" ]]; then
Kashyap Chamarthy7c9df102015-01-02 18:39:29 +010044 # On Fedora 20 firewalld interacts badly with libvirt and
Ian Wienand3380a162015-05-15 13:12:02 +100045 # slows things down significantly (this issue was fixed in
46 # later fedoras). There was also an additional issue with
47 # firewalld hanging after install of libvirt with polkit [1].
48 # firewalld also causes problems with neturon+ipv6 [2]
49 #
50 # Note we do the same as the RDO packages and stop & disable,
51 # rather than remove. This is because other packages might
52 # have the dependency [3][4].
53 #
54 # [1] https://bugzilla.redhat.com/show_bug.cgi?id=1099031
55 # [2] https://bugs.launchpad.net/neutron/+bug/1455303
56 # [3] https://github.com/redhat-openstack/openstack-puppet-modules/blob/master/firewall/manifests/linux/redhat.pp
Takashi NATSUMEfa007772017-07-22 08:59:43 +090057 # [4] https://docs.openstack.org/devstack/latest/guides/neutron.html
Dean Troyer85ebb3a2014-08-19 10:54:59 -050058 if is_package_installed firewalld; then
Ian Wienand3380a162015-05-15 13:12:02 +100059 sudo systemctl disable firewalld
Ben Nemec64b2ebc2015-06-05 12:22:36 -050060 # The iptables service files are no longer included by default,
61 # at least on a baremetal Fedora 21 Server install.
62 install_package iptables-services
Ian Wienand3380a162015-05-15 13:12:02 +100063 sudo systemctl enable iptables
64 sudo systemctl stop firewalld
65 sudo systemctl start iptables
Dean Troyer85ebb3a2014-08-19 10:54:59 -050066 fi
67 fi
Attila Fazekasc7e772c2015-09-01 15:18:57 +020068
Ian Wienandf0dc93d2018-04-20 10:42:07 +100069 # Since pip10, pip will refuse to uninstall files from packages
70 # that were created with distutils (rather than more modern
71 # setuptools). This is because it technically doesn't have a
72 # manifest of what to remove. However, in most cases, simply
73 # overwriting works. So this hacks around those packages that
74 # have been dragged in by some other system dependency
Carlos Goncalvesb9fe9c72020-08-20 14:42:55 +020075 sudo rm -rf /usr/lib64/python3*/site-packages/PyYAML-*.egg-info
Gregory Thiemongea5d52832021-06-18 13:53:21 +020076
77 # After updating setuptools based on the requirements, the files from the
78 # python3-setuptools RPM are deleted, it breaks some tools such as semanage
79 # (used in diskimage-builder) that use the -s flag of the python
80 # interpreter, enforcing the use of the packages from /usr/lib.
81 # Importing setuptools/pkg_resources in a such environment fails.
82 # Enforce the package re-installation to fix those applications.
83 if is_package_installed python3-setuptools; then
84 sudo dnf reinstall -y python3-setuptools
85 fi
IWAMOTO Toshihiro4d835e32018-02-05 16:57:41 +090086}
Vigneshvar.A.S834b8042015-02-14 01:05:55 +053087
aojeagarciaeb7d1ad2018-09-24 10:17:16 +020088function fixup_suse {
89 if ! is_suse; then
90 return
91 fi
92
Adam Spiers6c7337e2019-08-07 14:34:56 +010093 # Deactivate and disable apparmor profiles in openSUSE and SLE
94 # distros to avoid issues with haproxy and dnsmasq. In newer
95 # releases, systemctl stop apparmor is actually a no-op, so we
96 # have to use aa-teardown to make sure we've deactivated the
97 # profiles:
98 #
99 # https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15/#fate-325343
100 # https://gitlab.com/apparmor/apparmor/merge_requests/81
101 # https://build.opensuse.org/package/view_file/openSUSE:Leap:15.2/apparmor/apparmor.service?expand=1
102 if sudo systemctl is-active -q apparmor; then
103 sudo systemctl stop apparmor
104 fi
105 if [ -x /usr/sbin/aa-teardown ]; then
aojeagarciaeb7d1ad2018-09-24 10:17:16 +0200106 sudo /usr/sbin/aa-teardown
107 fi
Adam Spiers6c7337e2019-08-07 14:34:56 +0100108 if sudo systemctl is-enabled -q apparmor; then
109 sudo systemctl disable apparmor
110 fi
Colleen Murphy10f44092019-02-28 23:44:14 +0100111
112 # Since pip10, pip will refuse to uninstall files from packages
113 # that were created with distutils (rather than more modern
114 # setuptools). This is because it technically doesn't have a
115 # manifest of what to remove. However, in most cases, simply
116 # overwriting works. So this hacks around those packages that
117 # have been dragged in by some other system dependency
118 sudo rm -rf /usr/lib/python3.6/site-packages/ply-*.egg-info
Colleen Murphy6eb2c592019-09-25 12:51:23 -0700119 sudo rm -rf /usr/lib/python3.6/site-packages/six-*.egg-info
Colleen Murphy497caf02020-04-03 10:14:07 -0700120
121 # Ensure trusted CA certificates are up to date
122 # See https://bugzilla.suse.com/show_bug.cgi?id=1154871
123 # May be removed once a new opensuse-15 image is available in nodepool
124 sudo zypper up -y p11-kit ca-certificates-mozilla
aojeagarciaeb7d1ad2018-09-24 10:17:16 +0200125}
126
Lucas Alvares Gomese651d9e2020-11-19 14:50:01 +0000127function fixup_ovn_centos {
128 if [[ $os_VENDOR != "CentOS" ]]; then
129 return
130 fi
131 # OVN packages are part of this release for CentOS
132 yum_install centos-release-openstack-victoria
133}
134
Ian Wienand6b9a5642021-07-28 11:19:57 +1000135function fixup_ubuntu {
136 if ! is_ubuntu; then
137 return
138 fi
139
140 # Since pip10, pip will refuse to uninstall files from packages
141 # that were created with distutils (rather than more modern
142 # setuptools). This is because it technically doesn't have a
143 # manifest of what to remove. However, in most cases, simply
144 # overwriting works. So this hacks around those packages that
145 # have been dragged in by some other system dependency
146 sudo rm -rf /usr/lib/python3/dist-packages/PyYAML-*.egg-info
Dr. Jens Harbott61a37bf2021-10-08 10:59:09 +0200147 sudo rm -rf /usr/lib/python3/dist-packages/pyasn1_modules-*.egg-info
148 sudo rm -rf /usr/lib/python3/dist-packages/simplejson-*.egg-info
Ian Wienand6b9a5642021-07-28 11:19:57 +1000149}
150
Kevin Zhao7880ba62021-03-31 04:58:28 +0000151function fixup_openeuler {
152 if ! is_openeuler; then
153 return
154 fi
155
156 if is_arch "x86_64"; then
157 arch="x86_64"
158 elif is_arch "aarch64"; then
159 arch="aarch64"
160 fi
161
162 # Some packages' version in openEuler are too old, use the newer ones we
163 # provide in oepkg. (oepkg is an openEuler third part yum repo which is
164 # endorsed by openEuler community)
165 (echo '[openstack-ci]'
166 echo 'name=openstack'
167 echo 'baseurl=https://repo.oepkgs.net/openEuler/rpm/openEuler-20.03-LTS-SP2/budding-openeuler/openstack-master-ci/'$arch'/'
168 echo 'enabled=1'
169 echo 'gpgcheck=0') | sudo tee -a /etc/yum.repos.d/openstack-master.repo > /dev/null
170
171 yum_install liberasurecode-devel
172}
173
IWAMOTO Toshihiro4d835e32018-02-05 16:57:41 +0900174function fixup_all {
Ian Wienand6b9a5642021-07-28 11:19:57 +1000175 fixup_ubuntu
IWAMOTO Toshihiro4d835e32018-02-05 16:57:41 +0900176 fixup_fedora
aojeagarciaeb7d1ad2018-09-24 10:17:16 +0200177 fixup_suse
Kevin Zhao7880ba62021-03-31 04:58:28 +0000178 fixup_openeuler
IWAMOTO Toshihiro4d835e32018-02-05 16:57:41 +0900179}