-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
106 lines (94 loc) · 3.43 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
102
103
104
105
106
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)/
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:
help: ## Display this help
@perl -lne 'if (/^([\$$a-z][^:]+):(([^:]+):)?/) { if ($$3) {$$name = $$3} else {$$name = $$1} }; if ($$name && / ## (.+)$$/) { printf "%s: \033[36m%-30s\033[0m%s\n", $$name, $$1; $$name = "" }' $(MAKEFILE_LIST)
@echo
@echo "Reminder: foo-% => \$$@=foo-bar \$$*=bar"
@echo
@echo "Only some tools: TOOLS_RAW=\$$(jq -r '.tools[].name' metadata.json | grep ^k | xargs echo) make info"
@echo
.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