summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-12-17 00:15:27 +0100
committerThomas Haller <thaller@redhat.com>2014-12-17 14:55:38 +0100
commit83cb0aa0fca19e55cf96c10303bca414b44e2bbc (patch)
tree070ca60d729a236a113aea39631caa6672b71a63
parent2d5822f2642ae5ccb5cca9480fe8e688ced7526b (diff)
downloadNetworkManager-th/bgo741651.tar.gz
build: embed git-commit-id as string inside the compiled libnmth/bgo741651
In the 'configure.ac' script we already detect the git commit id for the current source version. When creating a tarball, it is also included inside the generated 'configure' script. Add the commit id as a static string to nm-utils.c. That way, having a build of libnm.so or NetworkManager, you can quickly find the corresponding git commit: strings src/NetworkManager | grep NM_GIT_SHA Note that this only works after a new autogen.sh. Simply rebuilding is not enough. Hence, to ensure that you have the right commit id embedded, rebuild cleanly.
-rw-r--r--configure.ac1
-rw-r--r--libnm-core/nm-utils.c6
-rw-r--r--libnm-util/nm-utils.c6
3 files changed, 13 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 9cfe2af355..6739b23316 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,7 @@ AC_SUBST(NM_MAJOR_VERSION)
AC_SUBST(NM_MINOR_VERSION)
AC_SUBST(NM_MICRO_VERSION)
AC_SUBST(NM_VERSION)
+AC_DEFINE_UNQUOTED(NM_GIT_SHA,"$NM_GIT_SHA",[git commit id of the original source code version])
dnl
dnl Checks for typedefs, structures, and compiler characteristics.
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 4b284cfefd..e5a49d74b1 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -36,6 +36,7 @@
#include "nm-setting-private.h"
#include "crypto.h"
#include "gsystem-local-alloc.h"
+#include "nm-utils-internal.h"
#include "nm-setting-bond.h"
#include "nm-setting-bridge.h"
@@ -46,6 +47,9 @@
#include "nm-setting-wired.h"
#include "nm-setting-wireless.h"
+/* Embed the commit id in the build binary */
+static const char *const __nm_git_sha = STRLEN (NM_GIT_SHA) > 0 ? "NM_GIT_SHA:"NM_GIT_SHA : "";
+
/**
* SECTION:nm-utils
* @short_description: Utility functions
@@ -221,6 +225,8 @@ _nm_utils_init (void)
GModule *self;
gpointer func;
+ (void) __nm_git_sha;
+
if (initialized)
return;
initialized = TRUE;
diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c
index b5bbfbd349..b6a9dc3004 100644
--- a/libnm-util/nm-utils.c
+++ b/libnm-util/nm-utils.c
@@ -37,6 +37,10 @@
#include "nm-dbus-glib-types.h"
#include "nm-setting-private.h"
#include "crypto.h"
+#include "nm-utils-internal.h"
+
+/* Embed the commit id in the build binary */
+static const char *const __nm_git_sha = STRLEN (NM_GIT_SHA) > 0 ? "NM_GIT_SHA:"NM_GIT_SHA : "";
/**
* SECTION:nm-utils
@@ -232,6 +236,8 @@ static gboolean initialized = FALSE;
gboolean
nm_utils_init (GError **error)
{
+ (void) __nm_git_sha;
+
if (!initialized) {
initialized = TRUE;