diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-11-04 14:56:36 +0000 |
---|---|---|
committer | Michael Wood <michael.g.wood@intel.com> | 2016-02-08 17:30:15 +0000 |
commit | 6863343c3434ce19aa4b609c83f48a06e6943366 (patch) | |
tree | 9aa50474db5026f52a69583ca968b0c7fbd7e96f /lib/toaster/orm/models.py | |
parent | f81bb65883baa6c0f8a4d48a4de3291a10543992 (diff) | |
download | bitbake-6863343c3434ce19aa4b609c83f48a06e6943366.tar.gz |
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.
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Diffstat (limited to 'lib/toaster/orm/models.py')
-rw-r--r-- | lib/toaster/orm/models.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py index 20557abfc..f826bcea3 100644 --- a/lib/toaster/orm/models.py +++ b/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) |