From c402ac2654cafb2c594c091a5a0a0f340af19a05 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Wed, 4 Nov 2015 14:56:36 +0000 Subject: bitbake: toaster: orm add CustomImageRecipe generate contents function Add function generate_recipe_file_contents to dump the custom image recipe instance to a string for use either to push to the user as a downloaded version of their custom image recipe or to use to generate the recipe that we build. (Bitbake rev: 6863343c3434ce19aa4b609c83f48a06e6943366) Signed-off-by: Michael Wood Signed-off-by: brian avery Signed-off-by: Richard Purdie --- bitbake/lib/toaster/orm/models.py | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'bitbake/lib/toaster/orm/models.py') 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) -- cgit v1.2.3-54-g00ecf