Skip to content

Commit

Permalink
Merge pull request #214 from dhaiducek/oc-compatibility
Browse files Browse the repository at this point in the history
Detect GLIBC version for `oc`
  • Loading branch information
Kyl-Bempah authored Jul 3, 2024
2 parents 7352561 + 253f7e9 commit f999b8a
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions modules/oc/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# A simple build harness module to install the newest version of the oc cli.

OC_BUILD_VERSION?=latest
OC_BUILD_VERSION ?= latest
OC_PLATFORM ?= $(shell echo $(BUILD_HARNESS_OS) | sed 's/darwin/mac/g')
OC_SOURCE_URL?="https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OC_BUILD_VERSION}/openshift-client-${OC_PLATFORM}.tar.gz"
OC_SOURCE_URL ?= https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$(OC_BUILD_VERSION)

OC_DEST_PATH?=${BUILD_HARNESS_PATH}/vendor
OC_TAR_PATH?=${OC_DEST_PATH}/oc.tar.gz
OC?=${OC_DEST_PATH}/oc
OC_DEST_PATH ?= ${BUILD_HARNESS_PATH}/vendor
OC_TAR_PATH ?= ${OC_DEST_PATH}/oc.tar.gz
OC ?= ${OC_DEST_PATH}/oc
OC_CLUSTER_USER ?=
OC_CLUSTER_PASS ?=
OC_CLUSTER_TOKEN ?=
Expand All @@ -19,14 +19,23 @@ OC_SILENT ?= true

.PHONY: oc/install
## Install the oc cli
# Contains GLIBC version detection since `oc` v4.16 is compatible with GLIBC 2.32 and greater. Errors appear as:
# oc: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by oc)
oc/install: %install:
@if [ ! -x $(OC) ]; then \
OC_BINARY="openshift-client-${OC_PLATFORM}"; \
if command -v ldd &>/dev/null; then \
OC_LIBC_VERSION="$$(ldd --version | head -1 | awk '{print $NF}')"; \
fi; \
if [ -n "$${OC_LIBC_VERSION}" ] && [ "$${OC_LIBC_VERSION%\.*}" -le "2" ] && [ "$${OC_LIBC_VERSION#*\.}" -lt "32" ]; then \
OC_BINARY="$${OC_BINARY}-${BUILD_HARNESS_ARCH}-rhel8"; \
fi; \
if [ ! -z "$(OC_SILENT)" ]; then \
curl -s -L -X GET ${OC_SOURCE_URL} -o ${OC_TAR_PATH} > /dev/null; \
curl -s -L -X GET ${OC_SOURCE_URL}/$${OC_BINARY}.tar.gz -o ${OC_TAR_PATH} > /dev/null; \
tar -xf ${OC_TAR_PATH} -C ${OC_DEST_PATH} > /dev/null; \
rm -f ${OC_TAR_PATH} > /dev/null; \
else \
curl -L -X GET ${OC_SOURCE_URL} -o ${OC_TAR_PATH}; \
curl -L -X GET ${OC_SOURCE_URL}/$${OC_BINARY}.tar.gz -o ${OC_TAR_PATH}; \
tar -xf ${OC_TAR_PATH} -C ${OC_DEST_PATH}; \
rm -f ${OC_TAR_PATH}; \
fi \
Expand Down

0 comments on commit f999b8a

Please sign in to comment.