Add in the mess from the original symbiosisware version.
[distorted-chroot] / mess / maint / Makefile
CommitLineData
fd0f20e1
MW
1### -*-makefile-*-
2
3all:
4clean::
5.PHONY: all clean
6.SECONDEXPANSION: #sorry
7
8confdir = /etc/schroot/chroot.d
9
10DISTS = stretch buster sid
11
12MYARCH = $(shell dpkg --print-architecture)
13OTHERARCHS = $(shell dpkg --print-foreign-architectures)
14TOOLSARCH = $(MYARCH)
15NATIVE_ARCHS = $(MYARCH) $(OTHERARCHS)
16FOREIGN_ARCHS =
17ARCHS = $(NATIVE_ARCHS) $(FOREIGN_ARCHS)
18
19cross = $(foreach i,$1, $(foreach j,$2, $i-$j))
20NATIVE_CHROOTS = $(call cross,$(DISTS),$(NATIVE_ARCHS))
21FOREIGN_CHROOTS = $(call cross,$(DISTS),$(FOREIGN_ARCHS))
22CHROOTS = $(NATIVE_CHROOTS) $(FOREIGN_CHROOTS)
23
24chroot-dist = $(patsubst %/,%,$(dir $(subst -,/,$1)))
25chroot-arch = $(notdir $(subst -,/,$1))
26
27native-chroot-p = $(findstring $(call chroot-arch,$1), $(NATIVE_ARCHS))
28
29qemuarch/armel = i386
30qemuarch/armhf = i386
31qemuarch/arm64 = amd64
32chroot-toolsarch = $(TOOLSARCH)
33chroot-qemuarch = $(qemuarch/$(call chroot-arch,$1))
34chroot-deps = $(if $(call native-chroot-p,$2),,$(addprefix $1/$(call chroot-dist,$2)-,\
35 $(sort $(call chroot-toolsarch,$2) $(call chroot-qemuarch,$2))))
36
37VG = vg-$(shell hostname)
38mkbuildchroot_OPTS = -a$(TOOLSARCH) -f -v$(VG)
39mkchrootconf_OPTS = -v$(VG)
40install-cross-tools_OPTS =
41update-cross-tools_OPTS =
42
43-include local.mk
44
45all: config
46CONFIG = $(confdir)/sbuild
47config:; locking -w Makefile make $(CONFIG)
48$(CONFIG): Makefile $(wildcard local.mk) mkchrootconf
49 ./mkchrootconf $(mkchrootconf_OPTS) $(CHROOTS) >$@.new && \
50 mv $@.new $@
51clean::; rm -f $(CONFIG)
52.PHONY: config
53
54UPDATE_CROSS = $(addprefix update-cross/, $(NATIVE_CHROOTS))
55update-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
61UPDATE = $(addprefix update/, $(CHROOTS))
62update: $(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
75all: create
76CREATESTAMPS = $(addprefix chroot-stamps/, $(CHROOTS))
77create: $(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 >$@
87clean::; rm -f chroot-stamps/*
88.PHONY: create
89
90all: prune
91PRUNESTAMPS = $(patsubst chroot-stamps/%,prune/%, \
92 $(filter-out $(CREATESTAMPS),$(wildcard chroot-stamps/*)))
93prune: $(PRUNESTAMPS)
94$(PRUNESTAMPS): prune/%:
95 lvremove -f $(VG)/$*
96 rm -f chroot-stamps/$*
97.PHONY: prune $(PRUNESTAMPS)