@@ -4,63 +4,83 @@ set -ex
44
55GAINROOT=" "
66if [ " $( 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
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
1212fi
1313
14+ build_lmdb () {
15+ if [ -f /usr/include/lmdb.h ]; then
16+ echo lmdb libraries already installed, no-op.
17+ return
18+ fi
19+ tmpdir=" $( mktemp -d) "
20+ echo building lmdb in " $tmpdir "
21+ (
22+ cd " $tmpdir "
23+ git clone --recursive --depth 1 https://github.com/LMDB/lmdb
24+ cd lmdb/libraries/liblmdb
25+ make
26+ $GAINROOT make install prefix=/usr
27+ )
28+ }
29+
30+ build_librsync () {
31+ tmpdir=" $( mktemp -d) "
32+ echo building librsync in " $tmpdir "
33+ (
34+ cd " $tmpdir "
35+ git clone --recursive --depth 1 https://github.com/librsync/librsync
36+ cd librsync
37+ cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .
38+ make
39+ $GAINROOT make install
40+ )
41+ }
42+
1443# limited support here, focused on rhel-like on aarch64 which has no previous CFEngine version to leverage: ENT-13016
1544if [ -f /etc/os-release ]; then
16- source /etc/os-release
17- VERSION_MAJOR=${VERSION_ID% .* }
18- if [ " $ID " = " rhel" ] || [[ " $ID_LIKE " =~ " rhel" ]]; then
19- if [ " $VERSION_MAJOR " -ge " 10" ]; then
20- # note that having a redhat subscription makes things easier: lmdb-devel and librsync-devel are available from codeready-builder repo
21- if subscription-manager status; then
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
26- # 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.
27- # fakeroot is only needed for running tests but can be worked around by using GAINROOT=env with tests/acceptance/testall script
28- else
29- # here we assume no subscription and so must build those two dependencies from source :)
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
33- tmpdir=" $( mktemp -d) "
34- echo " Building lmdb and librsync in $tmpdir "
35- (
36- cd " $tmpdir "
37- git clone --recursive --depth 1 https://github.com/LMDB/lmdb
38- cd lmdb/libraries/liblmdb
39- make
40- $GAINROOT make install prefix=/usr
41- cd -
42- $GAINROOT dnf install -y cmake
43- git clone --recursive --depth 1 https://github.com/librsync/librsync
44- cd librsync
45- cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .
46- make
47- $GAINROOT make install
48- )
49- fi
45+ source /etc/os-release
46+ VERSION_MAJOR=${VERSION_ID% .* }
47+ if [[ " $ID_LIKE " =~ " suse" ]]; then
48+ $GAINROOT zypper -qn install gdb gcc make lmdb autoconf automake libtool git python3 pcre2-devel libopenssl-devel pam-devel cmake flex byacc
49+ build_lmdb
50+ build_librsync
51+ elif [ " $ID " = " rhel" ] || [[ " $ID_LIKE " =~ " rhel" ]]; then
52+ if [ " $VERSION_MAJOR " -ge " 10" ]; then
53+ # note that having a redhat subscription makes things easier: lmdb-devel and librsync-devel are available from codeready-builder repo
54+ if subscription-manager status; then
55+ $GAINROOT subscription-manager config --rhsm.manage_repos=1
56+ $GAINROOT subscription-manager repos --enable codeready-builder-for-rhel-" $VERSION_MAJOR " -" $( uname -m) " -rpms
57+ $GAINROOT dnf install --assumeyes https://dl.fedoraproject.org/pub/epel/epel-release-latest-" $VERSION_MAJOR " .noarch.rpm
58+ $GAINROOT dnf install --assumeyes autoconf automake
59+ $GAINROOT dnf install --assumeyes gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre2-devel lmdb-devel pam-devel flex-devel libyaml-devel fakeroot libxml2-devel librsync-devel
60+ # 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.
61+ # fakeroot is only needed for running tests but can be worked around by using GAINROOT=env with tests/acceptance/testall script
62+ else
63+ # here we assume no subscription and so must build those two dependencies from source :)
64+ $GAINROOT yum groups install --assumeyes ' Development Tools'
65+ $GAINROOT yum update --assumeyes
66+ # cmake is for building librsync
67+ $GAINROOT yum install --assumeyes gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre2-devel pam-devel libxml2-devel cmake
68+ build_lmdb
69+ build_librsync
70+ fi
71+ else
72+ echo " Unsupported version of redhat for $0 "
73+ exit 1
74+ fi
75+ elif [ " $ID " = " debian" ] || [[ " $ID_LIKE " =~ " debian" ]]; then
76+ $GAINROOT apt update --yes
77+ $GAINROOT apt install --yes 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
5078 else
51- echo " Unsupported version of redhat for $0 "
52- exit 1
79+ echo " Unsupported distribution based on /etc/os-release."
5380 fi
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
57- else
58- echo " Unsupported distribution based on /etc/os-release."
59- fi
6081elif [ -n " $TERMUX_VERSION " ]; then
61- pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml
82+ pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml
6283else
63- echo " Unsupported operating system for $0 "
64- exit 1
84+ echo " Unsupported operating system for $0 "
85+ exit 1
6586fi
66-
0 commit comments