From 6684ead115799681e70515e3784f91ac5603e78f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 6 Apr 2026 20:31:09 +0200 Subject: [PATCH 1/5] Correctly handle build_oai --build-lib option This fixes two problem: 1. an omitted --build-lib library could yield strange grep errors. For instance, calling build_oai --build-lib --cmake-opt OPTION passed "--cmake-opt" to grep, that does not know this option. Handle by explicitly separating options and search pattern through --. 2. Even with this fixed, set -e triggered an exit because grep exits with non-zero error code. Remove set -e to have the error handling code pass. With set -e removed, properly check that the build passes. Update a log line to make it clearer. Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Robert Schmidt --- cmake_targets/build_oai | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index d8749ee39b..ebdce789cd 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -4,8 +4,6 @@ # file build_oai # brief OAI automated build tool that can be used to install, compile, run OAI. -set -e - # Include helper functions THIS_SCRIPT_PATH=$(dirname $(readlink -f "$0")) source "$THIS_SCRIPT_PATH"/tools/build_helper @@ -330,8 +328,8 @@ function main() { echo_info "Enabling build of all optional shared libraries ($OPTIONAL_LIBRARIES)" else for reqlib in $2; do - lib=$(echo $OPTIONAL_LIBRARIES | tr ' ' '\n' | grep -w $reqlib) # search given parameter in list - [[ $? -ne 0 ]] && echo_fatal "Unknown optional library in $reqlib, valid libraries are $OPTIONAL_LIBRARIES" + lib=$(echo $OPTIONAL_LIBRARIES | tr ' ' '\n' | grep -w -- $reqlib) # search given parameter in list + [[ $? -ne 0 ]] && echo_fatal "Unknown optional library \"$reqlib\", valid libraries are: $OPTIONAL_LIBRARIES" TARGET_LIST="$TARGET_LIST $lib" # will append the found library CMAKE_CMD="$CMAKE_CMD -DENABLE_${lib^^}=ON" echo_info "Enabling build of optional shared library $lib" @@ -441,11 +439,10 @@ function main() { # e.g., cmake_targets/ran_build/build, hence the ../../.. CMAKE_CMD="$CMAKE_CMD ../../.." echo_info "Running \"$CMAKE_CMD\"" - eval $CMAKE_CMD + eval $CMAKE_CMD || echo_fatal "cmake configuration failed" cmd="$CMAKE --build . --target ${TARGET_LIST} -- ${BUILD_TOOL_OPT}" echo_info "Running \"${cmd}\"" $green - eval $cmd - ret=$? + eval $cmd || echo_fatal "build failed" if [ "$UE" = 1 ] ; then echo_info "Generate LTE USIM default sim content UE specific part" From 57df1ede4b8ecada859f197704afb64c8eb350e6 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 6 Apr 2026 20:33:43 +0200 Subject: [PATCH 2/5] Remove log directory creation: it's not used Signed-off-by: Robert Schmidt --- cmake_targets/build_oai | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index ebdce789cd..f59a9ebfc7 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -387,9 +387,6 @@ function main() { echo "Erased all previously producted files" fi - dlog=$OPENAIR_DIR/cmake_targets/log - mkdir -p $dlog - if [ "$INSTALL_EXTERNAL" = "1" ] ; then echo_info "Installing packages" check_install_oai_software From be9fc79f77dc686c5f35507204e96879ca8a0704 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 6 Apr 2026 20:40:09 +0200 Subject: [PATCH 3/5] harmonize build_oai -c/-C Both do practically the same. Harmonize them into one while guaranteeing backwards compatibility. Signed-off-by: Robert Schmidt --- cmake_targets/build_oai | 15 +++------------ cmake_targets/tools/build_helper | 6 ------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index f59a9ebfc7..de6caba969 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -130,12 +130,9 @@ function main() { --build-tool-opt) BUILD_TOOL_OPT+=" $2" shift 2;; - -c | --clean) + -c | --clean | -C | --clean-all) CLEAN=1 shift;; - -C | --clean-all) - CLEAN_ALL=1 - shift;; --clean-kernel) clean_kernel echo_info "Erased iptables config and removed modules from kernel" @@ -382,10 +379,8 @@ function main() { echo "OPENAIR_DIR = $OPENAIR_DIR" - if [ "$CLEAN_ALL" = "1" ] ; then - clean_all_files - echo "Erased all previously producted files" - fi + DIR=$OPENAIR_DIR/cmake_targets + [ "$CLEAN" = "1" ] && rm -rf "$DIR/$BUILD_DIR" if [ "$INSTALL_EXTERNAL" = "1" ] ; then echo_info "Installing packages" @@ -418,10 +413,6 @@ function main() { check_install_additional_tools fi - DIR=$OPENAIR_DIR/cmake_targets - - [ "$CLEAN" = "1" ] && rm -rf $DIR/$BUILD_DIR/build - if [[ $TARGET_LIST != "" ]] && [[ -f $OPENAIR_DIR/CMakeLists.txt ]]; then # add some default libraries that should always be built # for eNB, gNB, UEs, simulators diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 32636a5bb2..37cccec18f 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -140,12 +140,6 @@ clean_kernel() { echo_info "Flushed iptables" } -clean_all_files() { - set_openair_env - dir=$OPENAIR_DIR/cmake_targets - rm -rf $dir/ran_build $dir/ran_build_noLOG -} - ############################################ # External packages installers ############################################ From 900fa704edf3638ea67f5948b4ce81ad55f81724 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Mon, 6 Apr 2026 20:56:39 +0200 Subject: [PATCH 4/5] bugfix run_asn1c: make make/ninja fail on error Functionality existed to print all output of asn1c on error, but the form asn1c || cat X makes the command exit with a 0 exit code (success). Fix by explicitly returning non-zero exit code in this case: asn1c || ( cat X && false ) Signed-off-by: Robert Schmidt --- cmake_targets/macros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_targets/macros.cmake b/cmake_targets/macros.cmake index 169ef600ce..c19eb285ef 100644 --- a/cmake_targets/macros.cmake +++ b/cmake_targets/macros.cmake @@ -83,7 +83,7 @@ function(run_asn1c ASN1C_GRAMMAR ASN1C_PREFIX) get_filename_component(GRAMMAR_FILE ${ASN1C_GRAMMAR} NAME) set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${GRAMMAR_FILE}.log") add_custom_command(OUTPUT ${ASN1C_OUTPUT} - COMMAND ASN1C_PREFIX=${ASN1C_PREFIX} ${ASN1C_EXEC} ${ASN1C_OPTIONS} -D ${CMAKE_CURRENT_BINARY_DIR} ${ASN1C_GRAMMAR} > ${LOGFILE} 2>&1 || cat ${LOGFILE} + COMMAND ASN1C_PREFIX=${ASN1C_PREFIX} ${ASN1C_EXEC} ${ASN1C_OPTIONS} -D ${CMAKE_CURRENT_BINARY_DIR} ${ASN1C_GRAMMAR} > ${LOGFILE} 2>&1 || ( cat ${LOGFILE} && false ) DEPENDS ${ASN1C_GRAMMAR} COMMENT "Generating ${ASN1C_COMMENT} from ${GRAMMAR_FILE}" ) From d63dc3a3216c909e6bf938c5ee6e0fafc4e3a776 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 7 Apr 2026 15:02:50 +0200 Subject: [PATCH 5/5] Remove build_oai --clean-kernel option This option is potentially dangerous as it might override custom user options. Signed-off-by: Robert Schmidt --- cmake_targets/build_oai | 4 ---- cmake_targets/tools/build_helper | 20 -------------------- 2 files changed, 24 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index de6caba969..ca387cda32 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -133,10 +133,6 @@ function main() { -c | --clean | -C | --clean-all) CLEAN=1 shift;; - --clean-kernel) - clean_kernel - echo_info "Erased iptables config and removed modules from kernel" - shift;; --cmake-opt) CMAKE_CMD="$CMAKE_CMD $2" shift 2;; diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 37cccec18f..2a18a0524e 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -120,26 +120,6 @@ handler_EXIT() { trap handler_EXIT EXIT -########################### -# Cleaners -########################### - -clean_kernel() { - $SUDO modprobe ip_tables - $SUDO modprobe x_tables - $SUDO iptables -P INPUT ACCEPT - $SUDO iptables -F INPUT - $SUDO iptables -P OUTPUT ACCEPT - $SUDO iptables -F OUTPUT - $SUDO iptables -P FORWARD ACCEPT - $SUDO iptables -F FORWARD - $SUDO iptables -t nat -F - $SUDO iptables -t mangle -F - $SUDO iptables -t filter -F - $SUDO iptables -t raw -F - echo_info "Flushed iptables" -} - ############################################ # External packages installers ############################################