chiark / gitweb /
Makefile, bin/chroot-maint: Allow source distribution selection for Qemu.
[distorted-chroot] / Makefile
index 7e622e9461e862e04c430b4b63aee25450a9075d..dfbdcb6349a9e824f8b21ec4b9720eaefc34e294 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ NOTIFY_FATAL           = 1
 
 ## Volume group from which to allocate chroot volumes and snapshots.
 CONFIG_VARS            += VG LVPREFIX
-VG                      = vg-$(shell hostname)
+VG                     := vg-$(shell hostname)
 LVPREFIX                =
 
 ## Logical volume size, as an LVM option.
@@ -64,7 +64,7 @@ APTCONF                        = $(notdir $(wildcard etc/apt-conf.d/[0-9]*[!~]))
 
 ## Proxy setting.
 CONFIG_VARS            += PROXY
-PROXY                  := $(shell \
+PROXY                   = $(shell \
        eval $$(apt-config $(foreach a,$(APTCONF),-cetc/apt-conf.d/$a) \
                shell proxy Acquire::http::proxy); \
        case $${proxy+t} in (t) echo "$$proxy" ;; (*) echo nil ;; esac)
@@ -76,8 +76,8 @@ DISTS                  = $(PRIMARY_DIST) buster bullseye sid
 
 ## Host's native architecture(s).
 CONFIG_VARS            += MYARCH NATIVE_ARCHS
-MYARCH                  = $(shell dpkg --print-architecture)
-OTHERARCHS              = $(shell dpkg --print-foreign-architectures)
+MYARCH                 := $(shell dpkg --print-architecture)
+OTHERARCHS             := $(shell dpkg --print-foreign-architectures)
 NATIVE_ARCHS            = $(MYARCH) $(OTHERARCHS)
 
 ## Foreign (emulated) architectures to support.
@@ -178,6 +178,9 @@ arm64_QEMUHOST               = $(64BIT_QEMUHOST)
 i386_QEMUHOST           = $(32BIT_QEMUHOST)
 amd64_QEMUHOST          = $(64BIT_QEMUHOST)
 
+## Which distribution of Qemu to use.
+CONFIG_VARS            += $(foreach d,$(DISTS),$d_QEMUDIST)
+
 ## Qemu architecture names.  These tell us which Qemu binary to use for a
 ## particular Debian architecture.
 CONFIG_VARS            += $(foreach a,$(FOREIGN_ARCHS),$a_QEMUARCH)
@@ -274,7 +277,8 @@ throwrc                      = { $1; echo $$? >&4; }
 ##     $(call squote,TXT)
 ##
 ## Single-quote TXT.
-squote                  = '$(subst ','\\'',$1)'
+squote                  = '$(subst ','\'',$1)'
+#'
 
 ##     $(call chroot-dist,D-A) -> D
 ##     $(call chroot-arch,D-A) -> A
@@ -419,9 +423,7 @@ $(PYMODULES): $(STATE)/lib/python/%.so: $$(call c-object,$$($$*_SOURCES))
 ### Scripts.
 
 SCRIPTS                        += chroot-maint
-SCRIPTS                        += mkbuildchroot
 SCRIPTS                        += mkchrootconf
-SCRIPTS                        += install-cross-tools update-cross-tools
 
 SUBST_SCRIPTS           = $(addprefix $(STATE)/bin/,$(SCRIPTS))
 all:: $(SUBST_SCRIPTS)
@@ -584,6 +586,17 @@ $(CHECK_SCHROOT_SCRIPTS): check-script/%:
        $(call check-symlink,WARN,/etc/schroot/setup.d/$*,$(ABSLOCAL)/etc/schroot/setup.d/$*)
 .PHONY: $(addprefix check-script/,$(SCHROOT_SCRIPTS))
 
+###--------------------------------------------------------------------------
+### Ccache setup.
+
+CCACHE_CONFIGS          = $(foreach r,$(ALL_CHROOTS), \
+       /var/lib/sbuild/build/.ccache/$(LVPREFIX)$r/ccache.conf)
+all:: $(CCACHE_CONFIGS)
+$(CCACHE_CONFIGS): /var/lib/sbuild/build/.ccache/$(LVPREFIX)%/ccache.conf: \
+               etc/ccache.conf
+       $(V_AT)mkdir -p $(dir $@)
+       $(call v_tag,COPY)cp $< $@.new && mv $@.new $@
+
 ###--------------------------------------------------------------------------
 ### `/usr/local/' structure.
 
@@ -594,7 +607,8 @@ $(foreach d,$(LOCAL_COMMON_DIRS) $(LOCAL_EXTRA_DIRS),$(LOCAL)/$d):
        $(V_AT)mkdir -p $(dir $(patsubst %/,%,$@))
        $(call v_tag,MKDIR)mkdir $@
 
-LOCAL_ARCH_DIRS                 = bin/ etc/ games/ include/ lib/ libexec/ sbin/
+LOCAL_ARCH_DIRS                 = bin/ etc/ games/ include/ include.aside/
+LOCAL_ARCH_DIRS                += lib/ libexec/ sbin/
 LOCAL_ARCH_LINKS        = man
 man_LINKDEST            = share/man
 all:: $(foreach a,$(ALL_ARCHS),\
@@ -624,12 +638,12 @@ $(foreach a,$(ALL_ARCHS),\
 ### Main chroot maintenance.
 
 OPTS                    =
-FRESH                   = create
+FRESH                   = 1w
 JOBS                    = chroot cross-tools pkg-build
 
 MAINTQ_                         = -q
 MAINTQ_0                = -q
-MAINT                   = +$(call v_tag,RUN)\
+MAINT                   = +$(call v_tag,MAINT)\
        PYTHONPATH=$(STATE)/lib/python $(STATE)/bin/chroot-maint \
                $(MAINTQ_$V) $(OPTS)
 
@@ -637,6 +651,19 @@ maint: all check
        $(MAINT) -f$(FRESH) $(JOBS)
 .PHONY: maint
 
+###--------------------------------------------------------------------------
+### Running random commands.
+
+CMD                     = echo %d %a
+subst-command           = $(subst %d,$(call chroot-dist,$1), \
+                               $(subst %a,$(call chroot-arch,$1), \
+                                       $(subst %r,$1, $(CMD))))
+
+run: $(foreach c,$(ALL_CHROOTS),run/$c)
+$(foreach c,$(ALL_CHROOTS),run/$c): run/%:
+       $(V_AT)$(call v_print,RUN,$(call subst-command,$*))\
+               $(call subst-command,$*)
+
 ###--------------------------------------------------------------------------
 ### Other maintenance targets.