22 import configuration |
22 import configuration |
23 import buildtools |
23 import buildtools |
24 |
24 |
25 |
25 |
26 class SisPreBuilder(buildtools.PreBuilder): |
26 class SisPreBuilder(buildtools.PreBuilder): |
27 """""" |
27 """ Generates a set of build commands for processing a SIS/X build |
28 def __init__(self, config): |
28 configuration file. """ |
29 buildtools.PreBuilder.__init__(self, config) |
29 def __init__(self, config_set, config_name=None): |
|
30 """ Initialisation. """ |
|
31 buildtools.PreBuilder.__init__(self, config_set) |
|
32 self._config_name = config_name |
30 |
33 |
31 def write(self, buildFilePath): |
34 def write(self, buildFilePath): |
32 sisConfigs = self.configSet.getConfigurations() |
35 """ Generate the build file that will run the actual commands. """ |
|
36 sisConfigs = self.configSet.getConfigurations(self._config_name) |
33 commandList = buildtools.CommandList() |
37 commandList = buildtools.CommandList() |
34 for config in sisConfigs: |
38 for config in sisConfigs: |
35 sis_filename = config['name'] + '.sis' |
39 if 'input' in config: |
36 if config.get('sis.name', None) != None: |
40 SisPreBuilder._write_v2(config, commandList) |
37 sis_filename = config['sis.name'] + '.sis' |
41 else: |
38 makeSisArgs = ['-v', config['name'] + '.pkg', sis_filename] |
42 SisPreBuilder._write_v1(config, commandList) |
39 makeSisCommand = buildtools.Command(config['makesis.tool'], config['path'], makeSisArgs) |
43 |
40 commandList.addCommand(makeSisCommand) |
44 self.writeBuildFile(commandList, buildFilePath) |
41 |
45 |
42 if config.get_boolean('publish.unsigned', False): |
46 @staticmethod |
43 # This is hardcoded xcopy operation that should be replaced by a more generic |
47 def _write_v1(config, commandList): |
44 # definition of tasks that can be created in build files |
48 """ v1 config that uses name and path properties. """ |
45 srcFile = os.path.join(config['path'], sis_filename) |
49 sis_filename = config['name'] + '.sis' |
46 todir = config['build.sisfiles.dir'] |
50 if config.get('sis.name', None) != None: |
47 copyCommand = buildtools.Copy(srcFile, todir) |
51 sis_filename = config['sis.name'] + '.sis' |
48 commandList.addCommand(copyCommand, newstage=True) |
52 makeSisArgs = ['-v', config['name'] + '.pkg', sis_filename] |
49 |
53 makeSisCommand = buildtools.Command(config['makesis.tool'], config['path'], makeSisArgs) |
50 sisx_filename = sis_filename + 'x' |
54 commandList.addCommand(makeSisCommand) |
51 signSisArgs = ['-v', sis_filename, sisx_filename, config['cert'], config['key']] |
55 |
52 signSisCommand = buildtools.Command(config['signsis.tool'], config['path'], signSisArgs) |
56 if config.get_boolean('publish.unsigned', False): |
53 commandList.addCommand(signSisCommand, newstage=True) |
57 srcFile = os.path.join(config['path'], sis_filename) |
54 |
|
55 # This is hardcoded xcopy operation that should be replaced by a more generic |
|
56 # definition of tasks that can be created in build files |
|
57 srcFile = os.path.join(config['path'], sisx_filename) |
|
58 todir = config['build.sisfiles.dir'] |
58 todir = config['build.sisfiles.dir'] |
59 copyCommand = buildtools.Copy(srcFile, todir) |
59 copyCommand = buildtools.Copy(srcFile, todir) |
60 commandList.addCommand(copyCommand, newstage=True) |
60 commandList.addCommand(copyCommand, newstage=True) |
61 |
61 |
62 self.writeBuildFile(commandList, buildFilePath) |
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 |