[CRIU] [PATCH] Makefile: suppress git describe warnings

Dmitry Safonov dsafonov at virtuozzo.com
Fri May 27 06:16:46 PDT 2016


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 <hash>":
  https://travis-ci.org/0x7f454c46/criu/jobs/133362045#L1748

Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 Makefile | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 23ee8e0a7fa3..c292cc7d0663 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
@@ -260,7 +261,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:
-- 
2.8.2



More information about the CRIU mailing list