diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 20557abfc7..f826bcea34 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -1400,6 +1400,55 @@ class CustomImageRecipe(Recipe): base_recipe = models.ForeignKey(Recipe, related_name='based_on_recipe') project = models.ForeignKey(Project) + def generate_recipe_file_contents(self): + """Generate the contents for the recipe file.""" + # If we have no excluded packages we only need to _append + if self.excludes_set.count() == 0: + packages_conf = "IMAGE_INSTALL_append = \" " + + for pkg in self.appends_set.all(): + packages_conf += pkg.name+' ' + else: + packages_conf = "IMAGE_INSTALL = \"" + # We add all the known packages to be built by this recipe apart + # from the packagegroups, which would bring the excluded package + # back in and locale packages which are dynamic packages which + # bitbake will not know about. + for pkg in \ + self.includes_set.exclude( + Q(pk__in=self.excludes_set.values_list('pk', flat=True)) | + Q(name__icontains="packagegroup") | + Q(name__icontains="locale")): + print pkg.name + packages_conf += pkg.name+' ' + + packages_conf += "\"" + + base_recipe = open("%s/%s" % + (self.base_recipe.layer_version.dirpath, + self.base_recipe.file_path), 'r').read() + + info = {"date" : timezone.now().strftime("%Y-%m-%d %H:%M:%S"), + "base_recipe" : base_recipe, + "recipe_name" : self.name, + "base_recipe_name" : self.base_recipe.name, + "license" : self.license, + "summary" : self.summary, + "description" : self.description, + "packages_conf" : packages_conf.strip(), + } + + recipe_contents = ("# Original recipe %(base_recipe_name)s \n" + "%(base_recipe)s\n\n" + "# Recipe %(recipe_name)s \n" + "# Customisation Generated by Toaster on %(date)s\n" + "SUMMARY = \"%(summary)s\"\n" + "DESCRIPTION = \"%(description)s\"\n" + "LICENSE = \"%(license)s\"\n" + "%(packages_conf)s") % info + + return recipe_contents + class ProjectVariable(models.Model): project = models.ForeignKey(Project) name = models.CharField(max_length=100)