Add in the mess from the original symbiosisware version.
[distorted-chroot] / mess / maint / Makefile
1 ### -*-makefile-*-
2
3 all:
4 clean::
5 .PHONY: all clean
6 .SECONDEXPANSION: #sorry
7
8 confdir = /etc/schroot/chroot.d
9
10 DISTS = stretch buster sid
11
12 MYARCH = $(shell dpkg --print-architecture)
13 OTHERARCHS = $(shell dpkg --print-foreign-architectures)
14 TOOLSARCH = $(MYARCH)
15 NATIVE_ARCHS = $(MYARCH) $(OTHERARCHS)
16 FOREIGN_ARCHS =
17 ARCHS = $(NATIVE_ARCHS) $(FOREIGN_ARCHS)
18
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)
23
24 chroot-dist = $(patsubst %/,%,$(dir $(subst -,/,$1)))
25 chroot-arch = $(notdir $(subst -,/,$1))
26
27 native-chroot-p = $(findstring $(call chroot-arch,$1), $(NATIVE_ARCHS))
28
29 qemuarch/armel = i386
30 qemuarch/armhf = i386
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))))
36
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 =
42
43 -include local.mk
44
45 all: config
46 CONFIG = $(confdir)/sbuild
47 config:; locking -w Makefile make $(CONFIG)
48 $(CONFIG): Makefile $(wildcard local.mk) mkchrootconf
49 ./mkchrootconf $(mkchrootconf_OPTS) $(CHROOTS) >$@.new && \
50 mv $@.new $@
51 clean::; rm -f $(CONFIG)
52 .PHONY: config
53
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)
60
61 UPDATE = $(addprefix update/, $(CHROOTS))
62 update: $(UPDATE)
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,$*) \
68 $*)
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)
74
75 all: create
76 CREATESTAMPS = $(addprefix chroot-stamps/, $(CHROOTS))
77 create: $(CREATESTAMPS)
78 $(CREATESTAMPS): chroot-stamps/%: $$(call chroot-deps,chroot-stamps,$$*)
79 make config
80 mkdir -p $(dir $@)
81 ./mkbuildchroot $(mkbuildchroot_OPTS) \
82 $(if $(call native-chroot-p,$*),,\
83 -Q -a$(call chroot-toolsarch,$*) \
84 -q$(call chroot-qemuarch,$*)) \
85 $*
86 echo done >$@
87 clean::; rm -f chroot-stamps/*
88 .PHONY: create
89
90 all: prune
91 PRUNESTAMPS = $(patsubst chroot-stamps/%,prune/%, \
92 $(filter-out $(CREATESTAMPS),$(wildcard chroot-stamps/*)))
93 prune: $(PRUNESTAMPS)
94 $(PRUNESTAMPS): prune/%:
95 lvremove -f $(VG)/$*
96 rm -f chroot-stamps/$*
97 .PHONY: prune $(PRUNESTAMPS)