Skip to content

Commit

Permalink
Check os-release file for rhel or centos string (#1001)
Browse files Browse the repository at this point in the history
* Check os-release file for rhel or centos string

Signed-off-by: grantseltzer <grantseltzer@gmail.com>

* Second major is minor

Signed-off-by: grantseltzer <grantseltzer@gmail.com>

* Use /etc/os-release instead of /usr/lib

Signed-off-by: grantseltzer <grantseltzer@gmail.com>
  • Loading branch information
grantseltzer committed Sep 10, 2021
1 parent cd26d25 commit 11e8451
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tracee-ebpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,9 +41,12 @@ DOCKER_BUILDER_KERN_SRC ?= $(if $(shell readlink -f $(KERN_SRC_PATH)),$(shell re
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=' $(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)
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
Expand Down

0 comments on commit 11e8451

Please sign in to comment.