build_hue_common.sh 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. #!/usr/bin/env bash
  2. big_console_header() {
  3. set +x
  4. local text="$*"
  5. local spacing=$(( (75+${#text}) /2 ))
  6. printf "\n\n============================================================================\n"
  7. printf "%*s\n" ${spacing} "${text}"
  8. printf "============================================================================\n\n\n"
  9. set -x
  10. }
  11. is_supported_os() {
  12. local -n _array=$1
  13. local _os=$2
  14. for item in "${_array[@]}"; do
  15. if [[ "$item" == "$_os" ]]; then
  16. return 0
  17. fi
  18. done
  19. return 1
  20. }
  21. is_supported_python_version() {
  22. local PYBIN="$1"
  23. local version="$2"
  24. IFS='.' read -r major minor patch <<< "$version"
  25. "$PYBIN" -c "import sys; exit(0) if sys.version_info >= ($major, $minor, $patch) else exit(1)"
  26. return $?
  27. }
  28. function install_python311() {
  29. local DOCKEROS=${1:-"ubuntu22"}
  30. local PYTHON_VERSION=${2:-"3.11.12"}
  31. pushd .
  32. cd $HOME
  33. local INSTALL_PREFIX="/opt/python/${PYTHON_VERSION}"
  34. local PYTHON_TGZ="Python-${PYTHON_VERSION}.tgz"
  35. local PYTHON_SRC_DIR="Python-${PYTHON_VERSION}"
  36. export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/mit/bin:$PATH
  37. export LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib:/opt/sqlite3/lib:${LD_LIBRARY_PATH}
  38. export CPPFLAGS="-I/opt/sqlite3/include"
  39. export LDFLAGS="-L/opt/sqlite3/lib"
  40. echo "Installing build dependencies..."
  41. case "${DOCKEROS}" in
  42. ubuntu22)
  43. sudo -- sh -c 'apt update && \
  44. apt install -y \
  45. build-essential \
  46. libbz2-dev libncurses5-dev libgdbm-dev libreadline-dev libkrb5-dev \
  47. liblzma-dev uuid-dev libldap2-dev libffi-dev zlib1g-dev libssl-dev wget curl'
  48. ;;
  49. redhat9|redhat8|redhat8-arm64)
  50. sudo -- sh -c 'yum groupinstall -y "Development Tools" && \
  51. yum install -y \
  52. bzip2-devel ncurses-devel gdbm-devel readline-devel krb5-devel \
  53. xz-devel libuuid-devel openldap-devel libffi-devel zlib-devel openssl-devel wget curl'
  54. ;;
  55. sles15)
  56. sudo -- sh -c 'zypper refresh'
  57. sudo -- sh -c 'zypper install -y \
  58. gcc gcc-c++ make \
  59. ncurses-devel gdbm-devel readline-devel krb5-devel \
  60. xz-devel libuuid-devel openldap2-devel libffi-devel zlib-devel libopenssl-devel wget curl'
  61. ;;
  62. *)
  63. echo "Unsupported OS: ${DOCKEROS}. Exiting."
  64. exit 1
  65. ;;
  66. esac
  67. echo "Installing sqlite3..."
  68. sudo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} PATH=${PATH} \
  69. -- sh -c 'cd /tmp && \
  70. mkdir -p /opt/sqlite3 && \
  71. curl -o sqlite-autoconf-3350500.tar.gz https://www.sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  72. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  73. cd sqlite-autoconf-3350500 && \
  74. ./configure --prefix=/opt/sqlite3 && make && make install && \
  75. libtool --finish /opt/sqlite3/lib'
  76. echo "Installing Python ${PYTHON_VERSION}..."
  77. sudo DOCKEROS=${DOCKEROS} PYTHON_VERSION=${PYTHON_VERSION} INSTALL_PREFIX=${INSTALL_PREFIX} \
  78. PYTHON_TGZ=${PYTHON_TGZ} PYTHON_SRC_DIR=${PYTHON_SRC_DIR} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
  79. CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS} PATH=${PATH} \
  80. -- sh -c 'cd /tmp && mkdir -p "${INSTALL_PREFIX}" && \
  81. curl -o "${PYTHON_TGZ}" "https://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_TGZ}" && \
  82. tar zxf "${PYTHON_TGZ}" && \
  83. cd "${PYTHON_SRC_DIR}" && \
  84. ./configure --prefix="${INSTALL_PREFIX}" --enable-shared --enable-optimizations --with-lto && \
  85. make altinstall'
  86. # echo "Stripping debug symbols to reduce size..."
  87. # sudo -- sh -c '/usr/bin/strip "${INSTALL_PREFIX}/bin/python3.11" && \
  88. # /usr/bin/strip "${INSTALL_PREFIX}/lib/libpython3.11.so.1.0"'
  89. sudo DOCKEROS=${DOCKEROS} PYTHON_VERSION=${PYTHON_VERSION} INSTALL_PREFIX=${INSTALL_PREFIX} \
  90. PYTHON_TGZ=${PYTHON_TGZ} PYTHON_SRC_DIR=${PYTHON_SRC_DIR} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
  91. CPPFLAGS=${CPPFLAGS} LDFLAGS=${LDFLAGS} PATH=${PATH} \
  92. -- sh -c 'cd /tmp && curl -sS https://bootstrap.pypa.io/get-pip.py | "${INSTALL_PREFIX}/bin/python3.11"'
  93. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  94. export PYTHON311_PATH=${INSTALL_PREFIX}
  95. export PATH=${INSTALL_PREFIX}/bin:$PATH
  96. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
  97. popd
  98. }
  99. function centos7_install() {
  100. if [[ $FORCEINSTALL -eq 1 ]]; then
  101. # pre-req install
  102. sudo -- sh -c 'yum install -y cyrus-sasl-gssapi \
  103. cyrus-sasl-plain \
  104. java-11-openjdk \
  105. java-11-openjdk-devel \
  106. java-11-openjdk-headless \
  107. krb5-workstation \
  108. libpcap \
  109. ncurses-devel \
  110. nmap-ncat \
  111. xmlsec1 \
  112. xmlsec1-openssl \
  113. unzip \
  114. python3-devel \
  115. postgresql-devel'
  116. # Ensure pg_config is available
  117. export PG_CONFIG=$(which pg_config)
  118. if [ -z "$PG_CONFIG" ]; then
  119. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  120. exit 1
  121. fi
  122. echo "PG_CONFIG is set to $PG_CONFIG"
  123. # MySQLdb install
  124. sudo -- sh -c 'cd /tmp && curl -sSLO https://cloudera-build-us-west-1.vpc.cloudera.com/s3/ARTIFACTS/mysql80-community-release-el7-11.noarch.rpm && \
  125. rpm -ivh mysql80-community-release-el7-11.noarch.rpm && \
  126. yum install -y mysql-community-libs mysql-community-client-plugins mysql-community-common'
  127. # NODEJS 16 install
  128. # Upgrading to node-v16 because of the following CVE's in node-v14 "CVE-2021-3450, CVE-2021-44531, CVE-2023-32004, CVE-2023-32006"
  129. # Node-v20-LTS is not supported by old OS'es - Redhat7_ppc, Centos7, Ubuntu18, Sles12. So upgrading to node-v16
  130. sudo -- sh -c 'cd /tmp && curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash - && \
  131. yum install -y nodejs npm'
  132. # sqlite3 install
  133. sudo -- sh -c 'cd /tmp && curl -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  134. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  135. cd sqlite-autoconf-3350500 && \
  136. ./configure --prefix=/opt/sqlite3 && make && make install'
  137. # python3.8 re install for sqlite3 3.35.5 or higher version
  138. sudo LD_LIBRARY_PATH=/opt/sqlite3/lib:$ORACLE_INSTANTCLIENT19_PATH:$LD_LIBRARY_PATH \
  139. LD_RUN_PATH=/opt/sqlite3/lib:$ORACLE_INSTANTCLIENT19_PATH:$LD_RUN_PATH \
  140. -- sh -c 'cd /tmp && curl -o Python-3.8.13.tgz https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz && \
  141. tar zxvf Python-3.8.13.tgz && \
  142. cd Python-3.8.13 && \
  143. ./configure --enable-shared --prefix=/opt/cloudera/cm-agent && \
  144. make altinstall'
  145. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  146. export PYTHON38_PATH="/opt/cloudera/cm-agent"
  147. pip_bin="${PYTHON38_PATH}/bin/pip3.8"
  148. export VIRTUAL_ENV_VERSION="20.19.0"
  149. # Pip modules install
  150. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  151. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  152. sudo pip_bin=${pip_bin} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  153. fi
  154. }
  155. function redhat8_install() {
  156. if [[ $FORCEINSTALL -eq 1 ]]; then
  157. # pre-req install
  158. sudo -- sh -c 'yum install -y \
  159. java-11-openjdk \
  160. java-11-openjdk-devel \
  161. java-11-openjdk-headless \
  162. krb5-workstation \
  163. ncurses-devel \
  164. nmap-ncat \
  165. xmlsec1 \
  166. xmlsec1-openssl \
  167. libss \
  168. ncurses-c++-libs \
  169. python3-devel \
  170. postgresql-devel'
  171. # Ensure pg_config is available
  172. export PG_CONFIG=$(which pg_config)
  173. if [ -z "$PG_CONFIG" ]; then
  174. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  175. exit 1
  176. fi
  177. echo "PG_CONFIG is set to $PG_CONFIG"
  178. # MySQLdb install
  179. sudo -- sh -c 'yum install -y python3-mysqlclient'
  180. # NODEJS 20 install
  181. sudo -- sh -c 'cd /tmp && curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash - && \
  182. yum install -y nodejs'
  183. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  184. install_python311 "redhat8" "$REQ_PYTHON311"
  185. fi
  186. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  187. export VIRTUAL_ENV_VERSION="20.30.0"
  188. # Pip modules install
  189. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  190. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  191. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  192. fi
  193. }
  194. function redhat8_arm64_install() {
  195. if [[ $FORCEINSTALL -eq 1 ]]; then
  196. # pre-req install
  197. sudo -- sh -c 'yum install -y \
  198. java-11-openjdk \
  199. java-11-openjdk-devel \
  200. java-11-openjdk-headless \
  201. krb5-workstation \
  202. ncurses-devel \
  203. nmap-ncat \
  204. xmlsec1 \
  205. xmlsec1-openssl \
  206. libss \
  207. ncurses-c++-libs'
  208. # MySQLdb install
  209. sudo -- sh -c 'yum install -y python3-mysqlclient'
  210. # NODEJS 20 install
  211. sudo -- sh -c 'cd /tmp && curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash - && \
  212. yum install -y nodejs'
  213. # Pip modules install
  214. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  215. install_python311 "redhat8-arm64" "$REQ_PYTHON311"
  216. fi
  217. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  218. export VIRTUAL_ENV_VERSION="20.30.0"
  219. # Pip modules install
  220. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  221. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2-binary==2.9.6'
  222. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  223. fi
  224. }
  225. function redhat9_install() {
  226. if [[ $FORCEINSTALL -eq 1 ]]; then
  227. # pre-req install
  228. sudo -- sh -c 'yum install -y \
  229. java-11-openjdk \
  230. java-11-openjdk-devel \
  231. java-11-openjdk-headless \
  232. krb5-workstation \
  233. ncurses-devel \
  234. nmap-ncat \
  235. xmlsec1 \
  236. xmlsec1-openssl \
  237. libss \
  238. ncurses-c++-libs \
  239. postgresql-devel'
  240. # Ensure pg_config is available
  241. export PG_CONFIG=$(which pg_config)
  242. if [ -z "$PG_CONFIG" ]; then
  243. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  244. exit 1
  245. fi
  246. echo "PG_CONFIG is set to $PG_CONFIG"
  247. # MySQLdb install
  248. sudo -- sh -c 'yum install -y python3-mysqlclient'
  249. # NODEJS 20 install
  250. sudo -- sh -c 'cd /tmp && curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash - && \
  251. yum install -y nodejs'
  252. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  253. install_python311 "redhat9" "$REQ_PYTHON311"
  254. fi
  255. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  256. export VIRTUAL_ENV_VERSION="20.30.0"
  257. # Pip modules install
  258. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  259. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  260. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  261. fi
  262. }
  263. function sles12_install() {
  264. if [[ $FORCEINSTALL -eq 1 ]]; then
  265. # pre-req install
  266. sudo -- sh -c 'zypper refresh'
  267. sudo -- sh -c 'zypper install -y cyrus-sasl-gssapi \
  268. cyrus-sasl-plain \
  269. java-11-openjdk \
  270. java-11-openjdk-devel \
  271. java-11-openjdk-headless \
  272. krb5-client pam_krb5 krb5-appl-clients krb5-plugin-kdb-ldap \
  273. libpcap \
  274. ncurses-devel \
  275. nmap \
  276. python3-devel \
  277. postgresql-server-devel \
  278. xmlsec1 xmlsec1-devel xmlsec1-openssl-devel'
  279. # Ensure pg_config is available
  280. export PG_CONFIG=$(which pg_config)
  281. if [ -z "$PG_CONFIG" ]; then
  282. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  283. exit 1
  284. fi
  285. echo "PG_CONFIG is set to $PG_CONFIG"
  286. # MySQLdb install
  287. sudo -- sh -c 'zypper install -y libmysqlclient-devel libmysqlclient18 libmysqld18 libmysqld-devel'
  288. # NODEJS 16 install
  289. # Upgrading to node-v16 because of the following CVE's in node-v14 "CVE-2021-3450, CVE-2021-44531, CVE-2023-32004, CVE-2023-32006"
  290. # Node-v20-LTS is not supported by old OS'es - Redhat7_ppc, Centos7, Ubuntu18, Sles12. So upgrading to node-v16
  291. sudo -- sh -c 'zypper install -y npm14 nodejs14'
  292. pip_bin="${PYTHON38_PATH}/bin/pip3.8"
  293. VIRTUAL_ENV_VERSION="20.19.0"
  294. # Pip modules install
  295. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  296. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  297. sudo pip_bin=${pip_bin} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  298. # sqlite3 install
  299. sudo -- sh -c 'cd /tmp && curl --insecure -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  300. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  301. cd sqlite-autoconf-3350500 && \
  302. ./configure --prefix=/opt/sqlite3 && make && make install'
  303. export LD_LIBRARY_PATH=/opt/sqlite3/lib:$LD_LIBRARY_PATH
  304. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  305. fi
  306. }
  307. function sles15_install() {
  308. if [[ $FORCEINSTALL -eq 1 ]]; then
  309. # pre-req install
  310. sudo -- sh -c 'zypper refresh'
  311. sudo -- sh -c 'zypper install -y cyrus-sasl-gssapi \
  312. cyrus-sasl-plain \
  313. java-11-openjdk \
  314. java-11-openjdk-devel \
  315. java-11-openjdk-headless \
  316. krb5-client pam_krb5 krb5-plugin-kdb-ldap \
  317. libpcap1 \
  318. ncurses-devel \
  319. nmap \
  320. postgresql-server-devel \
  321. xmlsec1 xmlsec1-devel xmlsec1-openssl-devel'
  322. # Ensure pg_config is available
  323. export PG_CONFIG=$(which pg_config)
  324. if [ -z "$PG_CONFIG" ]; then
  325. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  326. exit 1
  327. fi
  328. echo "PG_CONFIG is set to $PG_CONFIG"
  329. # MySQLdb install
  330. sudo -- sh -c 'zypper install -y libmariadb-devel mariadb-client python3-mysqlclient'
  331. # NODEJS 18 install
  332. sudo -- sh -c 'zypper install -y nodejs18 npm20'
  333. sudo -- sh -c 'rm -f /usr/local/bin/node && ln -s /usr/bin/node18 /usr/local/bin/node'
  334. sudo -- sh -c 'rm -f /usr/local/bin/npm && ln -s /usr/bin/npm20 /usr/local/bin/npm'
  335. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  336. install_python311 "sles15" "$REQ_PYTHON311"
  337. fi
  338. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  339. export VIRTUAL_ENV_VERSION="20.30.0"
  340. # Pip modules install
  341. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  342. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  343. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  344. fi
  345. }
  346. function ubuntu18_install() {
  347. if [[ $FORCEINSTALL -eq 1 ]]; then
  348. # pre-req install
  349. sudo -- sh -c 'apt-get update'
  350. sudo -- sh -c 'DEBIAN_FRONTEND=noninteractive apt -qq -y install \
  351. krb5-user \
  352. krb5-kdc \
  353. krb5-config \
  354. libkrb5-dev'
  355. sudo -- sh -c 'apt -y install \
  356. ldap-utils \
  357. libpython3.8-dev \
  358. libpython3.8-minimal \
  359. libpython3.8-stdlib \
  360. libxmlsec1 \
  361. libxmlsec1-openssl \
  362. netcat \
  363. nmap \
  364. python3-asn1crypto \
  365. python3-cffi-backend \
  366. python3-crypto \
  367. python3-cryptography \
  368. python3-keyring \
  369. python3-psycopg2 \
  370. python3-setuptools \
  371. python3-wheel \
  372. python3.8-venv \
  373. python3-dev \
  374. libpq-dev \
  375. zlibc'
  376. # Ensure pg_config is available
  377. export PG_CONFIG=$(which pg_config)
  378. if [ -z "$PG_CONFIG" ]; then
  379. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  380. exit 1
  381. fi
  382. echo "PG_CONFIG is set to $PG_CONFIG"
  383. # MySQLdb install
  384. # It is pre-installed
  385. # NODEJS 16 install
  386. # Upgrading to node-v16 because of the following CVE's in node-v14 "CVE-2021-3450, CVE-2021-44531, CVE-2023-32004, CVE-2023-32006"
  387. # Node-v20-LTS is not supported by old OS'es - Redhat7_ppc, Centos7, Ubuntu18, Sles12. So upgrading to node-v16
  388. sudo -- sh -c 'cd /tmp && curl -sL https://deb.nodesource.com/setup_16.x | sudo bash - && \
  389. apt -y install nodejs'
  390. pip_bin="${PYTHON38_PATH}/bin/pip3.8"
  391. VIRTUAL_ENV_VERSION="20.19.0"
  392. # Pip modules install
  393. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  394. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  395. sudo pip_bin=${pip_bin} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  396. # sqlite3 install
  397. sudo -- sh -c 'cd /tmp && curl -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  398. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  399. cd sqlite-autoconf-3350500 && \
  400. ./configure --prefix=/opt/sqlite3 && make && make install'
  401. export LD_LIBRARY_PATH=/opt/sqlite3/lib:$LD_LIBRARY_PATH
  402. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  403. fi
  404. }
  405. function ubuntu20_install() {
  406. if [[ $FORCEINSTALL -eq 1 ]]; then
  407. # pre-req install
  408. sudo -- sh -c 'DEBIAN_FRONTEND=noninteractive apt -qq -y install \
  409. krb5-user \
  410. krb5-kdc \
  411. krb5-config \
  412. libkrb5-dev'
  413. sudo -- sh -c 'apt -y install \
  414. ldap-utils \
  415. libpython3.8-dev \
  416. libpython3.8-minimal \
  417. libpython3.8-stdlib \
  418. libxmlsec1 \
  419. libxmlsec1-openssl \
  420. libpq-dev \
  421. netcat \
  422. nmap \
  423. python-asn1crypto \
  424. python3-crypto \
  425. python3-cryptography \
  426. python3-keyring \
  427. python3-psycopg2 \
  428. python3-setuptools \
  429. python3-wheel \
  430. python3.8-venv \
  431. zlibc \
  432. openssl \
  433. sudo \
  434. tar \
  435. util-linux'
  436. # Ensure pg_config is available
  437. export PG_CONFIG=$(which pg_config)
  438. if [ -z "$PG_CONFIG" ]; then
  439. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  440. exit 1
  441. fi
  442. echo "PG_CONFIG is set to $PG_CONFIG"
  443. # MySQLdb install
  444. # It is pre-installed
  445. # NODEJS 20 install
  446. sudo -- sh -c 'apt-get install -y curl && \
  447. cd /tmp && curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && \
  448. apt-get install -y nodejs'
  449. # sqlite3 install
  450. sudo -- sh -c 'cd /tmp && curl -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  451. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  452. cd sqlite-autoconf-3350500 && \
  453. ./configure --prefix=/opt/sqlite3 && make && make install'
  454. # python3.8 re install for sqlite3 3.35.5 or higher version
  455. sudo LD_LIBRARY_PATH=/opt/sqlite3/lib:$ORACLE_INSTANTCLIENT19_PATH:$LD_LIBRARY_PATH \
  456. LD_RUN_PATH=/opt/sqlite3/lib:$ORACLE_INSTANTCLIENT19_PATH:$LD_RUN_PATH \
  457. -- sh -c 'cd /tmp && curl -o Python-3.8.13.tgz https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz && \
  458. tar zxvf Python-3.8.13.tgz && \
  459. cd Python-3.8.13 && \
  460. ./configure --enable-shared --prefix=/opt/cloudera/cm-agent && \
  461. make altinstall'
  462. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  463. export PYTHON38_PATH="/opt/cloudera/cm-agent"
  464. export pip_bin="${PYTHON38_PATH}/bin/pip3.8"
  465. VIRTUAL_ENV_VERSION="20.19.0"
  466. # Pip modules install
  467. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  468. sudo pip_bin=${pip_bin} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  469. sudo pip_bin=${pip_bin} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  470. # sqlite3 install
  471. sudo -- sh -c 'cd /tmp && curl -o sqlite-autoconf-3350500.tar.gz https://sqlite.org/2021/sqlite-autoconf-3350500.tar.gz && \
  472. tar zxvf sqlite-autoconf-3350500.tar.gz && \
  473. cd sqlite-autoconf-3350500 && \
  474. ./configure --prefix=/opt/sqlite3 && make && make install'
  475. export LD_LIBRARY_PATH=/opt/sqlite3/lib:$LD_LIBRARY_PATH
  476. export SQLITE3_PATH=/opt/sqlite3/bin/sqlite3
  477. fi
  478. }
  479. function ubuntu22_install() {
  480. local PYTHON_VERSION=${1:-"python3.11"} # Default to Python 3.11 if not provided
  481. if [[ $FORCEINSTALL -eq 1 ]]; then
  482. sudo -- sh -c 'apt update'
  483. # Add deadsnakes PPA for Python 3.8
  484. sudo -- sh -c 'add-apt-repository ppa:deadsnakes/ppa -y'
  485. sudo -- sh -c 'apt update'
  486. # pre-req install
  487. sudo -- sh -c 'DEBIAN_FRONTEND=noninteractive apt -qq -y install \
  488. krb5-user \
  489. krb5-kdc \
  490. krb5-config \
  491. libkrb5-dev'
  492. sudo -- sh -c "apt -y install \
  493. ldap-utils \
  494. libxmlsec1 \
  495. libxmlsec1-openssl \
  496. libpq-dev \
  497. netcat \
  498. nmap \
  499. openssl \
  500. sudo \
  501. tar \
  502. util-linux"
  503. # Ensure pg_config is available
  504. export PG_CONFIG=$(which pg_config)
  505. if [ -z "$PG_CONFIG" ]; then
  506. echo "Error: pg_config not found. Ensure PostgreSQL development libraries are installed."
  507. exit 1
  508. fi
  509. echo "PG_CONFIG is set to $PG_CONFIG"
  510. # MySQLdb install
  511. # It is pre-installed
  512. # NODEJS 20 install
  513. sudo -- sh -c 'apt-get install -y curl && \
  514. cd /tmp && curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && \
  515. apt-get install -y nodejs'
  516. if ! is_supported_python_version "$PYTHON311_PATH/bin/python3.11" $REQ_PYTHON311; then
  517. install_python311 "ubuntu22" "$REQ_PYTHON311"
  518. fi
  519. export pip_bin=${PYTHON311_PATH}/bin/pip3.11
  520. export VIRTUAL_ENV_VERSION="20.30.0"
  521. # Pip modules install
  522. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install virtualenv=='${VIRTUAL_ENV_VERSION}' virtualenv-make-relocatable==0.0.1 mysqlclient==2.1.1'
  523. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c '${pip_bin} install psycopg2==2.9.6 --global-option=build_ext --global-option="--pg-config=$PG_CONFIG"'
  524. sudo pip_bin=${pip_bin} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} -- sh -c 'ln -fs ${pip_bin} $(dirname ${pip_bin})/pip'
  525. fi
  526. }