summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/orm/models.py2
-rw-r--r--bitbake/lib/toaster/toastergui/api.py98
2 files changed, 62 insertions, 38 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 7aaebedc2d..3a7dff8ca6 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1658,7 +1658,7 @@ class CustomImageRecipe(Recipe):
1658 1658
1659 def get_base_recipe_file(self): 1659 def get_base_recipe_file(self):
1660 """Get the base recipe file path if it exists on the file system""" 1660 """Get the base recipe file path if it exists on the file system"""
1661 path_schema_one = "%s/%s" % (self.base_recipe.layer_version.dirpath, 1661 path_schema_one = "%s/%s" % (self.base_recipe.layer_version.local_path,
1662 self.base_recipe.file_path) 1662 self.base_recipe.file_path)
1663 1663
1664 path_schema_two = self.base_recipe.file_path 1664 path_schema_two = self.base_recipe.file_path
diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py
index 88d6aa7f68..cb8f0f3127 100644
--- a/bitbake/lib/toaster/toastergui/api.py
+++ b/bitbake/lib/toaster/toastergui/api.py
@@ -18,6 +18,7 @@
18 18
19# Please run flake8 on this file before sending patches 19# Please run flake8 on this file before sending patches
20 20
21import os
21import re 22import re
22import logging 23import logging
23import json 24import json
@@ -28,7 +29,7 @@ from orm.models import LayerVersionDependency, LayerSource, ProjectLayer
28from orm.models import Recipe, CustomImageRecipe, CustomImagePackage 29from orm.models import Recipe, CustomImageRecipe, CustomImagePackage
29from orm.models import Layer, Target, Package, Package_Dependency 30from orm.models import Layer, Target, Package, Package_Dependency
30from orm.models import ProjectVariable 31from orm.models import ProjectVariable
31from bldcontrol.models import BuildRequest 32from bldcontrol.models import BuildRequest, BuildEnvironment
32from bldcontrol import bbcontroller 33from bldcontrol import bbcontroller
33 34
34from django.http import HttpResponse, JsonResponse 35from django.http import HttpResponse, JsonResponse
@@ -509,6 +510,27 @@ class XhrCustomRecipe(View):
509 (tpackage.package.name, e)) 510 (tpackage.package.name, e))
510 pass 511 pass
511 512
513 # pre-create layer directory structure, so that other builds
514 # are not blocked by this new recipe dependecy
515 # NOTE: this is parallel code to 'localhostbecontroller.py'
516 be = BuildEnvironment.objects.all()[0]
517 layerpath = os.path.join(be.builddir,
518 CustomImageRecipe.LAYER_NAME)
519 for name in ("conf", "recipes"):
520 path = os.path.join(layerpath, name)
521 if not os.path.isdir(path):
522 os.makedirs(path)
523 # pre-create layer.conf
524 config = os.path.join(layerpath, "conf", "layer.conf")
525 if not os.path.isfile(config):
526 with open(config, "w") as conf:
527 conf.write('BBPATH .= ":${LAYERDIR}"\nBBFILES += "${LAYERDIR}/recipes/*.bb"\n')
528 # pre-create new image's recipe file
529 recipe_path = os.path.join(layerpath, "recipes", "%s.bb" %
530 recipe.name)
531 with open(recipe_path, "w") as recipef:
532 recipef.write(recipe.generate_recipe_file_contents())
533
512 return JsonResponse( 534 return JsonResponse(
513 {"error": "ok", 535 {"error": "ok",
514 "packages": recipe.get_all_packages().count(), 536 "packages": recipe.get_all_packages().count(),
@@ -752,7 +774,6 @@ class XhrCustomRecipePackages(View):
752 return error_response("Package %s not found in excludes" 774 return error_response("Package %s not found in excludes"
753 " but was in included list" % 775 " but was in included list" %
754 package.name) 776 package.name)
755
756 else: 777 else:
757 recipe.appends_set.add(package) 778 recipe.appends_set.add(package)
758 # Make sure that package is not in the excludes set 779 # Make sure that package is not in the excludes set
@@ -760,26 +781,27 @@ class XhrCustomRecipePackages(View):
760 recipe.excludes_set.remove(package) 781 recipe.excludes_set.remove(package)
761 except: 782 except:
762 pass 783 pass
763 # Add the dependencies we think will be added to the recipe 784
764 # as a result of appending this package. 785 # Add the dependencies we think will be added to the recipe
765 # TODO this should recurse down the entire deps tree 786 # as a result of appending this package.
766 for dep in package.package_dependencies_source.all_depends(): 787 # TODO this should recurse down the entire deps tree
788 for dep in package.package_dependencies_source.all_depends():
789 try:
790 cust_package = CustomImagePackage.objects.get(
791 name=dep.depends_on.name)
792
793 recipe.includes_set.add(cust_package)
767 try: 794 try:
768 cust_package = CustomImagePackage.objects.get( 795 # When adding the pre-requisite package, make
769 name=dep.depends_on.name) 796 # sure it's not in the excluded list from a
770 797 # prior removal.
771 recipe.includes_set.add(cust_package) 798 recipe.excludes_set.remove(cust_package)
772 try: 799 except package.DoesNotExist:
773 # When adding the pre-requisite package, make 800 # Don't care if the package had never been excluded
774 # sure it's not in the excluded list from a 801 pass
775 # prior removal. 802 except:
776 recipe.excludes_set.remove(cust_package) 803 logger.warning("Could not add package's suggested"
777 except package.DoesNotExist: 804 "dependencies to the list")
778 # Don't care if the package had never been excluded
779 pass
780 except:
781 logger.warning("Could not add package's suggested"
782 "dependencies to the list")
783 return JsonResponse({"error": "ok"}) 805 return JsonResponse({"error": "ok"})
784 806
785 def delete(self, request, *args, **kwargs): 807 def delete(self, request, *args, **kwargs):
@@ -797,22 +819,24 @@ class XhrCustomRecipePackages(View):
797 recipe.excludes_set.add(package) 819 recipe.excludes_set.add(package)
798 else: 820 else:
799 recipe.appends_set.remove(package) 821 recipe.appends_set.remove(package)
800 all_current_packages = recipe.get_all_packages() 822
801 823 # remove dependencies as well
802 reverse_deps_dictlist = self._get_all_dependents( 824 all_current_packages = recipe.get_all_packages()
803 package.pk, 825
804 all_current_packages) 826 reverse_deps_dictlist = self._get_all_dependents(
805 827 package.pk,
806 ids = [entry['pk'] for entry in reverse_deps_dictlist] 828 all_current_packages)
807 reverse_deps = CustomImagePackage.objects.filter(id__in=ids) 829
808 for r in reverse_deps: 830 ids = [entry['pk'] for entry in reverse_deps_dictlist]
809 try: 831 reverse_deps = CustomImagePackage.objects.filter(id__in=ids)
810 if r.id in included_packages: 832 for r in reverse_deps:
811 recipe.excludes_set.add(r) 833 try:
812 else: 834 if r.id in included_packages:
813 recipe.appends_set.remove(r) 835 recipe.excludes_set.add(r)
814 except: 836 else:
815 pass 837 recipe.appends_set.remove(r)
838 except:
839 pass
816 840
817 return JsonResponse({"error": "ok"}) 841 return JsonResponse({"error": "ok"})
818 except CustomImageRecipe.DoesNotExist: 842 except CustomImageRecipe.DoesNotExist: