Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 0E1AAE00CB8; Mon, 25 Apr 2016 02:48:17 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.192.181 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pf0-f181.google.com (mail-pf0-f181.google.com [209.85.192.181]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id F0706E00C9D for ; Mon, 25 Apr 2016 02:48:11 -0700 (PDT) Received: by mail-pf0-f181.google.com with SMTP id c189so19699362pfb.3 for ; Mon, 25 Apr 2016 02:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=gXXlYVwLg5jtvKsNcu2ihbwQs5cLLYxusQfWC01vUqI=; b=ldExHK0gkDw625CV0eG/HfvQ186MdN1vpzu7YftC6FQpsIolfrVLrGmcqBGpFenitQ L1IUMg3Lk0wj0Zu9GSnoMXdwb45VQCacLnRgI4Di09hQfFqwknqrDn7UQjgG4+K7oQ8+ zkwmq88DSY2f9kq99MlULX6V9yR/jchNsAohv5L+UF2QzB4xRyqqanxxjFfwj1MbPBHY IJ57yMAoCF78PwPcF0j6vEIhNUQUht5COjIRlqfjnOdNZo2eB8aseJoR6l4TrhUkFDBS z2+xluMy70XVNId1aJpUVdfMsNtm9hcFpMQWzDFThXbRRZWDFxZlK5sqqRXy7+XPVV13 hzAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gXXlYVwLg5jtvKsNcu2ihbwQs5cLLYxusQfWC01vUqI=; b=T67DJqeoaAj5Osc12nto2Avgg8D13H/SJ0rcgNOkaBEbZS+A3B0La+dGl7HRqe1VFY PqkH4ZveUcwK+eWgrMi9dZ0ePWfVTDb6GjLu5N5vXMvoseFUDnxw0m7SJrnJ/QFvNZJD vhrvvrxtxp6n9F1JUfENJBCmctvW1Y8jKejZdSObJyfnibZaPa2OGEj1wD/xYGUV7wU6 w9wUky6zfUOYfT4NWRQ2+enzd364fEVlPR/FPk7CU8a6VLuSccYjjHKfMk/sRH6+uPvM LFZUH3uks66HjkhIBi3zJ3qX5vTzZkqcFYw3ZVuxIvAp0lJaBJ0Z/qpiQmsdQdzfueV9 zcZQ== X-Gm-Message-State: AOPr4FW0a9wLTGRo923UHZhVYIVCdG7/Qmzuf+pwfQb7EwugR6Z+xNQGqBhlTpid5lwxfxAO X-Received: by 10.98.49.71 with SMTP id x68mr47223019pfx.105.1461577690833; Mon, 25 Apr 2016 02:48:10 -0700 (PDT) Received: from dorado.ger.corp.intel.com ([192.55.54.44]) by smtp.gmail.com with ESMTPSA id xs10sm28447712pab.4.2016.04.25.02.48.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Apr 2016 02:48:10 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Mon, 25 Apr 2016 10:48:03 +0100 Message-Id: <1461577684-4768-1-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [PATCH 1/2] toaster: orm Add get_base_recipe_file to CustomImageRecipe X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Apr 2016 09:48:17 -0000 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 Signed-off-by: Michael Wood --- bitbake/lib/toaster/orm/models.py | 60 ++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 0b83b99..6716ddf 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -1585,6 +1585,21 @@ class CustomImageRecipe(Recipe): Q(recipe_includes=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): """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 # from locale packages which are are controlled with IMAGE_LINGUAS. for pkg in self.get_all_packages().exclude( - name__icontains="locale"): + name__icontains="locale"): packages_conf += pkg.name+' ' packages_conf += "\"" - try: - base_recipe = open("%s/%s" % - (self.base_recipe.layer_version.dirpath, - self.base_recipe.file_path), 'r').read() - except IOError: - # The path may now be the full path if the recipe has been built - base_recipe = open(self.base_recipe.file_path, 'r').read() + + base_recipe_path = self.get_base_recipe_file() + if base_recipe_path: + base_recipe = open(base_recipe_path, 'r').read() + else: + raise IOError("Based on recipe file not found") # Add a special case for when the recipe we have based a custom image # recipe on requires another recipe. @@ -1618,8 +1632,8 @@ class CustomImageRecipe(Recipe): # "require recipes-core/images/core-image-minimal.bb" req_search = re.search(r'(require\s+)(.+\.bb\s*$)', - base_recipe, - re.MULTILINE) + base_recipe, + re.MULTILINE) if req_search: require_filename = req_search.group(2).strip() @@ -1629,19 +1643,19 @@ class CustomImageRecipe(Recipe): new_require_line = "require %s" % corrected_location - base_recipe = \ - base_recipe.replace(req_search.group(0), new_require_line) - - - 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(), - } + base_recipe = base_recipe.replace(req_search.group(0), + new_require_line) + + 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" -- 2.7.4