1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/usr/bin/python
# artifact.py:
# Set of RPMs built into a repository.
#
# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
# Copyright (C) 2010 Red Hat, Inc.
# Written by Colin Walters <walters@verbum.org>
FEDORA_ANONGIT_URL = 'git://pkgs.fedoraproject.org'
class BuildTarget(object):
def __init__(self, module, os, architecture):
self.module = module
self.os = os
self.architecture = architecture
def __cmp__(self, other):
i = cmp(self.module, other.module)
if i != 0:
return i
i = cmp(self.os, other.os)
if i != 0:
return i
i = cmp(self.architecture, other.architecture)
if i != 0:
return i
return 0
class Artifact(object):
def __init__(self, targets):
self.targets = targets
class ArtifactSet(object):
def __init__(self, artifacts):
self.artifacts = artifacts
def get_build_targets(self):
"""Returns unordered set of build targets."""
targets = set()
for artifact in self.artifacts:
for target in artifact.targets:
targets.add(target)
return targets
@classmethod
def from_config(cls, config, section):
artifacts_str = config.get('releases', 'artifacts')
artifact_list = map(str.strip, artifacts_str.split(' '))
artifacts = []
for artifact_name in artifact_list:
artifact_build_targets = []
config_name = artifact_name.replace('-', '_')
modules = config.get(section, 'artifact_%s_modules' % (config_name, )).split(' ')
modules = map(str.strip, modules)
os = config.get(section, 'artifact_%s_os' % (config_name, ))
architectures = config.get(section, 'artifact_%s_architectures' % (config_name, )).split(' ')
architectures = map(str.strip, architectures)
for module in modules:
for architecture in architectures:
target = BuildTarget(module, os, architecture)
artifact_build_targets.append(target)
artifacts.append(Artifact(artifact_build_targets))
return cls(artifacts)
def fedora_git_url_for_build_target(config, buildtarget):
fedora_os_master = config.get('fedora', 'master')
base = '%s/%s.git' % (FEDORA_ANONGIT_URL, buildtarget.module)
if buildtarget.os == fedora_os_master:
return base
else:
return '%s#%s/master' % (base, buildtarget.os)
|