11#! /usr/bin/env bash
22# dependencies.sh is called by install.sh to install libraries and packages needed to build and install CFEngine from source.
33set -ex
4+
5+ GAINROOT=" "
6+ if [ " $( id -u) " != " 0" ]; then
7+ GAINROOT=" sudo"
8+ if ! command -v sudo > /dev/null; then
9+ echo " Sorry, either run $0 as root or install sudo."
10+ exit 1
11+ fi
12+ fi
13+
414# limited support here, focused on rhel-like on aarch64 which has no previous CFEngine version to leverage: ENT-13016
515if [ -f /etc/os-release ]; then
616 source /etc/os-release
@@ -9,41 +19,41 @@ if [ -f /etc/os-release ]; then
919 if [ " $VERSION_MAJOR " -ge " 10" ]; then
1020 # note that having a redhat subscription makes things easier: lmdb-devel and librsync-devel are available from codeready-builder repo
1121 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
22+ $GAINROOT subscription-manager config --rhsm.manage_repos=1
23+ $GAINROOT subscription-manager repos --enable codeready-builder-for-rhel-" $VERSION_MAJOR " -" $( uname -m) " -rpms
24+ $GAINROOT dnf install --assumeyes https://dl.fedoraproject.org/pub/epel/epel-release-latest-" $VERSION_MAJOR " .noarch.rpm
25+ $GAINROOT dnf install --assumeyes flex-devel lmdb-devel librsync-devel fakeroot # only available via subscription with codeready-builder installed
1626 # 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.
1727 # fakeroot is only needed for running tests but can be worked around by using GAINROOT=env with tests/acceptance/testall script
1828 else
1929 # 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
30+ $GAINROOT yum groups install -y ' Development Tools'
31+ $GAINROOT yum update --assumeyes
32+ $GAINROOT yum install -y gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre2-devel pam-devel libxml2-devel
2333 tmpdir=" $( mktemp -d) "
2434 echo " Building lmdb and librsync in $tmpdir "
2535 (
2636 cd " $tmpdir "
2737 git clone --recursive --depth 1 https://github.com/LMDB/lmdb
2838 cd lmdb/libraries/liblmdb
2939 make
30- sudo make install prefix=/usr
40+ $GAINROOT make install prefix=/usr
3141 cd -
32- sudo dnf install -y cmake
42+ $GAINROOT dnf install -y cmake
3343 git clone --recursive --depth 1 https://github.com/librsync/librsync
3444 cd librsync
3545 cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .
3646 make
37- sudo make install
47+ $GAINROOT make install
3848 )
3949 fi
4050 else
4151 echo " Unsupported version of redhat for $0 "
4252 exit 1
4353 fi
44- elif [ " $ID " = " ubuntu " ]; then
45- sudo apt update -y
46- sudo apt install -y libssl-dev libpam0g -dev liblmdb-dev byacc curl librsync-dev
54+ elif [ " $ID " = " debian " ] || [[ " $ID_LIKE " =~ " debian " ] ]; then
55+ $GAINROOT apt update -y
56+ $GAINROOT apt install -y build-essential git libtool autoconf automake bison flex libssl-dev libpcre2 -dev libbison-dev libacl1 libacl1-dev lmdb-utils liblmdb-dev libpam0g-dev libtool libyaml-dev libxml2-dev librsync-dev
4757 else
4858 echo " Unsupported distribution based on /etc/os-release."
4959 fi
0 commit comments