-
Notifications
You must be signed in to change notification settings - Fork 1
/
tamarin_setup.py
73 lines (56 loc) · 2.49 KB
/
tamarin_setup.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
import sys
sys.path.append("tools")
import os
import colors
import shutil
import urllib2
# patch the tamarin working copy
apply_tamarin_path = True
# the tamarin mercurial repository url
tamarin_repository = "http://hg.mozilla.org/tamarin-redux"
# the tamarin revision that shall be used with this version of caspin
tamarin_revision = "227bc825a1bd"
# the download url for the latest ActionScript 3 Compiler version
asc_url = "ftp.mozilla.org/pub/js/tamarin/builds/asc/latest/asc.jar"
# the initial working directory
cwd = os.getcwd()
# clear the tamarin directory
if os.path.exists(cwd + "/tamarin"):
colors.println("y", "clearing tamarin directory...")
shutil.rmtree(cwd + "/tamarin")
# the mercurial command
cmd = "hg clone -r " + tamarin_revision + " " + tamarin_repository + " " + cwd + "/tamarin"
colors.println("y", "checking out tamarin...\n(this may take serveral minutes depending on your internet connection)")
# invoke the mercurial command to check out tamarin
os.system(cmd);
# apply the changes to tamarin that are necessarry via a patch
if apply_tamarin_path:
colors.println("y", "patching tamarin...")
os.chdir(cwd + "/tamarin/")
os.system("hg patch --no-commit ../tamarin_changes.diff")
os.chdir(cwd)
# on unix we can start the build process by calling the "tamarin_build.py" script
if os.name == "posix":
os.system("python tamarin_build.py")
# download asc.jar
colors.println("y", "downloading \"asc.jar\"...")
try:
jar_url = urllib2.urlopen("ftp://" + asc_url)
jar_file = open(cwd + "/tamarin/utils/asc.jar", "wb")
jar_file.write(jar_url.read())
jar_file.close()
except Exception:
colors.println("r", "FTP download failed, retrying via HTTP...")
jar_url = urllib2.urlopen("http://" + asc_url)
jar_file = open(cwd + "/tamarin/utils/asc.jar", "wb")
jar_file.write(jar_url.read())
jar_file.close()
# display some final information
if os.name == "posix":
colors.println("y", "To make use of the capin tools (cspcompile, cspgenerate, etc.) you need to set up the 'CASPIN_HOME' environment variable inside your '~home/.bash_profile' config file.")
colors.println("y", "Copy the following text to the end of the file: 'export CASPIN_HOME=" + cwd + "'")
elif os.name == "nt":
colors.println("y", "To make use of the capin tools (cspcompile, cspgenerate, etc.) you need to set up the 'CASPIN_HOME' environment variable.")
colors.println("y", "Execute the following command at the command prompt: 'setx CASPIN_HOME " + cwd + "'")
colors.println("g", "finished setup procedure...")