summaryrefslogtreecommitdiffstats
path: root/eurephiadm
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2010-11-09 18:45:46 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2010-11-09 18:45:46 +0100
commitb895db8cef71822a98ce60886113a9ba34e51fa8 (patch)
tree38ee843bd833550f3d95b0702309e6f3218c7968 /eurephiadm
parent83a6d2aee10e81862dbd1d6526ccbab93ef9afbe (diff)
downloadeurephia-b895db8cef71822a98ce60886113a9ba34e51fa8.tar.gz
eurephia-b895db8cef71822a98ce60886113a9ba34e51fa8.tar.xz
eurephia-b895db8cef71822a98ce60886113a9ba34e51fa8.zip
eurephiadm: Added a buildinfo command
This just adds some gathered information about the build, useful for debugging later on. Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'eurephiadm')
-rw-r--r--eurephiadm/CMakeLists.txt10
-rw-r--r--eurephiadm/commands.h6
-rw-r--r--eurephiadm/commands/buildinfo.c87
-rwxr-xr-xeurephiadm/mk_buildinfo.sh51
4 files changed, 154 insertions, 0 deletions
diff --git a/eurephiadm/CMakeLists.txt b/eurephiadm/CMakeLists.txt
index 51f9d83..eb1ad34 100644
--- a/eurephiadm/CMakeLists.txt
+++ b/eurephiadm/CMakeLists.txt
@@ -31,6 +31,14 @@ IF(FIREWALL)
ADD_DEFINITIONS(-DFIREWALL)
ENDIF(FIREWALL)
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/buildinfo.h
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mk_buildinfo.sh
+ DEPENDS commands/buildinfo.c
+ COMMENT "Creating buildinfo.h"
+)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES buildinfo.h)
+
# Build rules for eurephiadm
ADD_EXECUTABLE(eurephiadm
eurephiadm.c
@@ -50,6 +58,8 @@ ADD_EXECUTABLE(eurephiadm
commands/adminaccess.c
commands/edit_config.c
commands/fwprofiles.c
+ buildinfo.h
+ commands/buildinfo.c
../common/eurephiadb_session_common.c
)
diff --git a/eurephiadm/commands.h b/eurephiadm/commands.h
index 8a15bcd..c4a0b1b 100644
--- a/eurephiadm/commands.h
+++ b/eurephiadm/commands.h
@@ -92,6 +92,9 @@ int cmd_AdminAccess(eurephiaCTX *, eurephiaSESSION *, eurephiaVALUES *cfg, int a
void help_EditConfig();
int cmd_EditConfig(eurephiaCTX *, eurephiaSESSION *, eurephiaVALUES *cfg, int argc, char **argv);
+void help_BuildInfo();
+int cmd_BuildInfo(eurephiaCTX *, eurephiaSESSION *, eurephiaVALUES *cfg, int argc, char **argv);
+
/**
* Declaration of all valid commands
* {command, need_session, acclvl, arghints,
@@ -138,6 +141,9 @@ static const eurephiadm_functions cmdline_functions[] = {
{"config", 1, "config", "[-s|-d] <key> [<val>] | [-l]",
"Add, delete or show one config setting", help_EditConfig, cmd_EditConfig},
+ {"buildinfo", 0, "buildinfo", NULL,
+ "Show information related to the eurephia build", help_BuildInfo, cmd_BuildInfo},
+
// End of records marker
{NULL, 0, NULL, NULL,
NULL, NULL, NULL}
diff --git a/eurephiadm/commands/buildinfo.c b/eurephiadm/commands/buildinfo.c
new file mode 100644
index 0000000..57ca9b6
--- /dev/null
+++ b/eurephiadm/commands/buildinfo.c
@@ -0,0 +1,87 @@
+/* buildinfo.c -- eurephiadm buildinfo command:
+ * Shows info about the eurephia build
+ *
+ * GPLv2 only - Copyright (C) 2009 - 2010
+ * David Sommerseth <dazo@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/**
+ * @file eurephiadm/commands/buildinfo.c
+ * @author David Sommerseth <dazo@users.sourceforge.net>
+ * @date 2010-11-09
+ *
+ * @brief eurephiadm buildinfo command. Debug info related to the eurephia build
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#ifdef HAVE_LIBXML2
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+#endif
+
+#define MODULE "eurephia::BuildInfo" /**< Need to define the active module before including argparser.h */
+#include <eurephia_nullsafe.h>
+#include <eurephia_context.h>
+#include <eurephia_log.h>
+#include <eurephia_values_struct.h>
+#include <eurephiadb_session_struct.h>
+
+#include "../argparser.h"
+#include "../buildinfo.h"
+
+/**
+ * Help screen for the buildinfo command
+ */
+void help_BuildInfo()
+{
+ printf("eurephiadm::BuildInfo\n\n"
+ "This command will just show some basic information about the\n"
+ "current eurephia build. This is mostly useful when reporting bugs.\n\n"
+ );
+}
+
+
+/**
+ * Main function for the buildinfo command. Does the querying of the database and show the result
+ *
+ * @param ctx eurephiaCTX
+ * @param sess eurephiaSESSION of the current logged in user
+ * @param cfg eurephiaVALUES struct of the current configuration
+ * @param argc argument count for the eurephiadm command
+ * @param argv argument table for the eurephiadm command
+ *
+ * @return returns 0 on success, otherwise 1.
+ */
+int cmd_BuildInfo(eurephiaCTX *ctx, eurephiaSESSION *sess, eurephiaVALUES *cfg, int argc, char **argv)
+{
+ printf("** eurephia build information:\n"
+ " Version: " EUREPHIAVERSION "\n"
+ " Source base: " BUILDSOURCE "\n"
+ " Build date: " BUILDDATE "\n"
+ " Build host: " BUILDHOST "\n"
+ " System info: " BUILDSYSTEM "\n");
+#ifdef BUILDBRANCH
+ printf(" git branch: " BUILDBRANCH "\n"
+ " git commit: " BUILDGITREV "\n\n");
+#endif
+ return 0;
+}
diff --git a/eurephiadm/mk_buildinfo.sh b/eurephiadm/mk_buildinfo.sh
new file mode 100755
index 0000000..2f45bbe
--- /dev/null
+++ b/eurephiadm/mk_buildinfo.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# A simple script to gather some build information and prepare
+# a little include file for the eurephiadm buildinfo command
+#
+# GPLv2 only - Copyright (C) 2010
+# David Sommerseth <dazo@users.sourceforge.net>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; version 2
+# of the License.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+#
+builddate="`date -u`"
+buildsystem="`uname -a`"
+buildhost="`hostname`"
+if [[ -d ../.git ]]; then
+ # If we have a .git directory, presume the source is from a git tree
+ branch=`awk '{print $2}' ../.git/HEAD`
+ gitrev=`git rev-list ${branch} -1`
+ buildsource="`git remote -v | awk '/^origin/{print $2; exit 0}'`"
+else
+ # Otherwise, it's from a source tarball
+ buildsource="tar.bz2"
+fi
+
+cat <<EOF > buildinfo.h
+/* Generated automatically by $0 */
+/* Do not edit manually */
+#define BUILDDATE "${builddate}"
+#define BUILDSYSTEM "${buildsystem}"
+#define BUILDHOST "${buildhost}"
+#define BUILDSOURCE "${buildsource}"
+EOF
+
+if [[ -n "${gitrev}" ]]; then
+ cat <<EOF >> buildinfo.h
+#define BUILDBRANCH "${branch}"
+#define BUILDGITREV "${gitrev}"
+EOF
+fi