From 84daa40bc7600df75d93db358be94cac10452936 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Wed, 9 Dec 2015 19:56:38 -0800 Subject: bitbake: toaster: use OneToOneField instead of ForeignKey Used OneToOneField to reference BuildRequest in BRBitbake model. Fixed django warning: WARNINGS: Setting unique=True on a ForeignKey has the same effect as using a OneToOneField. (Bitbake rev: aaa4319ebbb06facb77b4ba936cf3aa2068ff238) Signed-off-by: Elliot Smith Signed-off-by: Ed Bartosh Signed-off-by: brian avery Signed-off-by: Richard Purdie --- bitbake/lib/toaster/bldcontrol/bbcontroller.py | 4 ++-- bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | 13 ++++++------- .../lib/toaster/bldcontrol/management/commands/runbuilds.py | 2 +- bitbake/lib/toaster/bldcontrol/models.py | 2 +- bitbake/lib/toaster/bldcontrol/tests.py | 6 +++--- 5 files changed, 13 insertions(+), 14 deletions(-) (limited to 'bitbake/lib/toaster/bldcontrol') diff --git a/bitbake/lib/toaster/bldcontrol/bbcontroller.py b/bitbake/lib/toaster/bldcontrol/bbcontroller.py index 781ff73d1a..1387bdaa7b 100644 --- a/bitbake/lib/toaster/bldcontrol/bbcontroller.py +++ b/bitbake/lib/toaster/bldcontrol/bbcontroller.py @@ -141,10 +141,10 @@ class BuildEnvironmentController(object): raise Exception("FIXME: Must override in order to actually start the BB server") - def setLayers(self, bbs, ls): + def setLayers(self, bitbake, ls): """ Checks-out bitbake executor and layers from git repositories. Sets the layer variables in the config file, after validating local layer paths. - The bitbakes must be a 1-length list of BRBitbake + bitbake must be a single BRBitbake instance The layer paths must be in a list of BRLayer object a word of attention: by convention, the first layer for any build will be poky! diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index 00228e9ef0..4f6f15c601 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py @@ -115,18 +115,17 @@ class LocalhostBEController(BuildEnvironmentController): return local_checkout_path - def setLayers(self, bitbakes, layers, targets): + def setLayers(self, bitbake, layers, targets): """ a word of attention: by convention, the first layer for any build will be poky! """ assert self.be.sourcedir is not None - assert len(bitbakes) == 1 # set layers in the layersource # 1. get a list of repos with branches, and map dirpaths for each layer gitrepos = {} - gitrepos[(bitbakes[0].giturl, bitbakes[0].commit)] = [] - gitrepos[(bitbakes[0].giturl, bitbakes[0].commit)].append( ("bitbake", bitbakes[0].dirpath) ) + gitrepos[(bitbake.giturl, bitbake.commit)] = [] + gitrepos[(bitbake.giturl, bitbake.commit)].append( ("bitbake", bitbake.dirpath) ) for layer in layers: # we don't process local URLs @@ -198,7 +197,7 @@ class LocalhostBEController(BuildEnvironmentController): # make sure we have a working bitbake if not os.path.exists(os.path.join(self.pokydirname, 'bitbake')): logger.debug("localhostbecontroller: checking bitbake into the poky dirname %s " % self.pokydirname) - self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbakes[0].commit, bitbakes[0].giturl, os.path.join(self.pokydirname, 'bitbake'))) + self._shellcmd("git clone -b \"%s\" \"%s\" \"%s\" " % (bitbake.commit, bitbake.giturl, os.path.join(self.pokydirname, 'bitbake'))) # verify our repositories for name, dirpath in gitrepos[(giturl, commit)]: @@ -224,7 +223,7 @@ class LocalhostBEController(BuildEnvironmentController): for target in targets: try: customrecipe = CustomImageRecipe.objects.get(name=target.target, - project=bitbakes[0].req.project) + project=bitbake.req.project) except CustomImageRecipe.DoesNotExist: continue # not a custom recipe, skip @@ -278,7 +277,7 @@ class LocalhostBEController(BuildEnvironmentController): def triggerBuild(self, bitbake, layers, variables, targets): - # set up the buid environment with the needed layers + # set up the build environment with the needed layers self.setLayers(bitbake, layers, targets) # get the bb server running with the build req id and build env id diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py index d40dedb4b0..edf71a7d7b 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py @@ -57,7 +57,7 @@ class Command(NoArgsCommand): br.save() # this triggers an async build - bec.triggerBuild(br.brbitbake_set.all(), br.brlayer_set.all(), br.brvariable_set.all(), br.brtarget_set.all()) + bec.triggerBuild(br.brbitbake, br.brlayer_set.all(), br.brvariable_set.all(), br.brtarget_set.all()) except Exception as e: logger.error("runbuilds: Error launching build %s" % e) diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py index ab41105303..a3a49ce472 100644 --- a/bitbake/lib/toaster/bldcontrol/models.py +++ b/bitbake/lib/toaster/bldcontrol/models.py @@ -106,7 +106,7 @@ class BRLayer(models.Model): layer_version = models.ForeignKey(Layer_Version, null=True) class BRBitbake(models.Model): - req = models.ForeignKey(BuildRequest, unique = True) # only one bitbake for a request + req = models.OneToOneField(BuildRequest) # only one bitbake for a request giturl = models.CharField(max_length =254) commit = models.CharField(max_length = 254) dirpath = models.CharField(max_length = 254) diff --git a/bitbake/lib/toaster/bldcontrol/tests.py b/bitbake/lib/toaster/bldcontrol/tests.py index f54cf7f366..141b42acbc 100644 --- a/bitbake/lib/toaster/bldcontrol/tests.py +++ b/bitbake/lib/toaster/bldcontrol/tests.py @@ -18,7 +18,7 @@ import subprocess import os # standard poky data hardcoded for testing -BITBAKE_LAYERS = [type('bitbake_info', (object,), { "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "", "commit": "HEAD"})] +BITBAKE_LAYER = type('bitbake_info', (object,), { "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "", "commit": "HEAD"}) POKY_LAYERS = [ type('poky_info', (object,), { "name": "meta", "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "meta", "commit": "HEAD"}), type('poky_info', (object,), { "name": "meta-yocto", "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "meta-yocto", "commit": "HEAD"}), @@ -53,7 +53,7 @@ class BEControllerTests(object): bc = self._getBEController(obe) try: # setting layers, skip any layer info - bc.setLayers(BITBAKE_LAYERS, POKY_LAYERS) + bc.setLayers(BITBAKE_LAYER, POKY_LAYERS) except NotImplementedException, e: print "Test skipped due to command not implemented yet" return True @@ -80,7 +80,7 @@ class BEControllerTests(object): layerSet = False try: # setting layers, skip any layer info - layerSet = bc.setLayers(BITBAKE_LAYERS, POKY_LAYERS) + layerSet = bc.setLayers(BITBAKE_LAYER, POKY_LAYERS) except NotImplementedException: print "Test skipped due to command not implemented yet" return True -- cgit v1.2.3-54-g00ecf