625
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
1 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
2 |
# hudson runs this from the raptor/util/install-windows directory
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
3 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
4 |
import os
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
5 |
import re
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
6 |
import shutil
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
7 |
import subprocess
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
8 |
import sys
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
9 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
10 |
# run "hg id" to get the current branch name and tip changeset
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
11 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
12 |
hgid = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
13 |
stdout = hgid.communicate()[0]
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
14 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
15 |
if hgid.returncode == 0 and len(stdout) >= 12:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
16 |
changeset = stdout[0:12]
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
17 |
print "CHANGESET", changeset
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
18 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
19 |
prototype = ("wip" in stdout or "fix" in stdout)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
20 |
print "PROTOTYPE", prototype
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
21 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
22 |
sys.stderr.write("error: failed to get tip mercurial changeset.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
23 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
24 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
25 |
# get the raptor version string
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
26 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
27 |
sbs_v = subprocess.Popen(["../../bin/sbs", "-v"], stdout=subprocess.PIPE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
28 |
version = sbs_v.communicate()[0]
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
29 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
30 |
if sbs_v.returncode == 0:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
31 |
print "VERSION", version
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
32 |
if not changeset in version:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
33 |
sys.stderr.write("error: changeset does not match the sbs version.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
34 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
35 |
if prototype and not "PROTOTYPE" in version:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
36 |
sys.stderr.write("error: the sbs version should be marked PROTOTYPE.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
37 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
38 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
39 |
sys.stderr.write("error: failed to get sbs version.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
40 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
41 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
42 |
# find the SBS_HOME and WIN32_SUPPORT
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
43 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
44 |
if 'SBS_HOME' in os.environ:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
45 |
sbs_home = os.environ['SBS_HOME']
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
46 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
47 |
sys.stderr.write("error: no SBS_HOME is set.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
48 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
49 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
50 |
if 'WIN32_SUPPORT' in os.environ:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
51 |
win32_support = os.environ['WIN32_SUPPORT']
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
52 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
53 |
sys.stderr.write("error: no WIN32_SUPPORT is set.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
54 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
55 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
56 |
# run the Windows installer maker script
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
57 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
58 |
if prototype:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
59 |
postfix = "-PROTOTYPE-" + changeset
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
60 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
61 |
postfix = "-" + changeset
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
62 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
63 |
package_sbs = subprocess.Popen(["python", "raptorinstallermaker.py",
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
64 |
"-s", sbs_home, "-w", win32_support,
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
65 |
"--postfix=" + postfix],
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
66 |
stdout=subprocess.PIPE) #, stderr=subprocess.PIPE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
67 |
(stdout, stderr) = package_sbs.communicate()
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
68 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
69 |
if package_sbs.returncode == 0:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
70 |
match = re.search('Output: "([^"]+)"', stdout)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
71 |
zip_match = re.search('Zipoutput: "([^"]+)"', stdout)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
72 |
if match:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
73 |
tmp_archive = match.group(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
74 |
print "TMP ARCHIVE", tmp_archive
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
75 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
76 |
sys.stderr.write("error: failed to find packaged filename.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
77 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
78 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
79 |
if zip_match:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
80 |
tmp_zip_archive = zip_match.group(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
81 |
print "TMP ZIP ARCHIVE", tmp_zip_archive
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
82 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
83 |
sys.stderr.write("error: failed to find zip filename.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
84 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
85 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
86 |
sys.stderr.write("error: failed to create windows package of sbs.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
87 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
88 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
89 |
# move the results to WORKSPACE
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
90 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
91 |
if 'WORKSPACE' in os.environ:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
92 |
final_archive = os.path.join(os.environ['WORKSPACE'], os.path.basename(tmp_archive))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
93 |
final_zip_archive = os.path.join(os.environ['WORKSPACE'], os.path.basename(tmp_zip_archive))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
94 |
print "WORKSPACE ARCHIVE", final_archive
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
95 |
print "WORKSPACE ZIP ARCHIVE", final_zip_archive
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
96 |
else:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
97 |
sys.stderr.write("error: no WORKSPACE is set.\n")
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
98 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
99 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
100 |
try:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
101 |
shutil.move(tmp_archive, final_archive)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
102 |
except Error, err:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
103 |
sys.stderr.write("error: could not rename '%s' as '%s'.\n" % (tmp_archive, final_archive))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
104 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
105 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
106 |
try:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
107 |
shutil.move(tmp_zip_archive, final_zip_archive)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
108 |
except Error, err:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
109 |
sys.stderr.write("error: could not rename '%s' as '%s'.\n" % (tmp_zip_archive, final_zip_archive))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
110 |
sys.exit(1)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
111 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
112 |
# the end
|