diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 30 |
1 files changed, 17 insertions, 13 deletions
@@ -38,6 +38,7 @@ BOOTTARGETS := $(foreach template, $(TEMPLATES), $(template)/base/boot) BOOTTARGETS += $(foreach prov, $(PROVTARGETS), $(prov)/boot) + PACKER_OPTS := -var-file=base.json ifdef DEBUG VERBOSE := 1 @@ -51,6 +52,22 @@ endif TIMESTAMP := $(shell date "+%Y-%m-%d_%H-%M-%S") +# The ROOTPW is only needed for the base, boot and provisioning targets. +# In every other case it must not be checked as it should be possible to call +# help or cleanup without the need of defining the password. +PW_NEEDED := $(filter $(strip $(PROVTARGETS) $(BOOTTARGETS)),$(MAKECMDGOALS)) +ifneq ($(PW_NEEDED),) + ifeq ($(strip $(ROOTPW)),) + $(error No root password is set, set it as ROOTPW in your environment.) + else + $(foreach cur,$(PW_NEEDED),\ + $(shell printf "$(ROOTPW)" | $(HASHER) --check --status "$(firstword $(subst /, ,$(cur)))/base/rootpw.$(HASHER)")\ + $(if $(filter 1,$(.SHELLSTATUS)),\ + $(error The wrong ROOTPW is set. Please correct it))) + endif +endif + + ifdef VERBOSE PACKER_OPTS += -var='headless=false' @@ -74,23 +91,12 @@ ifdef VERBOSE endif -check_rootpw = $(if $(strip $(ROOTPW)),\ - $(if $1,\ - $(if $(shell echo "$(ROOTPW)" | $(HASHER) --check --quiet $1/base/rootpw.$(HASHER)),\ - $(error ROOTPW password hash does not match $1/base/rootpw.$(HASHER)),\ - ),\ - ),\ - $(error No root password is set, set it as ROOTPW in your environment.) \ -) - - .PHONY: help clean_except_last clean_bases clean_all help: # Creating base images $(BASETARGETS): - $(call check_rootpw) $(info ** Building template '$(@D)' using '$(BUILDER)' **) $(PACKER) build -only=$(BUILDER) \ $(PACKER_OPTS) \ @@ -103,7 +109,6 @@ $(BASETARGETS): # Provisioning images $(PROVTARGETS): $(foreach flav, $(FLAVORS), %/$(flav)): %/base - $(call check_rootpw,$(@D)) $(eval BUILD_DIR := $(@D)/$(@F).$(TIMESTAMP)) $(info ** Provisioning '$(@D)' with '$(@F)' **) @mkdir -p $(BUILD_DIR) @@ -121,7 +126,6 @@ $(foreach flav, $(FLAVORS), %/$(flav)): %/base # Generating boot files $(BOOTTARGETS): %/boot: % - $(call check_rootpw,$(dir $(@D))) $(eval BUILD_DIR := $(@D).$(TIMESTAMP)) $(info ** Generating boot files for '$(BUILD_DIR)') $(PACKER) build -only=$(BUILDER) \ |