diff options
-rwxr-xr-x | rpmci-admin (renamed from rpmci-inject-rebuild) | 6 | ||||
-rw-r--r-- | rpmci/rpmci_admin_main.py (renamed from rpmci/rpmci_inject_rebuild_main.py) | 32 | ||||
-rw-r--r-- | rpmci/rpmci_binrpm_builder_main.py | 18 |
3 files changed, 46 insertions, 10 deletions
diff --git a/rpmci-inject-rebuild b/rpmci-admin index bacbf2f..5851a96 100755 --- a/rpmci-inject-rebuild +++ b/rpmci-admin @@ -1,7 +1,7 @@ #!/usr/bin/python -# rpmci-inject-rebuild: -# Request a rebuild +# rpmci-admin: +# Administrative tools # # Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php) # Copyright (C) 2010 Red Hat, Inc. @@ -14,7 +14,7 @@ if os.path.isdir('.git'): sys.path.insert(0, os.getcwd()) import rpmci -from rpmci.rpmci_inject_rebuild_main import main +from rpmci.rpmci_admin_main import main if __name__ == '__main__': main() diff --git a/rpmci/rpmci_inject_rebuild_main.py b/rpmci/rpmci_admin_main.py index 5349be6..67f19d0 100644 --- a/rpmci/rpmci_inject_rebuild_main.py +++ b/rpmci/rpmci_admin_main.py @@ -1,7 +1,7 @@ #!/usr/bin/python -# rpmci_inject_rebuild_main.py: -# Implementation of rpmci-inject-rebuild +# rpmci_admin_main.py: +# Implementation of rpmci-admin # # Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php) # Copyright (C) 2010 Red Hat, Inc. @@ -24,7 +24,11 @@ import gio from . import artifact from . import msgqueue -def inject_rebuild(options, config, module): +def rebuild_one(options, config, args): + if len(args) != 1: + print "Usage: rebuild-one MODULE" + sys.exit(1) + module = args[0] artifact_set = artifact.ArtifactSet.from_config(config) target = None for target_iter in artifact_set.get_build_targets(): @@ -41,6 +45,15 @@ def inject_rebuild(options, config, module): vcs_msgqueue.append(msg) print "Wrote %s" % (msg.ident, ) +def rebuild_all(options, config, module): + build_msgqueue_dir = config.get('build', 'msgqueue') + build_msgqueue = msgqueue.MessageQueue(build_msgqueue_dir) + + msg = msgqueue.Message(None, {}, {'rebuild': True}) + build_msgqueue.append(msg) + + print "Wrote %s" % (msg.ident, ) + def main(): if hasattr('glib', 'threads_init'): glib.threads_init() @@ -61,12 +74,17 @@ def main(): logging.basicConfig(stream=sys.stderr, level=level) if len(args) < 1: - print "Must specify module to be rebuilt" + print "Must specify a valid command:" + print " rebuild-one MODNAME" + print " rebuild-all" opts.print_usage() sys.exit(1) - module = args[0] - - inject_rebuild(options, config, module) + if args[0] == 'rebuild-one': + rebuild_one(options, config, args[1:]) + elif args[0] == 'rebuild-all': + rebuild_all(options, config, args[1:]) + else: + print "Invalid command" sys.exit(0) diff --git a/rpmci/rpmci_binrpm_builder_main.py b/rpmci/rpmci_binrpm_builder_main.py index 3854434..d62eafb 100644 --- a/rpmci/rpmci_binrpm_builder_main.py +++ b/rpmci/rpmci_binrpm_builder_main.py @@ -36,6 +36,9 @@ class BinRPMBuilder(object): srpm_msgqueue_dir = config.get('SRPM', 'msgqueue') self._srpm_msgqueue = msgqueue.MessageQueue(srpm_msgqueue_dir) + build_msgqueue_dir = config.get('build', 'msgqueue') + self._build_msgqueue = msgqueue.MessageQueue(build_msgqueue_dir) + self._artifactset = artifact.ArtifactSet.from_config(config) self._artifact_to_repo = {} artifact_basedir = config.get('build', 'artifactdir') @@ -48,9 +51,11 @@ class BinRPMBuilder(object): def start(self): latest = self._srcrepo.get_latest_version() + logging.info("Doing an initial build now") if latest is not None: self._rebuild_to_repoversion(latest.version) self._srpm_msgqueue.connect(self._on_srpm_message) + self._build_msgqueue.connect(self._on_build_message) def _target_for_srpm(self, srpm_name): (name, ver, rest) = srpm_name.rsplit('-', 2) @@ -80,6 +85,18 @@ class BinRPMBuilder(object): arch = architecture return '%s-%s' % (mock_os, arch) + def _on_build_message(self, q, messages): + rebuild_all = False + for msg in messages: + if 'rebuild' in msg.payload: + logging.info("Processing rebuild all message") + rebuild_all = True + q.consume(msg) + + if rebuild_all: + latest_repo = self._srcrepo.get_latest_version() + self._rebuild_to_repoversion(latest_repo.version) + def _on_srpm_message(self, q, messages): msg_list = list(messages) num_msgs = len(msg_list) @@ -99,6 +116,7 @@ class BinRPMBuilder(object): exec_basedir = os.path.dirname(sys.argv[0]) for artifact in self._artifactset.artifacts: + logging.info("Preparing rebuild of artifact %r" % (artifact.name, )) artifact_srpms = set() failed = False for target in artifact.targets: |