From: Michael Tremer Date: Thu, 22 Apr 2010 17:55:50 +0000 (+0200) Subject: naoki: Implemented ./make.sh batch cron. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fff4b24f4f5c64511559a0d71fa709ce81ecee39;p=ipfire-3.x.git naoki: Implemented ./make.sh batch cron. This will randomly build packages and report errors. --- diff --git a/naoki/__init__.py b/naoki/__init__.py index a3c4a9abd..239d8f598 100644 --- a/naoki/__init__.py +++ b/naoki/__init__.py @@ -2,6 +2,7 @@ import ConfigParser import os.path +import random import sys import time @@ -42,6 +43,7 @@ class Naoki(object): "shell" : self.call_shell, "repository" : self.call_repository, "generate" : self.call_generate, + "batch" : self.call_batch, } return actionmap[args.action.name](args.action) @@ -319,3 +321,39 @@ Release : %(release)s gen = chroot.Generator(self, arches.current, args.type) return gen.run() + + def call_batch(self, args): + actionmap = { + "cron" : self.call_batch_cron, + } + + return actionmap[args.action.name](args.action) + + def call_batch_cron(self, args): + packages = [] + packages_must = [] + packages_may = [] + for package in backend.parse_package_info(backend.get_package_names()): + if not package.built and package.buildable: + packages_must.append(package) + continue + + if package.buildable: + packages_may.append(package) + + packages += packages_must + + while len(packages) < 10 and packages_may: + package = random.choice(packages_may) + packages_may.remove(package) + packages.append(package) + + random.shuffle(packages) + + # Bad hack because we lack a _build method + args.packages = [p.name for p in packages] + args.onlydeps = False + args.withdeps = False + args.shell = False + + self.call_build(args)