From e194084c18d4a18f39dd7582eb0af791489ad4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Tue, 12 Nov 2024 09:40:53 +0100 Subject: [PATCH] share system_probe enablement conditions in an helper --- omnibus/config/projects/agent.rb | 3 ++- omnibus/config/software/datadog-agent.rb | 5 ++--- omnibus/config/software/system-probe.rb | 4 +++- omnibus/lib/project_helpers.rb | 12 ++++++++++++ 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 omnibus/lib/project_helpers.rb diff --git a/omnibus/config/projects/agent.rb b/omnibus/config/projects/agent.rb index d59595dca906fc..922ecc6a981612 100644 --- a/omnibus/config/projects/agent.rb +++ b/omnibus/config/projects/agent.rb @@ -3,6 +3,7 @@ # This product includes software developed at Datadog (https:#www.datadoghq.com/). # Copyright 2016-present Datadog, Inc. require "./lib/ostools.rb" +require "./lib/project_helpers.rb" flavor = ENV['AGENT_FLAVOR'] output_config_dir = ENV["OUTPUT_CONFIG_DIR"] @@ -222,7 +223,7 @@ dependency 'datadog-agent' # System-probe - if linux_target? && !heroku_target? + if sysprobe_enabled? dependency 'system-probe' end diff --git a/omnibus/config/software/datadog-agent.rb b/omnibus/config/software/datadog-agent.rb index 2bb2784c5b4335..c22fcfee6c45db 100644 --- a/omnibus/config/software/datadog-agent.rb +++ b/omnibus/config/software/datadog-agent.rb @@ -4,6 +4,7 @@ # Copyright 2016-present Datadog, Inc. require './lib/ostools.rb' +require './lib/project_helpers.rb' require 'pathname' name 'datadog-agent' @@ -144,9 +145,7 @@ end # System-probe - sysprobe_support = (not heroku_target?) && (linux_target? || (windows_target? && do_windows_sysprobe != "")) && - ENV.has_key?('SYSTEM_PROBE_BIN') and not ENV['SYSTEM_PROBE_BIN'].empty? - if sysprobe_support + if sysprobe_enabled? || (windows_target? && do_windows_sysprobe != "") if not bundled_agents.include? "system-probe" if windows_target? command "invoke -e system-probe.build", env: env diff --git a/omnibus/config/software/system-probe.rb b/omnibus/config/software/system-probe.rb index 19fdf7f0b9dbb1..5e84d0d662b094 100644 --- a/omnibus/config/software/system-probe.rb +++ b/omnibus/config/software/system-probe.rb @@ -5,6 +5,8 @@ name 'system-probe' +require './lib/project_helpers.rb' + source path: '..' relative_path 'src/github.com/DataDog/datadog-agent' @@ -21,7 +23,7 @@ mkdir "#{install_dir}/embedded/share/system-probe/ebpf/co-re/btf" mkdir "#{install_dir}/embedded/share/system-probe/java" - if ENV.has_key?('SYSTEM_PROBE_BIN') and not ENV['SYSTEM_PROBE_BIN'].empty? + if sysprobe_enabled? arch = `uname -m`.strip if arch == "aarch64" arch = "arm64" diff --git a/omnibus/lib/project_helpers.rb b/omnibus/lib/project_helpers.rb new file mode 100644 index 00000000000000..cf428cf2d26950 --- /dev/null +++ b/omnibus/lib/project_helpers.rb @@ -0,0 +1,12 @@ +# +# Profect related helpers +# + +require './lib/ostools.rb' + +def sysprobe_enabled?() + # This doesn't account for Windows special case which build system probe as part of the + # agent build process + return not heroku_target? && linux_target? && ENV.fetch('SYSTEM_PROBE_BIN', '').empty? +end +