Files
image-specs/Makefile

88 lines
2.5 KiB
Makefile
Raw Normal View History

all: shasums
# List all the supported and built Pi platforms here. They get expanded
# to names like 'raspi_arm64_trixie.yaml' and 'raspi_arm64_trixie.img.xz'.
BUILD_ARCHS := armhf arm64
BUILD_RELEASES := bookworm trixie forky
platforms := $(foreach plat, $(BUILD_ARCHS),$(foreach rel, $(BUILD_RELEASES), raspi_$(plat)_$(rel)))
shasums: $(addsuffix .img.sha256,$(platforms)) $(addsuffix .img.xz.sha256,$(platforms))
xzimages: $(addsuffix .img.xz,$(platforms))
images: $(addsuffix .img,$(platforms))
yaml: $(addsuffix .yaml,$(platforms))
ifeq ($(shell id -u),0)
as_root =
else ifneq (,$(wildcard /usr/bin/fakemachine))
$(warning "This should normally be run as root, but found 'fakemachine', so using that.")
as_root = fakemachine -v $(CURDIR) -- env --chdir $(CURDIR)
else
$(error "This must be run as root")
endif
target_platforms:
@echo $(platforms)
# Generate targets based on all architecture * release combinations:
define dynamic_yaml_target =
raspi_$(1)_$(2).yaml: raspi_master.yaml generate-recipe.py
raspi_$(1)_$(2).yaml:
./generate-recipe.py $(1) $(2)
endef
$(foreach release,$(BUILD_RELEASES), \
$(foreach arch,$(BUILD_ARCHS), \
$(eval $(call dynamic_yaml_target,$(arch),$(release)))))
%.img.sha256: %.img
if [ -e $< ]; then \
echo $@; \
sha256sum $< > $@; \
fi
%.img.xz.sha256: %.img.xz
if [ -e $< ]; then \
echo $@; \
sha256sum $< > $@; \
fi
%.img.xz: %.img
if [ -e $< ]; then \
xz -f -k -z -9 $<; \
fi
%.img.bmap: %.img
if [ -e $< ]; then \
bmaptool create -o $@ $<; \
fi
%.img: %.yaml
if [ ! -s $< ]; then \
echo "W: skipping empty recipe ($<)"; \
else \
touch $(@:.img=.log); \
time nice $(as_root) vmdb2 --verbose --rootfs-tarball=$(subst .img,.tar.gz,$@) --output=$@ $(subst .img,.yaml,$@) --log $(subst .img,.log,$@); \
chmod 0644 $@ $(@,.img=.log); \
fi
_ck_root:
[ `whoami` = 'root' ] # Only root can summon vmdb2 ☹
_clean_yaml:
rm -f $(addsuffix .yaml,$(platforms)) $(foreach rel,$(BUILD_RELEASES),raspi_base_$(rel).yaml)
_clean_images:
rm -f $(addsuffix .img,$(platforms))
_clean_xzimages:
rm -f $(addsuffix .img.xz,$(platforms))
_clean_bmaps:
rm -f $(addsuffix .img.bmap,$(platforms))
_clean_shasums:
rm -f $(addsuffix .img.sha256,$(platforms)) $(addsuffix .img.xz.sha256,$(platforms))
_clean_logs:
rm -f $(addsuffix .log,$(platforms))
_clean_tarballs:
rm -f $(addsuffix .tar.gz,$(platforms))
clean: _clean_xzimages _clean_images _clean_shasums _clean_yaml _clean_tarballs _clean_logs _clean_bmaps
.PHONY: _ck_root _build_img clean _clean_images _clean_yaml _clean_tarballs _clean_logs