From fa8b12a1ec0f4eb76d04ca99fe1991f5029a0030 Mon Sep 17 00:00:00 2001 From: Dmitry Safonov Date: Fri, 27 May 2016 16:16:00 +0300 Subject: [PATCH] Makefile: suppress git describe warnings This should fix errors on build envs, where git tags haven't been fetched. I.e, Travis-ci does not fetch tags before building a project, wich results in: ---> Running in 0d63a3d28a7a fatal: No names found, cannot describe anything. fatal: No names found, cannot describe anything. make[1]: Entering directory '/criu' The other way is to fetch tags on `git describe` failure, but it that way has two cons: - it will change user's git (and I'm not sure it's right); - we need not only fetch tags in that case, but also remotes, as otherwise it will fail with "fatal: No tags can describe ": https://travis-ci.org/0x7f454c46/criu/jobs/133362045#L1748 Cc: Cyrill Gorcunov Signed-off-by: Dmitry Safonov Acked-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 99991d0e2..c4810db1d 100644 --- a/Makefile +++ b/Makefile @@ -141,8 +141,9 @@ include Makefile.versions VERSION_HEADER := $(SRC_DIR)/criu/include/version.h GITID_FILE := .gitid -GITID := $(shell if [ -d ".git" ]; then git describe; fi) +GITID := $(shell if [ -d ".git" ]; then git describe --always; fi) +# Git repository wasn't inited in CRIU folder ifeq ($(GITID),) GITID := 0 else @@ -248,7 +249,16 @@ test: zdtm # "v" prefix stripped. head-name := $(shell git tag -l v$(CRIU_VERSION)) ifeq ($(head-name),) - head-name := $(shell git describe) + head-name := $(shell git describe 2>/dev/null) +endif +# If no git tag could describe current commit, +# use pre-defined CRIU_VERSION with GITID (if any). +ifeq ($(head-name),) + ifneq ($(GITID),) + head-name := $(CRIU_VERSION)-$(GITID) + else + head-name := $(CRIU_VERSION) + endif endif tar-name := $(shell echo $(head-name) | sed -e 's/^v//g') criu-$(tar-name).tar.bz2: