Skip to content

Commit 2826d0a

Browse files
committed
Allow for heroku variant build.
- Create agent "flavor" flags (none, fips, heroku) - These can be used from the command line to install different pieces of the agent as needed. - Use the distinction to install the correct set of OSS licenses. - Fix license file for libpopt Changing for heroku will invalidate the cache, but I can live with that - it is a smaller build than the rest, an already a distinct pipeline - for now, we are only using it for the packaging layers. My plan is to adopt project files to be able to limit the scope of the flavor flag so that it will not reach outside of //packages/... This is a precursor to #44033 and #44183, which add top level package targets for the distinct distribution artifacts. At that time, the "select()"ion of all deps will happen from the top, and we won't need license generation in //compliance.
1 parent 456046f commit 2826d0a

File tree

5 files changed

+81
-5
lines changed

5 files changed

+81
-5
lines changed

compliance/BUILD.bazel

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ py_binary(
1212
deps = ["//tasks:licenses"],
1313
)
1414

15+
filegroup(
16+
name = "all_agent_deps",
17+
srcs = [
18+
"//deps:all_deps",
19+
] + select({
20+
"//packages/agent:linux_heroku": [],
21+
"//conditions:default": [
22+
# This will become "//deps/openscap:all_deps" in the future
23+
"@popt",
24+
],
25+
}),
26+
)
27+
1528
# Gather the licenses for dependencies that not built by omnibus any more.
1629
# The target is a temporary hack. In the future, it should become //distrib:agent.
1730
license_csv(
@@ -20,7 +33,7 @@ license_csv(
2033
licenses_dir = "licenses_dir",
2134
offers_dir = "sources_dir",
2235
tags = ["manual"],
23-
target = "//deps:all_deps",
36+
target = ":all_agent_deps",
2437
)
2538

2639
# Turn the copied licenses into a target we can feed to other rules.
@@ -62,7 +75,7 @@ filter_directory(
6275
strip_prefix = ".",
6376
)
6477

65-
# You would expect that filter_directory returns something usuable to pkg_* rules.
78+
# You would expect that filter_directory returns something usable to pkg_* rules.
6679
# It does not, so we have to wrap it.
6780
pkg_files(
6881
name = "offer_copies",

deps/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ filegroup(
2929
"@libxslt",
3030
"@nghttp2",
3131
"@pcre2",
32-
"@popt",
3332
"@zstd",
3433
],
3534
"//:macos_arm64": [

omnibus/config/software/datadog-agent-finalize.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
# TODO too many things done here, should be split
2626
block do
2727
# Push all the pieces built with Bazel.
28-
command_on_repo_root "bazelisk run -- //packages/install_dir:install --destdir=#{install_dir}", env: {"BUILD_WORKSPACE_DIRECTORY" => "." }
28+
29+
# TODO: flavor can be defaulted and set from the bazel wrapper based on the environment.
30+
command_on_repo_root "bazelisk run --//:install_dir=#{install_dir} --//packages/agent:flavor=#{flavor_arg} -- //packages/install_dir:install"
2931

3032
# Conf files
3133
if windows_target?
@@ -64,6 +66,7 @@
6466
delete "#{install_dir}/embedded/include/dbus-1.0"
6567
end
6668

69+
# TODO: Rather than move these, let's install them to the right place to start
6770
if linux_target?
6871
# Move configuration files
6972
mkdir "#{output_config_dir}/etc/datadog-agent"

packages/agent/BUILD.bazel

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Agent packages
2+
3+
load("@bazel_skylib//lib:selects.bzl", "selects")
4+
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
5+
6+
package(default_visibility = ["//visibility:public"])
7+
8+
string_flag(
9+
name = "flavor",
10+
build_setting_default = "base",
11+
# These values match omnibus.
12+
values = [
13+
"base",
14+
"fips",
15+
"heroku",
16+
],
17+
)
18+
19+
alias(
20+
name = "default_flavor",
21+
actual = ":base_flavor",
22+
)
23+
24+
config_setting(
25+
name = "base_flavor",
26+
flag_values = {"@@//packages/agent:flavor": "base"},
27+
)
28+
29+
config_setting(
30+
name = "fips_flavor",
31+
flag_values = {"@@//packages/agent:flavor": "fips"},
32+
)
33+
34+
config_setting(
35+
name = "heroku_flavor",
36+
flag_values = {"@@//packages/agent:flavor": "heroku"},
37+
)
38+
39+
selects.config_setting_group(
40+
name = "linux_heroku",
41+
match_all = [
42+
":heroku_flavor",
43+
"@platforms//os:linux",
44+
],
45+
)

packages/install_dir/BUILD.bazel

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,27 @@ pkg_filegroup(
2929
}),
3030
)
3131

32+
# All the things that belong in /etc
33+
# This is not strictly in install_dir but it is a cousin.
34+
# TODO: split this cleanly. The way the omnibus script works
35+
# is to install everything into install_dir (/opt/datadog-agent)
36+
# and then bulk move things to {output_dir}/etc/ in the finalizer.
37+
# We need to fix that so we just generate to the right place. For
38+
# now, let's just try to keep etc things separate.
39+
pkg_filegroup(
40+
name = "etc",
41+
srcs = [
42+
"//deps/snmp_traps:all_files",
43+
],
44+
)
45+
46+
# Gather everything that goes in /opt/datadog-agent/...
3247
pkg_install(
3348
name = "install",
3449
srcs = [
3550
":embedded",
51+
":etc",
3652
":licenses",
37-
"//deps/snmp_traps:all_files",
3853
],
54+
destdir_flag = "//:install_dir",
3955
)

0 commit comments

Comments
 (0)