Skip to content

Commit 659654e

Browse files
committed
rules.mk: Fix dist target output names
I didn't notice that when I previously re-worked the make setup that I changed the names away from what boots expects. Boots expect gnu style arch names where docker use go names (x86_64 vs amd64 and aarch64 vs arm64). I ended up coming across a way to sort of do a staticly defined look up table in make using something called "Constructed Macro Names", see http://make.mad-scientist.net/constructed-macro-names/ for details. So now we can use make to do the cp instead of in shell. I also reworked the deploy target so it pushes multiple files instead of one tarball as thats how boots and sandbox use them, this way we avoid needing to post-process the deployed artifacts. But this is disabled at the moment as pushing to the s3 bucket is failing due to issue with creds. Once we get creds fixed up this can be re-enabled. Signed-off-by: Manuel Mendez <github@i.m.mmlb.dev>
1 parent 39e05b1 commit 659654e

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

Makefile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,10 @@ help: ## Print this help
2222
include rules.mk
2323
include lint.mk
2424

25-
all: containers images ## Build release mode boot files and container images for all supported architectures
26-
27-
dev: image-dbg-$(ARCH) ## Build debug mode boot files and container images for currently running architecture
28-
29-
images: ## Build release mode boot files for all supported architectures
30-
25+
all: dist dbg-dist ## Build release mode boot files and container images for all supported architectures
3126
containers: hook-bootkit hook-docker ## Build container images
32-
3327
debug: ## Build debug mode boot files and container images for all supported architectures
34-
28+
dev: dbg-image-$(ARCH) ## Build debug mode boot files and container images for currently running architecture
29+
images: ## Build release mode boot files for all supported architectures
3530
push: push-hook-bootkit push-hook-docker ## Push container images to registry
36-
3731
run: run-$(ARCH) ## Boot system using qemu

rules.mk

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ ARCH = arm64
2323
endif
2424

2525
arches := amd64 arm64
26-
modes := rel dbg
26+
DOCKER_2_HW_amd64 := x86_64
27+
DOCKER_2_HW_arm64 := aarch64
2728

29+
dist-files :=
2830
hook-bootkit-deps := $(wildcard hook-bootkit/*)
2931
hook-docker-deps := $(wildcard hook-docker/*)
32+
modes := rel dbg
3033

3134
define foreach_mode_arch_rules =
3235
# mode := $(1)
@@ -49,17 +52,22 @@ out/$T/$(1)/$(2)/hook.yaml: $$(LINUXKIT_CONFIG)
4952
if [[ $(1) == dbg ]]; then
5053
sed -i '/^\s*#dbg/ s|#dbg||' $$@
5154
fi
55+
56+
out/$T/$(1)/hook_$(DOCKER_2_HW_$(2)).tar.gz: out/$T/$(1)/initramfs-$(DOCKER_2_HW_$(2)) out/$T/$(1)/vmlinuz-$(DOCKER_2_HW_$(2))
57+
out/$T/$(1)/initramfs-$(DOCKER_2_HW_$(2)): out/$T/$(1)/$(2)/initrd.img
58+
out/$T/$(1)/vmlinuz-$(DOCKER_2_HW_$(2)): out/$T/$(1)/$(2)/kernel
59+
dist-files += out/$T/$(1)/initramfs-$(DOCKER_2_HW_$(2)) out/$T/$(1)/vmlinuz-$(DOCKER_2_HW_$(2))
5260
endef
5361
$(foreach m,$(modes),$(foreach a,$(arches),$(eval $(call foreach_mode_arch_rules,$m,$a))))
5462

5563
define foreach_arch_rules =
5664
# arch := $(1)
5765

58-
debug: out/$T/dbg/$(1)/hook.tar
66+
debug: dbg-image-$(1)
67+
dbg-image-$(1): out/$T/dbg/$(1)/hook.tar
68+
dist: out/$T/rel/hook_$(DOCKER_2_HW_$(1)).tar.gz
5969
images: out/$T/rel/$(1)/hook.tar
60-
image-dbg-$(1): out/$T/dbg/$(1)/hook.tar
6170

62-
out/$T/rel/hook.tar: out/$T/rel/$(1)/initrd.img out/$T/rel/$(1)/kernel
6371
hook-bootkit: out/$T/hook-bootkit-$(1)
6472
hook-docker: out/$T/hook-docker-$(1)
6573

@@ -77,6 +85,15 @@ run-$(1):
7785
endef
7886
$(foreach a,$(arches),$(eval $(call foreach_arch_rules,$a)))
7987

88+
define foreach_mode_rules =
89+
# mode := $(1)
90+
91+
out/$T/$(1)/hook_%.tar.gz:
92+
tar -C $$(@D) -cvf- $$(^F) | pigz > $$@
93+
94+
endef
95+
$(foreach m,$(modes),$(eval $(call foreach_mode_rules,$m)))
96+
8097
push-hook-bootkit: $(hook-bootkit-deps)
8198
push-hook-docker: $(hook-docker-deps)
8299
push-hook-bootkit push-hook-docker: platforms=$(addprefix linux/,$(arches))
@@ -87,21 +104,17 @@ push-hook-bootkit push-hook-docker:
87104
docker buildx build --platform $$platforms --push -t $(ORG)/$(container):$T $(container)
88105

89106
.PHONY: dist
90-
dist: out/$T/rel/hook-$T.tar.gz ## Build tarball for distribution
91-
out/$T/rel/hook-$T.tar.gz: out/$T/rel/hook.tar
92-
pigz < $< > $@
93-
94-
out/$T/rel/hook.tar:
95-
rm -rf out/$T/rel/dist
96-
mkdir -p out/$T/rel/dist
97-
for a in $(arches); do
98-
cp out/$T/rel/$$a/initrd.img out/$T/rel/dist/initramfs-$$a
99-
cp out/$T/rel/$$a/kernel out/$T/rel/dist/vmlinuz-$$a
100-
done
101-
cd out/$T/rel/dist && tar -cvf ../$(@F) ./*
107+
dist: ## Build tarballs for distribution
108+
$(dist-files):
109+
cp $< $@
102110

111+
.PHONY: dbg-dist
112+
dbg-dist: out/$T/dbg/hook_$(DOCKER_2_HW_$(ARCH)).tar.gz ## Build debug enabled tarball
113+
114+
.PHONY: deploy
103115
deploy: dist ## Push tarball to S3
104-
ifeq ($(shell git rev-parse --abbrev-ref HEAD),main)
105-
s3cmd sync ./out/hook-$T.tar.gz s3://s.gianarb.it/hook/$T.tar.gz
106-
s3cmd cp s3://s.gianarb.it/hook/hook-$T.tar.gz s3://s.gianarb.it/hook/hook-main.tar.gz
107-
endif
116+
exit 1
117+
for f in out/$T/rel/hook_*.tar.gz; do
118+
s3cmd sync $$f s3://s.gianarb.it/hook/$T/
119+
s3cmd cp s3://s.gianarb.it/hook/$T/$$(basename $$f) s3://s.gianarb.it/hook/latest/
120+
done

0 commit comments

Comments
 (0)