build: add git revision to --version output if build from git repository
PATCH 1/1 build: add git revision to --version output if build from git repository
If configure is located at git repository, acquire branch and revision of head to be printed at --version output.
--- configure.ac | 11 +++++++++++ src/openvpn/options.c | 3 +++ 2 files changed, 14 insertions(+), 0 deletions(-)
configure.ac +11 -0
@@ -307,11 +307,13 @@ AC_ARG_VAR([ROUTE], [full path to route utility]) AC_ARG_VAR([IPROUTE], [full path to ip utility]) AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests AC_ARG_VAR([MAN2HTML], [path to man2html utility]) +AC_ARG_VAR([GIT], [path to git utility]) AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests AC_CHECK_PROGS([MAN2HTML], [man2html]) +AC_CHECK_PROGS([GIT], [git]) # optional AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool]) AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool]) AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
@@ -781,6 +783,15 @@ PKG_CHECK_MODULES( [] ) +AC_MSG_CHECKING([git checkout]) +if test -n "${GIT}" -a -d "${srcdir}/.git"; then + PACKAGE_VERSION_EXTRA_GIT_REVISION="`GIT_DIR=\"${srcdir}/.git\" git rev-parse --symbolic-full-name HEAD`/`GIT_DIR=\"${srcdir}/.git\" git rev-parse --short HEAD`" + AC_MSG_RESULT([${PACKAGE_VERSION_EXTRA_GIT_REVISION}]) + AC_DEFINE_UNQUOTED([PACKAGE_VERSION_EXTRA_GIT_REVISION], ["${PACKAGE_VERSION_EXTRA_GIT_REVISION}"], [Git checkout revision]) +else + AC_MSG_RESULT([no]) +fi + if test -n "${SP_PLATFORM_WINDOWS}"; then AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #" AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
src/openvpn/options.c +3 -0
@@ -3430,6 +3430,9 @@ usage_version (void)#ifdef CONFIGURE_DEFINES msg (M_INFO |M_NOPREFIX ,"Compile time defines: %s" ,CONFIGURE_DEFINES );#endif +#ifdef PACKAGE_VERSION_EXTRA_GIT_REVISION +msg (M_INFO |M_NOPREFIX ,"git revision: %s" ,PACKAGE_VERSION_EXTRA_GIT_REVISION ); +#endif #endif openvpn_exit (OPENVPN_EXIT_STATUS_USAGE );/* exit point */ }
Signature · 1 line
1.7.3.4
Quoted 8 lines · Alon Bar-Lev
If configure is located at git repository, acquire branch and revision of head to be printed at --version output.
Signed-off-by Alon Bar-Lev <[email protected]...>---
configure.ac | 11 +++++++++++
src/openvpn/options.c | 3 +++2 files changed, 14 insertions(+), 0 deletions(-)
David,
Check if this meets your requirement.
It won't survive make dist, but if compiled directly from repository the HEAD will be visible.
Surviving make dist is doable if some file is generated, but this file will stay the same even if there are local modifications... So I don't think it worth both the effort and the confusion.
Alon.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 6 lines · Alon Bar-Lev
If configure is located at git repository, acquire branch and revision of head to be printed at --version output.
Signed-off-by Alon Bar-Lev <[email protected]...> ---configure.ac | 11 +++++++++++
src/openvpn/options.c|
3 +++ 2 files changed, 14 insertions(+), 0 deletions(-)
This is definitely a step in the right direction. However, it depends on ./configure being run to get the updated git revision set. When developing and testing out changes, you don't always need to run ./configure for each build. Thus this may provide a false reference.
Let me explain more carefully:
$ ./configure $ make (test src/openvpn/openvpn) (hack more on source files in src/openvpn) $ make (test src/openvpn/openvpn) $ src/openvpn/openvpn src/openvpn/openvpn-test1 (hack more on source files in src/openvpn) $ make (test src/openvpn/openvpn and compare against openvpn-test1)
If doing such an iteration over a day or two or maybe weeks (which is not uncommon for me, as I don't have time to dig into OpenVPN every day), the git revision reference provided with your patch will not help me much. And as I also work across several branches, testing different approaches for the same issue, I would need far better overview over what's git HEAD of 'make' and not the 'configure' run.
What I would like to see is something more like what's found in TOR projects' obfsproxy, where the Makefile generates a micro-version.i, which is included. As this file is forced to be (re-)created each time, it will always be accurate.
I don't say that obfsproxy have done the implementation correct, but it can at least be a seed for inspiration:
Makefile.am part:
<https://gitweb.torproject.org/obfsproxy.git/blob/94ebc4c3edf1e3e5f313444e59981ac557578df5:/Makefile.am#l106>
main.c parts:
<https://gitweb.torproject.org/obfsproxy.git/blob/94ebc4c3edf1e3e5f313444e59981ac557578df5:/src/main.c#l38>
<https://gitweb.torproject.org/obfsproxy.git/blob/94ebc4c3edf1e3e5f313444e59981ac557578df5:/src/main.c#l57>
Otherwise, that this git revision is not available when doing 'make dist' is no problem. In fact, that's fairly reasonable, as an official release is far easier to track back to a concrete commit.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk+iOakACgkQDC186MBRfrp1ZQCfZwJ740HBH2wGOEK5lAEt2681 W/gAoKHlGzxG124aj+CrK6uqsjCEcqvc
=lCZv
-----END PGP SIGNATURE-----
Hi,
2012/5/3 David Sommerseth <[email protected]...>:
Quoted 7 lines
What I would like to see is something more like what's found in TOR projects' obfsproxy, where the
Makefilegenerates a micro-version.i, which is included. As this file is forced to be (re-)created each time, it will always be accurate.I don't say that obfsproxy have done the implementation correct, but it can at least be a seed for inspiration:
I agree that the Makefile-based approach is more useful. Regarding the
implementation: Depending on compile vs link time it might be faster to move the re-compiled part into a dedicated version.c which only contains a
const char *get_ovpn_version()
{
return PACKAGE_VERSION_EXTRA_GIT_REVISION;
}Cheers
Fabian
PATCH 1/1 build: add git revision to --version output if build from git repository
In reply to David SommersethIf source is located at git repository, acquire branch and revision of head to be printed at --version output.
--- Makefile.am | 25 ++++++++++++++++++++++++- configure.ac | 11 +++++++++++ src/openvpn/options.c | 6 ++++++ 3 files changed, 41 insertions(+), 1 deletions(-)
Makefile.am +24 -1
@@ -40,11 +40,18 @@ MAINTAINERCLEANFILES = \ $(srcdir)/depcomp $(srcdir)/aclocal.m4 \ $(srcdir)/config.guess $(srcdir)/config.sub +CLEANFILES = \ + config-version.h + EXTRA_DIST = \ contrib \ debug -SUBDIRS = build distro include src sample doc tests +if GIT_CHECKOUT +.PHONY: config-version.h +endif + +SUBDIRS = . build distro include src sample doc tests dist_doc_DATA = \ COPYRIGHT.GPL \
@@ -53,6 +60,7 @@ dist_doc_DATA = \ dist_noinst_DATA = \ .gitignore \ .gitattributes \ + config-version.h.in \ PORTS \ README.IPv6 TODO.IPv6 \ README.polarssl \
@@ -75,3 +83,18 @@ if WIN32 rootdir=$(prefix) root_DATA = version.sh endif + +if GIT_CHECKOUT +nodist_noinst_HEADERS = \ + config-version.h +config-version.h: + @PACKAGE_VERSION_EXTRA_GIT_REVISION="`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --symbolic-full-name HEAD`/`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --short=16 HEAD`"; \ + sed "s#@PACKAGE_VERSION_EXTRA_GIT_REVISION[@]#$${PACKAGE_VERSION_EXTRA_GIT_REVISION}#g" "$(srcdir)/config-version.h.in" > config-version.h.tmp + @if ! [ -f config-version.h ] || ! cmp -s config-version.h.tmp config-version.h; then \ + echo "replacing config-version.h"; \ + mv config-version.h.tmp config-version.h; \ + else \ + rm config-version.h.tmp; \ + fi +endif +
configure.ac +11 -0
@@ -307,11 +307,13 @@ AC_ARG_VAR([ROUTE], [full path to route utility]) AC_ARG_VAR([IPROUTE], [full path to ip utility]) AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests AC_ARG_VAR([MAN2HTML], [path to man2html utility]) +AC_ARG_VAR([GIT], [path to git utility]) AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests AC_CHECK_PROGS([MAN2HTML], [man2html]) +AC_CHECK_PROGS([GIT], [git]) # optional AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool]) AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool]) AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
@@ -781,6 +783,14 @@ PKG_CHECK_MODULES( [] ) +AC_MSG_CHECKING([git checkout]) +GIT_CHECKOUT="no" +if test -n "${GIT}" -a -d "${srcdir}/.git"; then + AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h]) + GIT_CHECKOUT="yes" +fi +AC_MSG_RESULT([${GIT_CHECKOUT}]) + if test -n "${SP_PLATFORM_WINDOWS}"; then AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #" AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
@@ -928,6 +938,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS]) AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS]) AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) +AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"]) sampledir="\$(docdir)/sample" AC_SUBST([sampledir])
src/openvpn/options.c +6 -0
@@ -35,6 +35,9 @@#elif defined(_MSC_VER)#include "config-msvc.h" #endif +#ifdef HAVE_CONFIG_VERSION_H +#include "config-version.h" +#endif #include "syshead.h"
@@ -3430,6 +3433,9 @@ usage_version (void)#ifdef CONFIGURE_DEFINES msg (M_INFO |M_NOPREFIX ,"Compile time defines: %s" ,CONFIGURE_DEFINES );#endif +#ifdef PACKAGE_VERSION_EXTRA_GIT_REVISION +msg (M_INFO |M_NOPREFIX ,"git revision: %s" ,PACKAGE_VERSION_EXTRA_GIT_REVISION ); +#endif #endif openvpn_exit (OPENVPN_EXIT_STATUS_USAGE );/* exit point */ }
Signature · 1 line
1.7.3.4
Quoted 4 lines · Alon Bar-Lev
If source is located at git repository, acquire branch and revision of head to be printed at --version output.
Signed-off-by Alon Bar-Lev <[email protected]...>
Slowly I get what you need.
How is this one?
Alon.
PATCH 1/1 build: add git revision to --version output if build from git repository
In reply to David SommersethIf source is located at git repository, acquire branch and revision of head to be printed at --version output.
--- Makefile.am | 25 ++++++++++++++++++++++++- configure.ac | 11 +++++++++++ src/openvpn/options.c | 6 ++++++ 3 files changed, 41 insertions(+), 1 deletions(-)
Makefile.am +24 -1
@@ -40,11 +40,18 @@ MAINTAINERCLEANFILES = \ $(srcdir)/depcomp $(srcdir)/aclocal.m4 \ $(srcdir)/config.guess $(srcdir)/config.sub +CLEANFILES = \ + config-version.h + EXTRA_DIST = \ contrib \ debug -SUBDIRS = build distro include src sample doc tests +if GIT_CHECKOUT +.PHONY: config-version.h +endif + +SUBDIRS = . build distro include src sample doc tests dist_doc_DATA = \ COPYRIGHT.GPL \
@@ -53,6 +60,7 @@ dist_doc_DATA = \ dist_noinst_DATA = \ .gitignore \ .gitattributes \ + config-version.h.in \ PORTS \ README.IPv6 TODO.IPv6 \ README.polarssl \
@@ -75,3 +83,18 @@ if WIN32 rootdir=$(prefix) root_DATA = version.sh endif + +if GIT_CHECKOUT +nodist_noinst_HEADERS = \ + config-version.h +config-version.h: + @PACKAGE_VERSION_EXTRA_GIT_REVISION="`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --symbolic-full-name HEAD`/`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --short=16 HEAD`"; \ + sed "s#@PACKAGE_VERSION_EXTRA_GIT_REVISION[@]#$${PACKAGE_VERSION_EXTRA_GIT_REVISION}#g" "$(srcdir)/config-version.h.in" > config-version.h.tmp + @if ! [ -f config-version.h ] || ! cmp -s config-version.h.tmp config-version.h; then \ + echo "replacing config-version.h"; \ + mv config-version.h.tmp config-version.h; \ + else \ + rm config-version.h.tmp; \ + fi +endif +
configure.ac +11 -0
@@ -307,11 +307,13 @@ AC_ARG_VAR([ROUTE], [full path to route utility]) AC_ARG_VAR([IPROUTE], [full path to ip utility]) AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests AC_ARG_VAR([MAN2HTML], [path to man2html utility]) +AC_ARG_VAR([GIT], [path to git utility]) AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests AC_CHECK_PROGS([MAN2HTML], [man2html]) +AC_CHECK_PROGS([GIT], [git]) # optional AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool]) AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool]) AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
@@ -781,6 +783,14 @@ PKG_CHECK_MODULES( [] ) +AC_MSG_CHECKING([git checkout]) +GIT_CHECKOUT="no" +if test -n "${GIT}" -a -d "${srcdir}/.git"; then + AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h]) + GIT_CHECKOUT="yes" +fi +AC_MSG_RESULT([${GIT_CHECKOUT}]) + if test -n "${SP_PLATFORM_WINDOWS}"; then AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #" AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
@@ -928,6 +938,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS]) AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS]) AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) +AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"]) sampledir="\$(docdir)/sample" AC_SUBST([sampledir])
src/openvpn/options.c +6 -0
@@ -35,6 +35,9 @@#elif defined(_MSC_VER)#include "config-msvc.h" #endif +#ifdef HAVE_CONFIG_VERSION_H +#include "config-version.h" +#endif #include "syshead.h"
@@ -3430,6 +3433,9 @@ usage_version (void)#ifdef CONFIGURE_DEFINES msg (M_INFO |M_NOPREFIX ,"Compile time defines: %s" ,CONFIGURE_DEFINES );#endif +#ifdef PACKAGE_VERSION_EXTRA_GIT_REVISION +msg (M_INFO |M_NOPREFIX ,"git revision: %s" ,PACKAGE_VERSION_EXTRA_GIT_REVISION ); +#endif #endif openvpn_exit (OPENVPN_EXIT_STATUS_USAGE );/* exit point */ }
Signature · 1 line
1.7.3.4
Quoted 7 lines · Alon Bar-Lev
If source is located at git repository, acquire branch and revision of head to be printed at --version output.
Signed-off-by Alon Bar-Lev <[email protected]...> --- Makefile.am| 25 ++++++++++++++++++++++++- configure.ac | 11 +++++++++++ src/openvpn/options.c | 6 ++++++ 3 files changed, 41insertions(+), 1 deletions(-)
Just a detail ... but isn't config-version.h.in lacking? Haven't tested it yet, just read through the patch - so I might have overlooked something.
But this looks far closer to what I'd like from such a feature. Thanks for poking into this!
kind regards,
David Sommerseth
Quoted 13 lines · David Sommerseth
Quoted 7 lines · Alon Bar-Lev
If source is located at git repository, acquire branch and revision of head to be printed at --version output.
Signed-off-by Alon Bar-Lev <[email protected]...> --- Makefile.am| 25 ++++++++++++++++++++++++- configure.ac | 11 +++++++++++ src/openvpn/options.c | 6 ++++++ 3 files changed, 41insertions(+), 1 deletions(-)
Just a detail ... but isn't config-version.h.in lacking? Haven't tested it yet, just read through the patch - so I might have overlooked something.
Quoted 7 lines
But this looks far closer to what I'd like from such a feature. Thanks for poking into this!
kind regards,
David Sommerseth
Right!
I was way too tired!
Sorry.
Alon.
PATCH 1/1 build: add git revision to --version output if build from git repository
If source is located at git repository, acquire branch and revision of head to be printed at --version output.
--- .gitignore | 1 + Makefile.am | 21 +++++++++++++++++++++ compat.m4 | 5 +++++ config-version.h.in | 1 + configure.ac | 12 ++++++++++++ src/openvpn/options.c | 6 ++++++ 6 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 config-version.h.in
.gitignore +1 -0
@@ -49,3 +49,4 @@ doc/openvpn.8.html distro/rpm/openvpn.spec tests/t_client.sh src/openvpn/openvpn +config-version.h
Makefile.am +21 -0
@@ -40,10 +40,20 @@ MAINTAINERCLEANFILES = \ $(srcdir)/depcomp $(srcdir)/aclocal.m4 \ $(srcdir)/config.guess $(srcdir)/config.sub +CLEANFILES = \ + config-version.h + EXTRA_DIST = \ contrib \ debug +.PHONY: config-version.h + +if GIT_CHECKOUT +BUILT_SOURCES = \ + config-version.h +endif + SUBDIRS = build distro include src sample doc tests dist_doc_DATA = \
@@ -53,6 +63,7 @@ dist_doc_DATA = \ dist_noinst_DATA = \ .gitignore \ .gitattributes \ + config-version.h.in \ PORTS \ README.IPv6 TODO.IPv6 \ README.polarssl \
@@ -75,3 +86,13 @@ if WIN32 rootdir=$(prefix) root_DATA = version.sh endif + +config-version.h: + @PACKAGE_VERSION_EXTRA_GIT_REVISION="`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --symbolic-full-name HEAD`/`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --short=16 HEAD`"; \ + $(SED) "s#@PACKAGE_VERSION_EXTRA_GIT_REVISION[@]#$${PACKAGE_VERSION_EXTRA_GIT_REVISION}#g" "$(srcdir)/config-version.h.in" > config-version.h.tmp + @if ! [ -f config-version.h ] || ! cmp -s config-version.h.tmp config-version.h; then \ + echo "replacing config-version.h"; \ + mv config-version.h.tmp config-version.h; \ + else \ + rm -f config-version.h.tmp; \ + fi
compat.m4 +5 -0
@@ -43,6 +43,11 @@ ifdef( [AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], [GNU_SOURCE])] ) ifdef( + [AC_PROG_SED], + , + [AC_DEFUN([AC_PROG_SED], [AC_CHECK_PROGS([SED], [sed])])] +) +ifdef( [AC_TYPE_INT8_T], , [
config-version.h.in new file +1 -0
@@ -0,0 +1 @@ +#define PACKAGE_VERSION_EXTRA_GIT_REVISION "@PACKAGE_VERSION_EXTRA_GIT_REVISION@"
configure.ac +12 -0
@@ -300,6 +300,7 @@ PKG_PROG_PKG_CONFIG AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S +AC_PROG_SED AC_PROG_MAKE_SET AC_ARG_VAR([IFCONFIG], [full path to ipconfig utility])
@@ -307,11 +308,13 @@ AC_ARG_VAR([ROUTE], [full path to route utility]) AC_ARG_VAR([IPROUTE], [full path to ip utility]) AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests AC_ARG_VAR([MAN2HTML], [path to man2html utility]) +AC_ARG_VAR([GIT], [path to git utility]) AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests AC_CHECK_PROGS([MAN2HTML], [man2html]) +AC_CHECK_PROGS([GIT], [git]) # optional AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool]) AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool]) AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
@@ -781,6 +784,14 @@ PKG_CHECK_MODULES( [] ) +AC_MSG_CHECKING([git checkout]) +GIT_CHECKOUT="no" +if test -n "${GIT}" -a -d "${srcdir}/.git"; then + AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h]) + GIT_CHECKOUT="yes" +fi +AC_MSG_RESULT([${GIT_CHECKOUT}]) + if test -n "${SP_PLATFORM_WINDOWS}"; then AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #" AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
@@ -928,6 +939,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS]) AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS]) AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) +AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"]) sampledir="\$(docdir)/sample" AC_SUBST([sampledir])
src/openvpn/options.c +6 -0
@@ -35,6 +35,9 @@#elif defined(_MSC_VER)#include "config-msvc.h" #endif +#ifdef HAVE_CONFIG_VERSION_H +#include "config-version.h" +#endif #include "syshead.h"
@@ -3430,6 +3433,9 @@ usage_version (void)#ifdef CONFIGURE_DEFINES msg (M_INFO |M_NOPREFIX ,"Compile time defines: %s" ,CONFIGURE_DEFINES );#endif +#ifdef PACKAGE_VERSION_EXTRA_GIT_REVISION +msg (M_INFO |M_NOPREFIX ,"git revision: %s" ,PACKAGE_VERSION_EXTRA_GIT_REVISION ); +#endif #endif openvpn_exit (OPENVPN_EXIT_STATUS_USAGE );/* exit point */ }
Signature · 1 line
1.7.3.4
Quoted 11 lines · Alon Bar-Lev
If source is located at git repository, acquire branch and revision of head to be printed at --version output.
Signed-off-by Alon Bar-Lev <[email protected]...>---
.gitignore | 1 +
Makefile.am | 21 +++++++++++++++++++++ compat.m4 | 5 +++++ config-version.h.in | 1 + configure.ac | 12 ++++++++++++src/openvpn/options.c| 6 ++++++
Quoted 2 lines
6 files changed, 46 insertions(+), 0 deletions(-)create mode 100644 config-version.h.in
David,
This should be complete, even simpler than the original. Alon.
PATCH 1/2 build: add git revision to --version output if build from git repository
If source is located at git repository, acquire branch and revision of head to be printed at --version output.
--- .gitignore | 1 + Makefile.am | 21 +++++++++++++++++++++ compat.m4 | 5 +++++ config-version.h.in | 1 + configure.ac | 12 ++++++++++++ src/openvpn/options.c | 6 ++++++ 6 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 config-version.h.in
.gitignore +1 -0
@@ -49,3 +49,4 @@ doc/openvpn.8.html distro/rpm/openvpn.spec tests/t_client.sh src/openvpn/openvpn +config-version.h
Makefile.am +21 -0
@@ -40,10 +40,20 @@ MAINTAINERCLEANFILES = \ $(srcdir)/depcomp $(srcdir)/aclocal.m4 \ $(srcdir)/config.guess $(srcdir)/config.sub +CLEANFILES = \ + config-version.h + EXTRA_DIST = \ contrib \ debug +.PHONY: config-version.h + +if GIT_CHECKOUT +BUILT_SOURCES = \ + config-version.h +endif + SUBDIRS = build distro include src sample doc tests dist_doc_DATA = \
@@ -53,6 +63,7 @@ dist_doc_DATA = \ dist_noinst_DATA = \ .gitignore \ .gitattributes \ + config-version.h.in \ PORTS \ README.IPv6 TODO.IPv6 \ README.polarssl \
@@ -75,3 +86,13 @@ if WIN32 rootdir=$(prefix) root_DATA = version.sh endif + +config-version.h: + @CONFIGURE_GIT_REVISION="`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --symbolic-full-name HEAD`/`GIT_DIR=\"$(top_srcdir)/.git\" $(GIT) rev-parse --short=16 HEAD`"; \ + $(SED) "s#@CONFIGURE_GIT_REVISION[@]#$${CONFIGURE_GIT_REVISION}#g" "$(srcdir)/config-version.h.in" > config-version.h.tmp + @if ! [ -f config-version.h ] || ! cmp -s config-version.h.tmp config-version.h; then \ + echo "replacing config-version.h"; \ + mv config-version.h.tmp config-version.h; \ + else \ + rm -f config-version.h.tmp; \ + fi
compat.m4 +5 -0
@@ -43,6 +43,11 @@ ifdef( [AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], [GNU_SOURCE])] ) ifdef( + [AC_PROG_SED], + , + [AC_DEFUN([AC_PROG_SED], [AC_CHECK_PROGS([SED], [sed])])] +) +ifdef( [AC_TYPE_INT8_T], , [
config-version.h.in new file +1 -0
@@ -0,0 +1 @@ +#define CONFIGURE_GIT_REVISION "@CONFIGURE_GIT_REVISION@"
configure.ac +12 -0
@@ -300,6 +300,7 @@ PKG_PROG_PKG_CONFIG AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S +AC_PROG_SED AC_PROG_MAKE_SET AC_ARG_VAR([IFCONFIG], [full path to ipconfig utility])
@@ -307,11 +308,13 @@ AC_ARG_VAR([ROUTE], [full path to route utility]) AC_ARG_VAR([IPROUTE], [full path to ip utility]) AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests AC_ARG_VAR([MAN2HTML], [path to man2html utility]) +AC_ARG_VAR([GIT], [path to git utility]) AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin]) AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests AC_CHECK_PROGS([MAN2HTML], [man2html]) +AC_CHECK_PROGS([GIT], [git]) # optional AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool]) AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool]) AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
@@ -781,6 +784,14 @@ PKG_CHECK_MODULES( [] ) +AC_MSG_CHECKING([git checkout]) +GIT_CHECKOUT="no" +if test -n "${GIT}" -a -d "${srcdir}/.git"; then + AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h]) + GIT_CHECKOUT="yes" +fi +AC_MSG_RESULT([${GIT_CHECKOUT}]) + if test -n "${SP_PLATFORM_WINDOWS}"; then AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #" AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
@@ -928,6 +939,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS]) AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS]) AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) +AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"]) sampledir="\$(docdir)/sample" AC_SUBST([sampledir])
src/openvpn/options.c +6 -0
@@ -35,6 +35,9 @@#elif defined(_MSC_VER)#include "config-msvc.h" #endif +#ifdef HAVE_CONFIG_VERSION_H +#include "config-version.h" +#endif #include "syshead.h"
@@ -3481,6 +3484,9 @@ usage_version (void)#ifdef CONFIGURE_DEFINES msg (M_INFO |M_NOPREFIX ,"Compile time defines: %s" ,CONFIGURE_DEFINES );#endif +#ifdef CONFIGURE_GIT_REVISION +msg (M_INFO |M_NOPREFIX ,"git revision: %s" ,CONFIGURE_GIT_REVISION ); +#endif #endif openvpn_exit (OPENVPN_EXIT_STATUS_USAGE );/* exit point */ }
Signature · 1 line
1.7.3.4
Quoted 4 lines · Alon Bar-Lev
If source is located at git repository, acquire branch and revision of head to be printed at --version output.
Signed-off-by Alon Bar-Lev <[email protected]...>
Exactly the same patch, just renamed the variable CONFIGURE_GIT_REVISION to be consistent with next patch and previous configure defs constant name.
Alon.
Quoted 4 lines · Alon Bar-Lev
If source is located at git repository, acquire branch and revision of head to be printed at --version output.
Signed-off-by Alon Bar-Lev <[email protected]...>
Quoted 9 lines
--- .gitignore | 1 + Makefile.am | 21 +++++++++++++++++++++ compat.m4 | 5 +++++ config-version.h.in | 1 + configure.ac | 12 ++++++++++++ src/openvpn/options.c | 6 ++++++ 6 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 config-version.h.in
ACK. Applied to master branch.
commit 7046ff20f93eca1d850df43fe716922e6d105c1c
Author: Alon Bar-Lev <[email protected]...> Date: Sat May 5 09:39:42 2012 +0300
build: add git revision to --version output if build from git repository
If source is located at git repository, acquire branch and revision
of head to be printed at --version output.
Signed-off-by: Alon Bar-Lev <[email protected]...>
Acked-by: David Sommerseth <[email protected]...>
Message-Id: [email protected]...
URL: http://article.gmane.org/gmane.network.openvpn.devel/6431
Signed-off-by: David Sommerseth <[email protected]...>kind regards,
David Sommerseth
PATCH 2/2 build: add --with-special-build to provide special build string
In reply to Alon Bar-LevSpecial build string is printed when --version is specified.
This is handy when building a snapshot or if not git repository.
--- configure.ac | 6 ++++++ src/openvpn/options.c | 3 +++ 2 files changed, 9 insertions(+), 0 deletions(-)
configure.ac +6 -0
@@ -229,6 +229,12 @@ AC_ARG_ENABLE( ) AC_ARG_WITH( + [special-build], + [AS_HELP_STRING([--with-special-build=STRING], [specify special build string])], + [AC_DEFINE_UNQUOTED([CONFIGURE_SPECIAL_BUILD], ["${withval}"], [special build string])] +) + +AC_ARG_WITH( [mem-check], [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|dmalloc|valgrind|ssl @<:@default=no@:>@])], [
src/openvpn/options.c +3 -0
@@ -3484,6 +3484,9 @@ usage_version (void)#ifdef CONFIGURE_DEFINES msg (M_INFO |M_NOPREFIX ,"Compile time defines: %s" ,CONFIGURE_DEFINES );#endif +#ifdef CONFIGURE_SPECIAL_BUILD +msg (M_INFO |M_NOPREFIX ,"special build: %s" ,CONFIGURE_SPECIAL_BUILD ); +#endif #ifdef CONFIGURE_GIT_REVISION msg (M_INFO |M_NOPREFIX ,"git revision: %s" ,CONFIGURE_GIT_REVISION );#endif
Signature · 1 line
1.7.3.4
PATCH 1/1 build: add --with-special-build to provide special build string
Special build string is printed when --version is specified.
Empty = no special build.
This is handy when building a snapshot or if not git repository.
--- configure.ac | 6 ++++++ src/openvpn/options.c | 3 +++ 2 files changed, 9 insertions(+), 0 deletions(-)
configure.ac +6 -0
@@ -229,6 +229,12 @@ AC_ARG_ENABLE( ) AC_ARG_WITH( + [special-build], + [AS_HELP_STRING([--with-special-build=STRING], [specify special build string])], + [test -n "${withval}" && AC_DEFINE_UNQUOTED([CONFIGURE_SPECIAL_BUILD], ["${withval}"], [special build string])] +) + +AC_ARG_WITH( [mem-check], [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|dmalloc|valgrind|ssl @<:@default=no@:>@])], [
src/openvpn/options.c +3 -0
@@ -3484,6 +3484,9 @@ usage_version (void)#ifdef CONFIGURE_DEFINES msg (M_INFO |M_NOPREFIX ,"Compile time defines: %s" ,CONFIGURE_DEFINES );#endif +#ifdef CONFIGURE_SPECIAL_BUILD +msg (M_INFO |M_NOPREFIX ,"special build: %s" ,CONFIGURE_SPECIAL_BUILD ); +#endif #ifdef CONFIGURE_GIT_REVISION msg (M_INFO |M_NOPREFIX ,"git revision: %s" ,CONFIGURE_GIT_REVISION );#endif
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH] build: add --with-special-build to provide special build string
Quoted 4 lines · Alon Bar-Lev
Special build string is printed when --version is specified.
Empty = no special build.
Quoted 8 lines
This is handy when building a snapshot or if not git repository.
Signed-off-by Alon Bar-Lev <[email protected]...>--- configure.ac | 6 ++++++ src/openvpn/options.c | 3 +++ 2 files changed, 9 insertions(+), 0 deletions(-)
ACK. Applied to master.
commit 10b4b65e0318ce305e05cdec4b44b8f6bcd3915f
Author: Alon Bar-Lev <[email protected]...> Date: Sat May 5 11:01:17 2012 +0300
build: add --with-special-build to provide special build string
Special build string is printed when --version is specified.
Empty = no special build.
This is handy when building a snapshot or if not git repository.
Message-Id: [email protected]...
URL: http://article.gmane.org/gmane.network.openvpn.devel/6435
kind regards,
David Sommerseth