aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-02-07 22:11:23 +0000
committerlloyd <[email protected]>2011-02-07 22:11:23 +0000
commit02ed4e271a6287a0c23b137e826e62d2be752b82 (patch)
treee50ccc16f91dc52671fdd24dd5d36d4685968511
parent80d591ec716fb6cea829db45b68da1af4afd1d0e (diff)
Add a new configure.py option --distribution-info which sets a macro
in build.h named BOTAN_DISTRIBUTION_INFO. The default value is 'unspecified'. People packaging botan could set this to another value, for instance 'Gentoo 1.9.13-r3' or 'Debian 1.9.13-1', or 'pristine' to indicate a completely unmodified/stock version. This was suggested by Zooko for Crypto++ in http://sourceforge.net/apps/trac/cryptopp/ticket/11 and seemed like an idea worth stealing. Don't default the version datestmap to the current day if unset, instead set to zero. This allows applications to detect unreleased versions. Document that version_datestamp will return zero for unreleased versions. Change the version_string function to return more information about the current version, including the release date and distribution information. It will now return strings like: Botan 1.9.13 (released 20110207, distribution Gentoo 1.9.13-r3) or for an unreleased version: Botan 1.9.13 (unreleased version, distribution unspecified)
-rw-r--r--checks/check.cpp3
-rwxr-xr-xconfigure.py14
-rw-r--r--doc/license.txt2
-rw-r--r--src/build-data/buildh.in3
-rw-r--r--src/utils/version.cpp20
-rw-r--r--src/utils/version.h15
6 files changed, 37 insertions, 20 deletions
diff --git a/checks/check.cpp b/checks/check.cpp
index 601e41227..e32f57ed7 100644
--- a/checks/check.cpp
+++ b/checks/check.cpp
@@ -127,8 +127,7 @@ int main(int argc, char* argv[])
if(opts.is_set("help") || argc <= 1)
{
std::cerr << "Test driver for "
- << Botan::version_string()
- << " (released " << Botan::version_datestamp() << ")\n"
+ << Botan::version_string() << "\n"
<< "Options:\n"
<< " --test || --validate: Run tests (do this at least once)\n"
<< " --benchmark: Benchmark everything\n"
diff --git a/configure.py b/configure.py
index b5422fdac..69381ef05 100755
--- a/configure.py
+++ b/configure.py
@@ -47,7 +47,7 @@ class BuildConfigurationInformation(object):
version_so_patch = 13
version_suffix = '-dev'
- version_datestamp = None
+ version_datestamp = 0
version_string = '%d.%d.%d%s' % (
version_major, version_minor, version_patch, version_suffix)
@@ -59,10 +59,6 @@ class BuildConfigurationInformation(object):
"""
def __init__(self, options, modules):
- # If not preset, use today
- if self.version_datestamp is None:
- self.version_datestamp = time.strftime("%Y%m%d", time.gmtime())
-
self.build_dir = os.path.join(options.with_build_dir, 'build')
self.checkobj_dir = os.path.join(self.build_dir, 'checks')
@@ -229,6 +225,10 @@ def process_command_line(args):
action='store_false', default=True,
help=SUPPRESS_HELP)
+ build_group.add_option('--distribution-info', metavar='STRING',
+ help='set distribution specific versioning',
+ default='unspecified')
+
wrapper_group = OptionGroup(parser, 'Wrapper options')
wrapper_group.add_option('--with-boost-python', dest='boost_python',
@@ -243,7 +243,7 @@ def process_command_line(args):
wrapper_group.add_option('--use-python-version', dest='python_version',
metavar='N.M',
default='.'.join(map(str, sys.version_info[0:2])),
- help='specify version of Python to build against (eg %default)')
+ help='specify Python to build against (eg %default)')
mods_group = OptionGroup(parser, 'Module selection')
@@ -943,6 +943,8 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
'version_patch': build_config.version_patch,
'version': build_config.version_string,
+ 'distribution_info': options.distribution_info,
+
'version_datestamp': build_config.version_datestamp,
'so_version': build_config.soversion_string,
diff --git a/doc/license.txt b/doc/license.txt
index 6d9143ee1..f1b261eab 100644
--- a/doc/license.txt
+++ b/doc/license.txt
@@ -1,6 +1,6 @@
Botan (http://botan.randombit.net/) is distributed under these terms:
-Copyright (C) 1999-2010 Jack Lloyd
+Copyright (C) 1999-2011 Jack Lloyd
2001 Peter J Jones
2004-2007 Justin Karneges
2004 Vaclav Ovsik
diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in
index fb5e5fabc..2682d2ad9 100644
--- a/src/build-data/buildh.in
+++ b/src/build-data/buildh.in
@@ -15,9 +15,10 @@
#define BOTAN_VERSION_MAJOR %{version_major}
#define BOTAN_VERSION_MINOR %{version_minor}
#define BOTAN_VERSION_PATCH %{version_patch}
-
#define BOTAN_VERSION_DATESTAMP %{version_datestamp}
+#define BOTAN_DISTRIBUTION_INFO "%{distribution_info}"
+
#ifndef BOTAN_DLL
#define BOTAN_DLL %{dll_import_flags}
#endif
diff --git a/src/utils/version.cpp b/src/utils/version.cpp
index 22827cbe5..cf3205d19 100644
--- a/src/utils/version.cpp
+++ b/src/utils/version.cpp
@@ -1,12 +1,13 @@
/*
* Version Information
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2011 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
#include <botan/version.h>
#include <botan/parsing.h>
+#include <sstream>
namespace Botan {
@@ -21,9 +22,20 @@ namespace Botan {
*/
std::string version_string()
{
- return to_string(version_major()) + "." +
- to_string(version_minor()) + "." +
- to_string(version_patch());
+ std::ostringstream out;
+
+ out << "Botan " << version_major() << "."
+ << version_minor() << "."
+ << version_patch() << " (";
+
+ if(BOTAN_VERSION_DATESTAMP == 0)
+ out << "unreleased version";
+ else
+ out << "released " << version_datestamp();
+
+ out << ", distribution " << BOTAN_DISTRIBUTION_INFO << ")";
+
+ return out.str();
}
u32bit version_datestamp() { return BOTAN_VERSION_DATESTAMP; }
diff --git a/src/utils/version.h b/src/utils/version.h
index 13d0ac8bb..219c261a5 100644
--- a/src/utils/version.h
+++ b/src/utils/version.h
@@ -1,6 +1,6 @@
/*
* Version Information
-* (C) 1999-2007 Jack Lloyd
+* (C) 1999-2011 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -18,16 +18,19 @@ namespace Botan {
*/
/**
-* Get the version string identifying the version of Botan.
+* Get a human-readable string identifying the version of Botan.
+* No particular format should be assumed.
* @return version string
*/
BOTAN_DLL std::string version_string();
/**
-* Return the date this version of botan was released, in an
-* integer of the form YYYYMMDD. For instance a version released
-* on May 21, 2013 would return the integer 20130521
-* @return release date
+* Return the date this version of botan was released, in an integer of
+* the form YYYYMMDD. For instance a version released on May 21, 2013
+* would return the integer 20130521. If the currently running version
+* is not an official release, this function will return 0 instead.
+*
+* @return release date, or zero if unreleased
*/
BOTAN_DLL u32bit version_datestamp();