diff options
Diffstat (limited to 'import-layers/yocto-poky/bitbake/lib/toaster/toastergui/api.py')
-rw-r--r-- | import-layers/yocto-poky/bitbake/lib/toaster/toastergui/api.py | 111 |
1 files changed, 71 insertions, 40 deletions
diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastergui/api.py b/import-layers/yocto-poky/bitbake/lib/toaster/toastergui/api.py index 1a6507c3f..ab6ba69e0 100644 --- a/import-layers/yocto-poky/bitbake/lib/toaster/toastergui/api.py +++ b/import-layers/yocto-poky/bitbake/lib/toaster/toastergui/api.py @@ -18,6 +18,7 @@ # Please run flake8 on this file before sending patches +import os import re import logging import json @@ -28,7 +29,7 @@ from orm.models import LayerVersionDependency, LayerSource, ProjectLayer from orm.models import Recipe, CustomImageRecipe, CustomImagePackage from orm.models import Layer, Target, Package, Package_Dependency from orm.models import ProjectVariable -from bldcontrol.models import BuildRequest +from bldcontrol.models import BuildRequest, BuildEnvironment from bldcontrol import bbcontroller from django.http import HttpResponse, JsonResponse @@ -509,6 +510,27 @@ class XhrCustomRecipe(View): (tpackage.package.name, e)) pass + # pre-create layer directory structure, so that other builds + # are not blocked by this new recipe dependecy + # NOTE: this is parallel code to 'localhostbecontroller.py' + be = BuildEnvironment.objects.all()[0] + layerpath = os.path.join(be.builddir, + CustomImageRecipe.LAYER_NAME) + for name in ("conf", "recipes"): + path = os.path.join(layerpath, name) + if not os.path.isdir(path): + os.makedirs(path) + # pre-create layer.conf + config = os.path.join(layerpath, "conf", "layer.conf") + if not os.path.isfile(config): + with open(config, "w") as conf: + conf.write('BBPATH .= ":${LAYERDIR}"\nBBFILES += "${LAYERDIR}/recipes/*.bb"\n') + # pre-create new image's recipe file + recipe_path = os.path.join(layerpath, "recipes", "%s.bb" % + recipe.name) + with open(recipe_path, "w") as recipef: + recipef.write(recipe.generate_recipe_file_contents()) + return JsonResponse( {"error": "ok", "packages": recipe.get_all_packages().count(), @@ -752,7 +774,6 @@ class XhrCustomRecipePackages(View): return error_response("Package %s not found in excludes" " but was in included list" % package.name) - else: recipe.appends_set.add(package) # Make sure that package is not in the excludes set @@ -760,26 +781,27 @@ class XhrCustomRecipePackages(View): recipe.excludes_set.remove(package) except: pass - # Add the dependencies we think will be added to the recipe - # as a result of appending this package. - # TODO this should recurse down the entire deps tree - for dep in package.package_dependencies_source.all_depends(): + + # Add the dependencies we think will be added to the recipe + # as a result of appending this package. + # TODO this should recurse down the entire deps tree + for dep in package.package_dependencies_source.all_depends(): + try: + cust_package = CustomImagePackage.objects.get( + name=dep.depends_on.name) + + recipe.includes_set.add(cust_package) try: - cust_package = CustomImagePackage.objects.get( - name=dep.depends_on.name) - - recipe.includes_set.add(cust_package) - try: - # When adding the pre-requisite package, make - # sure it's not in the excluded list from a - # prior removal. - recipe.excludes_set.remove(cust_package) - except package.DoesNotExist: - # Don't care if the package had never been excluded - pass - except: - logger.warning("Could not add package's suggested" - "dependencies to the list") + # When adding the pre-requisite package, make + # sure it's not in the excluded list from a + # prior removal. + recipe.excludes_set.remove(cust_package) + except package.DoesNotExist: + # Don't care if the package had never been excluded + pass + except: + logger.warning("Could not add package's suggested" + "dependencies to the list") return JsonResponse({"error": "ok"}) def delete(self, request, *args, **kwargs): @@ -797,22 +819,24 @@ class XhrCustomRecipePackages(View): recipe.excludes_set.add(package) else: recipe.appends_set.remove(package) - all_current_packages = recipe.get_all_packages() - - reverse_deps_dictlist = self._get_all_dependents( - package.pk, - all_current_packages) - - ids = [entry['pk'] for entry in reverse_deps_dictlist] - reverse_deps = CustomImagePackage.objects.filter(id__in=ids) - for r in reverse_deps: - try: - if r.id in included_packages: - recipe.excludes_set.add(r) - else: - recipe.appends_set.remove(r) - except: - pass + + # remove dependencies as well + all_current_packages = recipe.get_all_packages() + + reverse_deps_dictlist = self._get_all_dependents( + package.pk, + all_current_packages) + + ids = [entry['pk'] for entry in reverse_deps_dictlist] + reverse_deps = CustomImagePackage.objects.filter(id__in=ids) + for r in reverse_deps: + try: + if r.id in included_packages: + recipe.excludes_set.add(r) + else: + recipe.appends_set.remove(r) + except: + pass return JsonResponse({"error": "ok"}) except CustomImageRecipe.DoesNotExist: @@ -874,6 +898,12 @@ class XhrProject(View): machinevar.value = request.POST['machineName'] machinevar.save() + # Distro name change + if 'distroName' in request.POST: + distrovar = prj.projectvariable_set.get(name="DISTRO") + distrovar.value = request.POST['distroName'] + distrovar.save() + return JsonResponse({"error": "ok"}) def get(self, request, *args, **kwargs): @@ -960,10 +990,11 @@ class XhrProject(View): except ProjectVariable.DoesNotExist: data["machine"] = None try: - data["distro"] = project.projectvariable_set.get( - name="DISTRO").value + data["distro"] = {"name": + project.projectvariable_set.get( + name="DISTRO").value} except ProjectVariable.DoesNotExist: - data["distro"] = "-- not set yet" + data["distro"] = None data['error'] = "ok" |