Skip to content

Commit

Permalink
build-info: Add xorp version string to xorpsh.
Browse files Browse the repository at this point in the history
This also makes the version available to all code,
so remove the #define hack in master_conf_tree.cc

This means one less place we have to change the xorp
version.

Also, add run-time info (uname -a, cat /etc/issue if it exists)
to the xorp logs to aid trouble-shooting bug reports.

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Sep 28, 2011
1 parent 1f32abb commit f66bae2
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 34 deletions.
7 changes: 6 additions & 1 deletion xorp/RELEASE_NOTES
Expand Up @@ -3,8 +3,13 @@

This file contains XORP release notes (most recent releases first).

Release 1.8.5

Release 1.8.4
* Compile in build-information to better track versions in logs and
bug reports.


Release 1.8.4 (September 20, 2011)

* Add async-XRL support, from Steven Simpson

Expand Down
9 changes: 9 additions & 0 deletions xorp/SConstruct
Expand Up @@ -826,6 +826,15 @@ else:
( 'XRL_PF', ord(xrl_pf_dict[env['transport']]) ),
])

# Read our VERSION file and use it's contents to pass the
# version into the compile process.
vf = open('VERSION', 'r')
ver = vf.readline()
ver = ver.strip()
env.AppendUnique(CPPDEFINES = [
( 'XORP_VERSION', ver),
])

# Forcibly disable GCC's SSP support., as it may be incompatible
# with the XORP code base.
env.AppendUnique(CPPDEFINES = [
Expand Down
6 changes: 3 additions & 3 deletions xorp/cli/cli_node_net.cc
Expand Up @@ -54,9 +54,8 @@

#include "cli_client.hh"
#include "cli_private.hh"
#ifdef XORP_BUILDINFO
#include "libxorp/build_info.hh"
#endif

#ifdef HAVE_ARPA_TELNET_H
#include <arpa/telnet.h>
#endif
Expand Down Expand Up @@ -563,7 +562,8 @@ CliClient::start_connection(string& error_msg)
strncpy(hostname, "xorp", sizeof(hostname) - 1);
}
hostname[sizeof(hostname) - 1] = '\0';
cli_print(c_format("%s%s\n", XORP_CLI_WELCOME, hostname));
cli_print(c_format("Welcome to XORP v%s on %s\n",
BuildInfo::getXorpVersion(), hostname));
#ifdef XORP_BUILDINFO
const char* bits = "32-bit";
if (sizeof(void*) == 8)
Expand Down
15 changes: 0 additions & 15 deletions xorp/cli/cli_private.hh
Expand Up @@ -17,7 +17,6 @@
// XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
// http://xorp.net

// $XORP: xorp/cli/cli_private.hh,v 1.12 2008/10/02 21:56:30 bms Exp $


#ifndef __CLI_CLI_PRIVATE_HH__
Expand All @@ -34,7 +33,6 @@
//
#define CLI_MAX_CONNECTIONS 129 // XXX: intentionally not 2^n number

#define XORP_CLI_WELCOME "Welcome to XORP on "
#define XORP_CLI_PROMPT "Xorp> "
#define XORP_CLI_PROMPT_ENABLE "XORP# "

Expand All @@ -45,17 +43,4 @@
#define CHAR_TO_META(c) ((c) | 0x080)
#endif


//
// Structures/classes, typedefs and macros
//

//
// Global variables
//

//
// Global functions prototypes
//

#endif // __CLI_CLI_PRIVATE_HH__
25 changes: 17 additions & 8 deletions xorp/libxorp/build_info.hh
Expand Up @@ -21,15 +21,24 @@

class BuildInfo {
public:
/** git md5sum for HEAD */
static const char* getGitVersion();
/** Last 3 git change logs */
static const char* getGitLog();
/** As in: 1.8.5-WIP */
#define DEFSTR1(a) #a
#define DEFSTR(a) DEFSTR1(a)
static const char* getXorpVersion() {
return DEFSTR(XORP_VERSION);
}

static const char* getShortBuildDate();
static const char* getBuildDate();
static const char* getBuilder();
static const char* getBuildMachine();
#ifdef XORP_BUILDINFO
/** git md5sum for HEAD */
static const char* getGitVersion();
/** Last 3 git change logs */
static const char* getGitLog();

static const char* getShortBuildDate();
static const char* getBuildDate();
static const char* getBuilder();
static const char* getBuildMachine();
#endif
};

#endif
2 changes: 1 addition & 1 deletion xorp/libxorp/build_info.prefix
@@ -1,5 +1,5 @@

// The BuildInfo.cc file is Autogenerated, modifying by hand
// The build_info.cc file is Autogenerated, modifying by hand
// will be a waste of time. You should modify the create_buildinfo.sh
// script or the build_info.prefix file instead.

Expand Down
44 changes: 40 additions & 4 deletions xorp/rtrmgr/main_rtrmgr.cc
Expand Up @@ -28,10 +28,7 @@
#include "libxorp/daemon.h"
#include "libxorp/eventloop.hh"
#include "libxorp/utils.hh"

#ifdef XORP_BUILDINFO
#include "libxorp/build_info.hh"
#endif

#include <signal.h>

Expand Down Expand Up @@ -714,11 +711,50 @@ main(int argc, char* const argv[])
open_syslog();

#ifdef XORP_BUILDINFO
XLOG_INFO("\n\nXORP BuildInfo, git version: %s built: %s\nBy: %s on machine: %s\nRecent git changes:\n%s\n",
XLOG_INFO("\n\nXORP %s BuildInfo:\ngit version: %s built: %s\nBy: %s on machine: %s\nRecent git changes:\n%s\n",
BuildInfo::getXorpVersion(),
BuildInfo::getGitVersion(), BuildInfo::getBuildDate(),
BuildInfo::getBuilder(), BuildInfo::getBuildMachine(),
BuildInfo::getGitLog());
#else
XLOG_INFO("\n\nXORP %s\n", BuildInfo::getXorpVersion());
#endif

// Log our current system, if on unix
#ifndef __WIN32__
string tmp_fname(c_format("/tmp/xorp-tmp-%i.txt", getpid()));
string cmd(c_format("uname -a > %s", tmp_fname.c_str()));
system(cmd.c_str());
ifstream tstf("/etc/issue");
if (tstf) {
string cmd(c_format("cat /etc/issue >> %s", tmp_fname.c_str()));
system(cmd.c_str());
}
tstf.close();
tstf.clear();
tstf.open(tmp_fname.c_str());
if (tstf) {
cmd = "";
char tmpb[500];
while (tstf) {
tstf.getline(tmpb, 499);
if (tstf.gcount()) {
tmpb[tstf.gcount()] = 0;
cmd += tmpb;
}
else {
break;
}
}
XLOG_INFO("\nHost Information:\n%s\n\n",
cmd.c_str());
tstf.close();
}
unlink(tmp_fname.c_str());
#else
XLOG_INFO("\nHost Information: Windows\n\n");
#endif


//
// The main procedure
Expand Down
4 changes: 2 additions & 2 deletions xorp/rtrmgr/master_conf_tree.cc
Expand Up @@ -27,6 +27,7 @@
#include "libxorp/xlog.h"
#include "libxorp/debug.h"
#include "libxorp/utils.hh"
#include "libxorp/build_info.hh"

#ifdef HAVE_GRP_H
#include <grp.h>
Expand Down Expand Up @@ -71,7 +72,6 @@
#endif

#define XORP_CONFIG_FORMAT_VERSION "1.1"
#define XORP_CONFIG_XORP_VERSION "1.8.5-WIP"

//
// The strings that are used to add and delete a load or save file, to
Expand Down Expand Up @@ -915,7 +915,7 @@ MasterConfigTree::save_to_file(const string& filename, uid_t user_id,
header += "\n * Configuration format: ";
header += XORP_CONFIG_FORMAT_VERSION;
header += "\n * XORP version: ";
header += XORP_CONFIG_XORP_VERSION;
header += BuildInfo::getXorpVersion();
header += "\n * Date: ";
header += xlog_localtime2string();
header += "\n * Host: ";
Expand Down

0 comments on commit f66bae2

Please sign in to comment.