Commit 551cd032 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

version: Print git id if present

If criu is built from git repo print git commit id, convenient for debug.

For example

 | $ ./criu -V
 | Version: 0.7
 | GitID: 7985251
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5006ed5f
......@@ -266,6 +266,8 @@ int main(int argc, char *argv[])
break;
case 'V':
pr_msg("Version: %s\n", CRIU_VERSION);
if (strcmp(CRIU_GITID, "0"))
pr_msg("GitID: %s\n", CRIU_GITID);
return 0;
case 'h':
default:
......
CRTOOLSVERSION := $(VERSION_MAJOR)$(if $(VERSION_MINOR),.$(VERSION_MINOR))$(if $(VERSION_SUBLEVEL),.$(VERSION_SUBLEVEL))
VERSION_HEADER := include/version.h
GITID := $(shell if [ -d ".git" ]; then git reflog -n 1 | cut -f1 -d' '; fi)
ifeq ($(GITID),)
GITID := 0
endif
$(VERSION_HEADER): Makefile scripts/Makefile.version
$(E) " GEN " $@
......@@ -10,6 +14,7 @@ $(VERSION_HEADER): Makefile scripts/Makefile.version
$(Q) echo "#define CRIU_VERSION \"$(CRTOOLSVERSION)\"" >> $(VERSION_HEADER)
$(Q) echo "#define CRIU_VERSION_MAJOR " $(VERSION_MAJOR) >> $(VERSION_HEADER)
$(Q) echo "#define CRIU_VERSION_MINOR " $(VERSION_MINOR) >> $(VERSION_HEADER)
$(Q) echo "#define CRIU_GITID \"$(GITID)\"" >> $(VERSION_HEADER)
$(Q) echo "#endif /* __CR_VERSION_H__ */" >> $(VERSION_HEADER)
##
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment