]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: toaster: use OneToOneField instead of ForeignKey
authorEd Bartosh <ed.bartosh@linux.intel.com>
Thu, 10 Dec 2015 03:56:38 +0000 (19:56 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 14 Dec 2015 23:13:07 +0000 (23:13 +0000)
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 <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/toaster/bldcontrol/bbcontroller.py
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py
bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
bitbake/lib/toaster/bldcontrol/models.py
bitbake/lib/toaster/bldcontrol/tests.py

index 781ff73d1ac32db952834dfc524d7d74b81c9a49..1387bdaa7b90f42759f2f4c0aef8ba9cd132c492 100644 (file)
@@ -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!
index 00228e9ef09de0b64ddee82793587920d92123f1..4f6f15c601b5601acaf6b2247562c3de5f796fb7 100644 (file)
@@ -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
index d40dedb4b0f25f996914ecef30f201abc5e8ffda..edf71a7d7b01521b619c3aa36f3048d0aa0aa145 100644 (file)
@@ -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)
index ab411053035e9d1f78f28f88ab6291b72af0be86..a3a49ce472de0b0c1fcad919cf328d473e789184 100644 (file)
@@ -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)
index f54cf7f366cfcfbe2dfaa00eb4ad6c611b7df59d..141b42acbc68d421cbd347cd87358760ab550b7c 100644 (file)
@@ -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