Files
linuxkit/pkg/package.mk
Ian Campbell fe918f8a31 pkg: Run git update-index --refresh before git diff-index.
Otherwise files which have an updated timestamp but no actual changes are
marked as changes because `git diff-index` only uses the `lstat` result and not
the actual file contents. Running `git update-index --refresh` updates the
cache.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-07-03 10:27:31 +01:00

44 lines
1.1 KiB
Makefile

.PHONY: image tag show-tag
default: push
ORG?=linuxkit
ifeq ($(HASH),)
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")
endif
endif
TAG=$(ORG)/$(IMAGE):$(HASH)$(DIRTY)
BASE_DEPS=Dockerfile Makefile
# Get a release tag, if present
RELEASE=$(shell git tag -l --points-at HEAD)
ifdef NETWORK
NET_OPT=
else
NET_OPT=--network=none
endif
show-tag:
@echo $(TAG)
tag: $(BASE_DEPS) $(DEPS)
DOCKER_CONTENT_TRUST=1 docker pull $(TAG) || \
docker build $(NET_OPT) -t $(TAG) .
push: tag
ifneq ($(DIRTY),)
$(error Your repository is not clean. Will not push package image.)
endif
DOCKER_CONTENT_TRUST=1 docker pull $(TAG) || \
DOCKER_CONTENT_TRUST=1 docker push $(TAG)
ifneq ($(RELEASE),)
docker tag $(TAG) $(ORG)/$(IMAGE):$(RELEASE)
DOCKER_CONTENT_TRUST=1 docker push $(ORG)/$(IMAGE):$(RELEASE)
endif