summaryrefslogtreecommitdiff
path: root/buildscripts/sourcepush.py
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2010-01-31 08:32:52 +0100
committerAntonin Kral <a.kral@bobek.cz>2010-01-31 08:32:52 +0100
commit4eefaf421bfeddf040d96a3dafb12e09673423d7 (patch)
treecb2e5ccc7f98158894f977ff131949da36673591 /buildscripts/sourcepush.py
downloadmongodb-4eefaf421bfeddf040d96a3dafb12e09673423d7.tar.gz
Imported Upstream version 1.3.1
Diffstat (limited to 'buildscripts/sourcepush.py')
-rw-r--r--buildscripts/sourcepush.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/buildscripts/sourcepush.py b/buildscripts/sourcepush.py
new file mode 100644
index 0000000..e389afb
--- /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()