1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

bitbake: toaster: orm Add get_base_recipe_file to CustomImageRecipe

This function returns the base recipe file path only if it currently
exists. This allows us to know whether we can proceed at this point with
generating a custom image recipe. It also enables us to call this
function from the templates to enable visual indication of this state.

Some whitespace fixes also added in generate_recipe_file_contents

(Bitbake rev: bc30d1b235b9ecacef5b2eaa851b9247d857f317)

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Wood
2016-04-26 17:18:06 +01:00
committed by Richard Purdie
parent f7b520878b
commit d3b5b0b4bb
+36 -22
View File
@@ -1585,6 +1585,21 @@ class CustomImageRecipe(Recipe):
Q(recipe_includes=self)) & Q(recipe_includes=self)) &
~Q(recipe_excludes=self)) ~Q(recipe_excludes=self))
def get_base_recipe_file(self):
"""Get the base recipe file path if it exists on the file system"""
path_schema_one = "%s/%s" % (self.base_recipe.layer_version.dirpath,
self.base_recipe.file_path)
path_schema_two = self.base_recipe.file_path
if os.path.exists(path_schema_one):
return path_schema_one
# The path may now be the full path if the recipe has been built
if os.path.exists(path_schema_two):
return path_schema_two
return None
def generate_recipe_file_contents(self): def generate_recipe_file_contents(self):
"""Generate the contents for the recipe file.""" """Generate the contents for the recipe file."""
@@ -1599,17 +1614,16 @@ class CustomImageRecipe(Recipe):
# We add all the known packages to be built by this recipe apart # We add all the known packages to be built by this recipe apart
# from locale packages which are are controlled with IMAGE_LINGUAS. # from locale packages which are are controlled with IMAGE_LINGUAS.
for pkg in self.get_all_packages().exclude( for pkg in self.get_all_packages().exclude(
name__icontains="locale"): name__icontains="locale"):
packages_conf += pkg.name+' ' packages_conf += pkg.name+' '
packages_conf += "\"" packages_conf += "\""
try:
base_recipe = open("%s/%s" % base_recipe_path = self.get_base_recipe_file()
(self.base_recipe.layer_version.dirpath, if base_recipe_path:
self.base_recipe.file_path), 'r').read() base_recipe = open(base_recipe_path, 'r').read()
except IOError: else:
# The path may now be the full path if the recipe has been built raise IOError("Based on recipe file not found")
base_recipe = open(self.base_recipe.file_path, 'r').read()
# Add a special case for when the recipe we have based a custom image # Add a special case for when the recipe we have based a custom image
# recipe on requires another recipe. # recipe on requires another recipe.
@@ -1618,8 +1632,8 @@ class CustomImageRecipe(Recipe):
# "require recipes-core/images/core-image-minimal.bb" # "require recipes-core/images/core-image-minimal.bb"
req_search = re.search(r'(require\s+)(.+\.bb\s*$)', req_search = re.search(r'(require\s+)(.+\.bb\s*$)',
base_recipe, base_recipe,
re.MULTILINE) re.MULTILINE)
if req_search: if req_search:
require_filename = req_search.group(2).strip() require_filename = req_search.group(2).strip()
@@ -1629,19 +1643,19 @@ class CustomImageRecipe(Recipe):
new_require_line = "require %s" % corrected_location new_require_line = "require %s" % corrected_location
base_recipe = \ base_recipe = base_recipe.replace(req_search.group(0),
base_recipe.replace(req_search.group(0), new_require_line) new_require_line)
info = {
info = {"date" : timezone.now().strftime("%Y-%m-%d %H:%M:%S"), "date": timezone.now().strftime("%Y-%m-%d %H:%M:%S"),
"base_recipe" : base_recipe, "base_recipe": base_recipe,
"recipe_name" : self.name, "recipe_name": self.name,
"base_recipe_name" : self.base_recipe.name, "base_recipe_name": self.base_recipe.name,
"license" : self.license, "license": self.license,
"summary" : self.summary, "summary": self.summary,
"description" : self.description, "description": self.description,
"packages_conf" : packages_conf.strip(), "packages_conf": packages_conf.strip()
} }
recipe_contents = ("# Original recipe %(base_recipe_name)s \n" recipe_contents = ("# Original recipe %(base_recipe_name)s \n"
"%(base_recipe)s\n\n" "%(base_recipe)s\n\n"