summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Reams <jbreams@mongodb.com>2015-05-21 14:15:43 -0400
committerJonathan Reams <jbreams@mongodb.com>2015-07-10 16:58:08 -0400
commit180a24d624984c7994ff52862699d45ebc609dc1 (patch)
treea3b9c46f8f0381a3c93473a3719360766daace1a
parent9a200e2eabc59a0ac421f4cf7ec7b1c30971f9f3 (diff)
downloadmongo-180a24d624984c7994ff52862699d45ebc609dc1.tar.gz
BUILD-770 Backport version info and source tarball changes
-rw-r--r--SConstruct98
-rw-r--r--buildscripts/generate_compile_expansions.py59
-rw-r--r--buildscripts/sourcepush.py77
-rw-r--r--buildscripts/utils.py9
-rw-r--r--etc/evergreen.yml125
-rw-r--r--site_scons/site_tools/distsrc.py194
-rw-r--r--site_scons/site_tools/gziptool.py42
-rw-r--r--src/mongo/SConscript65
-rw-r--r--src/mongo/db/commands/auth_schema_upgrade_d.cpp6
-rw-r--r--src/mongo/db/db.cpp2
-rw-r--r--src/mongo/db/dbcommands_generic.cpp2
-rw-r--r--src/mongo/db/dbwebserver.cpp1
-rw-r--r--src/mongo/db/log_process_details.cpp1
-rw-r--r--src/mongo/db/mongod_options.cpp1
-rw-r--r--src/mongo/dbtests/framework.cpp2
-rw-r--r--src/mongo/dbtests/perftests.cpp1
-rw-r--r--src/mongo/installer/msi/SConscript3
-rw-r--r--src/mongo/s/version_mongos.cpp1
-rw-r--r--src/mongo/shell/shell_utils.cpp2
-rw-r--r--src/mongo/util/version.cpp137
-rw-r--r--src/mongo/util/version.cpp.in (renamed from src/mongo/util/version_reporting.cpp)111
-rw-r--r--src/mongo/util/version.h34
-rw-r--r--src/mongo/util/version_reporting.h56
-rw-r--r--src/mongo/util/version_test.cpp61
-rw-r--r--version.json3
25 files changed, 663 insertions, 430 deletions
diff --git a/SConstruct b/SConstruct
index 5e2837c4e6d..aaedd510ec3 100644
--- a/SConstruct
+++ b/SConstruct
@@ -17,6 +17,8 @@ import buildscripts
import copy
import datetime
import imp
+import errno
+import json
import os
import re
import shlex
@@ -380,6 +382,32 @@ add_option('variable-parse-mode',
type='choice', default=variable_parse_mode_choices[0],
choices=variable_parse_mode_choices)
+try:
+ with open("version.json", "r") as version_fp:
+ version_data = json.load(version_fp)
+
+ if 'version' not in version_data:
+ print "version.json does not contain a version string"
+ Exit(1)
+ if 'githash' not in version_data:
+ version_data['githash'] = utils.getGitVersion()
+
+except IOError as e:
+ # If the file error wasn't because the file is missing, error out
+ if e.errno != errno.ENOENT:
+ print "Error opening version.json: {0}".format(e.strerror)
+ Exit(1)
+
+ version_data = {
+ 'version': utils.getGitDescribe()[1:],
+ 'githash': utils.getGitVersion(),
+ }
+
+except ValueError as e:
+ print "Error decoding version.json: {0}".format(e)
+ Exit(1)
+
+
# Setup the command-line variables
def variable_shlex_converter(val):
parse_mode = get_option('variable-parse-mode')
@@ -387,6 +415,11 @@ def variable_shlex_converter(val):
parse_mode = 'other' if windows else 'posix'
return shlex.split(val, posix=(parse_mode == 'posix'))
+def variable_distsrc_converter(val):
+ if not val.endswith("/"):
+ return val + "/"
+ return val
+
env_vars = Variables()
env_vars.Add('ARFLAGS',
@@ -425,6 +458,19 @@ env_vars.Add('LINKFLAGS',
help='Sets flags for the linker',
converter=variable_shlex_converter)
+env_vars.Add('MONGO_DIST_SRC_PREFIX',
+ help='Sets the prefix for files in the source distribution archive',
+ converter=variable_distsrc_converter,
+ default="mongodb-r${MONGO_VERSION}")
+
+env_vars.Add('MONGO_VERSION',
+ help='Sets the version string for MongoDB',
+ default=version_data['version'])
+
+env_vars.Add('MONGO_GIT_HASH',
+ help='Sets the githash to store in the MongoDB version information',
+ default=version_data['githash'])
+
env_vars.Add('RPATH',
help='Set the RPATH for dynamic libraries and executables',
converter=variable_shlex_converter)
@@ -555,7 +601,9 @@ def decide_platform_tools():
else:
return ["default"]
-tools = decide_platform_tools() + ["gch", "jsheader", "mergelib", "mongo_unittest", "textfile"]
+tools = decide_platform_tools() + [
+ "gch", "jsheader", "mergelib", "mongo_unittest", "textfile", "distsrc", "gziptool"
+]
# We defer building the env until we have determined whether we want certain values. Some values
# in the env actually have semantics for 'None' that differ from being absent, so it is better
@@ -2318,27 +2366,31 @@ def getSystemInstallName():
return n
-def getCodeVersion():
- fullSource = open( "src/mongo/util/version.cpp" , "r" ).read()
- allMatches = re.findall( r"versionString.. = \"(.*?)\"" , fullSource );
- if len(allMatches) != 1:
- print( "can't find version # in code" )
- return None
- return allMatches[0]
-
-mongoCodeVersion = getCodeVersion()
-if mongoCodeVersion == None:
- Exit(-1)
+# This function will add the version.txt file to the source tarball
+# so that versioning will work without having the git repo available.
+def add_version_to_distsrc(env, archive):
+ version_file_path = env.subst("$MONGO_DIST_SRC_PREFIX") + "version.json"
+ if version_file_path not in archive:
+ version_data = {
+ 'version': env['MONGO_VERSION'],
+ 'githash': env['MONGO_GIT_HASH'],
+ }
+ archive.append_file_contents(
+ version_file_path,
+ json.dumps(
+ version_data,
+ sort_keys=True,
+ indent=4,
+ separators=(',', ': ')
+ )
+ )
+
+env.AddDistSrcCallback(add_version_to_distsrc)
if has_option('distname'):
distName = GetOption( "distname" )
-elif mongoCodeVersion[-1] not in ("+", "-"):
- dontReplacePackage = True
- distName = mongoCodeVersion
else:
- isBuildingLatest = True
- distName = utils.getGitBranchString("" , "-") + datetime.date.today().strftime("%Y-%m-%d")
-
+ distName = env['MONGO_VERSION']
env['SERVER_DIST_BASENAME'] = 'mongodb-%s-%s' % (getSystemInstallName(), distName)
@@ -2438,7 +2490,6 @@ module_sconscripts = moduleconfig.get_module_sconscripts(mongo_modules)
Export("env")
Export("get_option")
Export("has_option use_system_version_of_library")
-Export("mongoCodeVersion")
Export("usev8")
Export("v8version v8suffix")
Export("boostSuffix")
@@ -2453,8 +2504,15 @@ def injectMongoIncludePaths(thisEnv):
thisEnv.AppendUnique(CPPPATH=['$BUILD_DIR'])
env.AddMethod(injectMongoIncludePaths, 'InjectMongoIncludePaths')
+env.Alias("distsrc-tar", env.DistSrc("mongodb-src-${MONGO_VERSION}.tar"))
+env.Alias("distsrc-tgz", env.GZip(
+ target="mongodb-src-${MONGO_VERSION}.tgz",
+ source=["mongodb-src-${MONGO_VERSION}.tar"])
+)
+env.Alias("distsrc-zip", env.DistSrc("mongodb-src-${MONGO_VERSION}.zip"))
+env.Alias("distsrc", "distsrc-tgz")
+
env.SConscript('src/SConscript', variant_dir='$BUILD_DIR', duplicate=False)
-env.SConscript(['SConscript.buildinfo', 'SConscript.smoke'])
def clean_old_dist_builds(env, target, source):
prefix = "mongodb-%s-%s" % (platform, processor)
diff --git a/buildscripts/generate_compile_expansions.py b/buildscripts/generate_compile_expansions.py
new file mode 100644
index 00000000000..78cca293452
--- /dev/null
+++ b/buildscripts/generate_compile_expansions.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# This script generates the compile expansions file used by MCI as part of the push/
+# release process.
+#
+# You can invoke it either with git describe:
+# $ git describe | python generate_compile_expansions.py > compile_expansions.yml
+# or with the version.json file
+# $ python generate_compile_expansions.py version.json > compile_expansions.yml
+#
+
+import fileinput
+import json
+import re
+
+# This function matches a version string and captures the "extra" part
+# If the version is a release like "2.3.4" or "2.3.4-rc0", this will return
+# ( None )
+# If the version is a pre-release like "2.3.4-325-githash" or "2.3.4-pre-", this will return
+# ( "-pre-" ) or ( "-325-githash" )
+# If the version begins with the letter 'r', it will also match, e.g.
+# r2.3.4, r2.3.4-rc0, r2.3.4-git234, r2.3.4-rc0-234-githash
+# If the version is invalid (i.e. doesn't start with "2.3.4" or "2.3.4-rc0", this will return
+# False
+def match_verstr(verstr):
+ res = re.match(r'^r?(?:\d+\.\d+\.\d+(?:-rc\d+)?)(-.*)?', verstr)
+ if not res:
+ return False
+ return res.groups()
+
+input_obj = fileinput.input()
+version_line = input_obj.readline()
+version_parts = match_verstr(version_line)
+if not version_parts:
+ if input_obj.filename().endswith(".json"):
+ version_data_buf = "".join([ version_line ] + [ l for l in input_obj ])
+ try:
+ version_data = json.loads(version_data_buf)
+ except Exception as e:
+ print "Unable to load json file: %s" % e
+ exit(1)
+ version_parts = match_verstr(version_data['version'])
+ version_line = version_data['version']
+else:
+ version_line = version_line.lstrip("r").rstrip()
+
+# If the version still doesn't match, give up and print an error message!
+if not version_parts:
+ print "Unable to parse version data!"
+ exit(1)
+
+if version_parts[0]:
+ print "suffix: v3.0-latest"
+ print "src_suffix: v3.0-latest"
+else:
+ print "suffix: {0}".format(version_line)
+ print "src_suffix: r{0}".format(version_line)
+
+print "version: {0}".format(version_line)
diff --git a/buildscripts/sourcepush.py b/buildscripts/sourcepush.py
deleted file mode 100644
index 36e4a7ecb48..00000000000
--- a/buildscripts/sourcepush.py
+++ /dev/null
@@ -1,77 +0,0 @@
-
-import os
-import sys
-
-sys.path.append( "." )
-sys.path.append( ".." )
-sys.path.append( "../../" )
-sys.path.append( "../../../" )
-
-import simples3
-import settings
-import subprocess
-
-# this pushes all source balls as tgz and zip
-
-def run_git( args ):
- cmd = "git " + args
- cmd = cmd.split( " " )
- x = subprocess.Popen( ( "git " + args ).split( " " ) , stdout=subprocess.PIPE).communicate()
- return x[0]
-
-def push_tag( bucket , tag , extension , gzip=False ):
- localName = "mongodb-src-" + tag + "." + extension
- remoteName = "src/" + localName
- if gzip:
- remoteName += ".gz"
- for ( key , modify , etag , size ) in bucket.listdir( prefix=remoteName ):
- print( "found old: " + key + " uploaded on: " + str( modify ) )
- return
-
- if os.path.exists( localName ):
- os.remove( localName )
-
- print( "need to do: " + remoteName )
-
- cmd = "archive --format %s --output %s --prefix mongodb-src-%s/ %s" % ( extension , localName , tag , tag )
- run_git( cmd )
-
- print( "\t" + cmd )
-
- if not os.path.exists( localName ) or os.path.getsize(localName) == 0 :
- raise( Exception( "creating archive failed: " + cmd ) )
-
- if gzip:
- newLocalName = localName + ".gz"
- if ( os.path.exists( newLocalName ) ):
- os.remove( newLocalName )
- subprocess.call( [ "gzip" , localName ] )
- localName = newLocalName
-
- if not os.path.exists( localName ) or os.path.getsize(localName) == 0 :
- raise( Exception( "gzipping failed" ) )
-
- bucket.put( remoteName , open( localName , "rb" ).read() , acl="public-read" )
- print( "\t uploaded to: http://s3.amazonaws.com/%s/%s" % ( bucket.name , remoteName ) )
-
- os.remove( localName )
-
-
-def push_all( filter=None):
- tags = run_git("tag -l").strip().split( "\n" )
-
- bucket = simples3.S3Bucket( settings.bucket , settings.id , settings.key )
-
- for tag in tags:
- if filter and tag.find( filter ) < 0:
- print( "skipping %s because it doesn't match filter %s" % ( tag, filter ) )
- continue
- push_tag( bucket , tag , "tar" , True )
- push_tag( bucket , tag , "zip" )
-
-if __name__ == "__main__":
- filter = None
- if len(sys.argv) > 1:
- filter = sys.argv[1]
- print( "filter: %s" % filter )
- push_all(filter)
diff --git a/buildscripts/utils.py b/buildscripts/utils.py
index 0a46ef440d4..62a2b1d13eb 100644
--- a/buildscripts/utils.py
+++ b/buildscripts/utils.py
@@ -80,6 +80,15 @@ def getGitVersion():
return version
return open( f , 'r' ).read().strip()
+def getGitDescribe():
+ with open(os.devnull, "r+") as devnull:
+ proc = subprocess.Popen("git describe",
+ stdout=subprocess.PIPE,
+ stderr=devnull,
+ stdin=devnull,
+ shell=True)
+ return proc.communicate()[0].strip()
+
def execsys( args ):
import subprocess
if isinstance( args , str ):
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index ea4dec348b2..259363322d2 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -236,13 +236,18 @@ tasks:
export MONGO_PHASE="${task_name}_${execution}"
rm -rf ${install_directory|/data/mongo-install-directory}
- ${scons|scons} ${compile_flags|} --use-new-tools all dist ${msi_target|}
- ${grep|grep} -E 'versionString.. = ' src/mongo/util/version.cpp | ${grep|grep} -oE '"(.+)"' | sed 's/"//g' > version.txt
- ${python|python} -c "ver = open('version.txt','r').read().strip(); print 'suffix: v3.0-latest' if ver[-1] == '-' else 'suffix: ' + ver; print 'version: ' + ver" > compile_expansions.yml
+ ${scons|scons} ${compile_flags|} --distname=binaries --use-new-tools all dist distsrc-${ext|tgz} ${msi_target|}
+
+ ${python|python} buildscripts/generate_compile_expansions.py version.json | \
+ tee compile_expansions.yml
+
if [ "${has_debugsymbols|}" = "true" ]; then ${scons|scons} ${compile_flags|} --nostrip --use-new-tools dist; original_filename=$(ls | grep debugsymbols); mv $original_filename $(echo $original_filename | sed 's/debugsymbols-//' | sed 's/mongodb/debugsymbols-mongodb/'); fi
${asan_symbolizer} ${enable_lsan} ${python|python} buildscripts/smoke.py --with-cleanbb --mode files --from-file build/unittests.txt --dont-start-mongod --report-file report.json core
- mv mongodb*.${ext|tgz} mongodb-binaries.tgz
+
+ mv mongodb-src-*.${ext|tgz} distsrc.${ext|tgz}
+ mv mongodb-*.${ext|tgz} mongodb-binaries.tgz
mv debugsymbols-*.${ext|tgz} mongo-debugsymbols.tgz || true
+
- command: archive.targz_pack
params:
target: "artifacts.tgz"
@@ -286,6 +291,19 @@ tasks:
permissions: public-read
content_type: application/tar
display_name: Artifacts
+ - command: s3.put
+ params:
+ aws_key: ${aws_key}
+ aws_secret: ${aws_secret}
+ local_file: src/distsrc.${ext|tgz}
+ remote_file: mongodb-mongo-master/${build_variant}/${revision}/sources/mongo-src-${build_id}.${ext|tgz}
+ bucket: mciuploads
+ permissions: public-read
+ content_type: ${content_type|application/x-gzip}
+ display_name: Source tarball
+ # We only need to upload the source tarball from one of the build variants
+ # because it should be the same everywhere, so just use linux-64/windows-64-2k8.
+ build_variants: [ linux-64, windows-64-2k8 ]
- name: lint
depends_on: []
@@ -1722,6 +1740,13 @@ tasks:
commands:
- func: "fetch artifacts"
- func: "fetch binaries"
+ - command: s3.get
+ params:
+ aws_key: ${aws_key}
+ aws_secret: ${aws_secret}
+ remote_file: mongodb-mongo-master/${build_variant}/${revision}/sources/mongo-src-${build_id}.${ext|tgz}
+ bucket: mciuploads
+ local_file: src/distsrc.${ext|tgz}
- command: expansions.update
params:
file: src/compile_expansions.yml
@@ -1743,9 +1768,10 @@ tasks:
mv mongo-debugsymbols.tgz debugsymbols-*.${ext|tgz} || true
cp mongodb-*.${ext|tgz} mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz}
cp debugsymbols-*.${ext|tgz} mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz} || true
+ mv distsrc.${ext|tgz} mongodb-src-${src_suffix}.${ext|tar.gz} || true
/usr/bin/find build/ -type f | grep msi$ | xargs -I original_filename cp original_filename mongodb-win32-${push_arch}-${suffix}.msi || true
- notary-client.py --key-name "${signing_key_name}" --auth-token-file ./signing_auth_token --comment "MCI Automatic Signing ${revision} - ${build_variant} - ${branch_name}" --notary-url http://notary-service.build.10gen.cc:5000 --skip-missing mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz} mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz} mongodb-win32-${push_arch}-${suffix}.msi
+ notary-client.py --key-name "${signing_key_name}" --auth-token-file ./signing_auth_token --comment "MCI Automatic Signing ${revision} - ${build_variant} - ${branch_name}" --notary-url http://notary-service.build.10gen.cc:5000 --skip-missing mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz} mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz} mongodb-win32-${push_arch}-${suffix}.msi mongodb-src-${src_suffix}.${ext|tar.gz}
rm signing_auth_token
# Put the binaries tarball/zipfile
@@ -1758,6 +1784,17 @@ tasks:
permissions: public-read
content_type: ${content_type|application/x-gzip}
remote_file: ${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}
+ # Put the source tarball
+ - command: s3.put
+ params:
+ aws_secret: ${aws_secret}
+ local_file: src/mongodb-src-${src_suffix}.${ext|tar.gz}
+ aws_key: ${aws_key}
+ bucket: build-push-testing
+ permissions: public-read
+ content_type: ${content_type|application/x-gzip}
+ remote_file: ${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}
+ build_variants: [ linux-64, windows-64-2k8 ]
# Put the debug symbols
- command: s3.put
@@ -1782,6 +1819,18 @@ tasks:
content_type: ${content_type|application/x-gzip}
remote_file: ${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}.sig
+ # Put the source tarball signature
+ - command: s3.put
+ params:
+ aws_secret: ${aws_secret}
+ local_file: src/mongodb-src-${src_suffix}.${ext|tar.gz}.sig
+ aws_key: ${aws_key}
+ bucket: build-push-testing
+ permissions: public-read
+ content_type: ${content_type|application/x-gzip}
+ remote_file: ${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}.sig
+ build_variants: [ linux-64, windows-64-2k8 ]
+
# Put the debug symbols signature
- command: s3.put
params:
@@ -1817,6 +1866,18 @@ tasks:
content_type: text/plain
remote_file: ${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}.sha1
+ # Put the source tarball sha1
+ - command: s3.put
+ params:
+ aws_secret: ${aws_secret}
+ local_file: src/mongodb-src-${src_suffix}.${ext|tar.gz}.sha1
+ aws_key: ${aws_key}
+ permissions: public-read
+ bucket: build-push-testing
+ content_type: text/plain
+ remote_file: ${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}.sha1
+ build_variants: [ linux-64, windows-64-2k8 ]
+
# Put the debug symbols sha1
- command: s3.put
params:
@@ -1852,6 +1913,18 @@ tasks:
content_type: text/plain
remote_file: ${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}.sha256
+ # Put the source tarball sha256
+ - command: s3.put
+ params:
+ aws_secret: ${aws_secret}
+ local_file: src/mongodb-src-${src_suffix}.${ext|tar.gz}.sha256
+ permissions: public-read
+ aws_key: ${aws_key}
+ bucket: build-push-testing
+ content_type: text/plain
+ remote_file: ${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}.sha256
+ build_variants: [ linux-64, windows-64-2k8 ]
+
# Put the debug symbols sha256
- command: s3.put
params:
@@ -1887,6 +1960,18 @@ tasks:
content_type: text/plain
remote_file: ${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}.md5
+ # Put the source tarball md5
+ - command: s3.put
+ params:
+ aws_secret: ${aws_secret}
+ local_file: src/mongodb-src-${src_suffix}.${ext|tar.gz}.md5
+ aws_key: ${aws_key}
+ bucket: build-push-testing
+ permissions: public-read
+ content_type: text/plain
+ remote_file: ${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}.md5
+ build_variants: [ linux-64, windows-64-2k8 ]
+
# Put the debug symbols md5
- command: s3.put
params:
@@ -1920,6 +2005,12 @@ tasks:
- {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}', 'bucket': 'build-push-testing'},
'destination': {'path': '${push_path}/mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz}', 'bucket': '${push_bucket}'}}
+ #Source tarball
+ - {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}', 'bucket': 'build-push-testing'},
+ 'destination': {'path': 'src/mongodb-src-${src_suffix}.${ext|tar.gz}', 'bucket': '${push_bucket}'},
+ 'build_variants': [ 'linux-64', 'windows-64-2k8' ]
+ }
+
#Debug Symbols
- {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}-${task_id}.${ext|tgz}', 'bucket': 'build-push-testing'},
'destination': {'path': '${push_path}/mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz}', 'bucket': '${push_bucket}'},
@@ -1977,10 +2068,22 @@ tasks:
'solaris-64-bit']
}
+ #Source tarball signature
+ - {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}.sig', 'bucket': 'build-push-testing'},
+ 'destination': {'path': 'src/mongodb-src-${src_suffix}.${ext|tar.gz}.sig', 'bucket': '${push_bucket}'},
+ 'build_variants': [ 'linux-64', 'windows-64-2k8' ]
+ }
+
#SHA1 for binaries
- {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}.sha1', 'bucket': 'build-push-testing'},
'destination': {'path': '${push_path}/mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz}.sha1', 'bucket': '${push_bucket}'}}
+ #SHA1 for source tarball
+ - {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}.sha1', 'bucket': 'build-push-testing'},
+ 'destination': {'path': 'src/mongodb-src-${src_suffix}.${ext|tar.gz}.sha1', 'bucket': '${push_bucket}'},
+ 'build_variants': [ 'linux-64', 'windows-64-2k8' ]
+ }
+
#SHA1 for debug symbols
- {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}-${task_id}.${ext|tgz}.sha1', 'bucket': 'build-push-testing'},
'destination': {'path': '${push_path}/mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz}.sha1', 'bucket': '${push_bucket}'},
@@ -2015,6 +2118,12 @@ tasks:
- {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}.sha256', 'bucket': 'build-push-testing'},
'destination': {'path': '${push_path}/mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz}.sha256', 'bucket': '${push_bucket}'}}
+ #SHA256 for source tarball
+ - {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}.sha256', 'bucket': 'build-push-testing'},
+ 'destination': {'path': 'src/mongodb-src-${src_suffix}.${ext|tar.gz}.sha256', 'bucket': '${push_bucket}'},
+ 'build_variants': [ 'linux-64', 'windows-64-2k8' ]
+ }
+
#SHA256 for debugsymbols
- {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}-${task_id}.${ext|tgz}.sha256', 'bucket': 'build-push-testing'},
'destination': {'path': '${push_path}/mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz}.sha256', 'bucket': '${push_bucket}'},
@@ -2049,6 +2158,12 @@ tasks:
- {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-${suffix}-${task_id}.${ext|tgz}.md5', 'bucket': 'build-push-testing'},
'destination': {'path': '${push_path}/mongodb-${push_name}-${push_arch}-${suffix}.${ext|tgz}.md5', 'bucket': '${push_bucket}'}}
+ #MD5 for source tarball
+ - {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-src-${src_suffix}-${task_id}.${ext|tar.gz}.md5', 'bucket': 'build-push-testing'},
+ 'destination': {'path': 'src/mongodb-src-${src_suffix}.${ext|tar.gz}.md5', 'bucket': '${push_bucket}'},
+ 'build_variants': [ 'linux-64', 'windows-64-2k8' ]
+ }
+
#MD5 for debugsymbols
- {'source': {'path': '${push_path}-STAGE/${push_name}/mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}-${task_id}.${ext|tgz}.md5', 'bucket': 'build-push-testing'},
'destination': {'path': '${push_path}/mongodb-${push_name}-${push_arch}-debugsymbols-${suffix}.${ext|tgz}.md5', 'bucket': '${push_bucket}'},
diff --git a/site_scons/site_tools/distsrc.py b/site_scons/site_tools/distsrc.py
new file mode 100644
index 00000000000..861f5d9e2e2
--- /dev/null
+++ b/site_scons/site_tools/distsrc.py
@@ -0,0 +1,194 @@
+# Copyright (C) 2015 MongoDB Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License, version 3,
+# as published by the Free Software Foundation.
+#
+# 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import SCons
+import os
+import os.path as ospath
+import subprocess
+import shutil
+import tarfile
+import time
+import zipfile
+import StringIO
+
+from distutils.spawn import find_executable
+
+__distsrc_callbacks = []
+
+class DistSrcFile:
+ def __init__(self, **kwargs):
+ [ setattr(self, key, val) for (key, val) in kwargs.items() ]
+
+ def __str__(self):
+ return self.name
+
+class DistSrcArchive:
+ def __init__(self, archive_type, archive_file, filename, mode):
+ self.archive_type = archive_type
+ self.archive_file = archive_file
+ self.archive_name = filename
+ self.archive_mode = mode
+
+ @staticmethod
+ def Open(filename):
+ if filename.endswith("tar"):
+ return DistSrcTarArchive(
+ 'tar',
+ tarfile.open(filename, 'r', format=tarfile.PAX_FORMAT),
+ filename,
+ 'r',
+ )
+ elif filename.endswith("zip"):
+ return DistSrcZipArchive(
+ 'zip',
+ zipfile.ZipFile(filename, 'a'),
+ filename,
+ 'a',
+ )
+
+ def close(self):
+ self.archive_file.close()
+
+class DistSrcTarArchive(DistSrcArchive):
+ def __iter__(self):
+ file_list = self.archive_file.getnames()
+ for name in file_list:
+ yield name
+
+ def __getitem__(self, key):
+ item_data = self.archive_file.getmember(key)
+ return DistSrcFile(
+ name=key,
+ size=item_data.size,
+ mtime=item_data.mtime,
+ mode=item_data.mode,
+ type=item_data.type,
+ uid=item_data.uid,
+ gid=item_data.gid,
+ uname=item_data.uname,
+ gname=item_data.uname
+ )
+
+ def append_file_contents(self, filename, file_contents,
+ mtime=time.time(),
+ mode=0644,
+ uname="root",
+ gname="root"):
+ file_metadata = tarfile.TarInfo(name=filename)
+ file_metadata.mtime = mtime
+ file_metadata.mode = mode
+ file_metadata.uname = uname
+ file_metadata.gname = gname
+ file_metadata.size = len(file_contents)
+ file_buf = StringIO.StringIO(file_contents)
+ if self.archive_mode == 'r':
+ self.archive_file.close()
+ self.archive_file = tarfile.open(
+ self.archive_name,
+ 'a',
+ format=tarfile.PAX_FORMAT,
+ )
+ self.archive_mode = 'a'
+ self.archive_file.addfile(file_metadata, fileobj=file_buf)
+
+ def append_file(self, filename, localfile):
+ self.archive_file.add(localfile, arcname=filename)
+
+class DistSrcZipArchive(DistSrcArchive):
+ def __iter__(self):
+ file_list = self.archive_file.namelist()
+ for name in file_list:
+ yield name
+
+ def __getitem__(self, key):
+ item_data = self.archive_file.getinfo(key)
+ fixed_time = item_data.date_time + (0, 0, 0)
+ is_dir = key.endswith("/")
+ return DistSrcFile(
+ name=key,
+ size=item_data.file_size,
+ mtime=time.mktime(fixed_time),
+ mode=0775 if is_dir else 0664,
+ type=tarfile.DIRTYPE if is_dir else tarfile.REGTYPE,
+ uid=0,
+ gid=0,
+ uname="root",
+ gname="root"
+ )
+
+ def append_file_contents(self, filename, file_contents,
+ mtime=time.time(),
+ mode=0644,
+ uname="root",
+ gname="root"):
+ self.archive_file.writestr(filename, file_contents)
+
+ def append_file(self, filename, localfile):
+ self.archive_file.write(localfile, arcname=filename)
+
+def build_error_action(msg):
+ def error_stub(target=None, source=None, env=None):
+ print msg
+ env.Exit(1)
+ return [ error_stub ]
+
+def distsrc_action_generator(source, target, env, for_signature):
+ # This is done in two stages because env.WhereIs doesn't seem to work
+ # correctly on Windows, but we still want to be able to override the PATH
+ # using the env.
+ git_path = env.WhereIs("git")
+ if not git_path:
+ git_path = find_executable("git")
+
+ if not git_path:
+ return build_error_action("Could not find git - cannot create distsrc archive")
+
+ def run_distsrc_callbacks(target=None, source=None, env=None):
+ archive_wrapper = DistSrcArchive.Open(str(target[0]))
+ for fn in __distsrc_callbacks:
+ fn(env, archive_wrapper)
+ archive_wrapper.close()
+
+ target_ext = str(target[0])[-3:]
+ if not target_ext in [ 'zip', 'tar' ]:
+ print "Invalid file format for distsrc. Must be tar or zip file"
+ env.Exit(1)
+
+ git_cmd = "\"%s\" archive --format %s --output %s --prefix ${MONGO_DIST_SRC_PREFIX} HEAD" % (
+ git_path, target_ext, target[0])
+
+ return [
+ SCons.Action.Action(git_cmd, "Running git archive for $TARGET"),
+ SCons.Action.Action(run_distsrc_callbacks, "Running distsrc callbacks for $TARGET")
+ ]
+
+def add_callback(env, fn):
+ __distsrc_callbacks.append(fn)
+
+def generate(env, **kwargs):
+ env.AddMethod(add_callback, 'AddDistSrcCallback')
+ env['BUILDERS']['__DISTSRC'] = SCons.Builder.Builder(
+ generator=distsrc_action_generator,
+ )
+
+ def DistSrc(env, target):
+ result = env.__DISTSRC(target=target, source=[])
+ env.AlwaysBuild(result)
+ env.NoCache(result)
+ return result
+
+ env.AddMethod(DistSrc, 'DistSrc')
+
+def exists(env):
+ return True
diff --git a/site_scons/site_tools/gziptool.py b/site_scons/site_tools/gziptool.py
new file mode 100644
index 00000000000..c44bd4f5e7f
--- /dev/null
+++ b/site_scons/site_tools/gziptool.py
@@ -0,0 +1,42 @@
+# Copyright (C) 2015 MongoDB Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License, version 3,
+# as published by the Free Software Foundation.
+#
+# 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import SCons
+import gzip
+import shutil
+
+def GZipAction(target, source, env, **kw):
+ dst_gzip = gzip.GzipFile(str(target[0]), 'wb')
+ with open(str(source[0]), 'r') as src_file:
+ shutil.copyfileobj(src_file, dst_gzip)
+ dst_gzip.close()
+
+def generate(env, **kwargs):
+ env['BUILDERS']['__GZIPTOOL'] = SCons.Builder.Builder(
+ action=SCons.Action.Action(GZipAction, "$GZIPTOOL_COMSTR")
+ )
+ env['GZIPTOOL_COMSTR'] = kwargs.get(
+ "GZIPTOOL_COMSTR",
+ "Compressing $TARGET with gzip"
+ )
+
+ def GZipTool(env, target, source):
+ result = env.__GZIPTOOL(target=target, source=source)
+ env.AlwaysBuild(result)
+ return result
+
+ env.AddMethod(GZipTool, 'GZip')
+
+def exists(env):
+ return True
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index c3b18c27e06..bdfe93f9c45 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -2,8 +2,11 @@
# This SConscript describes build rules for the "mongo" project.
-import os
import itertools
+import os
+import re
+import subprocess
+import sys
from buildscripts import utils
Import("env")
@@ -294,6 +297,58 @@ env.Library(
'index_names',
])
+js_engine = "V8" if usev8 else "Unknown"
+
+# This generates a numeric representation of the version string so that
+# you can easily compare versions of MongoDB without having to parse
+# the version string.
+#
+# The rules for this are
+# {major}{minor}{release}{pre/rc/final}
+# If the version is pre-release and not an rc, the final number is 0
+# If the version is an RC, the final number of 1 + rc number
+# If the version is pre-release between RC's, the final number is 1 + rc number
+# If the version is a final release, the final number is 99
+#
+# Examples:
+# 3.1.1-123 = 3010100
+# 3.1.1-rc2 = 3010103
+# 3.1.1-rc2-123 = 3010103
+# 3.1.1 = 3010199
+#
+version_parts = [ x for x in re.match(r'^(\d+)\.(\d+)\.(\d+)-?((?:(rc)(\d+))?.*)?',
+ env['MONGO_VERSION']).groups() ]
+version_extra = version_parts[3] if version_parts[3] else ""
+if version_parts[4] == 'rc':
+ version_parts[3] = int(version_parts[5]) + -50
+elif version_parts[3]:
+ version_parts[3] = -100
+else:
+ version_parts[3] = 0
+version_parts = [ int(x) for x in version_parts[:4]]
+
+sysInfo = " ".join(os.uname()) if not windows else "windows {0}".format(sys.getwindowsversion())
+gitVersion = env['MONGO_GIT_HASH']
+if len(env['MONGO_MODULES']) > 0:
+ gitVersion += " modules: " + ", ".join(env['MONGO_MODULES'])
+
+versionInfo = env.Substfile(
+ 'util/version.cpp.in',
+ SUBST_DICT=[
+ ('@mongo_version@', env['MONGO_VERSION']),
+ ('@mongo_version_major@', version_parts[0]),
+ ('@mongo_version_minor@', version_parts[1]),
+ ('@mongo_version_patch@', version_parts[2]),
+ ('@mongo_version_extra@', version_parts[3]),
+ ('@mongo_version_extra_str@', version_extra),
+ ('@mongo_git_version@', gitVersion),
+ ('@buildinfo_js_engine@', js_engine),
+ ('@buildinfo_allocator@', GetOption('allocator')),
+ ('@buildinfo_loader_flags@', env.subst("$LINKGFLAGS $LDFLAGS")),
+ ('@buildinfo_compiler_flags@', env.subst("$CXXFLAGS $CCFLAGS $CFLAGS")),
+ ('@buildinfo_sysinfo@', sysInfo),
+ ])
+
env.Library('clientdriver', [
"client/connpool.cpp",
"client/dbclient.cpp",
@@ -328,7 +383,6 @@ env.Library('lasterror', [
env.Library('version',
[
- 'buildinfo.cpp',
'util/version.cpp'
],
LIBDEPS=[
@@ -348,7 +402,6 @@ commonFiles = [ "shell/mongo.cpp",
"util/concurrency/rwlockimpl.cpp",
"util/text_startuptest.cpp",
'util/signal_win32.cpp',
- "util/version_reporting.cpp",
]
extraCommonLibdeps = []
@@ -430,12 +483,6 @@ env.Library('mongocommon', commonFiles,
] +
extraCommonLibdeps)
-env.CppUnitTest(
- target="util/version_test",
- source=["util/version_test.cpp"],
- LIBDEPS=["mongocommon"]
-)
-
env.Library('background_job', ["util/background.cpp"],
LIBDEPS=['spin_lock'])
diff --git a/src/mongo/db/commands/auth_schema_upgrade_d.cpp b/src/mongo/db/commands/auth_schema_upgrade_d.cpp
index 5980b06735e..5ea934d7195 100644
--- a/src/mongo/db/commands/auth_schema_upgrade_d.cpp
+++ b/src/mongo/db/commands/auth_schema_upgrade_d.cpp
@@ -88,13 +88,13 @@ namespace {
}
if (!isSameMajorVersion(version)) {
- BSONArray foundVersionArray = toVersionArray(version);
+ auto foundVersionArray = iter->result["versionArray"].Array();
return Status(ErrorCodes::RemoteValidationError, mongoutils::str::stream() <<
"To upgrade auth schema in a replica set, all members must be "
"running the same release series of mongod; found " <<
- foundVersionArray["0"] << '.' << foundVersionArray["1"] <<
+ foundVersionArray[0].Int() << '.' << foundVersionArray[1].Int() <<
" on host " << iter->toHost << " but expected " <<
- versionArray["0"] << '.' << versionArray["1"]);
+ kMongoVersionMajor << '.' << kMongoVersionMinor);
}
}
return Status::OK();
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 546fd53a1de..ed20baa2ab2 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -111,7 +111,7 @@
#include "mongo/util/startup_test.h"
#include "mongo/util/text.h"
#include "mongo/util/time_support.h"
-#include "mongo/util/version_reporting.h"
+#include "mongo/util/version.h"
#if !defined(_WIN32)
# include <sys/file.h>
diff --git a/src/mongo/db/dbcommands_generic.cpp b/src/mongo/db/dbcommands_generic.cpp
index 9c8bb287aab..d89990c7959 100644
--- a/src/mongo/db/dbcommands_generic.cpp
+++ b/src/mongo/db/dbcommands_generic.cpp
@@ -62,7 +62,7 @@
#include "mongo/util/ntservice.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/ramlog.h"
-#include "mongo/util/version_reporting.h"
+#include "mongo/util/version.h"
namespace mongo {
diff --git a/src/mongo/db/dbwebserver.cpp b/src/mongo/db/dbwebserver.cpp
index 92d7a3d9959..054df55eb5c 100644
--- a/src/mongo/db/dbwebserver.cpp
+++ b/src/mongo/db/dbwebserver.cpp
@@ -57,7 +57,6 @@
#include "mongo/util/mongoutils/html.h"
#include "mongo/util/ramlog.h"
#include "mongo/util/version.h"
-#include "mongo/util/version_reporting.h"
namespace mongo {
diff --git a/src/mongo/db/log_process_details.cpp b/src/mongo/db/log_process_details.cpp
index d6898ef95e9..e629460d0cf 100644
--- a/src/mongo/db/log_process_details.cpp
+++ b/src/mongo/db/log_process_details.cpp
@@ -41,7 +41,6 @@
#include "mongo/util/net/ssl_manager.h"
#include "mongo/util/processinfo.h"
#include "mongo/util/version.h"
-#include "mongo/util/version_reporting.h"
namespace mongo {
diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp
index 3fb50aa61a1..ecfa025d929 100644
--- a/src/mongo/db/mongod_options.cpp
+++ b/src/mongo/db/mongod_options.cpp
@@ -52,7 +52,6 @@
#include "mongo/util/net/ssl_options.h"
#include "mongo/util/options_parser/startup_options.h"
#include "mongo/util/version.h"
-#include "mongo/util/version_reporting.h"
namespace mongo {
diff --git a/src/mongo/dbtests/framework.cpp b/src/mongo/dbtests/framework.cpp
index 810dc1060a0..29cfa2dd608 100644
--- a/src/mongo/dbtests/framework.cpp
+++ b/src/mongo/dbtests/framework.cpp
@@ -52,7 +52,7 @@
#include "mongo/util/concurrency/mutex.h"
#include "mongo/util/exit.h"
#include "mongo/util/log.h"
-#include "mongo/util/version_reporting.h"
+#include "mongo/util/version.h"
namespace moe = mongo::optionenvironment;
diff --git a/src/mongo/dbtests/perftests.cpp b/src/mongo/dbtests/perftests.cpp
index a7bceba7fc0..b10b5005071 100644
--- a/src/mongo/dbtests/perftests.cpp
+++ b/src/mongo/dbtests/perftests.cpp
@@ -65,7 +65,6 @@
#include "mongo/util/mmap.h"
#include "mongo/util/timer.h"
#include "mongo/util/version.h"
-#include "mongo/util/version_reporting.h"
#include "mongo/db/concurrency/lock_state.h"
#if (__cplusplus >= 201103L)
diff --git a/src/mongo/installer/msi/SConscript b/src/mongo/installer/msi/SConscript
index 6468bd9d155..eb972012ba7 100644
--- a/src/mongo/installer/msi/SConscript
+++ b/src/mongo/installer/msi/SConscript
@@ -4,7 +4,6 @@ import os
Import("env")
Import("windows")
-Import("mongoCodeVersion")
Import("s3push")
Import("has_option")
@@ -83,7 +82,7 @@ else:
sources = ["wxs/" + file for file in sourcesList]
objects = ["$BUILD_DIR/msi/" + file.replace(".wxs", ".wixobj") for file in sourcesList]
-full_version = mongoCodeVersion.partition('-')[0]
+full_version = env['MONGO_VERSION'].partition('-')[0]
# major version is the x.y, not the x.y.z
major_version = full_version
diff --git a/src/mongo/s/version_mongos.cpp b/src/mongo/s/version_mongos.cpp
index e724bf23d07..bc936cc27f3 100644
--- a/src/mongo/s/version_mongos.cpp
+++ b/src/mongo/s/version_mongos.cpp
@@ -39,7 +39,6 @@
#include "mongo/util/log.h"
#include "mongo/util/net/sock.h"
#include "mongo/util/version.h"
-#include "mongo/util/version_reporting.h"
namespace mongo {
diff --git a/src/mongo/shell/shell_utils.cpp b/src/mongo/shell/shell_utils.cpp
index ee489a75dd4..6969380112d 100644
--- a/src/mongo/shell/shell_utils.cpp
+++ b/src/mongo/shell/shell_utils.cpp
@@ -43,7 +43,7 @@
#include "mongo/util/processinfo.h"
#include "mongo/util/quick_exit.h"
#include "mongo/util/text.h"
-#include "mongo/util/version_reporting.h"
+#include "mongo/util/version.h"
namespace mongo {
diff --git a/src/mongo/util/version.cpp b/src/mongo/util/version.cpp
deleted file mode 100644
index 915d983105c..00000000000
--- a/src/mongo/util/version.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-// @file version.cpp
-
-/* Copyright 2009 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects
- * for all of the code used other than as permitted herein. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version. If you
- * delete this exception statement from all source files in the program,
- * then also delete it in the license file.
- */
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/util/version.h"
-
-#include "mongo/base/parse_number.h"
-#include "mongo/db/jsobj.h"
-#include "mongo/util/mongoutils/str.h"
-
-namespace mongo {
-
- using std::string;
- using std::stringstream;
-
- /* Approved formats for versionString:
- * 1.2.3
- * 1.2.3-pre-
- * 1.2.3-rc4 (rc0 up to rc49)
- * 1.2.3-rc4-pre-
- * If you really need to do something else you'll need to fix _versionArray()
- */
- const char versionString[] = "3.0.5-pre-";
-
- // See unit test for example outputs
- BSONArray toVersionArray(const char* version){
- // this is inefficient, but cached so it doesn't matter
- BSONArrayBuilder b;
- string curPart;
- const char* c = version;
- int finalPart = 0; // 0 = final release, -100 = pre, -50 to -1 = -50 + X for rcX
- do { //walks versionString including NUL byte
- if (!(*c == '.' || *c == '-' || *c == '\0')){
- curPart += *c;
- continue;
- }
-
- int num;
- if ( parseNumberFromString( curPart, &num ).isOK() ) {
- b.append(num);
- }
- else if (curPart.empty()){
- verify(*c == '\0');
- break;
- }
- else if (str::startsWith(curPart, "rc")){
- int rc;
- invariantOK(parseNumberFromString( curPart.substr(2), &rc ));
- invariant(rc >= 0);
- invariant(rc < 50); // Need to adjust calculation if we pass this.
- finalPart = -50 + rc;
- break;
- }
- else if (curPart == "pre"){
- finalPart = -100;
- break;
- }
-
- curPart = "";
- } while (*c++);
-
- b.append(finalPart);
- return b.arr();
- }
-
- bool isSameMajorVersion( const char* version ) {
-
- BSONArray remoteVersionArray = toVersionArray( version );
-
- BSONObjIterator remoteIt(remoteVersionArray);
- BSONObjIterator myIt(versionArray);
-
- // Compare only the first two fields of the version
- int compareLen = 2;
- while (compareLen > 0 && remoteIt.more() && myIt.more()) {
- if (remoteIt.next().numberInt() != myIt.next().numberInt()) break;
- compareLen--;
- }
-
- return compareLen == 0;
- }
-
- const BSONArray versionArray = toVersionArray(versionString);
-
- string mongodVersion() {
- stringstream ss;
- ss << "db version v" << versionString;
- return ss.str();
- }
-
-#ifndef _SCONS
- //
- // The following implementations are provided for use when buildinfo.cpp is not autogenerated.
- //
-
- const char * gitVersion() { return "not-scons"; }
- const char * compiledJSEngine() { return ""; }
- const char * allocator() { return ""; }
- const char * loaderFlags() { return ""; }
- const char * compilerFlags() { return ""; }
-
-#if defined(_WIN32)
-
-#else // defined(_WIN32)
- string sysInfo() { return ""; }
-
-#endif // defined(_WIN32)
-#endif // !defined(_SCONS)
-
-} // namespace mongo
diff --git a/src/mongo/util/version_reporting.cpp b/src/mongo/util/version.cpp.in
index b3100c03123..11d1372bd75 100644
--- a/src/mongo/util/version_reporting.cpp
+++ b/src/mongo/util/version.cpp.in
@@ -31,70 +31,86 @@
#include "mongo/platform/basic.h"
-#include "mongo/util/version_reporting.h"
-
+#include <initializer_list>
#include <boost/version.hpp>
#include <sstream>
#include <string>
+#include "mongo/base/parse_number.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/jsobj.h"
#include "mongo/util/debug_util.h"
#include "mongo/util/log.h"
-#include "mongo/util/net/ssl_manager.h"
+#include "mongo/util/mongoutils/str.h"
#include "mongo/util/version.h"
+#ifdef MONGO_SSL
+#include <openssl/crypto.h>
+#endif
+
+#include <pcrecpp.h>
+#include <cstdlib>
namespace mongo {
- using std::endl;
using std::string;
using std::stringstream;
- void printGitVersion() { log() << "git version: " << gitVersion() << endl; }
-
- const std::string openSSLVersion(const std::string &prefix, const std::string &suffix) {
- return getSSLVersion(prefix, suffix);
- }
-
- void printOpenSSLVersion() {
-#ifdef MONGO_SSL
- log() << openSSLVersion("OpenSSL version: ") << endl;
-#endif
+ const char versionString[] = "@mongo_version@";
+ const char * gitVersion() { return "@mongo_git_version@"; }
+ const char * compiledJSEngine() { return "@buildinfo_js_engine@"; }
+ const char * allocator() { return "@buildinfo_allocator@"; }
+ const char * compilerFlags() { return "@buildinfo_compiler_flags@"; }
+ const char * loaderFlags() { return "@buildinfo_loader_flags@"; }
+ const char * sysInfo() { return "@buildinfo_sysinfo@ BOOST_LIB_VERSION=" BOOST_LIB_VERSION ; }
+
+ const int kMongoVersionMajor = @mongo_version_major@;
+ const int kMongoVersionMinor = @mongo_version_minor@;
+ const int kMongoVersionPatch = @mongo_version_patch@;
+ const int kMongoVersionExtra = @mongo_version_extra@;
+ const char kMongoVersionExtraStr[] = "@mongo_version_extra_str@";
+
+ bool isSameMajorVersion(const char* version) {
+ int major = -1, minor = -1;
+ pcrecpp::RE ver_regex("^(\\d+)\\.(\\d+)\\.");
+ ver_regex.PartialMatch(version, &major, &minor);
+
+ if(major == -1 || minor == -1)
+ return false;
+ return (major == kMongoVersionMajor && minor == kMongoVersionMinor);
}
-#ifndef _SCONS
-#if defined(_WIN32)
- string sysInfo() {
+ string mongodVersion() {
stringstream ss;
- ss << "not-scons win";
- ss << " mscver:" << _MSC_FULL_VER << " built:" << __DATE__;
- ss << " boostver:" << BOOST_VERSION;
-#if( !defined(_MT) )
-#error _MT is not defined
-#endif
- ss << (sizeof(char *) == 8 ? " 64bit" : " 32bit");
+ ss << "db version v" << versionString;
return ss.str();
}
-#else
- string sysInfo() { return ""; }
+ void printGitVersion() { log() << "git version: " << gitVersion(); }
+
+ const std::string openSSLVersion(const std::string &prefix, const std::string &suffix) {
+#ifndef MONGO_SSL
+ return "";
+#else
+ return prefix + SSLeay_version(SSLEAY_VERSION) + suffix;
#endif
+ }
+
+ void printOpenSSLVersion() {
+#ifdef MONGO_CONFIG_SSL
+ log() << openSSLVersion("OpenSSL version: ");
#endif
+ }
#if defined(_WIN32)
- std::string targetMinOS() {
- stringstream ss;
-#if (NTDDI_VERSION >= 0x06010000)
- ss << "Windows 7/Windows Server 2008 R2";
-#elif (NTDDI_VERSION >= 0x05020200)
- ss << "Windows Server 2003 SP2";
-#elif (NTDDI_VERSION >= 0x05010300)
- ss << "Windows XP SP3";
+ const char * targetMinOS() {
+#if (NTDDI_VERSION >= NTDDI_WIN7)
+ return "Windows 7/Windows Server 2008 R2";
+#elif (NTDDI_VERSION >= NTDDI_VISTA)
+ return "Windows Vista/Windows Server 2008";
#else
-#error This targetted Windows version is not supported
+#error This targeted Windows version is not supported
#endif // NTDDI_VERSION
- return ss.str();
}
void printTargetMinOS() {
@@ -102,12 +118,12 @@ namespace mongo {
}
#endif // _WIN32
- void printSysInfo() {
- log() << "build info: " << sysInfo() << endl;
+ void printAllocator() {
+ log() << "allocator: " << allocator() << std::endl;
}
- void printAllocator() {
- log() << "allocator: " << allocator() << endl;
+ void printSysInfo() {
+ log() << "build info: " << sysInfo() << std::endl;
}
void appendBuildInfo(BSONObjBuilder& result) {
@@ -117,14 +133,19 @@ namespace mongo {
<< "targetMinOS" << targetMinOS()
#endif
<< "OpenSSLVersion" << openSSLVersion()
- << "sysInfo" << sysInfo()
- << "loaderFlags" << loaderFlags()
+ << "sysInfo" << sysInfo();
+
+ BSONArrayBuilder versionArray(result.subarrayStart("versionArray"));
+ versionArray << kMongoVersionMajor
+ << kMongoVersionMinor
+ << kMongoVersionPatch
+ << kMongoVersionExtra;
+ versionArray.done();
+
+ result << "loaderFlags" << loaderFlags()
<< "compilerFlags" << compilerFlags()
<< "allocator" << allocator()
- << "versionArray" << versionArray
<< "javascriptEngine" << compiledJSEngine()
-/*TODO: add this back once the module system is in place -- maybe once we do something like serverstatus with callbacks*/
-// << "interpreterVersion" << globalScriptEngine->getInterpreterVersionString()
<< "bits" << ( sizeof( int* ) == 4 ? 32 : 64 );
result.appendBool( "debug" , debug );
result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize);
diff --git a/src/mongo/util/version.h b/src/mongo/util/version.h
index 1de46d666e6..324a420b3ee 100644
--- a/src/mongo/util/version.h
+++ b/src/mongo/util/version.h
@@ -34,15 +34,14 @@
#include "mongo/bson/bsonobj.h"
namespace mongo {
- struct BSONArray;
-
// mongo version
extern const char versionString[];
- extern const BSONArray versionArray;
+ extern const int versionNumber;
std::string mongodVersion();
- // Convert a version std::string into a numeric array
- BSONArray toVersionArray(const char* version);
+ // mongo git version
+ const char* gitVersion();
+ void printGitVersion();
// Checks whether another version is the same major version as us
bool isSameMajorVersion(const char* version);
@@ -52,8 +51,31 @@ namespace mongo {
const char * allocator();
const char * loaderFlags();
const char * compilerFlags();
- std::string sysInfo();
+ const char * sysInfo();
+ const std::string openSSLVersion(
+ const std::string& prefix = "",
+ const std::string& suffix = ""
+ );
+
+ void printAllocator();
+ void printGitVersion();
+ void printOpenSSLVersion();
+ void printSysInfo();
+ void printTargetMinOS();
+
+ extern const int kMongoVersionMajor;
+ extern const int kMongoVersionMinor;
+ extern const int kMongoVersionPatch;
+ extern const int kMongoVersionExtra;
+ extern const char kMongoVersionExtraStr[];
+
+ void appendBuildInfo(BSONObjBuilder& result);
+ extern const int kMongoVersionMajor;
+ extern const int kMongoVersionMinor;
+ extern const int kMongoVersionPatch;
+ extern const int kMongoVersionExtra;
+ extern const char kMongoVersionExtraStr[];
} // namespace mongo
#endif // UTIL_VERSION_HEADER
diff --git a/src/mongo/util/version_reporting.h b/src/mongo/util/version_reporting.h
deleted file mode 100644
index 278a2ec0e69..00000000000
--- a/src/mongo/util/version_reporting.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
-* Copyright (C) 2012 10gen Inc.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Affero General Public License, version 3,
-* as published by the Free Software Foundation.
-*
-* 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 Affero General Public License for more details.
-*
-* You should have received a copy of the GNU Affero General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* As a special exception, the copyright holders give permission to link the
-* code of portions of this program with the OpenSSL library under certain
-* conditions as described in each individual source file and distribute
-* linked combinations including the program with the OpenSSL library. You
-* must comply with the GNU Affero General Public License in all respects
-* for all of the code used other than as permitted herein. If you modify
-* file(s) with this exception, you may extend this exception to your
-* version of the file(s), but you are not obligated to do so. If you do not
-* wish to do so, delete this exception statement from your version. If you
-* delete this exception statement from all source files in the program,
-* then also delete it in the license file.
-*/
-
-#pragma once
-
-#include <string>
-
-namespace mongo {
- class BSONObjBuilder;
-
- void appendBuildInfo(BSONObjBuilder& result);
-
- const char * gitVersion();
- const char * compiledJSEngine();
- const char * allocator();
- const char * loaderFlags();
- const char * compilerFlags();
-
- void printGitVersion();
-
- const std::string openSSLVersion(const std::string &prefix = "", const std::string &suffix = "");
- void printOpenSSLVersion();
-
- std::string sysInfo();
- void printSysInfo();
- void printTargetMinOS();
- void printAllocator();
-
- void show_warnings();
-
-} // namespace mongo
diff --git a/src/mongo/util/version_test.cpp b/src/mongo/util/version_test.cpp
deleted file mode 100644
index 7764adae64e..00000000000
--- a/src/mongo/util/version_test.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright 2013 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects
- * for all of the code used other than as permitted herein. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version. If you
- * delete this exception statement from all source files in the program,
- * then also delete it in the license file.
- */
-
-#include "mongo/db/jsobj.h"
-#include "mongo/unittest/unittest.h"
-#include "mongo/util/version.h"
-
-namespace {
-
- using mongo::toVersionArray;
-
- TEST(VersionTest, NormalCase) {
- ASSERT_EQUALS( toVersionArray("1.2.3"), BSON_ARRAY(1 << 2 << 3 << 0) );
- ASSERT_EQUALS( toVersionArray("1.2.0"), BSON_ARRAY(1 << 2 << 0 << 0) );
- ASSERT_EQUALS( toVersionArray("2.0.0"), BSON_ARRAY(2 << 0 << 0 << 0) );
- }
-
- TEST(VersionTest, PreCase) {
- ASSERT_EQUALS( toVersionArray("1.2.3-pre-"), BSON_ARRAY(1 << 2 << 3 << -100) );
- ASSERT_EQUALS( toVersionArray("1.2.0-pre-"), BSON_ARRAY(1 << 2 << 0 << -100) );
- ASSERT_EQUALS( toVersionArray("2.0.0-pre-"), BSON_ARRAY(2 << 0 << 0 << -100) );
- }
-
- TEST(VersionTest, RcCase) {
- ASSERT_EQUALS( toVersionArray("1.2.3-rc0"), BSON_ARRAY(1 << 2 << 3 << -50) );
- ASSERT_EQUALS( toVersionArray("1.2.0-rc1"), BSON_ARRAY(1 << 2 << 0 << -49) );
- ASSERT_EQUALS( toVersionArray("2.0.0-rc2"), BSON_ARRAY(2 << 0 << 0 << -48) );
- }
-
- TEST(VersionTest, RcPreCase) {
- // Note that the pre of an rc is the same as the rc itself
- ASSERT_EQUALS( toVersionArray("1.2.3-rc3-pre-"), BSON_ARRAY(1 << 2 << 3 << -47) );
- ASSERT_EQUALS( toVersionArray("1.2.0-rc4-pre-"), BSON_ARRAY(1 << 2 << 0 << -46) );
- ASSERT_EQUALS( toVersionArray("2.0.0-rc5-pre-"), BSON_ARRAY(2 << 0 << 0 << -45) );
- }
-
-} // namespace
diff --git a/version.json b/version.json
new file mode 100644
index 00000000000..db3f1225d18
--- /dev/null
+++ b/version.json
@@ -0,0 +1,3 @@
+{
+ "version": "3.0.5-pre-"
+}