Last active
February 14, 2024 00:47
-
-
Save caelifer/7ea67210ed8a29e753553eae5b1543d2 to your computer and use it in GitHub Desktop.
Full Datadog Agent RPM Build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xeuo pipefail | |
RELEASED_VERSION_TAG=${DD_VERSION:-7.50.3} | |
PRESERVE_WORKSPACE=${KEEP_BUID_WS:-yes} | |
BUILD_BUILDER=${NEED_BUILDER:-""} | |
# Create a workspace | |
WS=$(mktemp --tmpdir=. -d) | |
echo "Building new package in '${WS}'" | |
# Kleen area unless | |
if [ M${PRESERVE_WORKSPACE} != Myes ] | |
then | |
trap "sudo rm -rf '${WS}'" 0 1 3 9 15 | |
fi | |
# Clean from possible previous runs | |
sudo rm -rf /tmp/omnibus /tmp/gems | |
# Build custom RPM buildimage based on the latest from Datadog to add missing software required by build process. | |
# In the original image Centos6 is used as a base and the patchelf is installed via yum. Unfortunately, `patchelf` | |
# package is only available on Centos7 and later. So, we have to install it manually using PIP. | |
( | |
cd "${WS}" | |
( | |
# Clone DD Builder repo | |
if [ ! -z "${BUILD_BUILDER}" ] | |
then | |
test -d datadog-agent-buildimages && sudo rm -rf datadog-agent-buildimages | |
git clone https://github.com/DataDog/datadog-agent-buildimages.git | |
cd datadog-agent-buildimages | |
docker build -t dd-builder-rpm-x64-7.50 -f rpm-x64/Dockerfile . | |
fi | |
# Build custom builder image | |
mkdir -p custom && cd custom && \ | |
docker build --rm --file - -t mybuilder . <<__EndOfDockerfile | |
FROM dd-builder-rpm-x64-7.50 | |
RUN source ~/.bash_profile; pip install patchelf | |
__EndOfDockerfile | |
) | |
# Clone Datadog Agent repo | |
test -d datadog-agent && sudo rm -rf datadog-agent | |
git clone https://github.com/DataDog/datadog-agent.git | |
cd datadog-agent | |
# Check out latest released version - 7.50.3 | |
git checkout -d ${RELEASED_VERSION_TAG} | |
# Patch distribution to fix system probe build | |
patch -p1 <<__EndOfPatch__ | |
diff --git a/tasks/build_tags.py b/tasks/build_tags.py | |
index 8ed18e6cff..abcb0c5052 100644 | |
--- a/tasks/build_tags.py | |
+++ b/tasks/build_tags.py | |
@@ -124,7 +124,7 @@ SECURITY_AGENT_TAGS = {"netcgo", "secrets", "docker", "containerd", "kubeapiserv | |
SERVERLESS_TAGS = {"serverless", "otlp"} | |
# SYSTEM_PROBE_TAGS lists the tags necessary to build system-probe | |
-SYSTEM_PROBE_TAGS = AGENT_TAGS.union({"clusterchecks", "linux_bpf", "npm"}).difference({"python", "systemd"}) | |
+SYSTEM_PROBE_TAGS = AGENT_TAGS.union({"clusterchecks", "npm"}).difference({"python", "systemd"}) | |
# TRACE_AGENT_TAGS lists the tags that have to be added when the trace-agent | |
TRACE_AGENT_TAGS = {"docker", "containerd", "kubeapiserver", "kubelet", "otlp", "netcgo", "podman", "secrets"} | |
__EndOfPatch__ | |
# Run docker command to build RPM | |
docker run \ | |
-v "$PWD:/go/src/github.com/DataDog/datadog-agent" \ | |
-v "/tmp/omnibus:/omnibus" \ | |
-v "/tmp/gems:/gems" \ | |
--workdir=/go/src/github.com/DataDog/datadog-agent \ | |
mybuilder \ | |
inv -e agent.omnibus-build --base-dir=/omnibus --gem-path=/gems | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment