587
|
1 |
#============================================================================
|
|
2 |
#Name : sis.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
588
|
19 |
""" SIS """
|
587
|
20 |
|
|
21 |
import os
|
|
22 |
import buildtools
|
|
23 |
|
|
24 |
|
|
25 |
class SisPreBuilder(buildtools.PreBuilder):
|
|
26 |
""" Generates a set of build commands for processing a SIS/X build
|
|
27 |
configuration file. """
|
|
28 |
def __init__(self, config_set, config_name=None):
|
|
29 |
""" Initialisation. """
|
|
30 |
buildtools.PreBuilder.__init__(self, config_set)
|
|
31 |
self._config_name = config_name
|
|
32 |
|
|
33 |
def write(self, buildFilePath):
|
|
34 |
""" Generate the build file that will run the actual commands. """
|
|
35 |
sisConfigs = self.configSet.getConfigurations(self._config_name)
|
|
36 |
commandList = buildtools.CommandList()
|
|
37 |
for config in sisConfigs:
|
|
38 |
if 'input' in config:
|
|
39 |
SisPreBuilder._write_v2(config, commandList)
|
|
40 |
else:
|
|
41 |
SisPreBuilder._write_v1(config, commandList)
|
|
42 |
|
|
43 |
self.writeBuildFile(commandList, buildFilePath)
|
|
44 |
|
|
45 |
@staticmethod
|
|
46 |
def _write_v1(config, commandList):
|
|
47 |
""" v1 config that uses name and path properties. """
|
|
48 |
sis_filename = config['name'] + '.sis'
|
|
49 |
if config.get('sis.name', None) != None:
|
|
50 |
sis_filename = config['sis.name'] + '.sis'
|
|
51 |
makeSisArgs = ['-v', config['name'] + '.pkg', sis_filename]
|
|
52 |
makeSisCommand = buildtools.Command(config['makesis.tool'], config['path'], makeSisArgs)
|
|
53 |
commandList.addCommand(makeSisCommand)
|
|
54 |
|
|
55 |
if config.get_boolean('publish.unsigned', False):
|
|
56 |
srcFile = os.path.join(config['path'], sis_filename)
|
|
57 |
todir = config['build.sisfiles.dir']
|
|
58 |
copyCommand = buildtools.Copy(srcFile, todir)
|
|
59 |
commandList.addCommand(copyCommand, newstage=True)
|
|
60 |
|
|
61 |
sisx_filename = sis_filename + 'x'
|
|
62 |
signSisArgs = ['-v', sis_filename, sisx_filename, config['cert'], config['key']]
|
|
63 |
signSisCommand = buildtools.Command(config['signsis.tool'], config['path'], signSisArgs)
|
|
64 |
commandList.addCommand(signSisCommand, newstage=True)
|
|
65 |
|
|
66 |
# Copy content to SIS files directory
|
|
67 |
srcFile = os.path.join(config['path'], sisx_filename)
|
|
68 |
todir = config['build.sisfiles.dir']
|
|
69 |
copyCommand = buildtools.Copy(srcFile, todir)
|
|
70 |
commandList.addCommand(copyCommand, newstage=True)
|
|
71 |
|
|
72 |
@staticmethod
|
|
73 |
def _write_v2(config, commandList):
|
|
74 |
""" v2 config that uses input and output properties. """
|
|
75 |
# Check for invalid old parameters
|
|
76 |
v1_properties = ['name', 'path', 'sis.name']
|
|
77 |
for property_ in v1_properties:
|
|
78 |
if property_ in config:
|
|
79 |
raise Exception("Invalid property %s if using new 'input' SIS configuration" % property_)
|
|
80 |
|
|
81 |
input_ = config['input']
|
588
|
82 |
(input_path, _) = os.path.split(input_)
|
587
|
83 |
(input_root, input_ext) = os.path.splitext(input_)
|
|
84 |
valid_extensions = ['.pkg', '.sis', '.sisx']
|
|
85 |
if input_ext not in valid_extensions:
|
|
86 |
raise Exception('Invalid extension for SIS configuration.')
|
|
87 |
|
|
88 |
# See if makesis needs to be run
|
|
89 |
if input_ext == '.pkg':
|
|
90 |
output = config.get('output', input_root + '.sis')
|
|
91 |
if output.endswith('.sisx'):
|
|
92 |
output = output[:-1]
|
|
93 |
# Set input for the next stage
|
|
94 |
makesis_args = ['-v', input_, output]
|
|
95 |
makesis_command = buildtools.Command(config['makesis.tool'], input_path, makesis_args)
|
|
96 |
commandList.addCommand(makesis_command)
|
|
97 |
input_ = output
|
|
98 |
|
|
99 |
# See if signsis needs to be run
|
|
100 |
if 'key' in config:
|
|
101 |
output = config.get('output', input_root + '.sisx')
|
|
102 |
signsis_args = ['-v', input_, output, config['cert'], config['key']]
|
|
103 |
signsis_command = buildtools.Command(config['signsis.tool'], input_path, signsis_args)
|
|
104 |
commandList.addCommand(signsis_command, newstage=True)
|
|
105 |
|
|
106 |
# Copy content to SIS files directory
|
|
107 |
copyCommand = buildtools.Copy(output, config['build.sisfiles.dir'])
|
|
108 |
commandList.addCommand(copyCommand, newstage=True)
|