From 5d2e1607cafa41ab91b0adb21b300f497aa05f34 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Tue, 24 Jun 2025 14:47:48 +0200 Subject: [PATCH 1/5] configure: Removed code duplication The code for adding the correct "configure" feature selection options (i.e., --with-dep=/path/to/dep/, --without-dep) based on the dependencies had a lot of repetitive code. I created a for loop for those that are nearly identical. Signed-off-by: Lars Erik Wik --- build-scripts/configure | 49 +++++++++++------------------------------ 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/build-scripts/configure b/build-scripts/configure index 931fa0319..e36bdb9f6 100755 --- a/build-scripts/configure +++ b/build-scripts/configure @@ -21,46 +21,23 @@ if [ $EMBEDDED_DB = lmdb ] then var_append ARGS "--with-lmdb=$P" fi -case "$DEPS" in - *pthreads-w32*) var_append ARGS "--with-pthreads=$P" ;; -esac -case "$DEPS" in - *openldap*) var_append ARGS "--with-ldap=$P" ;; - *) var_append ARGS "--without-ldap" ;; -esac -case "$DEPS" in - *libxml2*) var_append ARGS "--with-libxml2=$P" ;; - *) var_append ARGS "--without-libxml2" ;; -esac -case "$DEPS" in - *libyaml*) var_append ARGS "--with-libyaml=$P" ;; - *) var_append ARGS "--without-libyaml" ;; -esac -case "$DEPS" in - *librsync*) var_append ARGS "--with-librsync=$P" ;; - *) var_append ARGS "--without-librsync" ;; -esac -case "$DEPS" in - *leech*) var_append ARGS "--with-leech=$P" ;; - *) var_append ARGS "--without-leech" ;; -esac + +for dep in "pthreads-w32" "ldap" "libxml2" "libyaml" "librsync" "leech" "libacl" "libvirt" "libcurl" +do + case "$DEPS" in + *"$dep"*) + var_append ARGS "--with-$dep=$P" + ;; + *) + var_append ARGS "--without-$dep" + ;; + esac +done + case "$DEPS" in *postgresql*) var_append ARGS "--with-postgresql=$P --without-mysql" ;; *) var_append ARGS "--without-sql" ;; esac -case "$DEPS" in - *libacl*) var_append ARGS "--with-libacl=$P" ;; - *) var_append ARGS "--without-libacl" ;; -esac -case "$DEPS" in - *libvirt*) var_append ARGS "--with-libvirt=$P" ;; - *) var_append ARGS "--without-libvirt" ;; -esac -# both libcurl or libcurl-hub are valid -case "$DEPS" in - *libcurl*) var_append ARGS "--with-libcurl=$P" ;; - *) var_append ARGS "--without-libcurl" ;; -esac case "$ROLE" in hub) var_append ARGS "--with-cfmod --with-enterprise-api --with-postgresql=$P" ;; agent) var_append ARGS "--without-cfmod --without-postgresql" ;; From e2fdf3e97dcec57902013334f0bc50cb4851c640 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Tue, 24 Jun 2025 15:23:03 +0200 Subject: [PATCH 2/5] configure: Reformatted case statements for consistency Signed-off-by: Lars Erik Wik --- build-scripts/configure | 113 ++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 44 deletions(-) diff --git a/build-scripts/configure b/build-scripts/configure index e36bdb9f6..acafd4f0f 100755 --- a/build-scripts/configure +++ b/build-scripts/configure @@ -7,9 +7,15 @@ . version case "$PROJECT" in - community) NOVA=no ;; - nova) NOVA=yes ;; - *) fatal "Unknown project: $PROJECT" ;; + community) + NOVA=no + ;; + nova) + NOVA=yes + ;; + *) + fatal "Unknown project: $PROJECT" + ;; esac @@ -35,17 +41,33 @@ do done case "$DEPS" in - *postgresql*) var_append ARGS "--with-postgresql=$P --without-mysql" ;; - *) var_append ARGS "--without-sql" ;; + *postgresql*) + var_append ARGS "--with-postgresql=$P --without-mysql" + ;; + *) + var_append ARGS "--without-sql" + ;; esac + case "$ROLE" in - hub) var_append ARGS "--with-cfmod --with-enterprise-api --with-postgresql=$P" ;; - agent) var_append ARGS "--without-cfmod --without-postgresql" ;; - *) fatal "Unknown ROLE: $ROLE" ;; + hub) + var_append ARGS "--with-cfmod --with-enterprise-api --with-postgresql=$P" + ;; + agent) + var_append ARGS "--without-cfmod --without-postgresql" + ;; + *) + fatal "Unknown ROLE: $ROLE" + ;; esac + case "$WITH_SYSTEMD" in - yes) var_append ARGS "--with-systemd-service" ;; - *) var_append ARGS "--without-systemd-service" ;; + yes) + var_append ARGS "--with-systemd-service" + ;; + *) + var_append ARGS "--without-systemd-service" + ;; esac # RHEL 8 requires an SELinux policy @@ -55,45 +77,48 @@ fi # Cross-compiling Windows? case "$ARCH-${OS_FAMILY}" in - x86-mingw) var_append ARGS "--host=i686-w64-mingw32" ;; - x64-mingw) var_append ARGS "--host=x86_64-w64-mingw32" ;; + x86-mingw) + var_append ARGS "--host=i686-w64-mingw32" + ;; + x64-mingw) + var_append ARGS "--host=x86_64-w64-mingw32" + ;; esac case "$BUILD_TYPE" in - - RELEASE) - CFLAGS="-g2 -O2 -DNDEBUG $CFLAGS" - ;; - DEBUG) - ARGS="$ARGS --enable-debug" - # Override the default "-g3 -O0" that comes with ./configure --enable-debug - # in order to reduce the size of the packages - CFLAGS="-g2 -O1 $CFLAGS" - ;; - CODE_COVERAGE) - ARGS="$ARGS --enable-debug" - # lcov is not found in Windows and other platforms - case "${OS}-${OS_VERSION}" in - mingw*) - ;; - hpux*) - ;; - solaris*) + RELEASE) + CFLAGS="-g2 -O2 -DNDEBUG $CFLAGS" + ;; + DEBUG) + ARGS="$ARGS --enable-debug" + # Override the default "-g3 -O0" that comes with ./configure --enable-debug + # in order to reduce the size of the packages + CFLAGS="-g2 -O1 $CFLAGS" + ;; + CODE_COVERAGE) + ARGS="$ARGS --enable-debug" + # lcov is not found in Windows and other platforms + case "${OS}-${OS_VERSION}" in + mingw*) + ;; + hpux*) + ;; + solaris*) + ;; + rhel-4.*) + ;; + aix*) + ;; + *) + ARGS="$ARGS --enable-coverage" + ;; + esac + ;; + *) + echo "Unknown build type: $BUILD_TYPE" + exit 42 ;; - rhel-4.*) - ;; - aix*) - ;; - *) - ARGS="$ARGS --enable-coverage" - ;; - esac - ;; - *) - echo "Unknown build type: $BUILD_TYPE" - exit 42 - ;; esac if [ "x$OS" = "xsolaris" ] From bd74f5b1319a6d969dfa99761db0b6fe693a8f7f Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Tue, 24 Jun 2025 16:03:13 +0200 Subject: [PATCH 3/5] configure: Remove CODE_COVERAGE build type Because we don't use it. Signed-off-by: Lars Erik Wik --- build-scripts/configure | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/build-scripts/configure b/build-scripts/configure index acafd4f0f..cfede9942 100755 --- a/build-scripts/configure +++ b/build-scripts/configure @@ -96,25 +96,6 @@ case "$BUILD_TYPE" in # in order to reduce the size of the packages CFLAGS="-g2 -O1 $CFLAGS" ;; - CODE_COVERAGE) - ARGS="$ARGS --enable-debug" - # lcov is not found in Windows and other platforms - case "${OS}-${OS_VERSION}" in - mingw*) - ;; - hpux*) - ;; - solaris*) - ;; - rhel-4.*) - ;; - aix*) - ;; - *) - ARGS="$ARGS --enable-coverage" - ;; - esac - ;; *) echo "Unknown build type: $BUILD_TYPE" exit 42 From 71abcf00d3004252da54e1fbfcde34344cd4ebac Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Tue, 24 Jun 2025 16:10:31 +0200 Subject: [PATCH 4/5] configure: Fixed shellcheck issues Signed-off-by: Lars Erik Wik --- build-scripts/configure | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/build-scripts/configure b/build-scripts/configure index cfede9942..5d1f91bc9 100755 --- a/build-scripts/configure +++ b/build-scripts/configure @@ -1,7 +1,7 @@ #!/bin/sh -x -. `dirname "$0"`/functions +. "$(dirname "$0")"/functions . detect-environment . compile-options . version @@ -71,7 +71,7 @@ case "$WITH_SYSTEMD" in esac # RHEL 8 requires an SELinux policy -if [ "x$OS" = "xrhel" ] && [ "${VER%\.*}" -gt "7" ]; then +if [ "$OS" = rhel ] && [ "${VER%\.*}" -gt "7" ]; then var_append ARGS "--with-selinux-policy" fi @@ -102,21 +102,21 @@ case "$BUILD_TYPE" in ;; esac -if [ "x$OS" = "xsolaris" ] +if [ "$OS" = solaris ] then export PKG_CONFIG_PATH="$BUILDPREFIX/lib/pkgconfig" fi -( cd $BASEDIR/core && env $OPTS CFLAGS="$CFLAGS" ./configure $ARGS ) +( cd "$BASEDIR"/core && env "$OPTS" CFLAGS="$CFLAGS" ./configure "$ARGS" ) -if [ "x$NOVA" = "xyes" ] +if [ "$NOVA" = yes ] then - ( cd $BASEDIR/enterprise && env $OPTS CFLAGS="$CFLAGS" ./configure $ARGS ) - if [ "x$ROLE" = "xhub" ] + ( cd "$BASEDIR"/enterprise && env "$OPTS" CFLAGS="$CFLAGS" ./configure "$ARGS" ) + if [ "$ROLE" = hub ] then - ( cd $BASEDIR/nova && env $OPTS CFLAGS="$CFLAGS" ./configure $ARGS ) + ( cd "$BASEDIR"/nova && env "$OPTS" CFLAGS="$CFLAGS" ./configure "$ARGS" ) fi fi -( cd $BASEDIR/masterfiles && env $OPTS CFLAGS="$CFLAGS" ./configure $ARGS ) +( cd "$BASEDIR"/masterfiles && env "$OPTS" CFLAGS="$CFLAGS" ./configure "$ARGS" ) From a5837b7efa7b6f0f60636a7831215a68b47677f8 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Tue, 24 Jun 2025 16:51:38 +0200 Subject: [PATCH 5/5] configure: Decrease verbosity of script Signed-off-by: Lars Erik Wik --- build-scripts/configure | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/build-scripts/configure b/build-scripts/configure index 5d1f91bc9..ab5e71a9d 100755 --- a/build-scripts/configure +++ b/build-scripts/configure @@ -1,4 +1,4 @@ -#!/bin/sh -x +#!/bin/sh . "$(dirname "$0")"/functions @@ -14,7 +14,7 @@ case "$PROJECT" in NOVA=yes ;; *) - fatal "Unknown project: $PROJECT" + fatal "$(basename "$0"): Unknown project: $PROJECT" ;; esac @@ -57,7 +57,7 @@ case "$ROLE" in var_append ARGS "--without-cfmod --without-postgresql" ;; *) - fatal "Unknown ROLE: $ROLE" + fatal "$(basename "$0"): Unknown ROLE: $ROLE" ;; esac @@ -97,7 +97,7 @@ case "$BUILD_TYPE" in CFLAGS="-g2 -O1 $CFLAGS" ;; *) - echo "Unknown build type: $BUILD_TYPE" + echo "$(basename "$0"): Error: Unknown build type: $BUILD_TYPE" exit 42 ;; esac @@ -107,16 +107,19 @@ then export PKG_CONFIG_PATH="$BUILDPREFIX/lib/pkgconfig" fi - -( cd "$BASEDIR"/core && env "$OPTS" CFLAGS="$CFLAGS" ./configure "$ARGS" ) +echo "$(basename "$0"): Debug: running configure on core repo..." +( cd "$BASEDIR"/core && env "$OPTS" CFLAGS="$CFLAGS" run_and_print_on_failure ./configure "$ARGS" ) if [ "$NOVA" = yes ] then - ( cd "$BASEDIR"/enterprise && env "$OPTS" CFLAGS="$CFLAGS" ./configure "$ARGS" ) + echo "$(basename "$0"): Debug: running configure on enterprise repo..." + ( cd "$BASEDIR"/enterprise && env "$OPTS" CFLAGS="$CFLAGS" run_and_print_on_failure ./configure "$ARGS" ) if [ "$ROLE" = hub ] then - ( cd "$BASEDIR"/nova && env "$OPTS" CFLAGS="$CFLAGS" ./configure "$ARGS" ) + echo "$(basename "$0"): Debug: running configure on hub repo..." + ( cd "$BASEDIR"/nova && env "$OPTS" CFLAGS="$CFLAGS" run_and_print_on_failure ./configure "$ARGS" ) fi fi -( cd "$BASEDIR"/masterfiles && env "$OPTS" CFLAGS="$CFLAGS" ./configure "$ARGS" ) +echo "$(basename "$0"): Debug: running configure on masterfiles repo..." +( cd "$BASEDIR"/masterfiles && env "$OPTS" CFLAGS="$CFLAGS" run_and_print_on_failure ./configure "$ARGS" )