Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
290 lines (238 loc) · 9.57 KB
/
Copy pathMakefile
File metadata and controls
290 lines (238 loc) · 9.57 KB
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# THIS FILE WAS AUTOMATICALLY GENERATED BY KRES, PLEASE DO NOT EDIT.
#
# Generated on 2026-07-08T10:42:01Z by kres 14a38a3.
# common variables
SHA := $(shell git describe --match=none --always --abbrev=8 --dirty)
TAG ?= $(shell git describe --tag --always --dirty --match v[0-9]\*)
TAG_SUFFIX ?=
ABBREV_TAG ?= $(shell git describe --tags >/dev/null 2>/dev/null && git describe --tag --always --match v[0-9]\* --abbrev=0 || echo 'undefined')
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
ARTIFACTS := _out
IMAGE_TAG ?= $(TAG)$(TAG_SUFFIX)
OPERATING_SYSTEM := $(shell uname -s | tr '[:upper:]' '[:lower:]')
GOARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
CI_RELEASE_TAG := $(shell git log --oneline --format=%B -n 1 HEAD^2 -- 2>/dev/null | head -n 1 | sed -r "/^release\(.*\)/ s/^release\((.*)\):.*$$/\\1/; t; Q")
REGISTRY ?= ghcr.io
USERNAME ?= siderolabs
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
KRES_IMAGE ?= ghcr.io/siderolabs/kres:latest
CONFORMANCE_IMAGE ?= ghcr.io/siderolabs/conform:latest
# source date epoch of first commit
INITIAL_COMMIT_SHA := $(shell git rev-list --max-parents=0 HEAD)
SOURCE_DATE_EPOCH := $(shell git log $(INITIAL_COMMIT_SHA) --pretty=%ct)
# sync bldr image with pkgfile
BLDR_RELEASE := v0.6.1
BLDR_IMAGE := ghcr.io/siderolabs/bldr:$(BLDR_RELEASE)
BLDR := docker run --rm --user $(shell id -u):$(shell id -g) --volume $(PWD):/src --entrypoint=/bldr $(BLDR_IMAGE) --root=/src
# docker build settings
BUILD := docker buildx build
PLATFORM ?= linux/amd64,linux/arm64
PROGRESS ?= auto
PUSH ?= false
CI_ARGS ?=
WITH_BUILD_DEBUG ?=
BUILD_ARGS = --build-arg=SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
COMMON_ARGS = --file=Pkgfile
COMMON_ARGS += --provenance=false
COMMON_ARGS += --sbom=false
COMMON_ARGS += --progress=$(PROGRESS)
COMMON_ARGS += --platform=$(PLATFORM)
COMMON_ARGS += $(BUILD_ARGS)
# targets defines all the available targets
TARGETS = apparmor
TARGETS += btrfsprogs
TARGETS += ca-certificates
TARGETS += cni
TARGETS += containerd
TARGETS += cpio
TARGETS += cryptsetup
TARGETS += dosfstools
TARGETS += e2fsprogs
TARGETS += fhs
TARGETS += flannel-cni
TARGETS += glib
TARGETS += grub
TARGETS += igzip
TARGETS += ipmitool
TARGETS += iptables
TARGETS += ipxe
TARGETS += kmod
TARGETS += libaio
TARGETS += libarchive
TARGETS += libattr
TARGETS += libburn
TARGETS += libcap
TARGETS += libinih
TARGETS += libisoburn
TARGETS += libisofs
TARGETS += libjansson
TARGETS += libjson-c
TARGETS += liblzma
TARGETS += libmnl
TARGETS += libnftnl
TARGETS += libpopt
TARGETS += libseccomp
TARGETS += libselinux
TARGETS += libsepol
TARGETS += libucontext
TARGETS += liburcu
TARGETS += linux-firmware
TARGETS += lvm2
TARGETS += mdadm-pkg
TARGETS += mtools
TARGETS += musl
TARGETS += nftables
TARGETS += openssl
TARGETS += open-vmdk
TARGETS += pcre2
TARGETS += perf-pkg
TARGETS += pigz
TARGETS += qemu-tools
TARGETS += runc
TARGETS += sd-boot
TARGETS += socat
TARGETS += squashfs-tools
TARGETS += systemd-udevd
TARGETS += talosctl-cni-bundle
TARGETS += tar
TARGETS += util-linux
TARGETS += xfsprogs
TARGETS += xz
TARGETS += zlib
TARGETS += zstd
TARGETS += kernel
TARGETS += drbd-pkg
TARGETS += ena-pkg
TARGETS += gasket-driver-pkg
TARGETS += hailort-pkg
TARGETS += mellanox-mstflint-pkg
TARGETS += nvidia-open-gpu-kernel-modules-lts-pkg
TARGETS += nvidia-open-gpu-kernel-modules-production-pkg
TARGETS += px-fuse-pkg
TARGETS += tenstorrent-pkg
TARGETS += xdma-driver-pkg
TARGETS += zfs-pkg
NONFREE_TARGETS = nonfree-kmod-nvidia-lts-pkg
NONFREE_TARGETS += nonfree-kmod-nvidia-production-pkg
# help menu
export define HELP_MENU_HEADER
# Getting Started
To build this project, you must have the following installed:
- git
- make
- docker (19.03 or higher)
## Creating a Builder Instance
The build process makes use of experimental Docker features (buildx).
To enable experimental features, add 'experimental: "true"' to '/etc/docker/daemon.json' on
Linux or enable experimental features in Docker GUI for Windows or Mac.
To create a builder instance, run:
docker buildx create --name local --use
If running builds that needs to be cached aggresively create a builder instance with the following:
docker buildx create --name local --use --config=config.toml
config.toml contents:
[worker.oci]
gc = true
gckeepstorage = 50000
[[worker.oci.gcpolicy]]
keepBytes = 10737418240
keepDuration = 604800
filters = [ "type==source.local", "type==exec.cachemount", "type==source.git.checkout"]
[[worker.oci.gcpolicy]]
all = true
keepBytes = 53687091200
If you already have a compatible builder instance, you may use that instead.
## Artifacts
All artifacts will be output to ./$(ARTIFACTS). Images will be tagged with the
registry "$(REGISTRY)", username "$(USERNAME)", and a dynamic tag (e.g. $(IMAGE):$(IMAGE_TAG)).
The registry and username can be overridden by exporting REGISTRY, and USERNAME
respectively.
endef
ifneq (, $(filter $(WITH_BUILD_DEBUG), t true TRUE y yes 1))
BUILD := BUILDX_EXPERIMENTAL=1 docker buildx debug --invoke /bin/sh --on error build
endif
all: $(TARGETS) ## Builds all targets defined.
$(ARTIFACTS): ## Creates artifacts directory.
@mkdir -p $(ARTIFACTS)
.PHONY: clean
clean: ## Cleans up all artifacts.
@rm -rf $(ARTIFACTS)
.PHONY: ci-temp-release-tag
ci-temp-release-tag: ## Generates a temporary release tag for CI run.
@if [ -n "$(CI_RELEASE_TAG)" -a -n "$${GITHUB_ENV}" ]; then \
echo Setting temporary release tag "$(CI_RELEASE_TAG)"; \
echo "TAG=$(CI_RELEASE_TAG)" >> "$${GITHUB_ENV}"; \
echo "ABBREV_TAG=$(CI_RELEASE_TAG)" >> "$${GITHUB_ENV}"; \
fi
target-%: ## Builds the specified target defined in the Pkgfile. The build result will only remain in the build cache.
@$(BUILD) --target=$* $(COMMON_ARGS) $(TARGET_ARGS) $(CI_ARGS) .
local-%: ## Builds the specified target defined in the Pkgfile using the local output type. The build result will be output to the specified local destination.
@$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)"
docker-%: ## Builds the specified target defined in the Pkgfile using the docker output type. The build result will be loaded into Docker.
@$(MAKE) target-$* TARGET_ARGS="$(TARGET_ARGS)"
reproducibility-test: ## Builds the reproducibility test target
@$(MAKE) reproducibility-test-local-reproducibility
reproducibility-test-local-%: ## Builds the specified target defined in the Pkgfile using the local output type with and without cahce. The build result will be output to the specified local destination
@rm -rf $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b
@$(MAKE) local-$* DEST=$(ARTIFACTS)/build-a
@$(MAKE) local-$* DEST=$(ARTIFACTS)/build-b TARGET_ARGS="--no-cache"
@touch -ch -t $$(date -d @$(SOURCE_DATE_EPOCH) +%Y%m%d0000) $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b
@diffoscope $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b
@rm -rf $(ARTIFACTS)/build-a $(ARTIFACTS)/build-b
$(ARTIFACTS)/bldr: | $(ARTIFACTS) ## Downloads bldr binary.
@curl -sSL https://github.com/siderolabs/bldr/releases/download/$(BLDR_RELEASE)/bldr-$(OPERATING_SYSTEM)-$(GOARCH) -o $(ARTIFACTS)/bldr
@chmod +x $(ARTIFACTS)/bldr
.PHONY: update-checksums
update-checksums: $(ARTIFACTS)/bldr ## Updates the checksums in the Pkgfile/vars.yaml based on the changed version variables.
@git diff -U0 | $(ARTIFACTS)/bldr update
nonfree: $(NONFREE_TARGETS) ## Builds all nonfree targets defined.
.PHONY: $(TARGETS) $(NONFREE_TARGETS)
$(TARGETS) $(NONFREE_TARGETS):
@$(MAKE) docker-$@ TARGET_ARGS="--tag=$(REGISTRY_AND_USERNAME)/$@:$(TAG) --push=$(PUSH)"
.PHONY: deps.svg
deps.svg: ## Generates a dependency graph of the Pkgfile.
@rm -f deps.png
@$(BLDR) graph $(BUILD_ARGS) | dot -Tsvg -o deps.svg
kernel-olddefconfig:
@$(MAKE) local-kernel-build TARGET_ARGS="--build-arg=KERNEL_TARGET=olddefconfig" PLATFORM=linux/amd64 DEST="kernel/build"
@$(MAKE) local-kernel-build TARGET_ARGS="--build-arg=KERNEL_TARGET=olddefconfig" PLATFORM=linux/arm64 DEST="kernel/build"
kernel-%:
for platform in $(shell echo $(PLATFORM) | tr "," " "); do \
arch=`basename $$platform` ; \
$(MAKE) docker-kernel-prepare PLATFORM=$$platform BUILDKIT_MULTI_PLATFORM=0 TARGET_ARGS="--tag=$(REGISTRY)/$(USERNAME)/kernel:$(TAG)-$$arch --load"; \
docker run --rm -it --entrypoint=/bin/bash -w /src -v $$PWD/kernel/build/config-$$arch:/host/.hostconfig $(REGISTRY)/$(USERNAME)/kernel:$(TAG)-$$arch -c 'cp /host/.hostconfig .config && make LLVM=1 $* && cp .config /host/.hostconfig'; \
done
.PHONY: drbd-gen-compat
drbd-gen-compat:
@for platform in $(shell echo $(PLATFORM) | tr "," " "); do \
arch=`basename $$platform` ; \
ARCH=$$arch bash hack/drbd-gen-compat.sh ; \
done
.PHONY: check-dirty
check-dirty:
@if test -n "`git status --porcelain`"; then echo "Source tree is dirty"; git status; git diff; exit 1 ; fi
.PHONY: rekres
rekres:
@docker pull $(KRES_IMAGE)
@docker run --rm --net=host --user $(shell id -u):$(shell id -g) -v $(PWD):/src -w /src -e GITHUB_TOKEN $(KRES_IMAGE)
.PHONY: help
help: ## This help menu.
@echo "$$HELP_MENU_HEADER"
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: release-notes
release-notes: $(ARTIFACTS)
@ARTIFACTS=$(ARTIFACTS) ./hack/release.sh $@ $(ARTIFACTS)/RELEASE_NOTES.md $(TAG)
.PHONY: conformance
conformance:
@docker pull $(CONFORMANCE_IMAGE)
@docker run --rm -v $(PWD):/src -w /src $(CONFORMANCE_IMAGE) enforce
.PHONY: renovate-local
renovate-local: ## runs renovate locally to check syntax and test configuration
@docker run --rm \
--user $(shell id -u):$(shell id -g) \
-v $(PWD):/src \
-w /src \
-e GITHUB_TOKEN \
-e LOG_LEVEL=debug \
-e RENOVATE_PLATFORM=local \
-e RENOVATE_DRY_RUN=full \
renovate/renovate