X-Git-Url: https://git.distorted.org.uk/~mdw/distorted-chroot/blobdiff_plain/a914e8822d4102c41faedb42cbdbea69f995f2c4..168cdcfeb376c76e180a84513565540385747ea3:/Makefile diff --git a/Makefile b/Makefile index ec9db52..b09df97 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ PROXY = $(shell \ ## Debian distributions to support. CONFIG_VARS += PRIMARY_DIST DISTS PRIMARY_DIST = stretch -DISTS = $(PRIMARY_DIST) buster bullseye sid +DISTS = $(PRIMARY_DIST) buster bullseye bookworm sid ## Host's native architecture(s). CONFIG_VARS += MYARCH NATIVE_ARCHS @@ -265,6 +265,24 @@ CLEANFILES += log/*.log SILENCE_LVM = \ LVM_SUPPRESS_FD_WARNINGS=1; export LVM_SUPPRESS_FD_WARNINGS +## $(call file-name,PATH) +## +## Strip any trailing `/' from the PATH. +file-name = $(1:/=) + +## $(call base-name,PATH) +## +## Expand to the last component of PATH, whether or not it's a directory +## name with a trailing `/'. +base-name = $(notdir $(call file-name,$1)) + +## $(call parent-dir,PATH) +## +## Expand to the parent directory of PATH, whether or not it's a directory +## name with a trailing `/'. +## `/'. +parent-dir = $(dir $(call file-name,$1)) + ## $(call definedp,VAR) ## ## Expand non-empty if and only if VAR is defined (but possibly empty). @@ -388,6 +406,11 @@ check-mountpoint = $(call check,$1,"\`$2' is not a mount point", \ check-symlink = $(call check,$1,"\`$2' is not a link to \`$3'", \ [ -L "$2" ] && [ "$$(readlink "$2")" = "$3" ]) +## DIR/ +## +## Make a directory. Use as an order-only dependency. +%/:; $(V_AT)mkdir -p $@ + ###-------------------------------------------------------------------------- ### Python extensions. @@ -411,14 +434,13 @@ PYEXT_ALLSRC = $(foreach x,$(PYEXTS),\ $(call c-source,$($x_SOURCES))) PYEXT_ALLOBJ = $(foreach x,$(PYEXTS),\ $(call c-object,$($x_SOURCES))) -$(PYEXT_ALLOBJ): $(STATE)/obj/%.o: src/%.c - $(V_AT)mkdir -p $(dir $@) +$(PYEXT_ALLOBJ): $(STATE)/obj/%.o: src/%.c | $$(dir $$@) $(call v_tag,CC)$(CC) -c $(CFLAGS) $(PYEXT_CFLAGS) -o$@ $< PYMODULES = $(foreach x,$(PYEXTS),$(STATE)/lib/python/$x.so) all: $(PYMODULES) -$(PYMODULES): $(STATE)/lib/python/%.so: $$(call c-object,$$($$*_SOURCES)) - $(V_AT)mkdir -p $(dir $@) +$(PYMODULES): $(STATE)/lib/python/%.so: \ + $$(call c-object,$$($$*_SOURCES)) | $$(dir $$@) $(call v_tag,LD)$(LD) $(LDFLAGS) $(PYEXT_LDFLAGS) -o$@ $^ ###-------------------------------------------------------------------------- @@ -429,8 +451,7 @@ SCRIPTS += mkchrootconf SUBST_SCRIPTS = $(addprefix $(STATE)/bin/,$(SCRIPTS)) all: $(SUBST_SCRIPTS) -$(SUBST_SCRIPTS): $(STATE)/bin/%: bin/% $(STATE)/config.sh - $(V_AT)mkdir -p $(dir $@) +$(SUBST_SCRIPTS): $(STATE)/bin/%: bin/% $(STATE)/config.sh | $$(dir $$@) $(call v_tag,SUBST){ \ sed \ -e '2i### GENERATED by distorted-chroot: do not edit' \ @@ -448,8 +469,8 @@ $(SUBST_SCRIPTS): $(STATE)/bin/%: bin/% $(STATE)/config.sh APT_SOURCES = $(foreach d,$(DISTS),$(LOCAL)/etc/apt/sources.$d) all: $(APT_SOURCES) -$(foreach d,$(DISTS),$(STATE)/etc/apt/aptsrc.$d): $(STATE)/etc/apt/aptsrc.%: - $(V_AT)mkdir -p $(dir $@) +$(foreach d,$(DISTS),$(STATE)/etc/apt/aptsrc.$d): \ + $(STATE)/etc/apt/aptsrc.%: | $$(dir $$@) $(call v_tag,GEN){ \ echo "### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \ echo "subscribe"; \ @@ -457,8 +478,8 @@ $(foreach d,$(DISTS),$(STATE)/etc/apt/aptsrc.$d): $(STATE)/etc/apt/aptsrc.%: } >$@.new && mv $@.new $@ $(APT_SOURCES): $(LOCAL)/etc/apt/sources.%: \ - $$(APTSRC) $$($$*_APTSRC) $$(STATE)/etc/apt/aptsrc.$$* - $(V_AT)mkdir -p $(dir $@) + $$(APTSRC) $$($$*_APTSRC) $$(STATE)/etc/apt/aptsrc.$$* \ + | $$(dir $$@) $(call v_tag,GEN)bin/mkaptsrc \ $(APTSRC) $($*_APTSRC) $(STATE)/etc/apt/aptsrc.$* \ >$@.new && mv $@.new $@ @@ -469,8 +490,7 @@ CLEANFILES += $(APT_SOURCES) APT_CONFIGS = $(addprefix $(LOCAL)/etc/apt/apt.conf.d/,$(APTCONF)) all: $(APT_CONFIGS) $(APT_CONFIGS): $(LOCAL)/etc/apt/apt.conf.d/%: \ - $$(or $$(_$$*_APTCONFSRC) etc/apt-conf.d/$$*) - $(V_AT)mkdir -p $(dir $@) + $$(or $$(_$$*_APTCONFSRC) etc/apt-conf.d/$$*) | $$(dir $$@) $(call v_tag,COPY)cp $< $@.new && mv $@.new $@ clean::; rm -f $(APT_CONFIGS) @@ -483,16 +503,15 @@ EATMYDATA_HACKS += apt-get aptitude dpkg SYMLINK_EATMYDATA_HACKS = $(addprefix $(LOCAL)/hacks/,$(EATMYDATA_HACKS)) all: $(SYMLINK_EATMYDATA_HACKS) $(SYMLINK_EATMYDATA_HACKS): $(LOCAL)/hacks/%: \ - $$(if $$(call symlink-ok-p,$$@,/usr/bin/eatmydata),,_force) - $(V_AT)mkdir -p $(dir $@) + $$(if $$(call symlink-ok-p,$$@,/usr/bin/eatmydata),,_force) \ + | $$(dir $$@) $(call v_tag,SYMLINK)ln -sf /usr/bin/eatmydata $@.new && mv $@.new $@ clean::; rm -f $(SYMLINK_EATMYDATA_HACKS) SCRIPT_HACKS += buildwrap COPY_SCRIPT_HACKS = $(addprefix $(LOCAL)/hacks/,$(SCRIPT_HACKS)) all: $(COPY_SCRIPT_HACKS) -$(COPY_SCRIPT_HACKS): $(LOCAL)/hacks/%: bin/% - $(V_AT)mkdir -p $(dir $@) +$(COPY_SCRIPT_HACKS): $(LOCAL)/hacks/%: bin/% | $$(dir $$@) $(call v_tag,COPY)cp $< $@.new && mv $@.new $@ clean::; rm -f $(COPY_SCRIPT_HACKS) @@ -516,27 +535,25 @@ schroot-config_HASH := \ $(shell $(call %print-varlist,$(CONFIG_VARS)) | \ sha256sum | cut -c1-32) schroot-config_FILE = $(STATE)/config.sh-$(schroot-config_HASH) -$(schroot-config_FILE): - $(V_AT)mkdir -p $(STATE) +$(schroot-config_FILE): | $(STATE)/ $(V_AT)rm -f $(STATE)/config.sh-* $(call v_tag,GEN)$(call %print-varlist,$(CONFIG_VARS)) \ >$@.new && mv $@.new $@ schroot-config: $(STATE)/config.sh $(STATE)/config.sh: $(schroot-config_FILE) - $(call v_tag,SYMLINK)ln -sf $(notdir $<) $@ + $(call v_tag,SYMLINK)ln -sf $(call base-name,$<) $@ schroot-config: $(LOCAL)/etc/schroot/sbuild.schroot -$(LOCAL)/etc/schroot/sbuild.schroot: $(STATE)/bin/mkchrootconf - $(V_AT)mkdir -p $(dir $@) +$(LOCAL)/etc/schroot/sbuild.schroot: $(STATE)/bin/mkchrootconf | $$(dir $$@) $(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,$(ABSLOCAL)/etc/schroot/sbuild.schroot) schroot-config: $(LOCAL)/etc/schroot/sbuild.profile/copyfiles -$(LOCAL)/etc/schroot/sbuild.profile/copyfiles: $(schroot-config_STAMP) - $(V_AT)mkdir -p $(dir $@) +$(LOCAL)/etc/schroot/sbuild.profile/copyfiles: \ + $(schroot-config_STAMP) | $$(dir $$@) $(call v_tag,GEN){ \ echo "### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \ for i in $(SCHROOT_COPYFILES); do echo "$$i"; done; \ @@ -544,8 +561,8 @@ $(LOCAL)/etc/schroot/sbuild.profile/copyfiles: $(schroot-config_STAMP) CLEANFILES += $(LOCAL)/etc/schroot/sbuild.profile/copyfiles schroot-config: $(LOCAL)/etc/schroot/sbuild.profile/nssdatabases -$(LOCAL)/etc/schroot/sbuild.profile/nssdatabases: $(schroot-config_STAMP) - $(V_AT)mkdir -p $(dir $@) +$(LOCAL)/etc/schroot/sbuild.profile/nssdatabases: \ + $(schroot-config_STAMP) | $$(dir $$@) $(call v_tag,GEN){ \ echo "### -*-conf-*- GENERATED by distorted-chroot: do not edit"; \ for i in $(SCHROOT_NSSDATABASES); do echo "$$i"; done; \ @@ -554,8 +571,7 @@ CLEANFILES += $(LOCAL)/etc/schroot/sbuild.profile/nssdatabases schroot-config: $(LOCAL)/etc/schroot/sbuild.profile/fstab $(LOCAL)/etc/schroot/sbuild.profile/fstab: \ - etc/sbuild.fstab.in $(schroot-config_STAMP) - $(V_AT)mkdir -p $(dir $@) + etc/sbuild.fstab.in $(schroot-config_STAMP) | $$(dir $$@) $(call v_tag,SUBST)$(call subst-file,### -*-conf-*-) \ <$< >$@.new && mv $@.new $@ CLEANFILES += $(LOCAL)/etc/schroot/sbuild.profile/fstab @@ -563,8 +579,8 @@ CLEANFILES += $(LOCAL)/etc/schroot/sbuild.profile/fstab 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) - $(V_AT)mkdir -p $(dir $@) +$(LOCAL)/etc/sbuild.conf: etc/sbuild.conf.in \ + $(schroot-config_STAMP) | $$(dir $$@) $(call v_tag,SUBST)$(call subst-file,### -*-perl-*-) \ <$< >$@.new && mv $@.new $@ CLEANFILES += $(LOCAL)/etc/sbuild.conf @@ -577,8 +593,8 @@ SCHROOT_SCRIPTS += 51chrootenv COPY_SCHROOT_SCRIPTS = $(addprefix $(LOCAL)/etc/schroot/setup.d/,$(SCHROOT_SCRIPTS)) schroot-config: $(COPY_SCHROOT_SCRIPTS) $(COPY_SCHROOT_SCRIPTS): \ - $(LOCAL)/etc/schroot/setup.d/%: etc/schroot-scripts/% - $(V_AT)mkdir -p $(dir $@) + $(LOCAL)/etc/schroot/setup.d/%: etc/schroot-scripts/% \ + | $$(dir $$@) $(call v_tag,COPY)cp $< $@.new && mv $@.new $@ CLEANFILES += $(COPY_SCHROOT_SCRIPTS) @@ -595,8 +611,7 @@ 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 $@) + etc/ccache.conf | $$(dir $$@) $(call v_tag,COPY)cp $< $@.new && mv $@.new $@ ###-------------------------------------------------------------------------- @@ -605,9 +620,6 @@ $(CCACHE_CONFIGS): /var/lib/sbuild/build/.ccache/$(LVPREFIX)%/ccache.conf: \ LOCAL_COMMON_DIRS = share/ src/ LOCAL_EXTRA_DIRS = share/man/ all: $(foreach d,$(LOCAL_COMMON_DIRS) $(LOCAL_EXTRA_DIRS),$(LOCAL)/$d) -$(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/ include.aside/ LOCAL_ARCH_DIRS += lib/ libexec/ sbin/ @@ -619,22 +631,16 @@ all: $(foreach a,$(ALL_ARCHS),\ $(foreach d,$(LOCAL_ARCH_LINKS),$(LOCAL)/$a/$d) \ $(foreach d,$(LOCAL_COMMON_DIRS),$(LOCAL)/$a/$d)) -$(foreach a,$(ALL_ARCHS),$(LOCAL)/$a/): - $(call v_tag,MKDIR)mkdir $@ -$(foreach a,$(ALL_ARCHS),\ - $(foreach d,$(LOCAL_ARCH_DIRS),$(LOCAL)/$a/$d)): - $(V_AT)mkdir -p $(dir $(patsubst %/,%,$@)) - $(call v_tag,MKDIR)mkdir $@ $(foreach a,$(ALL_ARCHS),\ $(foreach d,$(LOCAL_ARCH_LINKS),$(LOCAL)/$a/$d)): \ - $$(if $$(call symlink-ok-p,$$@,$$($$(notdir $$@)_LINKDEST)),,_force) - $(V_AT)mkdir -p $(notdir $@) - $(call v_tag,SYMLINK)ln -sf $($(notdir $@)_LINKDEST) $@ + $$(if $$(call symlink-ok-p,$$@,$$($$(call base-name,$$@)_LINKDEST)),,_force) \ + | $$(dir $$@) + $(call v_tag,SYMLINK)ln -sf $($(call base-name,$@)_LINKDEST) $@ $(foreach a,$(ALL_ARCHS),\ $(foreach d,$(LOCAL_COMMON_DIRS),$(LOCAL)/$a/$d)): \ - $$(if $$(call symlink-ok-p,$$@,../$$(notdir $$(patsubst %/,%,$$@))),,_force) - $(V_AT)mkdir -p $(dir $(patsubst %/,%,$@)) - $(call v_tag,SYMLINK)ln -sf ../$(notdir $(patsubst %/,%,$@)) $(patsubst %/,%,$@) + $$(if $$(call symlink-ok-p,$$@,../$$(call base-name,$$@)),,_force) \ + | $$(call parent-dir,$$@) + $(call v_tag,SYMLINK)ln -sf ../$(call base-name,$@) $(call file-name,$@) ###-------------------------------------------------------------------------- ### Main chroot maintenance.