sbsv2/raptor/util/install-windows/raptorinstallermaker.py
author Dean Draper <dean.draper@nokia.com>
Fri, 30 Apr 2010 10:19:33 +0100
branchfix
changeset 491 f60c4282816c
parent 338 9372474d4b07
permissions -rw-r--r--
Release note: sf bug 2174: --layer option shows errors when bld.inf missing in another layer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     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
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     3
# All rights reserved.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     4
# This component and the accompanying materials are made available
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     6
# which accompanies this distribution, and is available
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     8
#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     9
# Initial Contributors:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    10
# Nokia Corporation - initial contribution.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    11
#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    12
# Contributors:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    13
#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    14
# Description: 
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    15
#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    16
#! python
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    17
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    18
# Raptor installer maker!
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    19
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    20
import os
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    21
import os.path
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    22
import subprocess
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    23
import re
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    24
import optparse
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    25
import sys
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    26
import tempfile
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    27
import shutil
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    28
import unzip
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    29
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    30
tempdir = ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    31
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    32
parser = optparse.OptionParser()
338
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    33
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    34
parser.add_option("-s", "--sbs-home", dest="sbshome", help="Path to use as SBS_HOME environment variable. If not present the script exits.")
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    35
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    36
parser.add_option("-w", "--win32-support", dest="win32support", help="Path to Win32 support directory. If not present the script exits.")
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    37
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    38
parser.add_option("-b", "--bv", dest="bv", help="Path to Binary variation CPP \"root\" directory. Can be a full/relatitve path; prefix with \"WIN32SUPPORT\\\" to be relative to the Win32 support directory. Omitting this value will assume a default to a path inside the Win32 support directory.")
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    39
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    40
parser.add_option("-c", "--cygwin", dest="cygwin", help="Path to Cygwin \"root\" directory. Can be a full/relatitve path; prefix with \"WIN32SUPPORT\\\" to be relative to the Win32 support directory. Omitting this value will assume a default to a path inside the Win32 support directory.")
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    41
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    42
parser.add_option("-m", "--mingw", dest="mingw", help="Path to MinGW \"root\" directory. Can be a full/relatitve path; prefix with \"WIN32SUPPORT\\\" to be relative to the Win32 support directory. Omitting this value will assume a default to a path inside the Win32 support directory.")
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    43
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    44
parser.add_option("-p", "--python", dest="python", help="Path to Python \"root\" directory. Can be a full/relatitve path; prefix with \"WIN32SUPPORT\\\" to be relative to the Win32 support directory. Omitting this value will assume a default to a path inside the Win32 support directory.")
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    45
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    46
parser.add_option("--prefix", dest="versionprefix", help="A string to use as a prefix to the Raptor version string. This will be present in the Raptor installer's file name, the installer's pages as well as the in output from sbs -v.", type="string", default="")
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    47
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    48
parser.add_option("--postfix", dest="versionpostfix", help="A string to use as a postfix to the Raptor version string. This will be present in the Raptor installer's file name, the installer's pages as well as the in output from sbs -v.", type="string", default="")
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    49
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    50
(options, args) = parser.parse_args()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    51
338
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    52
# Required directories inside the win32-support repository
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    53
win32supportdirs = {"bv":"bv", "cygwin":"cygwin", "mingw":"mingw", "python":"python264"}
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    54
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
    55
if options.sbshome == None:
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    56
	print "ERROR: no SBS_HOME passed in. Exiting..."
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    57
	sys.exit(2)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    58
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
    59
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
    60
	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
    61
	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
    62
else:
338
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    63
	# Check for command line overrides to defaults
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    64
	for directory in win32supportdirs:
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    65
		print "TEST %s" % directory
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    66
		value = getattr(options,directory)
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    67
		print "value =  %s" % str(value)
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    68
		if value != None: # Command line override
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    69
			if value.lower().startswith("win32support"):
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    70
				# Strip off "WIN32SUPPORT\" and join to Win32 support location
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    71
				win32supportdirs[directory] = os.path.join(options.win32support, value[13:]) 
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    72
			else:
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    73
				# Relative to current directory
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    74
				win32supportdirs[directory] = value
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    75
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    76
		else: # Use default location
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    77
			win32supportdirs[directory] = os.path.join(options.win32support, win32supportdirs[directory])
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    78
	
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    79
	print "\n\nwin32supportdirs = %s\n\n" % win32supportdirs
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    80
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    81
	# Check that all the specified directories exist and exit if any of them is missing.
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    82
	for directory in win32supportdirs:
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    83
		dir = win32supportdirs[directory]
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    84
		if os.path.isdir(dir):
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    85
			print "Found directory %s" % dir
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
    86
		else:
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
    87
			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
    88
			sys.exit(2)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    89
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
    90
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
    91
	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
    92
	shellenv["PYTHONPATH"] = os.path.join(sbshome, "python")
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    93
	
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
    94
	raptorversioncommand = "python -c \"import raptor_version; print raptor_version.numericversion()\""
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    95
	
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
    96
	# Raptor version is obtained from raptor_version module's numericversion function.
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    97
	sbs_version_matcher = re.compile(".*(\d+\.\d+\.\d+).*", re.I)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    98
	
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    99
	# 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
   100
	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
   101
	raptorversion = ""
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   102
	# 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
   103
	for line in versioncommand.stdout.readlines():
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   104
		res = sbs_version_matcher.match(line)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   105
		if res:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   106
			raptorversion = res.group(1)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   107
			print "Successfully determined Raptor version %s" % raptorversion
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   108
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
   109
	versioncommand.wait() # Wait for process to end
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   110
	
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   111
	raptorversion_nsis_header_string = "# Raptor version file\n\n!define RAPTOR_VERSION %s\n" % raptorversion
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   112
	
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   113
	fh = open("raptorversion.nsh", "w")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   114
	fh.write(raptorversion_nsis_header_string)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   115
	fh.close()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   116
	print "Wrote raptorversion.nsh"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   117
	return 0
338
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   118
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   119
def generateinstallerversion(sbshome = None):
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   120
	shellenv = os.environ.copy()
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   121
	shellenv["PYTHONPATH"] = os.path.join(sbshome, "python")
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   122
	
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   123
	raptorversioncommand = "python -c \"import raptor_version; print raptor_version.numericversion()\""
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   124
	
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   125
	# Raptor version is obtained from raptor_version module's numericversion function.
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   126
	sbs_version_matcher = re.compile(".*(\d+\.\d+\.\d+).*", re.I)
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   127
	
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   128
	# Create Raptor subprocess
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   129
	versioncommand = subprocess.Popen(raptorversioncommand, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=shellenv)
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   130
	raptorversion = ""
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   131
	# Get all the lines matching the RE
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   132
	for line in versioncommand.stdout.readlines():
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   133
		res = sbs_version_matcher.match(line)
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   134
		if res:
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   135
			raptorversion = res.group(1)
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   136
			print "Successfully determined Raptor version %s" % raptorversion
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   137
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   138
	versioncommand.wait() # Wait for process to end
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   139
	
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   140
	return raptorversion
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   141
	
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   142
def unzipnsis(pathtozip):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   143
    global tempdir
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   144
    tempdir = tempfile.mkdtemp()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   145
    un = unzip.unzip()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   146
    print "Unzipping NSIS to %s..." % tempdir
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   147
    un.extract(pathtozip, tempdir)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   148
    print "Done."
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   149
    
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   150
    return os.path.join(tempdir, "NSIS", "makensis.exe")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   151
    
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   152
def runmakensis(nsiscommand):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   153
	# Create makensis subprocess
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   154
	print "Running NSIS command\n%s" % nsiscommand
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   155
	makensis = subprocess.Popen(nsiscommand, shell=True)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   156
	makensis.wait() # Wait for process to end
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   157
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   158
def cleanup():
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   159
	""" Clean up tempdir """
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   160
	global tempdir
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   161
	print "Cleaning up temporary directory %s" % tempdir
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   162
	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
   163
	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
   164
		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
   165
		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
   166
	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
   167
		print "ERROR: failed to remove raptorversion.nsh - remove manually if needed."
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   168
	print "Done."
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   169
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   170
makensispath = unzipnsis(".\\NSIS.zip")
338
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   171
# generateinstallerversionheader(options.sbshome)
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   172
raptorversion = options.versionprefix + generateinstallerversion(options.sbshome) + options.versionpostfix
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   173
nsiscommand = makensispath + " /DRAPTOR_LOCATION=%s /DBV_LOCATION=%s /DCYGWIN_LOCATION=%s /DMINGW_LOCATION=%s /DPYTHON_LOCATION=%s /DRAPTOR_VERSION=%s raptorinstallerscript.nsi" % (options.sbshome, 
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   174
				win32supportdirs["bv"],
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   175
				win32supportdirs["cygwin"],
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   176
				win32supportdirs["mingw"],
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   177
				win32supportdirs["python"],
9372474d4b07 Updates to Raptor Windows installer maker tool.
Daniel Jacobs <daniel.jacobs@nokia.com>
parents: 143
diff changeset
   178
				raptorversion)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   179
print "nsiscommand = %s" % nsiscommand
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   180
runmakensis(nsiscommand)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   181
cleanup()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   182