* [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] <51421C12.5050907@gmail.com>
@ 2013-03-15 18:40 ` Raphaël Beamonte
[not found] ` <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com>
1 sibling, 0 replies; 9+ messages in thread
From: Raphaël Beamonte @ 2013-03-15 18:40 UTC (permalink / raw)
To: dgoulet; +Cc: Raphaël Beamonte, lttng-dev
Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
.gitignore | 2 ++
include/Makefile.am | 26 +++++++++++++++++++++++++-
include/version.h.tmpl | 27 +++++++++++++++++++++++++++
src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++++++
src/bin/lttng-sessiond/main.c | 2 +-
src/bin/lttng/commands/version.c | 4 +++-
src/bin/lttng/lttng.c | 5 ++++-
src/bin/lttng/utils.h | 13 +++++++++++++
8 files changed, 89 insertions(+), 4 deletions(-)
create mode 100644 include/version.h.tmpl
diff --git a/.gitignore b/.gitignore
index ac72bf4..a36f0b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,8 @@ config/
!config/epoll.m4
!config/config_feature.m4
+include/version.h
+
src/bin/lttng-sessiond/lttng-sessiond
src/bin/lttng/lttng
src/bin/lttng-consumerd/lttng-consumerd
diff --git a/include/Makefile.am b/include/Makefile.am
index 0bcb6f9..b46c1e2 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1 +1,25 @@
-lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h
+version.h: version.h.tmpl
+ (git_version="$$(git describe --long --all 2>/dev/null)"; \
+ version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \
+ version_h="$(top_builddir)/include/version.h"; \
+ if [ ! -e "$${version_h}" ] || \
+ [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \
+ cp "$${version_h_tmpl}" "$${version_h}"; \
+ fi; \
+ if [ -z "$${git_version}" ]; then \
+ if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
+ sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \
+ fi; \
+ else \
+ if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
+ if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
+ sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+ else \
+ sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+ fi; \
+ fi; \
+ fi)
+
+.PHONY: version.h
+
+lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h
diff --git a/include/version.h.tmpl b/include/version.h.tmpl
new file mode 100644
index 0000000..c42789c
--- /dev/null
+++ b/include/version.h.tmpl
@@ -0,0 +1,27 @@
+/*
+ * version.h
+ *
+ * Linux Trace Toolkit version header file
+ *
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#define GIT_VERSION
+
+#endif /* VERSION_H */
diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h
index 9258f38..e91918a 100644
--- a/src/bin/lttng-sessiond/lttng-sessiond.h
+++ b/src/bin/lttng-sessiond/lttng-sessiond.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
@@ -28,6 +29,8 @@
#include "session.h"
#include "ust-app.h"
+#include "version.h"
+
extern const char default_home_dir[],
default_tracing_group[],
@@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2];
int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
+/*
+ * This static const char allows to return the version number depending
+ * whether or not the GIT_VERSION value is available
+ */
+#ifdef GIT_VERSION
+static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")";
+#else /* GIT_VERSION */
+static const char lttng_sessiond_version[] = VERSION;
+#endif /* GIT_VERSION */
+
+
#endif /* _LTT_SESSIOND_H */
diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index f7bb53e..857a20d 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -3547,7 +3547,7 @@ static int parse_args(int argc, char **argv)
usage();
exit(EXIT_FAILURE);
case 'V':
- fprintf(stdout, "%s\n", VERSION);
+ fprintf(stdout, "%s\n", lttng_sessiond_version);
exit(EXIT_SUCCESS);
case 'S':
opt_sig_parent = 1;
diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c
index 7f69de3..2170d00 100644
--- a/src/bin/lttng/commands/version.c
+++ b/src/bin/lttng/commands/version.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "../command.h"
+#include "../utils.h"
enum {
OPT_HELP = 1,
@@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv)
}
MSG("lttng version " VERSION " - " VERSION_NAME);
- MSG("\n" VERSION_DESCRIPTION "\n");
+ MSG("%s", lttng_version);
+ MSG(VERSION_DESCRIPTION "\n");
MSG("Web site: http://lttng.org");
MSG("\nlttng is free software and under the GPL license and part LGPL");
diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
index 8562144..002bf4e 100644
--- a/src/bin/lttng/lttng.c
+++ b/src/bin/lttng/lttng.c
@@ -31,6 +31,7 @@
#include <common/error.h>
#include "command.h"
+#include "utils.h"
/* Variables */
static char *progname;
@@ -81,7 +82,9 @@ static struct cmd_struct commands[] = {
static void usage(FILE *ofp)
{
- fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n");
+ fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n");
+ fprintf(ofp, lttng_version);
+ fprintf(ofp, "\n");
fprintf(ofp, "usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n");
fprintf(ofp, "\n");
fprintf(ofp, "Options:\n");
diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h
index 9f7bfcc..12ee7c0 100644
--- a/src/bin/lttng/utils.h
+++ b/src/bin/lttng/utils.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
@@ -19,8 +20,20 @@
#define _LTTNG_UTILS_H
#include <popt.h>
+#include <version.h>
char *get_session_name(void);
void list_cmd_options(FILE *ofp, struct poptOption *options);
+/*
+ * This static const char allows to return the version number depending
+ * whether or not the GIT_VERSION value is available
+ */
+#ifdef GIT_VERSION
+static const char lttng_version[] = "Git version: " GIT_VERSION "\n";
+#else /* GIT_VERSION */
+static const char lttng_version[] = "";
+#endif /* GIT_VERSION */
+
+
#endif /* _LTTNG_UTILS_H */
--
1.7.10.4
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] ` <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com>
@ 2013-03-15 18:44 ` Raphaël Beamonte
2013-03-16 23:49 ` Raphaël Beamonte
[not found] ` <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com>
2 siblings, 0 replies; 9+ messages in thread
From: Raphaël Beamonte @ 2013-03-15 18:44 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
[-- Attachment #1.1: Type: text/plain, Size: 960 bytes --]
On 2013-03-15 14:40, Raphaël Beamonte wrote:
> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
> ---
> .gitignore | 2 ++
> include/Makefile.am | 26 +++++++++++++++++++++++++-
> include/version.h.tmpl | 27 +++++++++++++++++++++++++++
> src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++++++
> src/bin/lttng-sessiond/main.c | 2 +-
> src/bin/lttng/commands/version.c | 4 +++-
> src/bin/lttng/lttng.c | 5 ++++-
> src/bin/lttng/utils.h | 13 +++++++++++++
> 8 files changed, 89 insertions(+), 4 deletions(-)
> create mode 100644 include/version.h.tmpl
This new version of the patch should answer to your last comments. Feel
free to give new comments and critics !
I just wasn't able to check the "make dist" as it seems broken in the
last commit of lttng-tools.
Raphaël
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 155 bytes --]
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] ` <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com>
2013-03-15 18:44 ` Raphaël Beamonte
@ 2013-03-16 23:49 ` Raphaël Beamonte
[not found] ` <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com>
2 siblings, 0 replies; 9+ messages in thread
From: Raphaël Beamonte @ 2013-03-16 23:49 UTC (permalink / raw)
To: dgoulet; +Cc: Raphaël Beamonte, lttng-dev
Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
.gitignore | 2 ++
include/Makefile.am | 45 ++++++++++++++++++++++++++++++-
include/version.h.tmpl | 27 +++++++++++++++++++
src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++
src/bin/lttng-sessiond/main.c | 2 +-
src/bin/lttng/commands/version.c | 4 ++-
src/bin/lttng/lttng.c | 5 +++-
src/bin/lttng/utils.h | 13 +++++++++
8 files changed, 108 insertions(+), 4 deletions(-)
create mode 100644 include/version.h.tmpl
diff --git a/.gitignore b/.gitignore
index ac72bf4..a36f0b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,8 @@ config/
!config/epoll.m4
!config/config_feature.m4
+include/version.h
+
src/bin/lttng-sessiond/lttng-sessiond
src/bin/lttng/lttng
src/bin/lttng-consumerd/lttng-consumerd
diff --git a/include/Makefile.am b/include/Makefile.am
index 0bcb6f9..fce6276 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1 +1,44 @@
-lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h
+## The version.h file must be verified and generated or updated if the
+## git commit id (called git version here) changed since the last build
+## of lttng-tools.
+version.h: version.h.tmpl
+ ## We first create variables for the current git version and
+ ## the locations of the version.h and version.h.tmpl files
+ (git_version="$$(git describe --long --all 2>/dev/null)"; \
+ version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \
+ version_h="$(top_builddir)/include/version.h"; \
+ ## If the version.h file doesn't exist or is not up to date,
+ ## We replace it by the version.h.tmpl file
+ if [ ! -e "$${version_h}" ] || \
+ [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \
+ cp "$${version_h_tmpl}" "$${version_h}"; \
+ fi; \
+ if [ -z "$${git_version}" ]; then \
+ ## If we don't have a git version, we verify that there is
+ ## not any define of GIT_VERSION in the version.h file, or
+ ## we remove it.
+ if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
+ sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \
+ fi; \
+ else \
+ ## If we have a git version, we verify that it isn't the same
+ ## as the one currently in the file (if there is one), as we
+ ## don't want to update the file if it is already up to date
+ if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
+ if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
+ ## If there is already a GIT_VERSION defined,
+ ## we just replace it by the new version
+ sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+ else \
+ ## Else, we add a GIT_VERSION define
+ ## containing our new version.
+ sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+ fi; \
+ fi; \
+ fi)
+
+## version.h is defined as a .PHONY file even if it's a real file as
+## we want our routine to be runned for each build.
+.PHONY: version.h
+
+lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h
diff --git a/include/version.h.tmpl b/include/version.h.tmpl
new file mode 100644
index 0000000..c42789c
--- /dev/null
+++ b/include/version.h.tmpl
@@ -0,0 +1,27 @@
+/*
+ * version.h
+ *
+ * Linux Trace Toolkit version header file
+ *
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#define GIT_VERSION
+
+#endif /* VERSION_H */
diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h
index 9258f38..e91918a 100644
--- a/src/bin/lttng-sessiond/lttng-sessiond.h
+++ b/src/bin/lttng-sessiond/lttng-sessiond.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
@@ -28,6 +29,8 @@
#include "session.h"
#include "ust-app.h"
+#include "version.h"
+
extern const char default_home_dir[],
default_tracing_group[],
@@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2];
int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
+/*
+ * This static const char allows to return the version number depending
+ * whether or not the GIT_VERSION value is available
+ */
+#ifdef GIT_VERSION
+static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")";
+#else /* GIT_VERSION */
+static const char lttng_sessiond_version[] = VERSION;
+#endif /* GIT_VERSION */
+
+
#endif /* _LTT_SESSIOND_H */
diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index f7bb53e..857a20d 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -3547,7 +3547,7 @@ static int parse_args(int argc, char **argv)
usage();
exit(EXIT_FAILURE);
case 'V':
- fprintf(stdout, "%s\n", VERSION);
+ fprintf(stdout, "%s\n", lttng_sessiond_version);
exit(EXIT_SUCCESS);
case 'S':
opt_sig_parent = 1;
diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c
index 7f69de3..2170d00 100644
--- a/src/bin/lttng/commands/version.c
+++ b/src/bin/lttng/commands/version.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "../command.h"
+#include "../utils.h"
enum {
OPT_HELP = 1,
@@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv)
}
MSG("lttng version " VERSION " - " VERSION_NAME);
- MSG("\n" VERSION_DESCRIPTION "\n");
+ MSG("%s", lttng_version);
+ MSG(VERSION_DESCRIPTION "\n");
MSG("Web site: http://lttng.org");
MSG("\nlttng is free software and under the GPL license and part LGPL");
diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
index 8562144..002bf4e 100644
--- a/src/bin/lttng/lttng.c
+++ b/src/bin/lttng/lttng.c
@@ -31,6 +31,7 @@
#include <common/error.h>
#include "command.h"
+#include "utils.h"
/* Variables */
static char *progname;
@@ -81,7 +82,9 @@ static struct cmd_struct commands[] = {
static void usage(FILE *ofp)
{
- fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n");
+ fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n");
+ fprintf(ofp, lttng_version);
+ fprintf(ofp, "\n");
fprintf(ofp, "usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n");
fprintf(ofp, "\n");
fprintf(ofp, "Options:\n");
diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h
index 9f7bfcc..12ee7c0 100644
--- a/src/bin/lttng/utils.h
+++ b/src/bin/lttng/utils.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
@@ -19,8 +20,20 @@
#define _LTTNG_UTILS_H
#include <popt.h>
+#include <version.h>
char *get_session_name(void);
void list_cmd_options(FILE *ofp, struct poptOption *options);
+/*
+ * This static const char allows to return the version number depending
+ * whether or not the GIT_VERSION value is available
+ */
+#ifdef GIT_VERSION
+static const char lttng_version[] = "Git version: " GIT_VERSION "\n";
+#else /* GIT_VERSION */
+static const char lttng_version[] = "";
+#endif /* GIT_VERSION */
+
+
#endif /* _LTTNG_UTILS_H */
--
1.7.10.4
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] ` <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com>
@ 2013-03-16 23:55 ` Raphaël Beamonte
2013-03-21 17:35 ` David Goulet
1 sibling, 0 replies; 9+ messages in thread
From: Raphaël Beamonte @ 2013-03-16 23:55 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
[-- Attachment #1.1: Type: text/plain, Size: 842 bytes --]
On 2013-03-16 19:49, Raphaël Beamonte wrote:
> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
> ---
> .gitignore | 2 ++
> include/Makefile.am | 45 ++++++++++++++++++++++++++++++-
> include/version.h.tmpl | 27 +++++++++++++++++++
> src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++
> src/bin/lttng-sessiond/main.c | 2 +-
> src/bin/lttng/commands/version.c | 4 ++-
> src/bin/lttng/lttng.c | 5 +++-
> src/bin/lttng/utils.h | 13 +++++++++
> 8 files changed, 108 insertions(+), 4 deletions(-)
> create mode 100644 include/version.h.tmpl
This new version of the patch adds comments in the Makefile.am to help
to understand the work of the shell routine.
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 155 bytes --]
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] ` <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com>
2013-03-16 23:55 ` Raphaël Beamonte
@ 2013-03-21 17:35 ` David Goulet
1 sibling, 0 replies; 9+ messages in thread
From: David Goulet @ 2013-03-21 17:35 UTC (permalink / raw)
To: Raphaël Beamonte; +Cc: lttng-dev
This does not compile event after a clean and bootstrap.
make[3]: Entering directory
`/home/dgoulet/Documents/git/lttng-tools/src/bin/lttng'
CC conf.o
CC start.o
In file included from commands/../command.h:26:0,
from commands/start.c:27:
commands/../utils.h:23:21: fatal error: version.h: No such file or directory
compilation terminated.
David
Raphaël Beamonte:
> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
> ---
> .gitignore | 2 ++
> include/Makefile.am | 45 ++++++++++++++++++++++++++++++-
> include/version.h.tmpl | 27 +++++++++++++++++++
> src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++
> src/bin/lttng-sessiond/main.c | 2 +-
> src/bin/lttng/commands/version.c | 4 ++-
> src/bin/lttng/lttng.c | 5 +++-
> src/bin/lttng/utils.h | 13 +++++++++
> 8 files changed, 108 insertions(+), 4 deletions(-)
> create mode 100644 include/version.h.tmpl
>
> diff --git a/.gitignore b/.gitignore
> index ac72bf4..a36f0b9 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -31,6 +31,8 @@ config/
> !config/epoll.m4
> !config/config_feature.m4
>
> +include/version.h
> +
> src/bin/lttng-sessiond/lttng-sessiond
> src/bin/lttng/lttng
> src/bin/lttng-consumerd/lttng-consumerd
> diff --git a/include/Makefile.am b/include/Makefile.am
> index 0bcb6f9..fce6276 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -1 +1,44 @@
> -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h
> +## The version.h file must be verified and generated or updated if the
> +## git commit id (called git version here) changed since the last build
> +## of lttng-tools.
> +version.h: version.h.tmpl
> + ## We first create variables for the current git version and
> + ## the locations of the version.h and version.h.tmpl files
> + (git_version="$$(git describe --long --all 2>/dev/null)"; \
> + version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \
> + version_h="$(top_builddir)/include/version.h"; \
> + ## If the version.h file doesn't exist or is not up to date,
> + ## We replace it by the version.h.tmpl file
> + if [ ! -e "$${version_h}" ] || \
> + [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \
> + cp "$${version_h_tmpl}" "$${version_h}"; \
> + fi; \
> + if [ -z "$${git_version}" ]; then \
> + ## If we don't have a git version, we verify that there is
> + ## not any define of GIT_VERSION in the version.h file, or
> + ## we remove it.
> + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
> + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \
> + fi; \
> + else \
> + ## If we have a git version, we verify that it isn't the same
> + ## as the one currently in the file (if there is one), as we
> + ## don't want to update the file if it is already up to date
> + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
> + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
> + ## If there is already a GIT_VERSION defined,
> + ## we just replace it by the new version
> + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
> + else \
> + ## Else, we add a GIT_VERSION define
> + ## containing our new version.
> + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
> + fi; \
> + fi; \
> + fi)
> +
> +## version.h is defined as a .PHONY file even if it's a real file as
> +## we want our routine to be runned for each build.
> +.PHONY: version.h
> +
> +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h
> diff --git a/include/version.h.tmpl b/include/version.h.tmpl
> new file mode 100644
> index 0000000..c42789c
> --- /dev/null
> +++ b/include/version.h.tmpl
> @@ -0,0 +1,27 @@
> +/*
> + * version.h
> + *
> + * Linux Trace Toolkit version header file
> + *
> + * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
> + *
> + * This library is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License, version 2.1 only,
> + * as published by the Free Software Foundation.
> + *
> + * This library is distributed in the hope that it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
> + * for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with this library; if not, write to the Free Software Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef VERSION_H
> +#define VERSION_H
> +
> +#define GIT_VERSION
> +
> +#endif /* VERSION_H */
> diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h
> index 9258f38..e91918a 100644
> --- a/src/bin/lttng-sessiond/lttng-sessiond.h
> +++ b/src/bin/lttng-sessiond/lttng-sessiond.h
> @@ -1,5 +1,6 @@
> /*
> * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
> + * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License, version 2 only,
> @@ -28,6 +29,8 @@
>
> #include "session.h"
> #include "ust-app.h"
> +#include "version.h"
> +
>
> extern const char default_home_dir[],
> default_tracing_group[],
> @@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2];
> int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
> int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
>
> +/*
> + * This static const char allows to return the version number depending
> + * whether or not the GIT_VERSION value is available
> + */
> +#ifdef GIT_VERSION
> +static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")";
> +#else /* GIT_VERSION */
> +static const char lttng_sessiond_version[] = VERSION;
> +#endif /* GIT_VERSION */
> +
> +
> #endif /* _LTT_SESSIOND_H */
> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
> index f7bb53e..857a20d 100644
> --- a/src/bin/lttng-sessiond/main.c
> +++ b/src/bin/lttng-sessiond/main.c
> @@ -3547,7 +3547,7 @@ static int parse_args(int argc, char **argv)
> usage();
> exit(EXIT_FAILURE);
> case 'V':
> - fprintf(stdout, "%s\n", VERSION);
> + fprintf(stdout, "%s\n", lttng_sessiond_version);
> exit(EXIT_SUCCESS);
> case 'S':
> opt_sig_parent = 1;
> diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c
> index 7f69de3..2170d00 100644
> --- a/src/bin/lttng/commands/version.c
> +++ b/src/bin/lttng/commands/version.c
> @@ -26,6 +26,7 @@
> #include <config.h>
>
> #include "../command.h"
> +#include "../utils.h"
>
> enum {
> OPT_HELP = 1,
> @@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv)
> }
>
> MSG("lttng version " VERSION " - " VERSION_NAME);
> - MSG("\n" VERSION_DESCRIPTION "\n");
> + MSG("%s", lttng_version);
> + MSG(VERSION_DESCRIPTION "\n");
> MSG("Web site: http://lttng.org");
> MSG("\nlttng is free software and under the GPL license and part LGPL");
>
> diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
> index 8562144..002bf4e 100644
> --- a/src/bin/lttng/lttng.c
> +++ b/src/bin/lttng/lttng.c
> @@ -31,6 +31,7 @@
> #include <common/error.h>
>
> #include "command.h"
> +#include "utils.h"
>
> /* Variables */
> static char *progname;
> @@ -81,7 +82,9 @@ static struct cmd_struct commands[] = {
>
> static void usage(FILE *ofp)
> {
> - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n");
> + fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n");
> + fprintf(ofp, lttng_version);
> + fprintf(ofp, "\n");
> fprintf(ofp, "usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n");
> fprintf(ofp, "\n");
> fprintf(ofp, "Options:\n");
> diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h
> index 9f7bfcc..12ee7c0 100644
> --- a/src/bin/lttng/utils.h
> +++ b/src/bin/lttng/utils.h
> @@ -1,5 +1,6 @@
> /*
> * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
> + * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License, version 2 only,
> @@ -19,8 +20,20 @@
> #define _LTTNG_UTILS_H
>
> #include <popt.h>
> +#include <version.h>
>
> char *get_session_name(void);
> void list_cmd_options(FILE *ofp, struct poptOption *options);
>
> +/*
> + * This static const char allows to return the version number depending
> + * whether or not the GIT_VERSION value is available
> + */
> +#ifdef GIT_VERSION
> +static const char lttng_version[] = "Git version: " GIT_VERSION "\n";
> +#else /* GIT_VERSION */
> +static const char lttng_version[] = "";
> +#endif /* GIT_VERSION */
> +
> +
> #endif /* _LTTNG_UTILS_H */
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] ` <0ab8866c5deb744279d9150823d24203a51851b1.1364226619.git.raphael.beamonte@gmail.com>
@ 2013-03-25 15:55 ` Raphaël Beamonte
0 siblings, 0 replies; 9+ messages in thread
From: Raphaël Beamonte @ 2013-03-25 15:55 UTC (permalink / raw)
To: dgoulet; +Cc: lttng-dev
[-- Attachment #1.1: Type: text/plain, Size: 643 bytes --]
On 2013-03-25 10:30, David Goulet wrote:> Hi,
>
> Two things. First, the version.h.tmpl has to be added to EXTRA_DIST in
> include/Makefile.am
Done. And changed the "version.h" to "nodist_*_headers".
> Second thing, on line 86 of lttng.c, *never* *never* *never* pass a
> variable to printf without a format.
>
> fprintf(ofp, lttng_version);
>
> This is a huge vector attack to format strings. Furthermore, outside of
> the git tree, there is a warning:
>
> lttng.c:86:2: warning: zero-length gnu_printf format string
> [-Wformat-zero-length]
My mistake, forgot to correct that... It's ok in the new patch.
Raphaël
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 155 bytes --]
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] <51505F7A.7060108@efficios.com>
@ 2013-03-25 15:50 ` Raphaël Beamonte
[not found] ` <0ab8866c5deb744279d9150823d24203a51851b1.1364226619.git.raphael.beamonte@gmail.com>
1 sibling, 0 replies; 9+ messages in thread
From: Raphaël Beamonte @ 2013-03-25 15:50 UTC (permalink / raw)
To: dgoulet; +Cc: Raphaël Beamonte, lttng-dev
Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
.gitignore | 2 ++
Makefile.am | 4 +--
include/Makefile.am | 46 +++++++++++++++++++++++++++++++
include/version.h.tmpl | 27 ++++++++++++++++++
src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++
src/bin/lttng-sessiond/main.c | 2 +-
src/bin/lttng/commands/version.c | 4 ++-
src/bin/lttng/lttng.c | 5 +++-
src/bin/lttng/utils.h | 13 +++++++++
9 files changed, 112 insertions(+), 5 deletions(-)
create mode 100644 include/version.h.tmpl
diff --git a/.gitignore b/.gitignore
index ee58252..0385627 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,8 @@ config/
!config/epoll.m4
!config/config_feature.m4
+include/version.h
+
src/bin/lttng-sessiond/lttng-sessiond
src/bin/lttng/lttng
src/bin/lttng-consumerd/lttng-consumerd
diff --git a/Makefile.am b/Makefile.am
index b0537ce..03fdabc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,9 @@
ACLOCAL_AMFLAGS = -I config
-SUBDIRS = src \
+SUBDIRS = include \
+ src \
tests \
extras \
- include \
doc
dist_doc_DATA = LICENSE \
diff --git a/include/Makefile.am b/include/Makefile.am
index 0bcb6f9..850950f 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1 +1,47 @@
+## The version.h file must be verified and generated or updated if the
+## git commit id (called git version here) changed since the last build
+## of lttng-tools.
+version.h: version.h.tmpl
+ ## We first create variables for the current git version and
+ ## the locations of the version.h and version.h.tmpl files
+ (git_version="$$(git describe --long --all 2>/dev/null)"; \
+ version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \
+ version_h="$(top_builddir)/include/version.h"; \
+ ## If the version.h file doesn't exist or is not up to date,
+ ## We replace it by the version.h.tmpl file
+ if [ ! -e "$${version_h}" ] || \
+ [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \
+ cp "$${version_h_tmpl}" "$${version_h}"; \
+ fi; \
+ if [ -z "$${git_version}" ]; then \
+ ## If we don't have a git version, we verify that there is
+ ## not any define of GIT_VERSION in the version.h file, or
+ ## we remove it.
+ if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
+ sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \
+ fi; \
+ else \
+ ## If we have a git version, we verify that it isn't the same
+ ## as the one currently in the file (if there is one), as we
+ ## don't want to update the file if it is already up to date
+ if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
+ if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
+ ## If there is already a GIT_VERSION defined,
+ ## we just replace it by the new version
+ sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+ else \
+ ## Else, we add a GIT_VERSION define
+ ## containing our new version.
+ sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+ fi; \
+ fi; \
+ fi)
+
+## version.h is defined as a .PHONY file even if it's a real file as
+## we want our routine to be runned for each build.
+.PHONY: version.h
+
lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h
+nodist_lttnginclude_HEADERS = version.h
+
+EXTRA_DIST = version.h.tmpl
diff --git a/include/version.h.tmpl b/include/version.h.tmpl
new file mode 100644
index 0000000..c42789c
--- /dev/null
+++ b/include/version.h.tmpl
@@ -0,0 +1,27 @@
+/*
+ * version.h
+ *
+ * Linux Trace Toolkit version header file
+ *
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#define GIT_VERSION
+
+#endif /* VERSION_H */
diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h
index 9258f38..e91918a 100644
--- a/src/bin/lttng-sessiond/lttng-sessiond.h
+++ b/src/bin/lttng-sessiond/lttng-sessiond.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
@@ -28,6 +29,8 @@
#include "session.h"
#include "ust-app.h"
+#include "version.h"
+
extern const char default_home_dir[],
default_tracing_group[],
@@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2];
int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
+/*
+ * This static const char allows to return the version number depending
+ * whether or not the GIT_VERSION value is available
+ */
+#ifdef GIT_VERSION
+static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")";
+#else /* GIT_VERSION */
+static const char lttng_sessiond_version[] = VERSION;
+#endif /* GIT_VERSION */
+
+
#endif /* _LTT_SESSIOND_H */
diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index d88bafe..41701e9 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -3555,7 +3555,7 @@ static int parse_args(int argc, char **argv)
usage();
exit(EXIT_FAILURE);
case 'V':
- fprintf(stdout, "%s\n", VERSION);
+ fprintf(stdout, "%s\n", lttng_sessiond_version);
exit(EXIT_SUCCESS);
case 'S':
opt_sig_parent = 1;
diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c
index 7f69de3..2170d00 100644
--- a/src/bin/lttng/commands/version.c
+++ b/src/bin/lttng/commands/version.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "../command.h"
+#include "../utils.h"
enum {
OPT_HELP = 1,
@@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv)
}
MSG("lttng version " VERSION " - " VERSION_NAME);
- MSG("\n" VERSION_DESCRIPTION "\n");
+ MSG("%s", lttng_version);
+ MSG(VERSION_DESCRIPTION "\n");
MSG("Web site: http://lttng.org");
MSG("\nlttng is free software and under the GPL license and part LGPL");
diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
index d3aaa84..c8a9c71 100644
--- a/src/bin/lttng/lttng.c
+++ b/src/bin/lttng/lttng.c
@@ -31,6 +31,7 @@
#include <common/error.h>
#include "command.h"
+#include "utils.h"
/* Variables */
static char *progname;
@@ -81,7 +82,9 @@ static struct cmd_struct commands[] = {
static void usage(FILE *ofp)
{
- fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n");
+ fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n");
+ fprintf(ofp, "%s", lttng_version);
+ fprintf(ofp, "\n");
fprintf(ofp, "usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n");
fprintf(ofp, "\n");
fprintf(ofp, "Options:\n");
diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h
index 9f7bfcc..12ee7c0 100644
--- a/src/bin/lttng/utils.h
+++ b/src/bin/lttng/utils.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
@@ -19,8 +20,20 @@
#define _LTTNG_UTILS_H
#include <popt.h>
+#include <version.h>
char *get_session_name(void);
void list_cmd_options(FILE *ofp, struct poptOption *options);
+/*
+ * This static const char allows to return the version number depending
+ * whether or not the GIT_VERSION value is available
+ */
+#ifdef GIT_VERSION
+static const char lttng_version[] = "Git version: " GIT_VERSION "\n";
+#else /* GIT_VERSION */
+static const char lttng_version[] = "";
+#endif /* GIT_VERSION */
+
+
#endif /* _LTTNG_UTILS_H */
--
1.7.10.4
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] ` <2423f47f2d19009bcfe5af3cbe0c3350deb68fdf.1363903997.git.raphael.beamonte@gmail.com>
@ 2013-03-25 14:30 ` David Goulet
0 siblings, 0 replies; 9+ messages in thread
From: David Goulet @ 2013-03-25 14:30 UTC (permalink / raw)
To: Raphaël Beamonte; +Cc: lttng-dev
Hi,
Two things. First, the version.h.tmpl has to be added to EXTRA_DIST in
include/Makefile.am
Second thing, on line 86 of lttng.c, *never* *never* *never* pass a
variable to printf without a format.
fprintf(ofp, lttng_version);
This is a huge vector attack to format strings. Furthermore, outside of
the git tree, there is a warning:
lttng.c:86:2: warning: zero-length gnu_printf format string
[-Wformat-zero-length]
Thanks!
David
Raphaël Beamonte:
> Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
> ---
> .gitignore | 2 ++
> Makefile.am | 4 +--
> include/Makefile.am | 45 ++++++++++++++++++++++++++++++-
> include/version.h.tmpl | 27 +++++++++++++++++++
> src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++
> src/bin/lttng-sessiond/main.c | 2 +-
> src/bin/lttng/commands/version.c | 4 ++-
> src/bin/lttng/lttng.c | 5 +++-
> src/bin/lttng/utils.h | 13 +++++++++
> 9 files changed, 110 insertions(+), 6 deletions(-)
> create mode 100644 include/version.h.tmpl
>
> diff --git a/.gitignore b/.gitignore
> index ac72bf4..a36f0b9 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -31,6 +31,8 @@ config/
> !config/epoll.m4
> !config/config_feature.m4
>
> +include/version.h
> +
> src/bin/lttng-sessiond/lttng-sessiond
> src/bin/lttng/lttng
> src/bin/lttng-consumerd/lttng-consumerd
> diff --git a/Makefile.am b/Makefile.am
> index b0537ce..03fdabc 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -1,9 +1,9 @@
> ACLOCAL_AMFLAGS = -I config
>
> -SUBDIRS = src \
> +SUBDIRS = include \
> + src \
> tests \
> extras \
> - include \
> doc
>
> dist_doc_DATA = LICENSE \
> diff --git a/include/Makefile.am b/include/Makefile.am
> index 0bcb6f9..fce6276 100644
> --- a/include/Makefile.am
> +++ b/include/Makefile.am
> @@ -1 +1,44 @@
> -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h
> +## The version.h file must be verified and generated or updated if the
> +## git commit id (called git version here) changed since the last build
> +## of lttng-tools.
> +version.h: version.h.tmpl
> + ## We first create variables for the current git version and
> + ## the locations of the version.h and version.h.tmpl files
> + (git_version="$$(git describe --long --all 2>/dev/null)"; \
> + version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \
> + version_h="$(top_builddir)/include/version.h"; \
> + ## If the version.h file doesn't exist or is not up to date,
> + ## We replace it by the version.h.tmpl file
> + if [ ! -e "$${version_h}" ] || \
> + [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \
> + cp "$${version_h_tmpl}" "$${version_h}"; \
> + fi; \
> + if [ -z "$${git_version}" ]; then \
> + ## If we don't have a git version, we verify that there is
> + ## not any define of GIT_VERSION in the version.h file, or
> + ## we remove it.
> + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
> + sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \
> + fi; \
> + else \
> + ## If we have a git version, we verify that it isn't the same
> + ## as the one currently in the file (if there is one), as we
> + ## don't want to update the file if it is already up to date
> + if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
> + if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
> + ## If there is already a GIT_VERSION defined,
> + ## we just replace it by the new version
> + sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
> + else \
> + ## Else, we add a GIT_VERSION define
> + ## containing our new version.
> + sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
> + fi; \
> + fi; \
> + fi)
> +
> +## version.h is defined as a .PHONY file even if it's a real file as
> +## we want our routine to be runned for each build.
> +.PHONY: version.h
> +
> +lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h
> diff --git a/include/version.h.tmpl b/include/version.h.tmpl
> new file mode 100644
> index 0000000..c42789c
> --- /dev/null
> +++ b/include/version.h.tmpl
> @@ -0,0 +1,27 @@
> +/*
> + * version.h
> + *
> + * Linux Trace Toolkit version header file
> + *
> + * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
> + *
> + * This library is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Lesser General Public License, version 2.1 only,
> + * as published by the Free Software Foundation.
> + *
> + * This library is distributed in the hope that it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
> + * for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public License
> + * along with this library; if not, write to the Free Software Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef VERSION_H
> +#define VERSION_H
> +
> +#define GIT_VERSION
> +
> +#endif /* VERSION_H */
> diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h
> index 9258f38..e91918a 100644
> --- a/src/bin/lttng-sessiond/lttng-sessiond.h
> +++ b/src/bin/lttng-sessiond/lttng-sessiond.h
> @@ -1,5 +1,6 @@
> /*
> * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
> + * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License, version 2 only,
> @@ -28,6 +29,8 @@
>
> #include "session.h"
> #include "ust-app.h"
> +#include "version.h"
> +
>
> extern const char default_home_dir[],
> default_tracing_group[],
> @@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2];
> int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
> int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
>
> +/*
> + * This static const char allows to return the version number depending
> + * whether or not the GIT_VERSION value is available
> + */
> +#ifdef GIT_VERSION
> +static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")";
> +#else /* GIT_VERSION */
> +static const char lttng_sessiond_version[] = VERSION;
> +#endif /* GIT_VERSION */
> +
> +
> #endif /* _LTT_SESSIOND_H */
> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
> index d88bafe..41701e9 100644
> --- a/src/bin/lttng-sessiond/main.c
> +++ b/src/bin/lttng-sessiond/main.c
> @@ -3555,7 +3555,7 @@ static int parse_args(int argc, char **argv)
> usage();
> exit(EXIT_FAILURE);
> case 'V':
> - fprintf(stdout, "%s\n", VERSION);
> + fprintf(stdout, "%s\n", lttng_sessiond_version);
> exit(EXIT_SUCCESS);
> case 'S':
> opt_sig_parent = 1;
> diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c
> index 7f69de3..2170d00 100644
> --- a/src/bin/lttng/commands/version.c
> +++ b/src/bin/lttng/commands/version.c
> @@ -26,6 +26,7 @@
> #include <config.h>
>
> #include "../command.h"
> +#include "../utils.h"
>
> enum {
> OPT_HELP = 1,
> @@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv)
> }
>
> MSG("lttng version " VERSION " - " VERSION_NAME);
> - MSG("\n" VERSION_DESCRIPTION "\n");
> + MSG("%s", lttng_version);
> + MSG(VERSION_DESCRIPTION "\n");
> MSG("Web site: http://lttng.org");
> MSG("\nlttng is free software and under the GPL license and part LGPL");
>
> diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
> index d3aaa84..4289901 100644
> --- a/src/bin/lttng/lttng.c
> +++ b/src/bin/lttng/lttng.c
> @@ -31,6 +31,7 @@
> #include <common/error.h>
>
> #include "command.h"
> +#include "utils.h"
>
> /* Variables */
> static char *progname;
> @@ -81,7 +82,9 @@ static struct cmd_struct commands[] = {
>
> static void usage(FILE *ofp)
> {
> - fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n");
> + fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n");
> + fprintf(ofp, lttng_version);
> + fprintf(ofp, "\n");
> fprintf(ofp, "usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n");
> fprintf(ofp, "\n");
> fprintf(ofp, "Options:\n");
> diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h
> index 9f7bfcc..12ee7c0 100644
> --- a/src/bin/lttng/utils.h
> +++ b/src/bin/lttng/utils.h
> @@ -1,5 +1,6 @@
> /*
> * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
> + * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License, version 2 only,
> @@ -19,8 +20,20 @@
> #define _LTTNG_UTILS_H
>
> #include <popt.h>
> +#include <version.h>
>
> char *get_session_name(void);
> void list_cmd_options(FILE *ofp, struct poptOption *options);
>
> +/*
> + * This static const char allows to return the version number depending
> + * whether or not the GIT_VERSION value is available
> + */
> +#ifdef GIT_VERSION
> +static const char lttng_version[] = "Git version: " GIT_VERSION "\n";
> +#else /* GIT_VERSION */
> +static const char lttng_version[] = "";
> +#endif /* GIT_VERSION */
> +
> +
> #endif /* _LTTNG_UTILS_H */
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources
[not found] <514B44ED.3000702@efficios.com>
@ 2013-03-21 22:13 ` Raphaël Beamonte
[not found] ` <2423f47f2d19009bcfe5af3cbe0c3350deb68fdf.1363903997.git.raphael.beamonte@gmail.com>
1 sibling, 0 replies; 9+ messages in thread
From: Raphaël Beamonte @ 2013-03-21 22:13 UTC (permalink / raw)
To: dgoulet; +Cc: Raphaël Beamonte, lttng-dev
Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
---
.gitignore | 2 ++
Makefile.am | 4 +--
include/Makefile.am | 45 ++++++++++++++++++++++++++++++-
include/version.h.tmpl | 27 +++++++++++++++++++
src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++
src/bin/lttng-sessiond/main.c | 2 +-
src/bin/lttng/commands/version.c | 4 ++-
src/bin/lttng/lttng.c | 5 +++-
src/bin/lttng/utils.h | 13 +++++++++
9 files changed, 110 insertions(+), 6 deletions(-)
create mode 100644 include/version.h.tmpl
diff --git a/.gitignore b/.gitignore
index ac72bf4..a36f0b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,8 @@ config/
!config/epoll.m4
!config/config_feature.m4
+include/version.h
+
src/bin/lttng-sessiond/lttng-sessiond
src/bin/lttng/lttng
src/bin/lttng-consumerd/lttng-consumerd
diff --git a/Makefile.am b/Makefile.am
index b0537ce..03fdabc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,9 @@
ACLOCAL_AMFLAGS = -I config
-SUBDIRS = src \
+SUBDIRS = include \
+ src \
tests \
extras \
- include \
doc
dist_doc_DATA = LICENSE \
diff --git a/include/Makefile.am b/include/Makefile.am
index 0bcb6f9..fce6276 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1 +1,44 @@
-lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h
+## The version.h file must be verified and generated or updated if the
+## git commit id (called git version here) changed since the last build
+## of lttng-tools.
+version.h: version.h.tmpl
+ ## We first create variables for the current git version and
+ ## the locations of the version.h and version.h.tmpl files
+ (git_version="$$(git describe --long --all 2>/dev/null)"; \
+ version_h_tmpl="$(top_builddir)/include/version.h.tmpl"; \
+ version_h="$(top_builddir)/include/version.h"; \
+ ## If the version.h file doesn't exist or is not up to date,
+ ## We replace it by the version.h.tmpl file
+ if [ ! -e "$${version_h}" ] || \
+ [ "$${version_h_tmpl}" -nt "$${version_h}" ]; then \
+ cp "$${version_h_tmpl}" "$${version_h}"; \
+ fi; \
+ if [ -z "$${git_version}" ]; then \
+ ## If we don't have a git version, we verify that there is
+ ## not any define of GIT_VERSION in the version.h file, or
+ ## we remove it.
+ if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
+ sed -i "/^#define GIT_VERSION/d" "$${version_h}"; \
+ fi; \
+ else \
+ ## If we have a git version, we verify that it isn't the same
+ ## as the one currently in the file (if there is one), as we
+ ## don't want to update the file if it is already up to date
+ if [ $$(grep -cE "^#define GIT_VERSION \"?$${git_version}\"?$$" "$${version_h}") -eq 0 ]; then \
+ if [ $$(grep -c "^#define GIT_VERSION" "$${version_h}") -gt 0 ]; then \
+ ## If there is already a GIT_VERSION defined,
+ ## we just replace it by the new version
+ sed -i "s'^#define GIT_VERSION.*$$'#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+ else \
+ ## Else, we add a GIT_VERSION define
+ ## containing our new version.
+ sed -i "s'^\(#define VERSION_H.*\)$$'\1\n\n#define GIT_VERSION \"$${git_version}\"'" "$${version_h}"; \
+ fi; \
+ fi; \
+ fi)
+
+## version.h is defined as a .PHONY file even if it's a real file as
+## we want our routine to be runned for each build.
+.PHONY: version.h
+
+lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h version.h
diff --git a/include/version.h.tmpl b/include/version.h.tmpl
new file mode 100644
index 0000000..c42789c
--- /dev/null
+++ b/include/version.h.tmpl
@@ -0,0 +1,27 @@
+/*
+ * version.h
+ *
+ * Linux Trace Toolkit version header file
+ *
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License, version 2.1 only,
+ * as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef VERSION_H
+#define VERSION_H
+
+#define GIT_VERSION
+
+#endif /* VERSION_H */
diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h
index 9258f38..e91918a 100644
--- a/src/bin/lttng-sessiond/lttng-sessiond.h
+++ b/src/bin/lttng-sessiond/lttng-sessiond.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
@@ -28,6 +29,8 @@
#include "session.h"
#include "ust-app.h"
+#include "version.h"
+
extern const char default_home_dir[],
default_tracing_group[],
@@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2];
int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
+/*
+ * This static const char allows to return the version number depending
+ * whether or not the GIT_VERSION value is available
+ */
+#ifdef GIT_VERSION
+static const char lttng_sessiond_version[] = VERSION " (Git: " GIT_VERSION ")";
+#else /* GIT_VERSION */
+static const char lttng_sessiond_version[] = VERSION;
+#endif /* GIT_VERSION */
+
+
#endif /* _LTT_SESSIOND_H */
diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index d88bafe..41701e9 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -3555,7 +3555,7 @@ static int parse_args(int argc, char **argv)
usage();
exit(EXIT_FAILURE);
case 'V':
- fprintf(stdout, "%s\n", VERSION);
+ fprintf(stdout, "%s\n", lttng_sessiond_version);
exit(EXIT_SUCCESS);
case 'S':
opt_sig_parent = 1;
diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c
index 7f69de3..2170d00 100644
--- a/src/bin/lttng/commands/version.c
+++ b/src/bin/lttng/commands/version.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "../command.h"
+#include "../utils.h"
enum {
OPT_HELP = 1,
@@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv)
}
MSG("lttng version " VERSION " - " VERSION_NAME);
- MSG("\n" VERSION_DESCRIPTION "\n");
+ MSG("%s", lttng_version);
+ MSG(VERSION_DESCRIPTION "\n");
MSG("Web site: http://lttng.org");
MSG("\nlttng is free software and under the GPL license and part LGPL");
diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c
index d3aaa84..4289901 100644
--- a/src/bin/lttng/lttng.c
+++ b/src/bin/lttng/lttng.c
@@ -31,6 +31,7 @@
#include <common/error.h>
#include "command.h"
+#include "utils.h"
/* Variables */
static char *progname;
@@ -81,7 +82,9 @@ static struct cmd_struct commands[] = {
static void usage(FILE *ofp)
{
- fprintf(ofp, "LTTng Trace Control " VERSION" - " VERSION_NAME"\n\n");
+ fprintf(ofp, "LTTng Trace Control " VERSION " - " VERSION_NAME "\n");
+ fprintf(ofp, lttng_version);
+ fprintf(ofp, "\n");
fprintf(ofp, "usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n");
fprintf(ofp, "\n");
fprintf(ofp, "Options:\n");
diff --git a/src/bin/lttng/utils.h b/src/bin/lttng/utils.h
index 9f7bfcc..12ee7c0 100644
--- a/src/bin/lttng/utils.h
+++ b/src/bin/lttng/utils.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 only,
@@ -19,8 +20,20 @@
#define _LTTNG_UTILS_H
#include <popt.h>
+#include <version.h>
char *get_session_name(void);
void list_cmd_options(FILE *ofp, struct poptOption *options);
+/*
+ * This static const char allows to return the version number depending
+ * whether or not the GIT_VERSION value is available
+ */
+#ifdef GIT_VERSION
+static const char lttng_version[] = "Git version: " GIT_VERSION "\n";
+#else /* GIT_VERSION */
+static const char lttng_version[] = "";
+#endif /* GIT_VERSION */
+
+
#endif /* _LTTNG_UTILS_H */
--
1.7.10.4
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-03-25 15:55 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <51421C12.5050907@gmail.com>
2013-03-15 18:40 ` [lttng-tools PATCH] Add a git version information in LTTng versions compiled from git sources Raphaël Beamonte
[not found] ` <2f2984a90ab0b25a5b9e6259060fdd6c5c7bb00a.1363372839.git.raphael.beamonte@gmail.com>
2013-03-15 18:44 ` Raphaël Beamonte
2013-03-16 23:49 ` Raphaël Beamonte
[not found] ` <16a0408728b4c746985844ecd893bd569b599641.1363477794.git.raphael.beamonte@gmail.com>
2013-03-16 23:55 ` Raphaël Beamonte
2013-03-21 17:35 ` David Goulet
[not found] <514B44ED.3000702@efficios.com>
2013-03-21 22:13 ` Raphaël Beamonte
[not found] ` <2423f47f2d19009bcfe5af3cbe0c3350deb68fdf.1363903997.git.raphael.beamonte@gmail.com>
2013-03-25 14:30 ` David Goulet
[not found] <51505F7A.7060108@efficios.com>
2013-03-25 15:50 ` Raphaël Beamonte
[not found] ` <0ab8866c5deb744279d9150823d24203a51851b1.1364226619.git.raphael.beamonte@gmail.com>
2013-03-25 15:55 ` Raphaël Beamonte
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.