6 .SECONDEXPANSION: #sorry
8 confdir = /etc/schroot/chroot.d
10 DISTS = stretch buster sid
12 MYARCH = $(shell dpkg --print-architecture)
13 OTHERARCHS = $(shell dpkg --print-foreign-architectures)
15 NATIVE_ARCHS = $(MYARCH) $(OTHERARCHS)
17 ARCHS = $(NATIVE_ARCHS) $(FOREIGN_ARCHS)
19 cross = $(foreach i,$1, $(foreach j,$2, $i-$j))
20 NATIVE_CHROOTS = $(call cross,$(DISTS),$(NATIVE_ARCHS))
21 FOREIGN_CHROOTS = $(call cross,$(DISTS),$(FOREIGN_ARCHS))
22 CHROOTS = $(NATIVE_CHROOTS) $(FOREIGN_CHROOTS)
24 chroot-dist = $(patsubst %/,%,$(dir $(subst -,/,$1)))
25 chroot-arch = $(notdir $(subst -,/,$1))
27 native-chroot-p = $(findstring $(call chroot-arch,$1), $(NATIVE_ARCHS))
31 qemuarch/arm64 = amd64
32 chroot-toolsarch = $(TOOLSARCH)
33 chroot-qemuarch = $(qemuarch/$(call chroot-arch,$1))
34 chroot-deps = $(if $(call native-chroot-p,$2),,$(addprefix $1/$(call chroot-dist,$2)-,\
35 $(sort $(call chroot-toolsarch,$2) $(call chroot-qemuarch,$2))))
37 VG = vg-$(shell hostname)
38 mkbuildchroot_OPTS = -a$(TOOLSARCH) -f -v$(VG)
39 mkchrootconf_OPTS = -v$(VG)
40 install-cross-tools_OPTS =
41 update-cross-tools_OPTS =
46 CONFIG = $(confdir)/sbuild
47 config:; locking -w Makefile make $(CONFIG)
48 $(CONFIG): Makefile $(wildcard local.mk) mkchrootconf
49 ./mkchrootconf $(mkchrootconf_OPTS) $(CHROOTS) >$@.new && \
51 clean::; rm -f $(CONFIG)
54 UPDATE_CROSS = $(addprefix update-cross/, $(NATIVE_CHROOTS))
55 update-cross: $(UPDATE_CROSS)
56 $(UPDATE_CROSS): update-cross/%: update/%
57 ./update-cross-tools $(update-cross-tools_OPTS) \
58 -a$(call chroot-arch,$*) $(call chroot-dist,$*)
59 .PHONY: update-cross $(UPDATE_CROSS)
61 UPDATE = $(addprefix update/, $(CHROOTS))
63 $(UPDATE): update/%: chroot-stamps/% $$(call chroot-deps,update-cross,$$*)
64 $(if $(call native-chroot-p,$*),,\
65 ./install-cross-tools $(install-cross-tools_OPTS) \
66 -a$(call chroot-toolsarch,$*) \
67 -q$(call chroot-qemuarch,$*) \
69 schroot -uroot -csource:$* -- apt-get update
70 schroot -uroot -csource:$* -- apt-get -y dist-upgrade
71 schroot -uroot -csource:$* -- apt-get -y autoremove
72 schroot -uroot -csource:$* -- apt-get -y clean
73 .PHONY: update $(UPDATE)
76 CREATESTAMPS = $(addprefix chroot-stamps/, $(CHROOTS))
77 create: $(CREATESTAMPS)
78 $(CREATESTAMPS): chroot-stamps/%: $$(call chroot-deps,chroot-stamps,$$*)
81 ./mkbuildchroot $(mkbuildchroot_OPTS) \
82 $(if $(call native-chroot-p,$*),,\
83 -Q -a$(call chroot-toolsarch,$*) \
84 -q$(call chroot-qemuarch,$*)) \
87 clean::; rm -f chroot-stamps/*
91 PRUNESTAMPS = $(patsubst chroot-stamps/%,prune/%, \
92 $(filter-out $(CREATESTAMPS),$(wildcard chroot-stamps/*)))
94 $(PRUNESTAMPS): prune/%:
96 rm -f chroot-stamps/$*
97 .PHONY: prune $(PRUNESTAMPS)