diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-12-09 11:55:26 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-12-09 11:55:26 -0500 |
commit | 5660a25e9bf3bb86e2c84a3581154efc2d7d1b11 (patch) | |
tree | e7de302e7b16a610dcbd78d2816d1c94765aca24 | |
parent | e1b753b84d731d887919e5b010d049b1dd4604f3 (diff) | |
download | mongo-5660a25e9bf3bb86e2c84a3581154efc2d7d1b11.tar.gz |
source push script
-rw-r--r-- | buildscripts/sourcepush.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/buildscripts/sourcepush.py b/buildscripts/sourcepush.py new file mode 100644 index 00000000000..e389afb5cb0 --- /dev/null +++ b/buildscripts/sourcepush.py @@ -0,0 +1,70 @@ + +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(): + tags = run_git("tag -l").strip().split( "\n" ) + + bucket = simples3.S3Bucket( settings.bucket , settings.id , settings.key ) + + for tag in tags: + push_tag( bucket , tag , "tar" , True ) + push_tag( bucket , tag , "zip" ) + +if __name__ == "__main__": + push_all() |