author | timothy.murphy@nokia.com |
Sun, 14 Feb 2010 19:46:52 +0200 | |
branch | fix |
changeset 206 | 9bc64f367d8a |
parent 143 | a00bdef52597 |
child 338 | 9372474d4b07 |
permissions | -rw-r--r-- |
3 | 1 |
# |
142
26f2f0b4002b
Update Windows installation script to put Python 2.6.4 into the Windows installer.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
79
diff
changeset
|
2 |
# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 | 3 |
# All rights reserved. |
4 |
# This component and the accompanying materials are made available |
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
|
6 |
# which accompanies this distribution, and is available |
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
# |
|
9 |
# Initial Contributors: |
|
10 |
# Nokia Corporation - initial contribution. |
|
11 |
# |
|
12 |
# Contributors: |
|
13 |
# |
|
14 |
# Description: |
|
15 |
# |
|
16 |
#! python |
|
17 |
||
18 |
# Raptor installer maker! |
|
19 |
||
20 |
import os |
|
21 |
import os.path |
|
22 |
import subprocess |
|
23 |
import re |
|
24 |
import optparse |
|
25 |
import sys |
|
26 |
import tempfile |
|
27 |
import shutil |
|
28 |
import unzip |
|
29 |
||
30 |
tempdir = "" |
|
31 |
||
32 |
parser = optparse.OptionParser() |
|
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
33 |
parser.add_option("-s", "--sbs-home", dest="sbshome", |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
34 |
help="Path to use as SBS_HOME environment variable. If not present the script exits.") |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
35 |
parser.add_option("-w", "--win32-support", dest="win32support", |
143
a00bdef52597
Correct problems in raptorinstallermaker.py: ensure missing directories' names are printed rather than %s when checking Win32 support directory, and remove final reliance on SBS_HOME environment variable (use only the value passed to the -s switch).
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
142
diff
changeset
|
36 |
help="Path to Win32 support directory. If not present the script exits.") |
3 | 37 |
|
38 |
(options, args) = parser.parse_args() |
|
39 |
||
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
40 |
if options.sbshome == None: |
3 | 41 |
print "ERROR: no SBS_HOME passed in. Exiting..." |
42 |
sys.exit(2) |
|
43 |
||
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
44 |
if options.win32support == None: |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
45 |
print "ERROR: no win32support directory specified. Unable to proceed. Exiting..." |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
46 |
sys.exit(2) |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
47 |
else: |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
48 |
# Required irectories inside the win32-support repository |
142
26f2f0b4002b
Update Windows installation script to put Python 2.6.4 into the Windows installer.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
79
diff
changeset
|
49 |
win32supportdirs = ["bv", "cygwin", "mingw", "python264"] |
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
50 |
for dir in win32supportdirs: |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
51 |
if not os.path.isdir(os.path.join(options.win32support, dir)): |
143
a00bdef52597
Correct problems in raptorinstallermaker.py: ensure missing directories' names are printed rather than %s when checking Win32 support directory, and remove final reliance on SBS_HOME environment variable (use only the value passed to the -s switch).
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
142
diff
changeset
|
52 |
print "ERROR: directory %s does not exist. Cannot build installer. Exiting..." % dir |
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
53 |
sys.exit(2) |
3 | 54 |
|
55 |
def parseconfig(xmlFile="raptorinstallermaker.xml"): |
|
56 |
pass |
|
57 |
||
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
58 |
def generateinstallerversionheader(sbshome = None): |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
59 |
shellenv = os.environ.copy() |
143
a00bdef52597
Correct problems in raptorinstallermaker.py: ensure missing directories' names are printed rather than %s when checking Win32 support directory, and remove final reliance on SBS_HOME environment variable (use only the value passed to the -s switch).
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
142
diff
changeset
|
60 |
shellenv["PYTHONPATH"] = os.path.join(sbshome, "python") |
3 | 61 |
|
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
62 |
raptorversioncommand = "python -c \"import raptor_version; print raptor_version.numericversion()\"" |
3 | 63 |
|
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
64 |
# Raptor version is obtained from raptor_version module's numericversion function. |
3 | 65 |
sbs_version_matcher = re.compile(".*(\d+\.\d+\.\d+).*", re.I) |
66 |
||
67 |
# Create Raptor subprocess |
|
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
68 |
versioncommand = subprocess.Popen(raptorversioncommand, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=shellenv) |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
69 |
raptorversion = "" |
3 | 70 |
# Get all the lines matching the RE |
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
71 |
for line in versioncommand.stdout.readlines(): |
3 | 72 |
res = sbs_version_matcher.match(line) |
73 |
if res: |
|
74 |
raptorversion = res.group(1) |
|
75 |
print "Successfully determined Raptor version %s" % raptorversion |
|
76 |
||
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
77 |
versioncommand.wait() # Wait for process to end |
3 | 78 |
|
79 |
raptorversion_nsis_header_string = "# Raptor version file\n\n!define RAPTOR_VERSION %s\n" % raptorversion |
|
80 |
||
81 |
fh = open("raptorversion.nsh", "w") |
|
82 |
fh.write(raptorversion_nsis_header_string) |
|
83 |
fh.close() |
|
84 |
print "Wrote raptorversion.nsh" |
|
85 |
return 0 |
|
86 |
||
87 |
def unzipnsis(pathtozip): |
|
88 |
global tempdir |
|
89 |
tempdir = tempfile.mkdtemp() |
|
90 |
un = unzip.unzip() |
|
91 |
print "Unzipping NSIS to %s..." % tempdir |
|
92 |
un.extract(pathtozip, tempdir) |
|
93 |
print "Done." |
|
94 |
||
95 |
return os.path.join(tempdir, "NSIS", "makensis.exe") |
|
96 |
||
97 |
def runmakensis(nsiscommand): |
|
98 |
# Create makensis subprocess |
|
99 |
print "Running NSIS command\n%s" % nsiscommand |
|
100 |
makensis = subprocess.Popen(nsiscommand, shell=True) |
|
101 |
makensis.wait() # Wait for process to end |
|
102 |
||
103 |
def cleanup(): |
|
104 |
""" Clean up tempdir """ |
|
105 |
global tempdir |
|
106 |
print "Cleaning up temporary directory %s" % tempdir |
|
107 |
shutil.rmtree(tempdir,True) |
|
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
108 |
try: |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
109 |
os.remove("raptorversion.nsh") |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
110 |
print "Successfully deleted raptorversion.nsh." |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
111 |
except: |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
112 |
print "ERROR: failed to remove raptorversion.nsh - remove manually if needed." |
3 | 113 |
print "Done." |
114 |
||
115 |
makensispath = unzipnsis(".\\NSIS.zip") |
|
79
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
116 |
generateinstallerversionheader(options.sbshome) |
540de0f551cf
Updates to Raptor Installer Maker tool to take into account win32-support repository location.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents:
3
diff
changeset
|
117 |
nsiscommand = makensispath + " /DRAPTOR_LOCATION=%s /DWIN32SUPPORT=%s raptorinstallerscript.nsi" % (options.sbshome, options.win32support) |
3 | 118 |
print "nsiscommand = %s" % nsiscommand |
119 |
runmakensis(nsiscommand) |
|
120 |
cleanup() |
|
121 |