Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 581BEE00B8B; Tue, 8 Dec 2015 13:17:38 -0800 (PST) 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.220.52 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-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 1215BE00B9D for ; Tue, 8 Dec 2015 13:17:01 -0800 (PST) Received: by pacwq6 with SMTP id wq6so17733790pac.1 for ; Tue, 08 Dec 2015 13:17:01 -0800 (PST) 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:in-reply-to:references; bh=1kCMeIyeGTwckDDSG0Q/yr7eRTVxXKTKrLXKzBdx4jo=; b=Ij7FK2NG1gwW7EZ3PYqPhzQ8ToEpiyoxm1urZ0RfnltyRO7cP8z2iH29FwGPSlaYll uCxr8X6mETIAod3xH6LB3U3tOxImX5NT+SNJkGkv/Y3T0+PtuWY+QZv+yZpyhiEsWvA2 tHou46MgVBdn0fM6C6+z1rdSEtau7uZ+tjLV464ONpoDZPQi8KbgPV4vSTLJ2tzOkaog PHCh1hMtKaLBJSXO/oI0ON19LRYOeKNMzJo7DTtq1REf5xpXV4sYtvDhADcABK9/aZR1 XISO8ndl+a1+AW6gGnSMrk/1A5jPL2XsbLyQjt8lpW658SB2+tCR7gptQhCK46qewuCh cbOQ== 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:in-reply-to :references; bh=1kCMeIyeGTwckDDSG0Q/yr7eRTVxXKTKrLXKzBdx4jo=; b=BEfMREyt3HqTKj+QBlrwt7WvE9tbK+73Vap4Ai+t9FRN1YfwiA/MItAhGXhx0CW25V kf8td0b3k491ROA4ZYyFrDo2iWxaZkXqmviMCiZJ8r5jtRVH9k1XMqGL+Oseyx9+RbSH 9gY7nD40RdXkCDBcZlPdRFB7o+6r3a5XFO8NAwMJn60BVO6WEVIQGQhRrSjCD9PBpuGn TXhPUbHGlfEridUpouu+S6JBWoFWnPZ7wBpqlI9U4BxUVBHxvUEYm4Dn0/T7/U0/01h8 SAwJ4Bs65ITzgaM2Z4TM4sz+KJ9yE5imPFCm8CcFUb2DLPItjb4GeasQvwC8zZ4c0sE6 I+Sg== X-Gm-Message-State: ALoCoQmdcP52m6H7xECzdNfRne5DEtLc456GoYx2KJ/izzNUPQybUokDx802Ib4b9tuyOmCjAB8NuUXLz+hR30uXiQ6B1jEOXw== X-Received: by 10.66.232.170 with SMTP id tp10mr3030466pac.38.1449609421479; Tue, 08 Dec 2015 13:17:01 -0800 (PST) Received: from draco.ger.corp.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id v64sm6675766pfi.50.2015.12.08.13.16.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Dec 2015 13:16:59 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 8 Dec 2015 21:15:57 +0000 Message-Id: <1449609380-11073-12-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> References: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 11/34] toaster: orm add CustomImageRecipe generate contents function 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: Tue, 08 Dec 2015 21:17:38 -0000 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 --- bitbake/lib/toaster/orm/models.py | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 2cbbb85..b4cfe24 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -1264,6 +1264,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) -- 2.1.4