X-Git-Url: https://git.distorted.org.uk/~mdw/distorted-chroot/blobdiff_plain/a98c9dba94d44ada3a7e7f3b4ce8b6df6911a2d2..ef077e20240e8476bc390751f9b6474fa0843b32:/Makefile diff --git a/Makefile b/Makefile index 6870ddc..fb888c0 100644 --- a/Makefile +++ b/Makefile @@ -38,13 +38,9 @@ CONFIG_VARS = ## Level of pickiness to aspire to. NOTIFY_FATAL = 1 -## Path to this working tree. -CONFIG_VARS += HERE -HERE = $(abspath .) - ## 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. @@ -68,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) @@ -80,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. @@ -138,7 +134,7 @@ CROSS_PATHS += \ sha256sum sha384sum sha512sum shred shuf sort split stat \ stdbuf sum tac tail tee test timeout tr truncate tsort tty \ unexpand uniq unlink users wc who whoami yes) \ - /usr/lib/MULTI/coreutils/ \ + ?/usr/lib/MULTI/coreutils/ \ $(addprefix /lib/MULTI/, \ libnsl.so.* libnss_*.so.*) \ /usr/bin/gpgv \ @@ -159,7 +155,8 @@ CROSS_PATHS += \ $(addprefix /usr/bin/$a-, \ cpp gcc g++ gcov gcov-dump gcov-tool gprof \ gcc-ar gcc-nm gcc-ranlib) \ - /usr/lib/gcc-cross/$a/) + /usr/lib/gcc-cross/$a/ \ + /usr/$a/include/c++) ## Local packages to be compiled and installed in chroots. Archives can be ## found in `pkg/'. @@ -182,6 +179,10 @@ 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) +stretch_QEMUDIST = buster + ## Qemu architecture names. These tell us which Qemu binary to use for a ## particular Debian architecture. CONFIG_VARS += $(foreach a,$(FOREIGN_ARCHS),$a_QEMUARCH) @@ -208,8 +209,9 @@ STATE = state ## A directory which will be spliced into chroots as `/usr/local.schroot/'. ## This will be our primary point of contact with the chroot. -CONFIG_VARS += LOCAL +CONFIG_VARS += LOCAL ABSLOCAL LOCAL = local.schroot +ABSLOCAL = $(abspath $(LOCAL)) ## How to run a command as a privileged user. CONFIG_VARS += ROOTLY @@ -277,7 +279,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 @@ -422,9 +425,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) @@ -531,7 +532,7 @@ $(LOCAL)/etc/schroot/sbuild.schroot: $(STATE)/bin/mkchrootconf $(call v_tag,GEN)$(STATE)/bin/mkchrootconf >$@.new && \ $(ROOTLY) chown root:root $@.new && mv $@.new $@ CLEANFILES += $(LOCAL)/etc/schroot/sbuild.schroot -check::; $(call check-symlink,WARN,/etc/schroot/chroot.d/sbuild,$(HERE)/$(LOCAL)/etc/schroot/sbuild.schroot) +check::; $(call check-symlink,WARN,/etc/schroot/chroot.d/sbuild,$(ABSLOCAL)/etc/schroot/sbuild.schroot) schroot-config:: $(LOCAL)/etc/schroot/sbuild.profile/copyfiles $(LOCAL)/etc/schroot/sbuild.profile/copyfiles: $(schroot-config_STAMP) @@ -559,7 +560,7 @@ $(LOCAL)/etc/schroot/sbuild.profile/fstab: \ <$< >$@.new && mv $@.new $@ CLEANFILES += $(LOCAL)/etc/schroot/sbuild.profile/fstab -check::; $(call check-symlink,WARN,/etc/schroot/sbuild,$(HERE)/$(LOCAL)/etc/schroot/sbuild.profile) +check::; $(call check-symlink,WARN,/etc/schroot/sbuild,$(ABSLOCAL)/etc/schroot/sbuild.profile) schroot-config:: $(LOCAL)/etc/sbuild.conf $(LOCAL)/etc/sbuild.conf: etc/sbuild.conf.in $(schroot-config_STAMP) @@ -567,7 +568,7 @@ $(LOCAL)/etc/sbuild.conf: etc/sbuild.conf.in $(schroot-config_STAMP) $(call v_tag,SUBST)$(call subst-file,### -*-perl-*-) \ <$< >$@.new && mv $@.new $@ CLEANFILES += $(LOCAL)/etc/sbuild.conf -check::; $(call check-symlink,WARN,/etc/sbuild/sbuild.conf,$(HERE)/$(LOCAL)/etc/sbuild.conf) +check::; $(call check-symlink,WARN,/etc/sbuild/sbuild.conf,$(ABSLOCAL)/etc/sbuild.conf) check::; $(call check-executable,WARN,/usr/local.schroot/hacks/apt-get) SCHROOT_SCRIPTS += 11private @@ -584,10 +585,21 @@ CLEANFILES += $(COPY_SCHROOT_SCRIPTS) CHECK_SCHROOT_SCRIPTS = $(addprefix check-script/,$(SCHROOT_SCRIPTS)) check:: $(CHECK_SCHROOT_SCRIPTS) $(CHECK_SCHROOT_SCRIPTS): check-script/%: - $(call check-symlink,WARN,/etc/schroot/setup.d/$*,$(HERE)/$(LOCAL)/etc/schroot/setup.d/$*) + $(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. LOCAL_COMMON_DIRS = share/ src/ @@ -597,7 +609,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),\ @@ -627,12 +640,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) @@ -641,6 +654,19 @@ maint: all check .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. show:; : $x