Commits

Anonymous committed b58449b

add rbuild integration framework and initial buildmany plugin

  • Participants
  • Parent commits 974fce0

Comments (0)

Files changed (2)

File rbuild/buildmany.py

+#
+# Copyright (c) SAS Institute, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+rBuild plugin to bring buildmany support to rBuild users.
+"""
+
+from rbuild import errors
+from rbuild import pluginapi
+from rbuild.pluginapi import command
+
+class BuildManyCommand(command.BaseCommand):
+    help = 'Build many packages in sepparate rmake jobs'
+    commands = ['buildmany', ]
+
+    def runCommand(self, handle, argSet, args):
+        _, pkgList = self.requireParameters(args, allowExtra=True)
+        results = handle.MirrorBall.buildmany(pkgList)
+
+        if not results:
+            raise errors.PluginError('pacakges failed to build')
+
+
+class BuildMany(pluginapi.Plugin):
+    def registerCommands(self):
+        self.handle.Commands.registerCommand(BuildManyCommand)

File rbuild/mb.py

+#
+# Copyright (c) SAS Institute, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+Mirrorball plugin interface.
+"""
+
+from updatebot import log
+from updatebot import build
+from updatebot import config
+
+from rbuild import pluginapi
+
+class MirrorBall(pluginapi.Plugin):
+    def initialize(self):
+        """
+        Setup initial state.
+        """
+
+        store, product = self.handle.productStore, self.handle.product
+        ui = self.handle.ui
+        cny = self.handle.facade.conary
+        rmk = self.handle.facade.rmake
+
+        activeStage = store.getActiveStageName()
+        activeLabel = product.getLabelForStage(activeStage)
+        nextStage = store.getNextStageName(activeStage)
+        nextLabel = product.getLabelForStage(nextStage)
+
+        self.conarycfg = cny.getConaryConfig()
+        self.rmakecfg, contextNames = rmk._getRmakeConfigWithContexts()
+        self.updatebotcfg = config.UpdateBotConfig()
+
+        self.updatebotcfg.archContexts = [
+            (x, None) for x in contextNames.itervalues() ]
+
+        self.conarycfg.buildLabel = cny._getLabel(activeLabel)
+
+        self.builder = build.Builder(
+            self.updatebotcfg,
+            ui,
+            conaryCfg=self.conarycfg,
+            rmakeCfg=self.rmakecfg
+        )
+
+        log.addRootLogger()
+
+    def buildmany(self, packages):
+        pkgs = set([ (x, self.conarycfg.buildLabel.asString(), None)
+            for x in packages ])
+        return self.builder.buildmany(pkgs)