From a9842a280e5cddc7d787d64c7b29fead24786577 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Sun, 26 Oct 2025 13:18:55 -0500 Subject: [PATCH] Added helper scripts for platform package dependencies, build and install For now this is focused on redhat-10-aarch64 and termux environment. Ticket: ENT-13016 Changelog: none --- ci/build.sh | 14 ++++++++++++ ci/dependencies.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++ ci/install.sh | 13 ++++++++++++ 3 files changed, 80 insertions(+) create mode 100755 ci/build.sh create mode 100755 ci/dependencies.sh create mode 100755 ci/install.sh diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 0000000000..2cb55a9845 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# build.sh runs autogen/configure and then builds CFEngine core +# the script should take into account the operating system environment and adjust, such as --without-pam on termux, BSDs and such +set -ex +thisdir="$(dirname "$0")" +cd "$thisdir"/.. +OPTS="--enable-debug" + +if [ -n "$TERMUX_VERSION" ]; then + OPTS="$OPTS --without-pam" +fi + +./autogen.sh $OPTS +make diff --git a/ci/dependencies.sh b/ci/dependencies.sh new file mode 100755 index 0000000000..ea31dbeeb2 --- /dev/null +++ b/ci/dependencies.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# dependencies.sh is called by install.sh to install libraries and packages needed to build and install CFEngine from source. +set -ex +# limited support here, focused on rhel-like on aarch64 which has no previous CFEngine version to leverage: ENT-13016 +if [ -f /etc/os-release ]; then + source /etc/os-release + VERSION_MAJOR=${VERSION_ID%.*} + if [ "$ID" = "rhel" ] || [[ "$ID_LIKE" =~ "rhel" ]]; then + if [ "$VERSION_MAJOR" -ge "10" ]; then + # note that having a redhat subscription makes things easier: lmdb-devel and librsync-devel are available from codeready-builder repo + if subscription-manager status; then + sudo subscription-manager config --rhsm.manage_repos=1 + sudo subscription-manager repos --enable codeready-builder-for-rhel-"$VERSION_MAJOR"-"$(uname -m)"-rpms + sudo dnf install --assumeyes https://dl.fedoraproject.org/pub/epel/epel-release-latest-"$VERSION_MAJOR".noarch.rpm + sudo dnf install --assumeyes flex-devel lmdb-devel librsync-devel fakeroot # only available via subscription with codeready-builder installed + # 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. + # fakeroot is only needed for running tests but can be worked around by using GAINROOT=env with tests/acceptance/testall script + else + # here we assume no subscription and so must build those two dependencies from source :) + sudo yum groups install -y 'Development Tools' + sudo yum update --assumeyes + sudo yum install -y gcc gdb make git libtool autoconf automake byacc flex openssl-devel pcre2-devel pam-devel libxml2-devel + tmpdir="$(mktemp -d)" + echo "Building lmdb and librsync in $tmpdir" + ( + cd "$tmpdir" + git clone --recursive --depth 1 https://github.com/LMDB/lmdb + cd lmdb/libraries/liblmdb + make + sudo make install prefix=/usr + cd - + sudo dnf install -y cmake + git clone --recursive --depth 1 https://github.com/librsync/librsync + cd librsync + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release . + make + sudo make install + ) + fi + else + echo "Unsupported version of redhat for $0" + exit 1 + fi + else + echo "Unsupported distribution based on /etc/os-release." + fi +elif [ -n "$TERMUX_VERSION" ]; then + pkg install build-essential git autoconf automake bison flex liblmdb openssl pcre2 libacl libyaml +else + echo "Unsupported operating system for $0" + exit 1 +fi + diff --git a/ci/install.sh b/ci/install.sh new file mode 100755 index 0000000000..587836d0ef --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# install.sh ensures dependencies are installed, builds core, then installs it +set -ex +thisdir=$(dirname $0) +"$thisdir"/dependencies.sh +"$thisdir"/build.sh +cd "$thisdir"/.. +GAINROOT="" +if [ ! -n "$TERMUX_VERSION" ]; then + GAINROOT="sudo" +fi + +$GAINROOT make install