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