-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
87 lines (78 loc) · 2.72 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
# Use bash instead of sh
SHELL := /usr/bin/env bash
# Unify target echoing
PRINT_TARGET = @echo "--> $@"
# Default make goal
.DEFAULT_GOAL := help
# Required OpenCore version
REQUIRED_OPENCORE_VERSION := $(shell grep 'readonly OPENCORE_VERSION=' create-efi.sh | awk -F'"' '{ print $$2; }')
## Targets
.PHONY: clean
clean: ## Remove autogenerated and downloaded files
$(PRINT_TARGET)
-rm -fr ./EFI ./OC/Sample.plist ./util/ocvalidate EFI*.{tar.gz,zip}
git_tag_add: ## Create and push git tag from `OC_GIT_TAG` env var to create GitHub release and upload assets
$(PRINT_TARGET)
ifeq ($(OC_GIT_TAG),)
$(error OC_GIT_TAG variable is not set)
endif
git tag ${OC_GIT_TAG}
git push origin ${OC_GIT_TAG}
git_tag_delete: ## Delete and push git tag from `OC_GIT_TAG` env var
$(PRINT_TARGET)
ifeq ($(OC_GIT_TAG),)
$(error OC_GIT_TAG variable is not set)
endif
git tag -d ${OC_GIT_TAG}
git push --delete origin ${OC_GIT_TAG}
.PHONY: help
help: ## Display this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[0;32m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: lint
lint: ## Run linter checks
$(PRINT_TARGET)
@echo "GNU bash, version $${BASH_VERSION}"
@echo "Linting property list files..."
find "${CURDIR}" -name '*.plist' -print0 | xargs -0 -t -n1 plutil -lint
@echo "Linting bash scripts..."
shellcheck --version
find "${CURDIR}" -name '*.sh' -print0 | xargs -0 -t -n1 shellcheck --color=always --severity=style
@echo "Linting YAML files..."
yamllint --version
yamllint -s "${CURDIR}"
.PHONY: oc_get_ref_config
oc_get_ref_config: clean ## Download latest OpenCore reference configuration file to 'OC/Sample.plist' (used for debugging changes)
$(PRINT_TARGET)
ifeq "$(shell command -v wget)" ""
$(error Cannot find wget)
endif
wget -nv -c https://raw.githubusercontent.com/acidanthera/OpenCorePkg/$(REQUIRED_OPENCORE_VERSION)/Docs/Sample.plist -O ./OC/Sample.plist
ls -lah ./OC/Sample.plist
.PHONY: run
run: clean ## Generate EFI folder with 'config.plist' template
$(PRINT_TARGET)
LOCAL_RUN=1 "${CURDIR}/create-efi.sh"
.PHONY: test
test: clean ## Run tests
$(PRINT_TARGET)
@echo "GNU bash, version $${BASH_VERSION}"
bats --version
bats ${CI:--tap} --timing test
.PHONY: vault
vault: run ## Generate OpenCore 'config.plist' from template
$(PRINT_TARGET)
@# Check for required tools
ifeq "$(shell command -v sops)" ""
$(error Cannot find sops)
endif
sops --version
@# Replace placeholders in 'config.plist' with secrets
"${CURDIR}/util/vault.sh"
@# Validate 'config.plist'
@echo "Validating 'config.plist'..."
ifeq "$(shell command -v $(CURDIR)/util/ocvalidate)" ""
$(error Cannot find $(CURDIR)/util/ocvalidate)
endif
${CURDIR}/util/ocvalidate ${CURDIR}/EFI/OC/config.plist