forked from rancher/elemental-toolkit
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
223 lines (182 loc) · 4.29 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#
# cOS-toolkit Makefile
#
#
#----------------------- global variables -----------------------
#
# Path to luet binary
#
export LUET?=$(shell which luet 2> /dev/null)
ifeq ("$(LUET)","")
LUET="/usr/bin/luet"
endif
#
# Path to jq binary
#
export JQ?=$(shell which jq 2> /dev/null)
ifeq ("$(JQ)","")
JQ="/usr/bin/jq"
endif
#
# Path to hugo binary
#
export HUGO?=$(shell which hugo 2> /dev/null)
ifeq ("$(HUGO)","")
HUGO="/usr/bin/hugo"
endif
#
# Path to yq binary
#
export YQ?=$(shell which yq 2> /dev/null)
ifeq ("$(YQ)","")
YQ="/usr/bin/yq"
endif
#
# Path to luet-mtree binary
#
export MTREE?=$(shell which luet-mtree 2> /dev/null)
ifeq ("$(MTREE)","")
MTREE="/usr/bin/luet-mtree"
endif
#
# Path to luet-cosign binary
#
export COSIGN?=$(shell which luet-cosign 2> /dev/null)
ifeq ("$(COSIGN)","")
COSIGN="/usr/bin/luet-cosign"
endif
export ELEMENTAL?=$(shell which elemental 2> /dev/null)
ifeq ("$(ELEMENTAL)","")
ELEMENTAL="/usr/bin/elemental"
endif
#
# Location of package tree
#
TREE?=$(ROOT_DIR)/packages
#
# Directory of Makefile
#
export ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
#
# OS flavor to build
#
FLAVOR?=teal
#
# Arch to build for
#
ARCH?=x86_64
#
# Output for "make publish-repo" and base for "make iso"
#
ifneq ($(strip $(ARCH)), x86_64)
FINAL_REPO?=quay.io/costoolkit/releases-$(FLAVOR)-$(ARCH)
else
FINAL_REPO?=quay.io/costoolkit/releases-$(FLAVOR)
endif
#
# folder for build artefacts
#
DESTINATION?=$(ROOT_DIR)/build
#
# yaml specification of build targets
#
export MANIFEST?=$(ROOT_DIR)/manifest.yaml
#
# cos config environment file
#
export COS_CONFIG?=$(ROOT_DIR)/packages/cos-config/cos-config
#
# Packer target to build
#
PACKER_TARGET?=virtualbox-iso.cos
#
# Used by .iso, .test, and .run
#
ISO?=$(shell ls $(ROOT_DIR)/*.iso 2> /dev/null)
# Used by publish-repo and create-repo for the snapshot-id
# This is the commit of the latest tag
LAST_TAGGED_COMMIT=$(shell git rev-list --tags --max-count=1)
# this is the current commit
CURRENT_COMMIT ?= $(shell git rev-parse HEAD)
# get the tag
GIT_TAG ?= $(shell git describe --abbrev=0 --tags )
# if both match, we are on a tag, so use that for snapshot id, otherwise use the current commit
ifeq ($(strip $(LAST_TAGGED_COMMIT)), $(strip $(CURRENT_COMMIT)))
export SNAPSHOT_ID?=$(GIT_TAG)
else
export SNAPSHOT_ID?=$(CURRENT_COMMIT)
endif
#----------------------- end global variables -----------------------
#----------------------- default target -----------------------
all: deps build
#----------------------- includes -----------------------
include make/Makefile.build
include make/Makefile.iso
include make/Makefile.run
include make/Makefile.test
include make/Makefile.images
include make/Makefile.docs
#----------------------- targets -----------------------
deps: $(LUET) $(YQ) $(JQ) $(MAKEISO) $(MTREE) $(COSIGN) $(ELEMENTAL)
deps_ci: $(LUET) ci_deps
as_root:
ifneq ($(shell id -u), 0)
@echo "Please run 'make $@' as root"
@exit 1
endif
luet: as_root $(LUET)
add_local_repo: luet
$(LUET) repo add local -y --url $(DESTINATION) --type disk --priority 1 --description local-repo
$(LUET):
ifneq ($(shell id -u), 0)
@echo "'$@' is missing and you must be root to install it."
@exit 1
else
$(ROOT_DIR)/scripts/get_luet.sh
endif
$(YQ):
ifneq ($(shell id -u), 0)
@echo "'$@' is missing and you must be root to install it."
@exit 1
else
$(LUET) install -y toolchain/yq
endif
$(JQ):
ifneq ($(shell id -u), 0)
@echo "'$@' is missing and you must be root to install it."
@exit 1
else
$(LUET) install -y utils/jq
endif
$(HUGO):
ifneq ($(shell id -u), 0)
@echo "'$@' is missing and you must be root to install it."
@exit 1
else
$(LUET) install -y toolchain/hugo
endif
$(MTREE):
ifneq ($(shell id -u), 0)
@echo "'$@' is missing and you must be root to install it."
@exit 1
else
$(LUET) install -y toolchain/luet-mtree
endif
$(COSIGN):
ifneq ($(shell id -u), 0)
@echo "'$@' is missing and you must be root to install it."
@exit 1
else
$(LUET) install -y meta/cos-verify
endif
$(ELEMENTAL):
ifneq ($(shell id -u), 0)
@echo "'$@' is missing and you must be root to install it."
@exit 1
else
$(LUET) install -y toolchain/elemental-cli
endif
ci_deps: as_root
$(LUET) install -y toolchain/elemental-cli meta/cos-verify toolchain/luet-mtree utils/jq toolchain/yq
clean: clean_build clean_iso clean_run clean_test
rm -rf $(ROOT_DIR)/*.sha256