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 <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Wood 2015-11-04 14:56:36 +00:00 committed by Richard Purdie
parent a6e4f94b01
commit c402ac2654
1 changed files with 49 additions and 0 deletions

View File

@ -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)