summaryrefslogtreecommitdiff
blob: 8306819c2388b58a8204ae32a1815180846ebbde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python2
# Copyright 2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

"""Creates a tarball containing V8 sources based on an SVN tag."""

import optparse
import os.path
import pysvn
import shutil
import tarfile
import tempfile

import chromium_tools

parser = optparse.OptionParser(usage="%prog <v8-version>")
(options, args) = parser.parse_args()
if len(args) != 1:
	parser.error("Exactly one argument required: <v8-version>")

target_name = 'v8-%s' % args[0]

tmpdir = tempfile.mkdtemp()

try:
	checkout_dir = os.path.join(tmpdir, target_name)
	os.makedirs(checkout_dir)

	checkout_url = 'http://v8.googlecode.com/svn/tags/%s' % args[0]

	svn_client = pysvn.Client()
	svn_client.checkout(checkout_url, checkout_dir)

	version_contents = open(os.path.join(checkout_dir, 'src', 'version.cc')).read()
	actual_version = chromium_tools.v8_extract_version(version_contents)
	if actual_version != args[0]:
		print 'Version info inside version.cc does not match!'
		print 'Expected %s, got %s. Exiting' % (args[0], actual_version)
		sys.exit(1)

	archive_name = '%s.tar.gz' % target_name
	try:
		archive = tarfile.open(archive_name, 'w:gz')
		archive.add(checkout_dir, target_name, exclude=(lambda x: '.svn' in x))
	except:
		os.remove(archive_name)
		raise
	finally:
		archive.close()
finally:
	shutil.rmtree(tmpdir)
	pass