-### Constructing chroots.
-
-chroot-stamp = $(addprefix $(STATE)/stamp/chroot.,$1)
-BUILD_CHROOTS = $(addprefix chroot/,$(ALL_CHROOTS))
-CHROOT_STAMPS = $(call chroot-stamp,$(ALL_CHROOTS))
-setup-chroots: $(BUILD_CHROOTS)
-$(BUILD_CHROOTS): chroot/%: $(STATE)/stamp/chroot.%
-.PHONY: setup-chroots $(BUILD_CHROOTS)
-
-$(CHROOT_STAMPS): $(STATE)/stamp/chroot.%: \
- $$(call chroot-deps,$(STATE)/stamp/cross-tools.,$$*)
- $(V_AT)mkdir -p $(dir $@) log/
- $(MAKE) \
- $(STATE)/bin/mkbuildchroot $(STATE)/bin/install-cross-tools \
- $(STATE)/etc/schroot/sbuild.schroot
- $(call v_tag,CHROOT)$(call v_log,setup-chroot.$*, \
- $(SILENCE_LVM); \
- $(ROOTLY) $(STATE)/bin/mkbuildchroot \
- $(call chroot-dist,$*) $(call chroot-arch,$*))
- $(V_AT)touch $@
-
-UPDATE_CHROOTS = $(addprefix update/,$(ALL_CHROOTS))
-update-chroots: $(UPDATE_CHROOTS)
-$(UPDATE_CHROOTS): update/%: $(STATE)/stamp/chroot.%
- $(V_AT)mkdir -p log/
- $(MAKE) $(STATE)/bin/install-cross-tools
- $(call v_tag,UPDATE)$(call v_log,update-chroot.$*, { \
- schroot -uroot -csource:$(LVPREFIX)$* -- \
- apt-get update && \
- schroot -uroot -csource:$(LVPREFIX)$* -- \
- apt-get -y dist-upgrade && \
- schroot -uroot -csource:$(LVPREFIX)$* -- \
- apt-get -y autoremove && \
- schroot -uroot -csource:$(LVPREFIX)$* -- \
- apt-get -y clean && \
- $(if $(filter $*,$(FOREIGN_CHROOTS)), \
- $(ROOTLY) $(STATE)/bin/install-cross-tools \
- $(call chroot-dist,$*) \
- $(call chroot-arch,$*), \
- :); \
- })
-.PHONY: update-chroots $(UPDATE_CHROOTS)
-
-cross-tools-stamp = $(addprefix $(STATE)/stamp/cross-tools.,$1)
-CROSS_TOOLS = $(addprefix cross-tools/,$(NATIVE_CHROOTS))
-UPDATE_CROSS_TOOLS = $(addprefix update-cross-tools/,$(NATIVE_CHROOTS))
-cross-tools: $(CROSS_TOOLS)
-update-cross-tools: $(UPDATE_CROSS_TOOLS)
-$(CROSS_TOOLS): cross-tools/%: $(STATE)/stamp/cross-tools.%
-define updcross
- $(V_AT)mkdir -p log/
- $(MAKE) $(STATE)/bin/update-cross-tools
- $(call v_tag,UPDCROSS)$(call v_log,update-cross-tools.$*, \
- $(STATE)/bin/update-cross-tools \
- $(call chroot-dist,$*) \
- $(call chroot-arch,$*))
- $(V_AT)touch $(call cross-tools-stamp,$*)
-endef
-$(call cross-tools-stamp,$(NATIVE_CHROOTS)): $(STATE)/stamp/cross-tools.%: \
- $$(call chroot-stamp,$$*)
- $(V_AT)mkdir -p $(dir $@)
- $(updcross)
-$(UPDATE_CROSS_TOOLS): update-cross-tools/%: \
- $$(call chroot-stamp,$$*) _force
- $(updcross)
-.PHONY: cross-tools update-cross-tools $(CROSS_TOOLS) $(UPDATE_CROSS_TOOLS)
+### Main chroot maintenance.
+
+OPTS =
+FRESH = 1w
+JOBS = chroot cross-tools pkg-build
+
+MAINTQ_ = -q
+MAINTQ_0 = -q
+MAINT = +$(call v_tag,MAINT)\
+ PYTHONPATH=$(STATE)/lib/python $(STATE)/bin/chroot-maint \
+ $(MAINTQ_$V) $(OPTS)
+
+maint: all check
+ $(MAINT) -f$(FRESH) $(JOBS)
+.PHONY: maint
+
+help::
+ @echo "Maintenance targets" && \
+ echo " maint run chroot maintenance" && \
+ echo "Maintenance variables" && \
+ echo " FRESH max time between updates" && \
+ echo " N[smhdw] | create | force" && \
+ echo " JOBS maintenance jobs to run" && \
+ echo " ACT[.PAT,...][/FRESH]" && \
+ echo " OPTS additional options (bin/chroot-maint --help)" && \
+ echo "Maintenance actions" && \
+ echo " chroot create and populate chroot" && \
+ echo " cross-tools build cross-compilation toolchains" && \
+ echo " pkg-source download and unpack local utilities" && \
+ echo " pkg-build compile and install local utilities"