pkg: Reduce the number of times variables containing $(shell...) are invoked.

For DIRTY and RELEASED this means simply performing a static assignment with
`:=`. For HASH it is a little more complex since it is (and we want/need it to
be) a conditional assigment. However it is only used for defining TAG, so make
that a static assignment.

This reduces the number of times the complex DIRTY shell command in particular
is evaluated.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
Ian Campbell 2017-07-06 16:33:08 +01:00
parent 4fba9d8545
commit aee080f621

View File

@ -7,16 +7,16 @@ HASH_COMMIT?=HEAD # Setting this is only really useful with the show-tag target
HASH?=$(shell git ls-tree --full-tree $(HASH_COMMIT) -- $(CURDIR) | awk '{print $$3}')
ifneq ($(HASH_COMMIT),HEAD) # Others can't be dirty by definition
DIRTY=$(shell git update-index -q --refresh && git diff-index --quiet HEAD -- $(CURDIR) || echo "-dirty")
DIRTY:=$(shell git update-index -q --refresh && git diff-index --quiet HEAD -- $(CURDIR) || echo "-dirty")
endif
endif
TAG=$(ORG)/$(IMAGE):$(HASH)$(DIRTY)
TAG:=$(ORG)/$(IMAGE):$(HASH)$(DIRTY)
BASE_DEPS=Dockerfile Makefile
# Get a release tag, if present
RELEASE=$(shell git tag -l --points-at HEAD)
RELEASE:=$(shell git tag -l --points-at HEAD)
ifdef NETWORK
NET_OPT=