Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/acceptance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update -y && sudo apt-get install -y libssl-dev libpam0g-dev liblmdb-dev byacc curl libyaml-dev librsync-dev
run: ./ci/dependencies.sh
- name: Run autotools / configure
run: ./autogen.sh --enable-debug
- name: Compile and link (make)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/asan_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update -y && sudo apt-get install -y libssl-dev libpam0g-dev liblmdb-dev byacc curl librsync-dev
run: ./ci/dependencies.sh
- name: Run autotools / configure
run: ./autogen.sh --enable-debug
- name: Compile and link (make)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Install dependencies (C)
if: ${{ matrix.language == 'cpp' }}
run: sudo apt-get update -y && sudo apt-get install -y libssl-dev libpam0g-dev liblmdb-dev byacc curl librsync-dev
run: ./ci/dependencies.sh

- name: Build (C)
if: ${{ matrix.language == 'cpp' }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ jobs:
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update -y && sudo apt-get install -y libssl-dev libpam0g-dev liblmdb-dev byacc curl shellcheck librsync-dev
run: |
./ci/dependencies.sh
sudo apt install -y shellcheck
- name: Run autotools / configure
run: ./autogen.sh --enable-debug
- name: Run shellcheck
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
with:
submodules: recursive
- name: Install dependencies
run: sudo apt-get update -y && sudo apt-get install -y libssl-dev libpam0g-dev liblmdb-dev byacc curl librsync-dev
run: ./ci/dependencies.sh
- name: Run autotools / configure
run: ./autogen.sh --enable-debug
- name: Compile and link (make)
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
path: masterfiles
submodules: recursive
- name: Install dependencies
run: sudo apt-get update -y && sudo apt-get install -y libssl-dev libpam0g-dev liblmdb-dev byacc curl libyaml-dev valgrind librsync-dev
run: |
./ci/dependencies.sh
sudo apt install -y valgrind
- name: Run autotools / configure
run: ./autogen.sh --enable-debug --with-systemd-service
- name: Compile and link (make)
Expand Down
10 changes: 2 additions & 8 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#!/usr/bin/env bash
# build.sh runs autogen/configure and then builds CFEngine core
# build.sh runs after dependencies and configure scripts and 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
make -j8 CFLAGS="-Werror -Wall"
13 changes: 13 additions & 0 deletions ci/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# configure.sh runs autotools/configure as appropriate for the current environment
# 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
33 changes: 23 additions & 10 deletions ci/dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/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

GAINROOT=""
if [ "$(id -u)" != "0" ]; then
GAINROOT="sudo"
if ! command -v sudo >/dev/null; then
echo "Sorry, either run $0 as root or install sudo."
exit 1
fi
fi

# 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
Expand All @@ -9,38 +19,41 @@ if [ -f /etc/os-release ]; 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
$GAINROOT subscription-manager config --rhsm.manage_repos=1
$GAINROOT subscription-manager repos --enable codeready-builder-for-rhel-"$VERSION_MAJOR"-"$(uname -m)"-rpms
$GAINROOT dnf install --assumeyes https://dl.fedoraproject.org/pub/epel/epel-release-latest-"$VERSION_MAJOR".noarch.rpm
$GAINROOT 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
$GAINROOT yum groups install -y 'Development Tools'
$GAINROOT yum update --assumeyes
$GAINROOT 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
$GAINROOT make install prefix=/usr
cd -
sudo dnf install -y cmake
$GAINROOT 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
$GAINROOT make install
)
fi
else
echo "Unsupported version of redhat for $0"
exit 1
fi
elif [ "$ID" = "debian" ] || [[ "$ID_LIKE" =~ "debian" ]]; then
$GAINROOT apt update -y
$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
else
echo "Unsupported distribution based on /etc/os-release."
fi
Expand Down
9 changes: 8 additions & 1 deletion ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
set -ex
thisdir=$(dirname $0)
"$thisdir"/dependencies.sh
"$thisdir"/configure.sh
"$thisdir"/build.sh
cd "$thisdir"/..
GAINROOT=""
if [ ! -n "$TERMUX_VERSION" ]; then
GAINROOT="sudo"
if [ "$(id -u)" != "0" ]; then
if ! command -v sudo >/dev/null; then
echo "Sorry, run $0 as root or install and configure sudo."
exit 1
fi
GAINROOT="sudo"
fi
fi

$GAINROOT make install
Loading