This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
128 lines (106 loc) · 3.91 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
common_CHECKOPTS := --exclude=2034,2164
common_SRC := $(wildcard *.sh)
pipelines := build koji release watcher
koji_SRC := $(wildcard $(CURDIR)/koji/*.sh)
koji_STEPS := $(patsubst %.sh,%,$(notdir $(koji_SRC)))
build_CHECKOPTS := --exclude=2013,2024,2155
build_SRC := $(wildcard $(CURDIR)/build/*.sh)
build_STEPS := init-env local content mixer mca-check images license_info release_notes stage #skipping: koji
release_SRC := $(wildcard $(CURDIR)/release/*.sh)
release_STEPS := $(patsubst %.sh,%,$(notdir $(release_SRC)))
watcher_SRC := $(wildcard $(CURDIR)/watcher/*.sh)
watcher_STEPS := $(patsubst %.sh,%,$(notdir $(watcher_SRC)))
SRC := $(common_SRC) $(build_SRC) $(koji_SRC) $(release_SRC) $(watcher_SRC)
all:
@echo "Welcome to clr-distro-factory."
@echo ""
@echo "The 'make' targets of this project are for development purpose."
@echo "Please, access the online documentation for information about how"
@echo "to use and deploy this project in a production environment:"
@echo ""
@echo " https://github.com/clearlinux/clr-distro-factory/wiki"
@echo ""
@echo "Usage:"
@echo ""
@echo "'make <pipeline>' To run all steps of a pipeline'"
@echo ""
@echo "'make <pipeline>/<step>' To run an individual step. Steps may depend on"
@echo " the output of previous steps. It is up for the"
@echo " developer to fullfil its requirements."
@echo ""
@echo "'make serve' To run a webserver hosting updates."
@echo " Requires Python's SimpleHTTPServer."
@echo ""
@echo "pipelines: $(pipelines)"
@echo ""
@echo "build steps: $(build_STEPS)"
@echo ""
@echo "koji steps: $(koji_STEPS)"
@echo ""
@echo "release steps: $(release_STEPS)"
@echo ""
@echo "watcher steps: $(watcher_STEPS)"
NAMESPACE ?= developer-distro
CONFIG_REPO_HOST ?= $(CURDIR)/builder/
CLR_BUNDLES ?= "bootloader kernel-native os-core os-core-update"
HOSTNAME := $(shell hostname -f)
DISTRO_URL ?= http://$(HOSTNAME):8000/
MIXER_DIR := $(CURDIR)/builder/mixer
CONFIG_REPO := $(CURDIR)/builder/$(NAMESPACE)
STAGING_DIR := $(CURDIR)/builder/stage
WORK_DIR := $(CURDIR)/builder/work
$(MIXER_DIR) $(STAGING_DIR) $(WORK_DIR):
@mkdir -p $@
$(CONFIG_REPO):
@mkdir -p $@
@git init $@
@echo "DISTRO_NAME=$(NAMESPACE)" > $@/config.sh
@echo "DISTRO_URL=$(DISTRO_URL)" >> $@/config.sh
@echo "MIXER_DIR=$(MIXER_DIR)" >> $@/config.sh
@echo "STAGING_DIR=$(STAGING_DIR)" >> $@/config.sh
@git -C $@ add config.sh
@git -C $@ commit -m "Fake config.sh"
config: $(MIXER_DIR) $(STAGING_DIR) $(CONFIG_REPO)
.NOTPARALLEL: $(pipelines)
.PHONY: $(pipelines)
build: $(addprefix build/,$(build_STEPS))
.PHONY: $(addprefix build/,$(build_STEPS))
$(addprefix build/,$(build_STEPS)): config $(WORK_DIR)
@NAMESPACE=$(NAMESPACE) \
CONFIG_REPO_HOST=$(CONFIG_REPO_HOST) \
CLR_BUNDLES=$(CLR_BUNDLES) \
WORK_DIR=$(WORK_DIR) \
$@.sh
koji: $(addprefix koji/,$(koji_STEPS))
.PHONY: $(addprefix koji/,$(koji_STEPS))
$(addprefix koji/,$(koji_STEPS)):
@NAMESPACE=$(NAMESPACE) \
$@.sh
watcher: $(addprefix watcher/,$(watcher_STEPS))
.PHONY: $(addprefix watcher/,$(watcher_STEPS))
$(addprefix watcher/,$(watcher_STEPS)): config
@NAMESPACE=$(NAMESPACE) \
CONFIG_REPO_HOST=$(CONFIG_REPO_HOST) \
$@.sh
release: $(addprefix release/,$(release_STEPS))
.PHONY: $(addprefix release/,$(release_STEPS))
$(addprefix release/,$(release_STEPS)): config $(WORK_DIR)
@NAMESPACE=$(NAMESPACE) \
CONFIG_REPO_HOST=$(CONFIG_REPO_HOST) \
CLR_BUNDLES=$(CLR_BUNDLES) \
WORK_DIR=$(WORK_DIR) \
$@.sh
.PHONY: serve
serve: $(STAGING_DIR)
cd $(STAGING_DIR); python3 -m http.server
.PHONY: clean
clean:
rm -rf $(CURDIR)/builder
# Static Code Analysis
# ====================
check_CHECKOPTS := --exclude=1091
check_PIPELINES = check-common $(addprefix check-,$(pipelines))
$(check_PIPELINES): pipe = $(patsubst check-%,%,$@)
$(check_PIPELINES):
shellcheck -x $(check_CHECKOPTS) $($(pipe)_CHECKOPTS) $($(pipe)_SRC)
check: check-common $(check_PIPELINES)