summaryrefslogtreecommitdiffstats
path: root/rpmci/artifact.py
diff options
context:
space:
mode:
Diffstat (limited to 'rpmci/artifact.py')
-rw-r--r--rpmci/artifact.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/rpmci/artifact.py b/rpmci/artifact.py
new file mode 100644
index 0000000..6a4a5cb
--- /dev/null
+++ b/rpmci/artifact.py
@@ -0,0 +1,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)