-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
101 lines (90 loc) · 3.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
M = $(shell printf "\033[34;1m▶\033[0m")
SHELL := /bin/bash
GIT_BRANCH ?= $(shell git branch --show-current)
GIT_COMMIT_SHA = $(shell git rev-parse HEAD)
#VERSION ?= $(patsubst v%,%,$(GIT_BRANCH))
VERSION ?= main
DOCKER_TAG ?= $(subst /,-,$(VERSION))
TOOLS_DIR = tools
ALL_TOOLS = $(shell find tools -type f -wholename \*/manifest.yaml | cut -d/ -f1-2 | sort)
ALL_TOOLS_RAW = $(subst tools/,,$(ALL_TOOLS))
TOOLS ?= $(shell find tools -type f -wholename \*/manifest.yaml | cut -d/ -f1-2 | sort)
TOOLS_RAW ?= $(subst tools/,,$(TOOLS))
PREFIX ?= /uniget_bootstrap
TARGET ?= /usr/local
# Pre-defined colors: https://github.com/moby/buildkit/blob/master/util/progress/progressui/colors.go
BUILDKIT_COLORS ?= run=light-blue:warning=yellow:error=red:cancel=255,165,0
NO_COLOR ?= ""
OWNER ?= uniget-org
PROJECT ?= tools
REGISTRY ?= ghcr.io
REPOSITORY_PREFIX ?= $(OWNER)/$(PROJECT)/
REGISTRY2 ?= registry.gitlab.com
REPOSITORY_PREFIX2 ?= $(OWNER)/$(PROJECT)/
SOURCE1_PREFIX ?= $(REGISTRY)/$(REPOSITORY_PREFIX)
SOURCE2_PREFIX ?= $(REGISTRY2)/$(REPOSITORY_PREFIX2)
HELPER = helper
BIN = $(HELPER)/usr/local/bin
export PATH := $(BIN):$(PATH)
SUPPORTED_ARCH := x86_64 aarch64
SUPPORTED_ALT_ARCH := amd64 arm64
ARCH ?= $(shell uname -m)
ifeq ($(ARCH),x86_64)
ALT_ARCH := amd64
endif
ifeq ($(ARCH),aarch64)
ALT_ARCH := arm64
endif
ifndef ALT_ARCH
$(error ERROR: Unable to determine alternative name for architecture ($(ARCH)))
endif
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))
.PHONY:
all: $(ALL_TOOLS_RAW)
.PHONY:
info: ; $(info $(M) Runtime info...)
@echo "BUILDKIT_COLORS: $(BUILDKIT_COLORS)"
@echo "NO_COLOR: $(NO_COLOR)"
@echo "GIT_BRANCH: $(GIT_BRANCH)"
@echo "GIT_COMMIT_SHA: $(GIT_COMMIT_SHA)"
@echo "VERSION: $(VERSION)"
@echo "DOCKER_TAG: $(DOCKER_TAG)"
@echo "OWNER: $(OWNER)"
@echo "PROJECT: $(PROJECT)"
@echo "REGISTRY: $(REGISTRY)"
@echo "REPOSITORY_PREFIX: $(REPOSITORY_PREFIX)"
@echo "TOOLS_RAW: $(TOOLS_RAW)"
@echo "SUPPORTED_ARCH: $(SUPPORTED_ARCH)"
@echo "SUPPORTED_ALT_ARCH: $(SUPPORTED_ALT_ARCH)"
@echo "ARCH: $(ARCH)"
@echo "ALT_ARCH: $(ALT_ARCH)"
.PHONY:
clean: ## Remove all temporary files
@set -o errexit; \
rm -f metadata.json; \
rm -rf helper; \
for TOOL in $(ALL_TOOLS_RAW); do \
rm -f \
$(TOOLS_DIR)/$${TOOL}/manifest.json \
$(TOOLS_DIR)/$${TOOL}/Dockerfile \
$(TOOLS_DIR)/$${TOOL}/build.log \
$(TOOLS_DIR)/$${TOOL}/sbom.json; \
done
.PHONY:
list: ## List available tools
@echo "$(ALL_TOOLS_RAW)"
.PHONY:
$(addsuffix --show,$(ALL_TOOLS_RAW)):%--show: $(TOOLS_DIR)/$* ## Display directory contents
@ls -l $(TOOLS_DIR)/$*
-include .env.mk
include make/dev.mk
include make/metadata.mk
include make/tool.mk
include make/sbom.mk
include make/ghcr.mk
include make/helper.mk