|
| 1 | +#!/usr/bin/env bash |
| 2 | +# dependencies.sh is called by install.sh to install libraries and packages needed to build and install CFEngine from source. |
| 3 | +set -ex |
| 4 | +# limited support here, focused on rhel-like on aarch64 which has no previous CFEngine version to leverage: ENT-13016 |
| 5 | +if [ -f /etc/os-release ]; then |
| 6 | + source /etc/os-release |
| 7 | + VERSION_MAJOR=${VERSION_ID%.*} |
| 8 | + if [ "$ID" = "rhel" ] || [[ "$ID_LIKE" =~ "rhel" ]]; then |
| 9 | + if [ "$VERSION_MAJOR" -ge "10" ]; then |
| 10 | + # note that having a redhat subscription makes things easier: lmdb-devel and librsync-devel are available from codeready-builder repo |
| 11 | + if subscription-manager status; then |
| 12 | + sudo subscription-manager config --rhsm.manage_repos=1 |
| 13 | + sudo subscription-manager repos --enable codeready-builder-for-rhel-"$VERSION_MAJOR"-"$(uname -m)"-rpms |
| 14 | + sudo dnf install --assumeyes https://dl.fedoraproject.org/pub/epel/epel-release-latest-"$VERSION_MAJOR".noarch.rpm |
| 15 | + sudo dnf install --assumeyes flex-devel lmdb-devel librsync-devel fakeroot # only available via subscription with codeready-builder installed |
| 16 | + # flex-devel, libyaml-devel and fakeroot are also only available easily from codeready-builder but are not critical to building CFEngine usable enough to configure a build host. |
| 17 | + # fakeroot is only needed for running tests but can be worked around by using GAINROOT=env with tests/acceptance/testall script |
| 18 | + else |
| 19 | + # here we assume no subscription and so must build those two dependencies from source :) |
| 20 | + sudo yum groups install -y 'Development Tools' |
| 21 | + sudo yum update --assumeyes |
| 22 | + sudo yum install -y gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre2-devel pam-devel libxml2-devel |
| 23 | + tmpdir="$(mktemp -d)" |
| 24 | + echo "Building lmdb and librsync in $tmpdir" |
| 25 | + ( |
| 26 | + cd "$tmpdir" |
| 27 | + git clone --recursive --depth 1 https://github.com/LMDB/lmdb |
| 28 | + cd lmdb/libraries/liblmdb |
| 29 | + make |
| 30 | + sudo make install prefix=/usr |
| 31 | + cd - |
| 32 | + sudo dnf install -y cmake |
| 33 | + git clone --recursive --depth 1 https://github.com/librsync/librsync |
| 34 | + cd librsync |
| 35 | + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release . |
| 36 | + make |
| 37 | + sudo make install |
| 38 | + ) |
| 39 | + fi |
| 40 | + else |
| 41 | + echo "Unsupported version of redhat for $0" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + else |
| 45 | + echo "Unsupported distribution based on /etc/os-release." |
| 46 | + fi |
| 47 | +elif [ -n "$TERMUX_VERSION" ]; then |
| 48 | + pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml |
| 49 | +else |
| 50 | + echo "Unsupported operating system for $0" |
| 51 | + exit 1 |
| 52 | +fi |
| 53 | + |
0 commit comments