build: Capture git describe on build if available, add to --version

Many projects do this, and it really helps debugging to know the
exact hash.

(Of course this is broken in traditional rpm builds from a tarball,
 and rpmdistro-gitoverlay injects it into the Version field,
 but it will help me for vmcheck debugging)

Closes: #584
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-01-19 12:38:40 -05:00 committed by Atomic Bot
parent d277205c13
commit b099680d1d
3 changed files with 10 additions and 1 deletions

View File

@ -30,11 +30,14 @@ if ENABLE_GTK_DOC
SUBDIRS += api-doc SUBDIRS += api-doc
endif endif
RPM_OSTREE_GITREV=$(shell if command -v git >/dev/null 2>&1 && test -d $(srcdir)/.git; then git describe --abbrev=42 --tags --always HEAD; fi)
ACLOCAL_AMFLAGS += -I m4 ${ACLOCAL_FLAGS} ACLOCAL_AMFLAGS += -I m4 ${ACLOCAL_FLAGS}
AM_CPPFLAGS += -DDATADIR='"$(datadir)"' \ AM_CPPFLAGS += -DDATADIR='"$(datadir)"' \
-DLIBEXECDIR='"$(libexecdir)"' \ -DLIBEXECDIR='"$(libexecdir)"' \
-DLOCALEDIR=\"$(datadir)/locale\" \ -DLOCALEDIR=\"$(datadir)/locale\" \
-DRPM_OSTREE_FEATURES='"$(RPM_OSTREE_FEATURES)"' \ -DRPM_OSTREE_FEATURES='"$(RPM_OSTREE_FEATURES)"' \
-DRPM_OSTREE_GITREV='"$(RPM_OSTREE_GITREV)"' \
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40_ -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40_
AM_CFLAGS += -std=gnu11 $(WARN_CFLAGS) AM_CFLAGS += -std=gnu11 $(WARN_CFLAGS)
# bundled libdnf # bundled libdnf

View File

@ -147,7 +147,10 @@ rpmostree_option_context_parse (GOptionContext *context,
if (opt_version) if (opt_version)
{ {
g_print ("%s\n %s\n", PACKAGE_STRING, RPM_OSTREE_FEATURES); g_print ("%s", PACKAGE_STRING);
if (strlen (RPM_OSTREE_GITREV) > 0)
g_print (", git %s", RPM_OSTREE_GITREV);
g_print ("\n %s\n", RPM_OSTREE_FEATURES);
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }

View File

@ -93,6 +93,9 @@ vm_ssh_wait() {
while [ $timeout -gt 0 ]; do while [ $timeout -gt 0 ]; do
if bootid=$(vm_get_boot_id 2>/dev/null); then if bootid=$(vm_get_boot_id 2>/dev/null); then
if [[ $bootid != $old_bootid ]]; then if [[ $bootid != $old_bootid ]]; then
# Display some info per boot
vm_rpmostree status
vm_rpmostree --version
return 0 return 0
fi fi
fi fi