From 45f6d65fd4480970db6ad136ce34095cdef2a3d9 Mon Sep 17 00:00:00 2001 From: grantseltzer Date: Wed, 8 Sep 2021 16:40:39 -0400 Subject: [PATCH 1/3] Check os-release file for rhel or centos string Signed-off-by: grantseltzer --- tracee-ebpf/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tracee-ebpf/Makefile b/tracee-ebpf/Makefile index f5950062acb6..f4cc5053592a 100644 --- a/tracee-ebpf/Makefile +++ b/tracee-ebpf/Makefile @@ -39,9 +39,12 @@ DOCKER_BUILDER_KERN_SRC ?= $(if $(shell readlink $(KERN_SRC_PATH)),$(shell readl DOCKER_BUILDER_KERN_SRC_MNT ?= $(dir $(DOCKER_BUILDER_KERN_SRC)) LINUX_VERSION_CODE := $(shell uname -r | awk '{split($$0,a,"."); split(a[3], b, "-"); print lshift(a[1], 16) + lshift(a[2],8) + b[1];}') -ifneq (,$(wildcard /etc/redhat-release)) - RHEL_MAJOR := $(shell grep -Eoh -m 1 '[0-9]+\.[0-9]+' /etc/redhat-release | cut -d '.' -f 1) - RHEL_MINOR := $(shell grep -Eoh -m 1 '[0-9]+\.[0-9]+' /etc/redhat-release | cut -d '.' -f 2) +DIST_ID := $(shell grep -m 1 'ID=' /usr/lib/os-release | cut -d '=' -f '2' | sed 's/\"//g') +VERSION_ID := $(shell grep -m 1 'VERSION_ID=' /usr/lib/os-release | cut -d '=' -f '2' | sed 's/\"//g') +CENTOS_MERGED_RHEL := $(shell echo $(DIST_ID) | sed 's/centos/rhel/') +ifeq ($(CENTOS_MERGED_RHEL), rhel) + RHEL_MAJOR := $(shell echo $(VERSION_ID) | cut -d '.' -f 1) + RHEL_MAJOR := $(shell echo $(VERSION_ID) | cut -d '.' -f 2) RHEL_RELEASE_CODE := $(shell echo $$(($(RHEL_MAJOR) << 8 | $(RHEL_MINOR)))) else RHEL_RELEASE_CODE := 0 From 2e96b306ff85df8ca639aef11d36d87080203014 Mon Sep 17 00:00:00 2001 From: grantseltzer Date: Wed, 8 Sep 2021 18:54:31 -0400 Subject: [PATCH 2/3] Second major is minor Signed-off-by: grantseltzer --- tracee-ebpf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracee-ebpf/Makefile b/tracee-ebpf/Makefile index f4cc5053592a..fd4ba8c6529e 100644 --- a/tracee-ebpf/Makefile +++ b/tracee-ebpf/Makefile @@ -44,7 +44,7 @@ VERSION_ID := $(shell grep -m 1 'VERSION_ID=' /usr/lib/os-release | cut -d '=' - CENTOS_MERGED_RHEL := $(shell echo $(DIST_ID) | sed 's/centos/rhel/') ifeq ($(CENTOS_MERGED_RHEL), rhel) RHEL_MAJOR := $(shell echo $(VERSION_ID) | cut -d '.' -f 1) - RHEL_MAJOR := $(shell echo $(VERSION_ID) | cut -d '.' -f 2) + RHEL_MINOR := $(shell echo $(VERSION_ID) | cut -d '.' -f 2) RHEL_RELEASE_CODE := $(shell echo $$(($(RHEL_MAJOR) << 8 | $(RHEL_MINOR)))) else RHEL_RELEASE_CODE := 0 From 3575ff39ef28949bd02c50200efb89ff420ba7a0 Mon Sep 17 00:00:00 2001 From: grantseltzer Date: Fri, 10 Sep 2021 11:41:42 -0400 Subject: [PATCH 3/3] Use /etc/os-release instead of /usr/lib Signed-off-by: grantseltzer --- tracee-ebpf/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tracee-ebpf/Makefile b/tracee-ebpf/Makefile index fd4ba8c6529e..134f08f947c8 100644 --- a/tracee-ebpf/Makefile +++ b/tracee-ebpf/Makefile @@ -26,6 +26,8 @@ BPF_BUNDLE := $(OUT_DIR)/tracee.bpf.tar.gz LIBBPF_SRC := 3rdparty/libbpf/src LIBBPF_HEADERS := $(OUT_DIR)/libbpf/usr/include LIBBPF_OBJ := $(OUT_DIR)/libbpf/libbpf.a +OS_RELEASE_FILE := /etc/os-release + # static build: ifdef STATIC CGO_EXT_LDFLAGS += -static @@ -39,8 +41,8 @@ DOCKER_BUILDER_KERN_SRC ?= $(if $(shell readlink $(KERN_SRC_PATH)),$(shell readl DOCKER_BUILDER_KERN_SRC_MNT ?= $(dir $(DOCKER_BUILDER_KERN_SRC)) LINUX_VERSION_CODE := $(shell uname -r | awk '{split($$0,a,"."); split(a[3], b, "-"); print lshift(a[1], 16) + lshift(a[2],8) + b[1];}') -DIST_ID := $(shell grep -m 1 'ID=' /usr/lib/os-release | cut -d '=' -f '2' | sed 's/\"//g') -VERSION_ID := $(shell grep -m 1 'VERSION_ID=' /usr/lib/os-release | cut -d '=' -f '2' | sed 's/\"//g') +DIST_ID := $(shell grep -m 1 'ID=' $(OS_RELEASE_FILE) | cut -d '=' -f '2' | sed 's/\"//g') +VERSION_ID := $(shell grep -m 1 'VERSION_ID=' $(OS_RELEASE_FILE) | cut -d '=' -f '2' | sed 's/\"//g') CENTOS_MERGED_RHEL := $(shell echo $(DIST_ID) | sed 's/centos/rhel/') ifeq ($(CENTOS_MERGED_RHEL), rhel) RHEL_MAJOR := $(shell echo $(VERSION_ID) | cut -d '.' -f 1)