From e46c259a9057d220af1c9aa7045a924de6bd04c9 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Mon, 4 Feb 2013 19:18:06 +0400 Subject: [PATCH] ensure that IMAGEDIR exists (thus globbable) It appears that manually specified IMAGEDIR, e.g. by adding IMAGEDIR = ~/out/$(shell date +%Y%m%d) to ~/.mkimage/profiles.mk, might be problematic due to missing globbing. Let's make sure the paths are globbed and directories are created -- since make's wildcard() returns an empty string when there's nothing there [yet]. --- image.in/Makefile | 5 ++++- lib/build.mk | 2 +- lib/profile.mk | 4 ++-- main.mk | 6 ++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/image.in/Makefile b/image.in/Makefile index 54e80332..db174582 100644 --- a/image.in/Makefile +++ b/image.in/Makefile @@ -29,8 +29,11 @@ $(info warning: mkimage-$(MKI_VERSION) is suboptimal, consider upgrading) $(warning consider upgrading mkimage to $(MKI_VER_OPTIMAL) or better) endif +# glob it just in case +IMAGEDIR := $(wildcard $(IMAGEDIR)) + # additional means to reduce havoc in IMAGEDIR -IMAGE_SORTDIR := $(SORTDIR) +IMAGE_SORTDIR := $(wildcard $(SORTDIR)) # reconstruct instead of passing yet another variable IMAGE_OUTDIR := $(IMAGEDIR)$(IMAGE_SORTDIR:%=/%) diff --git a/lib/build.mk b/lib/build.mk index 2bfc806b..fdd0fac4 100644 --- a/lib/build.mk +++ b/lib/build.mk @@ -42,7 +42,7 @@ IMAGEDIR ?= $(shell \ fi; \ ) -LOGDIR ?= $(IMAGEDIR) +LOGDIR ?= $(wildcard $(IMAGEDIR)) # actual build starter # NB: our output MUST go into stderr to escape POSTPROC diff --git a/lib/profile.mk b/lib/profile.mk index c5dbd145..049805cb 100644 --- a/lib/profile.mk +++ b/lib/profile.mk @@ -82,8 +82,8 @@ profile/bare: profile/init } >&2 @$(call try,MKIMAGE_PREFIX,/usr/share/mkimage) @$(call try,GLOBAL_VERBOSE,) - @$(call try,IMAGEDIR,$(IMAGEDIR)) - @$(call try,LOGDIR,$(LOGDIR)) + @$(call try,IMAGEDIR,$(wildcard $(IMAGEDIR))) + @$(call try,LOGDIR,$(wildcard $(LOGDIR))) @$(call try,BRANDING,altlinux-sisyphus) ifeq (,$(REPO:altlinux%=)) @$(call set,IMAGE_INIT_LIST,+branding-$$(BRANDING)-release) diff --git a/main.mk b/main.mk index 94fe2bca..5ddbf46f 100644 --- a/main.mk +++ b/main.mk @@ -34,6 +34,12 @@ include $(sort $(wildcard lib/*.mk)) include conf.d/*.mk include features.in/*/config.mk +# ensure the outdir is created and globbable +ifdef IMAGEDIR +$(shell mkdir -p $(IMAGEDIR)) +IMAGEDIR := $(wildcard $(IMAGEDIR)) +endif + # FIXME: this is buggy since *.mk can expose parts conditionally # (e.g. test.mk does DEBUG-only bits) and these will fail DISTRO_TARGETS := $(shell sed -n 's,^\(distro/[^:.]\+\):.*$$,\1,p' \