From bdd7e7163b8661d05748e431186185f3373841d3 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 28 Jun 2017 12:43:36 +0100 Subject: [PATCH] pkg: Allow override of commit to calculate hash for show-tag Useful to answer the question of what the hash was at the point of some older commit. $ make --no-print-directory -C pkg/init/ show-tag linuxkit/init:36c56f0664d49c5a6adc1120d1bf5ba6ac30b389 $ make --no-print-directory -C pkg/init/ show-tag HASH_COMMIT=4699f80ef73141ee87a77d03f93065e541fab382 linuxkit/init:17693d233dd009b2a3a8d23673cb85969e1dce80 Signed-off-by: Ian Campbell --- pkg/package.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/package.mk b/pkg/package.mk index 6f32c4eb1..5ca8c14c1 100644 --- a/pkg/package.mk +++ b/pkg/package.mk @@ -2,10 +2,13 @@ default: push ORG?=linuxkit -HASH?=$(shell git ls-tree --full-tree HEAD -- $(CURDIR) | awk '{print $$3}') +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}') BASE_DEPS=Dockerfile Makefile +ifneq ($(HASH_COMMIT),HEAD) # Others can't be dirty by definition DIRTY=$(shell git diff-index --quiet HEAD -- $(CURDIR) || echo "-dirty") +endif TAG=$(ORG)/$(IMAGE):$(HASH)$(DIRTY) # Get a release tag, if present