From ae71b8fca146c060699f3af92921d0254ccc0d47 Mon Sep 17 00:00:00 2001 From: Eugene Arbatsky Date: Mon, 20 Jan 2025 22:48:28 +0800 Subject: [PATCH 1/4] install route for Makefile --- Makefile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Makefile b/Makefile index 6bcfd90..1d47725 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,39 @@ BINARY_NAME=ydbops BUILD_DIR=bin +PREFIX ?= ~/ydb/bin TODAY=$(shell date --iso=minutes) GIT_COMMIT=$(shell git rev-parse HEAD) +# Detect OS and architecture +ifeq ($(OS),Windows_NT) + SYSTEM_OS = win32 + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + SYSTEM_ARCH = amd64 + endif + ifeq ($(PROCESSOR_ARCHITECTURE),x86) + SYSTEM_ARCH = x86 + endif +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + SYSTEM_OS = linux + endif + ifeq ($(UNAME_S),Darwin) + SYSTEM_OS = darwin + endif + UNAME_P := $(shell uname -p) + ifeq ($(UNAME_P),x86_64) + SYSTEM_ARCH = amd64 + endif + ifneq ($(filter %86,$(UNAME_P)),) + SYSTEM_ARCH = x86 + endif + ifneq ($(filter arm%,$(UNAME_P)),) + SYSTEM_ARCH = arm64 + endif +endif + # APP_VERSION gets supplied from outside in CI as an env variable. # By default you can still build `ydbops` manually without specifying it, # but there won't be a nice tag in `--version`. There will be a commit SHA anyway. @@ -45,3 +75,11 @@ build-in-docker: clear docker docker create --name $(BINARY_NAME) $(BINARY_NAME) docker cp '$(BINARY_NAME):/app/bin/' $(BUILD_DIR) docker rm -f $(BINARY_NAME) + +install: +ifeq ($(UNAME_S),Darwin) + cp ${BUILD_DIR}/${BINARY_NAME}_$(SYSTEM_OS)_$(SYSTEM_ARCH) $(PREFIX)/ydbops +else + cp ${BUILD_DIR}/${BINARY_NAME} $(PREFIX)/ydbops +endif + chmod +x $(PREFIX)/ydbops \ No newline at end of file From cd2c261f3125cccf8ad5592d7ec70850beda9ee1 Mon Sep 17 00:00:00 2001 From: Eugene Arbatsky Date: Tue, 21 Jan 2025 15:52:25 +0800 Subject: [PATCH 2/4] +changes --- .changes/unreleased/Added-20250121-155155.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changes/unreleased/Added-20250121-155155.yaml diff --git a/.changes/unreleased/Added-20250121-155155.yaml b/.changes/unreleased/Added-20250121-155155.yaml new file mode 100644 index 0000000..cbfadc9 --- /dev/null +++ b/.changes/unreleased/Added-20250121-155155.yaml @@ -0,0 +1,3 @@ +kind: Added +body: Add new target into Makefile - install +time: 2025-01-21T15:51:55.43821+08:00 From a9b6b3fe020b9ddbcdd115932687ad84cd19e283 Mon Sep 17 00:00:00 2001 From: Eugene Arbatsky Date: Tue, 21 Jan 2025 18:09:31 +0800 Subject: [PATCH 3/4] Rename variable --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 1d47725..2f01f46 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BINARY_NAME=ydbops BUILD_DIR=bin -PREFIX ?= ~/ydb/bin +INSTALL_DIR ?= ~/ydb/bin TODAY=$(shell date --iso=minutes) GIT_COMMIT=$(shell git rev-parse HEAD) @@ -77,9 +77,9 @@ build-in-docker: clear docker docker rm -f $(BINARY_NAME) install: -ifeq ($(UNAME_S),Darwin) - cp ${BUILD_DIR}/${BINARY_NAME}_$(SYSTEM_OS)_$(SYSTEM_ARCH) $(PREFIX)/ydbops +ifeq ($(SYSTEM_OS),darwin) + cp ${BUILD_DIR}/${BINARY_NAME}_$(SYSTEM_OS)_$(SYSTEM_ARCH) $(INSTALL_DIR)/ydbops else - cp ${BUILD_DIR}/${BINARY_NAME} $(PREFIX)/ydbops + cp ${BUILD_DIR}/${BINARY_NAME} $(INSTALL_DIR)/ydbops endif chmod +x $(PREFIX)/ydbops \ No newline at end of file From bf03ec1186e1975eedb2f2af9226653ad6f2eca9 Mon Sep 17 00:00:00 2001 From: Eugene Arbatsky Date: Tue, 21 Jan 2025 18:10:00 +0800 Subject: [PATCH 4/4] Rename variable --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2f01f46..0216246 100644 --- a/Makefile +++ b/Makefile @@ -82,4 +82,4 @@ ifeq ($(SYSTEM_OS),darwin) else cp ${BUILD_DIR}/${BINARY_NAME} $(INSTALL_DIR)/ydbops endif - chmod +x $(PREFIX)/ydbops \ No newline at end of file + chmod +x $(INSTALL_DIR)/ydbops \ No newline at end of file