11#! /bin/bash
2- # This hook installs the centos dependencies needed to run the charm,
2+ # This hook installs the dependencies needed to run the charm,
33# creates the dispatch executable, regenerates the symlinks for start and
44# upgrade-charm, and kicks off the operator framework.
55
66set -e
77
8- # Source the os-release information into the env.
8+ # Source the os-release information into the env
99. /etc/os-release
1010
1111if ! [[ -f ' .installed' ]]
1212then
13- # Determine if we are running in centos or ubuntu, if centos
14- # provision the needed prereqs.
15- if [[ $ID == ' ubuntu' ]]
16- then
17- echo " Running Ubuntu."
18- # necessary to compile and install NHC
19- apt-get install --assume-yes make automake
20- elif [[ $ID == ' centos' ]]
21- then
22- # Determine the centos version and install prereqs accordingly
23- major=$( cat /etc/centos-release | tr -dc ' 0-9.' | cut -d \. -f1)
24- echo " Running CentOS$major , installing prereqs."
25- if [[ $major == " 7" ]]
26- then
27- yum -y install epel-release
28- yum -y install yum-priorities python3 make automake yum-utils
29- elif [[ $major == " 8" ]]
30- then
31- dnf -y install epel-release
32- dnf -y install yum-priorities python3 make automake yum-utils
33- else
34- echo " Running unsuppored version of centos: $major "
35- exit -1
36- fi
37- elif [[ $ID == ' rocky' ]]
13+
14+ # Rocky specific setup
15+ if [[ $ID == ' rocky' ]]
3816 then
3917 dnf install epel-release -y
4018 dnf install dnf-plugins-core -y
4119 dnf config-manager --set-enabled powertools -y
42- dnf install make automake yum-utils -y
43- else
44- echo " Running unsuppored os: $ID "
45- exit -1
4620 fi
21+
22+ if [[ $ID == ' centos' || $ID == ' rocky' ]]
23+ then
24+ # Install dependencies
25+ yum -y install epel-release
26+ yum -y install yum-priorities python3 automake yum-utils
27+
28+ # Install dependencies and build custom python
29+ yum -y install wget gcc make tar bzip2-devel zlib-devel xz-devel openssl-devel libffi-devel sqlite-devel ncurses-devel
30+
31+ export PYTHON_VERSION=3.8.16
32+ wget https://www.python.org/ftp/python/${PYTHON_VERSION} /Python-${PYTHON_VERSION} .tar.xz -P /tmp
33+ tar xvf /tmp/Python-${PYTHON_VERSION} .tar.xz -C /tmp
34+ cd /tmp/Python-${PYTHON_VERSION}
35+ ./configure --prefix=/opt/python/python3.8 --enable-optimizations
36+ make -C /tmp/Python-${PYTHON_VERSION} -j $( nproc) altinstall
37+ cd $OLDPWD
38+ rm -rf /tmp/Python*
39+
40+ # set the correct python bin path
41+ PYTHON_BIN=" /opt/python/python3.8/bin/python3.8"
42+ elif [[ $ID == ' ubuntu' ]]
43+ then
44+ # Necessary to compile and install NHC
45+ apt-get install --assume-yes make
46+
47+ # set the correct python bin path
48+ PYTHON_BIN=" /usr/bin/env python3"
49+ fi
50+
4751 touch .installed
4852fi
4953
50- JUJU_DISPATCH_PATH=" ${JUJU_DISPATCH_PATH:- $0 } " PYTHONPATH=lib:venv ./src/charm.py
54+
55+ JUJU_DISPATCH_PATH=" ${JUJU_DISPATCH_PATH:- $0 } " PYTHONPATH=lib:venv $PYTHON_BIN ./src/charm.py
0 commit comments