From 690ac72565acbe0ab686a094dfdeb06567b5b3ff Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Mon, 22 Sep 2025 16:33:09 +0200 Subject: [PATCH] compile-options: Document & refactor script Ticket: ENT-12600 Signed-off-by: Lars Erik Wik --- build-scripts/compile-options | 166 ++++++++++++++++++---------------- scripts/deptool.py | 3 - 2 files changed, 87 insertions(+), 82 deletions(-) diff --git a/build-scripts/compile-options b/build-scripts/compile-options index 24629dc3b..cc397437e 100644 --- a/build-scripts/compile-options +++ b/build-scripts/compile-options @@ -65,6 +65,11 @@ aix) ;; hpux) LDFLAGS="-L$BUILDPREFIX/lib -Wl,+b$BUILDPREFIX/lib" + + # Use ‘gcc’ when building things on HP-UX + # + # HP-UX ships with ‘cc’ which invokes the ‘HP-UX bundled C compiler’ which lacks some functionality we need to build things. + # Among the other things, it doesn’t know how to link ‘.so’ files directly and it doesn’t recognize them as valid input type. CC=gcc export CC ;; @@ -94,59 +99,85 @@ export LDFLAGS DEB_LDFLAGS_APPEND="$LDFLAGS" export DEB_LDFLAGS_APPEND -# Embedded DB selection -EMBEDDED_DB="lmdb" - ############### Fill in build dependencies in DEPS variable ################ # shellcheck disable=SC2034 # > DEPS appears unused. Verify use (or export if used externally). # This file is sourced by other scripts that uses it DEPS= -[ "$OS_FAMILY" = mingw ] && var_append DEPS "pthreads-w32 libgnurx" -# libgcc_s.so is needed before we compile any other dependency -# on some platforms! +# Windows specific dependencies +if [ "$OS_FAMILY" = mingw ]; then + # Win32 does not support pthreads natively. + # The pthreads-w32 project provides a solution to this problem + var_append DEPS "pthreads-w32" + + # libgnurx is a port of the regex functionality from the glibc Library for use on Windows platforms + var_append DEPS "libgnurx" +fi + +# AIX / Solaris specific dependencies case "$OS_FAMILY" in -solaris | aix) var_append DEPS "libgcc" ;; -esac +solaris | aix) + # libgcc_s.so is needed before we compile any other dependency on solaris and aix + var_append DEPS "libgcc" -var_append DEPS "$EMBEDDED_DB pcre2" + # iconv is needed for libxml2 on solaris and aix + var_append DEPS "libiconv" + ;; +esac +# We use system bundled SSL on RHEL >= 8 if [ "$SYSTEM_SSL" != 1 ]; then - # FIXME: Why do we need zlib? - # ANSWER: Openssl uses it optionally, TODO DISABLE - var_append DEPS "zlib openssl" + # zlib is a compression library which is a dependency of OpenSSL. + # TODO: can we remove zlib dependency? (CFE-4013) + var_append DEPS "zlib" + + # A toolkit for TLS + var_append DEPS "openssl" fi # libsasl needed for solaris case "$OS_FAMILY" in -solaris | hpux) var_append DEPS "sasl2" ;; -esac - -# iconv is needed for libxml2 on some platforms -case "$OS_FAMILY" in -aix | solaris) var_append DEPS "libiconv" ;; +solaris | hpux) + # Generic library that implements the Simple Authentication and Security Layer (SASL) framework + var_append DEPS "sasl2" + ;; esac -var_append DEPS "libxml2 libyaml" -var_append DEPS "diffutils" -var_append DEPS "librsync" +# Common dependencies +var_append DEPS "lmdb" # Library for key-value store, used extensively by CFEngine components (cf-agent, etc) +var_append DEPS "pcre2" # Library for compiling/matching regex +var_append DEPS "libxml2" # Library for parsing XML +var_append DEPS "libyaml" # Library for parsing YAML +var_append DEPS "diffutils" # Library for comparing files +var_append DEPS "librsync" # Library for synchronization of file -# LDAP functions in the agent -# and LDAP authentication functionality in Mission Portal +# Enterprise only dependencies case "$PROJECT" in -nova) var_append DEPS "openldap" ;; -esac - -case "$PROJECT" in -nova) var_append DEPS "leech" ;; +nova) + # openldap is used for storing accounts, passwords and group memberships + # - Agent has LDAP related policy functions + # - Mission Portal uses LDAP for authentication functionality + var_append DEPS "openldap" + + # leech is used for efficient synchronization of tabular data. + # - cf-hub requests state changes from cf-serverd + # - state changes are recorded by cf-agent + var_append DEPS "leech" + ;; esac -# libacl & libattr - not for the exotics (linux only?) +# Non-exotics dependencies case "$OS_FAMILY" in hpux | aix | solaris | freebsd | mingw) ;; -*) var_append DEPS "libattr libacl" ;; +*) + # Library for managing Extended Attributes (xattrs) on filesystems + var_append DEPS "libattr" + + # POSIX Access Control Lists (ACLs) on filesystems + var_append DEPS "libacl" + ;; esac # ROLE @@ -158,50 +189,15 @@ esac # and build according to the role specified by it. case "$EXPLICIT_ROLE" in -agent) ROLE=agent ;; -hub) ROLE=hub ;; +agent) + ROLE=agent + ;; +hub) + ROLE=hub + ;; *) - # Not running under Jenkins? - if [ -z "$JENKINS_SERVER_COOKIE" ]; then - case "$PROJECT-$ARCH-$OS-${OS_VERSION}" in - community-*) ROLE=agent ;; - # We do not support 32 bits hubs anymore - nova-i386-*-*) ROLE=agent ;; - nova-s390*-*-*) ROLE=agent ;; - nova-*-centos-*) ROLE=hub ;; - nova-*-debian-*) ROLE=hub ;; - nova-*-opensuse-*) ROLE=hub ;; - nova-*-rhel-*) ROLE=hub ;; - nova-*-sles-*) ROLE=hub ;; - nova-*-ubuntu-*) ROLE=hub ;; - nova-*-mingw-*) ROLE=agent ;; - nova-*) ROLE=agent ;; - *) - echo "Unknown project: $PROJECT" - exit 42 - ;; - esac - echo "Autodetected $ROLE role based on missing Jenkins label and OS." - - else # we are running under Jenkins - - # The "label" variable is set in multi-matrix jobs; - # thus it is *not set* in the bootstrap job. - case x"$label" in - x) - echo "label is not set, assuming that this is not the main build job; Setting ROLE=agent." - ROLE=agent - ;; - *_HUB_*) - echo "Autodetected hub role based on '_HUB_' in Jenkins label." - ROLE=hub - ;; - *) - echo "Autodetected agent role based on missing '_HUB_' in Jenkins label." - ROLE=agent - ;; - esac - fi + log_error "Bad EXPLICIT_ROLE '$EXPLICIT_ROLE': defaulting to 'agent'" + ROLE=agent ;; esac @@ -212,18 +208,29 @@ export ROLE case "$ROLE" in # HUB-ONLY dependencies hub) - var_append DEPS "libcurl-hub" - var_append DEPS "nghttp2 libexpat apr apr-util apache git rsync" - var_append DEPS "postgresql php" + # Note that we make a separate curl package for the hub. + # This is because the hub will include the curl binary, but we don't want that for the clients. + var_append DEPS "libcurl-hub" # Provides API for performing network requests + var_append DEPS "nghttp2" # Provides implementation of the HTTP/2 protocol + var_append DEPS "libexpat" # Provides stream-oriented XML parser + var_append DEPS "apr apr-util" # Provides a common interface to underlying OS features (used by Apache) + var_append DEPS "apache" # Provides HTTP server + var_append DEPS "git" # Provides a version control system + var_append DEPS "rsync" # Binary to efficiently synchronize files (used in federated reporting) + var_append DEPS "postgresql" # Relational database + var_append DEPS "php" # Scripting language for web development ;; # AGENT-ONLY dependencies agent) - var_append DEPS "libcurl" + var_append DEPS "libcurl" # Provides API for performing network requests ;; esac -# systemd is not a build dependency, but should we generate -# unit files for it? +# Make sure init.d script and systemd service is used where needed. +# +# We install in all Linux platforms, because it does no harm on platforms +# without systemd, and it has the advantage of working out of the box on +# platforms that adopt systemd later. case "$OS_FAMILY" in linux) WITH_SYSTEMD=yes ;; *) @@ -234,6 +241,7 @@ linux) WITH_SYSTEMD=yes ;; ;; esac +# Determine whether or not to run tests case "$OS_FAMILY" in mingw | freebsd) TESTS=no ;; *) TESTS=all ;; diff --git a/scripts/deptool.py b/scripts/deptool.py index d884c9cad..607d1ed29 100644 --- a/scripts/deptool.py +++ b/scripts/deptool.py @@ -236,8 +236,6 @@ def deps_list(self, ref="master"): """Returns a sorted list of dependencies for given ref, for example: `["lcov", "libgnurx", "pthreads-w32"]`. Assumes the proper ref is checked out by `self.buildscripts_repo`. """ - # TODO: get value of $EMBEDDED_DB from file - embedded_db = "lmdb" if ref == "3.7.x": options_file = self.buildscripts_repo.get_file( "build-scripts/install-dependencies" @@ -264,7 +262,6 @@ def deps_list(self, ref="master"): # in the middle we also do some clean-ups only_deps = ( " ".join(only_deps) - .replace("$EMBEDDED_DB", embedded_db) .replace("libgcc ", "") .split(" ") )