summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-04-26 17:18:06 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-06 10:12:16 +0100
commitd3b5b0b4bb517db077d06d6339bb4b2987c031bf (patch)
tree307a27ca30b1a32f76a2491f84ff32420c55014b /bitbake/lib
parentf7b520878babbaa7527151f22c031ae160512753 (diff)
downloadpoky-d3b5b0b4bb517db077d06d6339bb4b2987c031bf.tar.gz
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>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/orm/models.py60
1 files changed, 37 insertions, 23 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 0b83b991b9..6716ddfab3 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1585,6 +1585,21 @@ class CustomImageRecipe(Recipe):
1585 Q(recipe_includes=self)) & 1585 Q(recipe_includes=self)) &
1586 ~Q(recipe_excludes=self)) 1586 ~Q(recipe_excludes=self))
1587 1587
1588 def get_base_recipe_file(self):
1589 """Get the base recipe file path if it exists on the file system"""
1590 path_schema_one = "%s/%s" % (self.base_recipe.layer_version.dirpath,
1591 self.base_recipe.file_path)
1592
1593 path_schema_two = self.base_recipe.file_path
1594
1595 if os.path.exists(path_schema_one):
1596 return path_schema_one
1597
1598 # The path may now be the full path if the recipe has been built
1599 if os.path.exists(path_schema_two):
1600 return path_schema_two
1601
1602 return None
1588 1603
1589 def generate_recipe_file_contents(self): 1604 def generate_recipe_file_contents(self):
1590 """Generate the contents for the recipe file.""" 1605 """Generate the contents for the recipe file."""
@@ -1599,17 +1614,16 @@ class CustomImageRecipe(Recipe):
1599 # We add all the known packages to be built by this recipe apart 1614 # We add all the known packages to be built by this recipe apart
1600 # from locale packages which are are controlled with IMAGE_LINGUAS. 1615 # from locale packages which are are controlled with IMAGE_LINGUAS.
1601 for pkg in self.get_all_packages().exclude( 1616 for pkg in self.get_all_packages().exclude(
1602 name__icontains="locale"): 1617 name__icontains="locale"):
1603 packages_conf += pkg.name+' ' 1618 packages_conf += pkg.name+' '
1604 1619
1605 packages_conf += "\"" 1620 packages_conf += "\""
1606 try: 1621
1607 base_recipe = open("%s/%s" % 1622 base_recipe_path = self.get_base_recipe_file()
1608 (self.base_recipe.layer_version.dirpath, 1623 if base_recipe_path:
1609 self.base_recipe.file_path), 'r').read() 1624 base_recipe = open(base_recipe_path, 'r').read()
1610 except IOError: 1625 else:
1611 # The path may now be the full path if the recipe has been built 1626 raise IOError("Based on recipe file not found")
1612 base_recipe = open(self.base_recipe.file_path, 'r').read()
1613 1627
1614 # Add a special case for when the recipe we have based a custom image 1628 # Add a special case for when the recipe we have based a custom image
1615 # recipe on requires another recipe. 1629 # recipe on requires another recipe.
@@ -1618,8 +1632,8 @@ class CustomImageRecipe(Recipe):
1618 # "require recipes-core/images/core-image-minimal.bb" 1632 # "require recipes-core/images/core-image-minimal.bb"
1619 1633
1620 req_search = re.search(r'(require\s+)(.+\.bb\s*$)', 1634 req_search = re.search(r'(require\s+)(.+\.bb\s*$)',
1621 base_recipe, 1635 base_recipe,
1622 re.MULTILINE) 1636 re.MULTILINE)
1623 if req_search: 1637 if req_search:
1624 require_filename = req_search.group(2).strip() 1638 require_filename = req_search.group(2).strip()
1625 1639
@@ -1629,19 +1643,19 @@ class CustomImageRecipe(Recipe):
1629 1643
1630 new_require_line = "require %s" % corrected_location 1644 new_require_line = "require %s" % corrected_location
1631 1645
1632 base_recipe = \ 1646 base_recipe = base_recipe.replace(req_search.group(0),
1633 base_recipe.replace(req_search.group(0), new_require_line) 1647 new_require_line)
1634 1648
1635 1649 info = {
1636 info = {"date" : timezone.now().strftime("%Y-%m-%d %H:%M:%S"), 1650 "date": timezone.now().strftime("%Y-%m-%d %H:%M:%S"),
1637 "base_recipe" : base_recipe, 1651 "base_recipe": base_recipe,
1638 "recipe_name" : self.name, 1652 "recipe_name": self.name,
1639 "base_recipe_name" : self.base_recipe.name, 1653 "base_recipe_name": self.base_recipe.name,
1640 "license" : self.license, 1654 "license": self.license,
1641 "summary" : self.summary, 1655 "summary": self.summary,
1642 "description" : self.description, 1656 "description": self.description,
1643 "packages_conf" : packages_conf.strip(), 1657 "packages_conf": packages_conf.strip()
1644 } 1658 }
1645 1659
1646 recipe_contents = ("# Original recipe %(base_recipe_name)s \n" 1660 recipe_contents = ("# Original recipe %(base_recipe_name)s \n"
1647 "%(base_recipe)s\n\n" 1661 "%(base_recipe)s\n\n"