From patchwork Mon Dec 4 15:25:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15365C4167B for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.groups.io with SMTP id smtpd.web11.71449.1701703573537689677 for ; Mon, 04 Dec 2023 07:26:14 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=klZVmYDQ; spf=pass (domain: baylibre.com, ip: 209.85.221.47, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3316c6e299eso3970811f8f.1 for ; Mon, 04 Dec 2023 07:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703572; x=1702308372; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9BmDN1+RRD2JSJlTHpXnX4DHNnxVXDnsKlyPlGhM9EE=; b=klZVmYDQppr/or4WdgPMO7zIKw6ioAZ+nx/1qdct4WgXrI7gsF7mda8mmaomctvgya jE/0XmpryB6nyGT3V92ygDH6HuNFFgIrIKuFe319Ceh+mmNMvAoLfdcxtnn1+kCunjzD 8NbNePhs6Uyt9433d8OIg0/MK1SlZk4Zd3MUcyyZuRyZ3s2dZR7k8MG9bQWoDiaUTLJ8 5Nn77cJcS+oVqEJwjf1whJN72OS5gdbducY2t8kjGLoj1C6uLnPLSMlMLpCuTxDPfHFM VVuo+RNiP5WsRweEK/CUy0tWcFkr43A76F0M/1AB7rjLH9zz8xymHvuLVsO0ghOaIsQP jVEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703572; x=1702308372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9BmDN1+RRD2JSJlTHpXnX4DHNnxVXDnsKlyPlGhM9EE=; b=TcCtV8Loi/PHYj/GETyMNmb6Jrx4+Ue2IUivpU3BEU+L0RxYyUUxQOPAqGu1VOUMNR qfb3hahy650l/NkxaqyWWqID+pw3IvrwBoQJDp1XGPUzeQ4mxGTr5BXFhI73ziGtJlke HPx3kMIiuAqFhzspC0BXHZMKsdjJ+tDBuETg/GFydvEZQEDpasnQoXlJY0gRJmGX0+No Q1Qg6pympyDCsXAo4ynekNfSnBlN7C9HntxZlv3FnkLGYoJZHbe8Q7bmh6snpunckM6c bJoU99XSsBQ9ToZKp4PzeQR5gXHQyJkbrDL2E9oGPxUgwUObhR2IDKbnWgSPFc5njxxH 4wnQ== X-Gm-Message-State: AOJu0YwPPMpEIRjNG97M44nQN9HwT6/aduRut9fZjdkRdC9dYejBvnzL m24C1lOMeaBrxU/4FSnpsaSe9XE6sCTmKEHMekNP0w== X-Google-Smtp-Source: AGHT+IFdkRnzJPvSc7eQE2klEmK95lgQsJeHK9B+R+dRpQJPqKOELHTBATYItm+LTkWfgegdgFmWog== X-Received: by 2002:a5d:42d1:0:b0:333:5436:be45 with SMTP id t17-20020a5d42d1000000b003335436be45mr96965wrr.13.1701703571949; Mon, 04 Dec 2023 07:26:11 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:11 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 1/9] recipetool: appendsrcfile(s): add dry-run mode Date: Mon, 4 Dec 2023 16:25:55 +0100 Message-ID: <20231204152603.831495-2-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191743 Add dry-run mode for recipetool appendsrcfile and appendsrcfiles, with if necessary, a diff of changes Signed-off-by: Julien Stephan --- scripts/lib/recipetool/append.py | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/scripts/lib/recipetool/append.py b/scripts/lib/recipetool/append.py index 9dbb1cc4b5a..314ff4e20fd 100644 --- a/scripts/lib/recipetool/append.py +++ b/scripts/lib/recipetool/append.py @@ -18,6 +18,7 @@ import shutil import scriptutils import errno from collections import defaultdict +import difflib logger = logging.getLogger('recipetool') @@ -355,7 +356,35 @@ def appendsrc(args, files, rd, extralines=None): extralines.append('SRC_URI += {0}'.format(source_uri)) copyfiles[newfile] = srcfile - oe.recipeutils.bbappend_recipe(rd, args.destlayer, copyfiles, None, wildcardver=args.wildcard_version, machine=args.machine, extralines=extralines) + dry_run_output = None + dry_run_outdir = None + if args.dry_run: + import tempfile + dry_run_output = tempfile.TemporaryDirectory(prefix='devtool') + dry_run_outdir = dry_run_output.name + + appendfile, _ = oe.recipeutils.bbappend_recipe(rd, args.destlayer, copyfiles, None, wildcardver=args.wildcard_version, machine=args.machine, extralines=extralines, redirect_output=dry_run_outdir) + if args.dry_run: + output = '' + appendfilename = os.path.basename(appendfile) + newappendfile = appendfile + if appendfile and os.path.exists(appendfile): + with open(appendfile, 'r') as f: + oldlines = f.readlines() + else: + appendfile = '/dev/null' + oldlines = [] + + with open(os.path.join(dry_run_outdir, appendfilename), 'r') as f: + newlines = f.readlines() + diff = difflib.unified_diff(oldlines, newlines, appendfile, newappendfile) + difflines = list(diff) + if difflines: + output += ''.join(difflines) + if output: + logger.info('Diff of changed files:\n%s' % output) + else: + logger.info('No changed files') tinfoil.modified_files() def appendsrcfiles(parser, args): @@ -436,6 +465,7 @@ def register_commands(subparsers): help='Create/update a bbappend to add or replace source files', description='Creates a bbappend (or updates an existing one) to add or replace the specified file in the recipe sources, either those in WORKDIR or those in the source tree. This command lets you specify multiple files with a destination directory, so cannot specify the destination filename. See the `appendsrcfile` command for the other behavior.') parser.add_argument('-D', '--destdir', help='Destination directory (relative to S or WORKDIR, defaults to ".")', default='', type=destination_path) + parser.add_argument('-n', '--dry-run', help='Dry run mode', action='store_true') parser.add_argument('files', nargs='+', metavar='FILE', help='File(s) to be added to the recipe sources (WORKDIR or S)', type=existing_path) parser.set_defaults(func=lambda a: appendsrcfiles(parser, a), parserecipes=True) @@ -443,6 +473,7 @@ def register_commands(subparsers): parents=[common_src], help='Create/update a bbappend to add or replace a source file', description='Creates a bbappend (or updates an existing one) to add or replace the specified files in the recipe sources, either those in WORKDIR or those in the source tree. This command lets you specify the destination filename, not just destination directory, but only works for one file. See the `appendsrcfiles` command for the other behavior.') + parser.add_argument('-n', '--dry-run', help='Dry run mode', action='store_true') parser.add_argument('file', metavar='FILE', help='File to be added to the recipe sources (WORKDIR or S)', type=existing_path) parser.add_argument('destfile', metavar='DESTFILE', nargs='?', help='Destination path (relative to S or WORKDIR, optional)', type=destination_path) parser.set_defaults(func=lambda a: appendsrcfile(parser, a), parserecipes=True) From patchwork Mon Dec 4 15:25:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5457BC10F13 for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mx.groups.io with SMTP id smtpd.web11.71451.1701703575154967904 for ; Mon, 04 Dec 2023 07:26:15 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=2sf83vpf; spf=pass (domain: baylibre.com, ip: 209.85.221.49, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-332c7d4a6a7so3960873f8f.2 for ; Mon, 04 Dec 2023 07:26:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703573; x=1702308373; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TFVKm4pIe7h7Dz9AfxUKNMWAtw4drpneJh8hJVEETnQ=; b=2sf83vpfeP4ybjJJEykS0pMsrN5U+Fu/VpeMZghsDKEVckrheWEHOVQtuzC5l+EAqQ w0gYDetxpyU7dRsedeh5QeFHykGcBUgOr2O84o+i+ax7BUfJxkHadQdh44BuGnxNRO1A 4AwDwZcaY8rZJvT/Sm4LQqtBfVTBCT+h/hBrnJsf07MVunxtn1V8ZIPfKKRzeGeLBC96 dCpXLeQvAAIaYfVnHrCAFchg93rgJgwy5e0uxh2TWhmwo9p3lX3YxejZYyl5JQceTaBl F0DWRZzAo4rLPoEN3fBroogJos9e4Rh4YSIFe1W2ROEK+A2bW2jbCAzIw5R+zB1s1jDe oXLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703573; x=1702308373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TFVKm4pIe7h7Dz9AfxUKNMWAtw4drpneJh8hJVEETnQ=; b=RfJdfoKz3O3AjQ/QmC68qaTfyoz9gFOI/NSuMhfsxxr/MGyjYXXP/r/yDDI9LYHQgc wTeUmniVlIX3Gfp1+UWmYkZwZjrmWl3yptFBS+rLELjI45g4M0g/BcOPDnf6++WI9+Vn wvRb1d9PBPMAL/Mr2lgYYd7r0DxySDquu1NzZkzKwmZQDGvYhNO18DlUcsWtMjbnQwKv TPHhwIo+AcPWJUqJ8KF7hAVbKh+R8fzHvAFI+QDMUgM7JBnkQ8zAd/vkZ1vxXdsV5MWW 0aZU5ZdfeGnVuq/umjqAaIUuEsmNRDvsNbxZPDztWkoXYKd6nskqzPWEf1zPwKboDIcA lXXA== X-Gm-Message-State: AOJu0YyREIPmBeoQYSlirD7OHC/VWOQOzzOiStGeCvkS0EizzVKRCPlw eLtD+P0JoexYMkKHKwd9Zr7e8UKUEdEiLGUztPDD4g== X-Google-Smtp-Source: AGHT+IGRsj4co8S+x89xKHlw0+nrEeTq65rMQxpw6UYJhUV28Y4H2RwdeUfQsDDYPHDDkBOvd8zByQ== X-Received: by 2002:a5d:5051:0:b0:333:2fd2:3c1e with SMTP id h17-20020a5d5051000000b003332fd23c1emr2178867wrt.215.1701703572504; Mon, 04 Dec 2023 07:26:12 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:12 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 2/9] recipeutils: bbappend_recipe: fix undefined variable Date: Mon, 4 Dec 2023 16:25:56 +0100 Message-ID: <20231204152603.831495-3-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191746 In the case get_bbappend_path returns None (could not find the layer containing the recipe) the error message tries to print the recipefile, but it is not defined. Fix it. Signed-off-by: Julien Stephan --- meta/lib/oe/recipeutils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 3336db8ab06..7465a2d0ab4 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -702,6 +702,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, if not removevalues: removevalues = {} + recipefile = rd.getVar('FILE') # Determine how the bbappend should be named appendpath, pathok = get_bbappend_path(rd, destlayerdir, wildcardver) if not appendpath: From patchwork Mon Dec 4 15:25:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35622 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29F9AC46CA3 for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mx.groups.io with SMTP id smtpd.web10.72245.1701703574447889969 for ; Mon, 04 Dec 2023 07:26:15 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=aaNBgDBk; spf=pass (domain: baylibre.com, ip: 209.85.221.49, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-33330a5617fso2665062f8f.2 for ; Mon, 04 Dec 2023 07:26:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703573; x=1702308373; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=irohkeROhDHpKcZ2gm6k6FhrCsg9HzIhgY6tdZIIu4E=; b=aaNBgDBkcmoV2lnX4Q+WB2nyU6RaToGn3AQE6XcJ4whBTAIKk1F2pYDKTQLDNrrlTF qtsX/1Hsh05YA/vrJdgWNHkTQLZmNSYgAF41XQZAsm8HaI5QCx3Y2qWbZr1JFaRwopTK hzIfMuJHbzq1IHPteRbBTREljERJfjP/UPZnSPM7b6gGwQg2EYn9Lgja9aET/GNc9p0z YfjlCoX0sO7tEaTIEik7+3bwEudiUHdhxEGU8vVQPK6sbB2vZR7pxqaQcErSthohSvEp qZQFMb+YAIAYXbTyKiImGRBOYUTM18eCXWubGlQAIllXvXEMr0pYRI7Tu79hP9D0Iy+I X+zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703573; x=1702308373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=irohkeROhDHpKcZ2gm6k6FhrCsg9HzIhgY6tdZIIu4E=; b=uZDQe66GfirYjZLAM/zAKTDEOkh42zfnAekVtum0eGExME4PEwp6VzGhq+7Y9rSrr6 yJBuoTMazN4CssKLmvVM23e5D0D2P0YI16RMsfC4FVN1hC8F3Nv6GALZ76ka+iVgSSGO BWRgSEtmNXc51uya+l2Nu36VDjJVmpXMyZbjcRB2asfAYluSzWtXc2RoIh3meTSaVySa MBeZETiDCJXpv5AWO8aZesAnAT6GSkBqEUvxZCurZmhy9yAGIBbGKVn1OswqaJqJDIiM 71AXCVx7nLcqGn4neV52g2sJTwDmqtjKiPRfXbv6y3aCWi0W3MRnKo8tILeI6xhQ5ZTR WqbA== X-Gm-Message-State: AOJu0Yz+01bwMtyMTJ82wZDIGfxIOBGE6bNvUtaIYID5Xa6Yfcq7oFO7 oGGwsWlgCxeMk3gkSPMIx3gnaBsX7X/+Y/yBWUkGRw== X-Google-Smtp-Source: AGHT+IEHIv7gNIHIw4oF6BcUoWco/DTKeYYFVMJJq9VOSU3xwSJQQnxT5w7PWGf4dQF5mOIwu/9PVQ== X-Received: by 2002:a5d:65c7:0:b0:333:3ffe:dbcd with SMTP id e7-20020a5d65c7000000b003333ffedbcdmr1968939wrw.36.1701703572843; Mon, 04 Dec 2023 07:26:12 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:12 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 3/9] recipeutils: bbappend_recipe: add a way to specify the name of the file to add Date: Mon, 4 Dec 2023 16:25:57 +0100 Message-ID: <20231204152603.831495-4-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191745 bbappend_recipe can take a dict of source files to add to SRC_URI where the key is the full path to the file to be added and the value is the original file in the recipe space. Modify the dict value to use a tupple: (originalfile, newname), to allow specifying the name of the file we would like to add Signed-off-by: Julien Stephan --- meta/lib/oe/recipeutils.py | 20 ++++++++++++-------- scripts/lib/devtool/standard.py | 6 +++--- scripts/lib/recipetool/append.py | 4 ++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 7465a2d0ab4..9784ae3b031 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -671,12 +671,13 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, rd: data dictionary for the recipe destlayerdir: base directory of the layer to place the bbappend in (subdirectory path from there will be determined automatically) - srcfiles: dict of source files to add to SRC_URI, where the value - is the full path to the file to be added, and the value is the - original filename as it would appear in SRC_URI or None if it - isn't already present. You may pass None for this parameter if - you simply want to specify your own content via the extralines - parameter. + srcfiles: dict of source files to add to SRC_URI, where the key + is the full path to the file to be added, and the value is a tuple + containing the original filename as it would appear in SRC_URI + or None if it isn't already present and the new name of the file or + None to use by default basename(original filename). + You may pass None for this parameter if you simply want to specify + your own content via the extralines parameter. install: dict mapping entries in srcfiles to a tuple of two elements: install path (*without* ${D} prefix) and permission value (as a string, e.g. '0644'). @@ -764,11 +765,14 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, copyfiles = {} if srcfiles: instfunclines = [] - for i, (newfile, origsrcfile) in enumerate(srcfiles.items()): + for i, (newfile, (origsrcfile, newname)) in enumerate(srcfiles.items()): srcfile = origsrcfile srcurientry = None if not srcfile: - srcfile = os.path.basename(newfile) + if newname: + srcfile = newname + else: + srcfile = os.path.basename(newfile) srcurientry = 'file://%s' % srcfile if params and params[i]: srcurientry = '%s;%s' % (srcurientry, ';'.join('%s=%s' % (k,v) for k,v in params[i].items())) diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index d53fb810071..fa473014f90 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py @@ -1568,7 +1568,7 @@ def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wi update_srcuri = True if appendlayerdir: - files = dict((os.path.join(local_files_dir, key), val) for + files = dict((os.path.join(local_files_dir, key), (val, None)) for key, val in list(upd_f.items()) + list(new_f.items())) removevalues = {} if update_srcuri: @@ -1678,9 +1678,9 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil destpath = None srcuri = (rd.getVar('SRC_URI', False) or '').split() if appendlayerdir: - files = OrderedDict((os.path.join(local_files_dir, key), val) for + files = OrderedDict((os.path.join(local_files_dir, key), (val, None)) for key, val in list(upd_f.items()) + list(new_f.items())) - files.update(OrderedDict((os.path.join(patches_dir, key), val) for + files.update(OrderedDict((os.path.join(patches_dir, key), (val, None)) for key, val in list(upd_p.items()) + list(new_p.items()))) if files or remove_files: removevalues = None diff --git a/scripts/lib/recipetool/append.py b/scripts/lib/recipetool/append.py index 314ff4e20fd..09e314481f1 100644 --- a/scripts/lib/recipetool/append.py +++ b/scripts/lib/recipetool/append.py @@ -300,7 +300,7 @@ def appendfile(args): if st.st_mode & stat.S_IXUSR: perms = '0755' install = {args.newfile: (args.targetpath, perms)} - oe.recipeutils.bbappend_recipe(rd, args.destlayer, {args.newfile: sourcepath}, install, wildcardver=args.wildcard_version, machine=args.machine) + oe.recipeutils.bbappend_recipe(rd, args.destlayer, {args.newfile: (None, sourcepath)}, install, wildcardver=args.wildcard_version, machine=args.machine) tinfoil.modified_files() return 0 else: @@ -354,7 +354,7 @@ def appendsrc(args, files, rd, extralines=None): logger.warning('{0!r} is already in SRC_URI, not adding'.format(source_uri)) else: extralines.append('SRC_URI += {0}'.format(source_uri)) - copyfiles[newfile] = srcfile + copyfiles[newfile] = (None, srcfile) dry_run_output = None dry_run_outdir = None From patchwork Mon Dec 4 15:25:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45CCCC10F09 for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web10.72246.1701703576275089697 for ; Mon, 04 Dec 2023 07:26:16 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=JT5DH+tr; spf=pass (domain: baylibre.com, ip: 209.85.128.47, mailfrom: jstephan@baylibre.com) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40c08af319cso17432035e9.2 for ; Mon, 04 Dec 2023 07:26:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703574; x=1702308374; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Dc6Qr+QyoV76QwdroYpOrzxahT28GhtB7MPw3CWaRSA=; b=JT5DH+trfyO89cr/XWhkcC8RLQlp3Lh9+cCTWlJYqoFwHAzrz9Qb7ajdbLGpkjsDhh LE5ntEjogNY5QBJZjP7GS+8vy6TyZIFeHs6qxzzF4kh7vW79tM44S0jFRLNkCiHVSX/9 JrOU1FIYRUI1zGXYl1rU3t6vVm9qNEXonIZH/FC1fRjfkUSiR1/NhmtP3Inq3hxpt7uo jC2fsOYkzUuMmM6hz7FsivK+HnSXNHk+VEKzatF2ix+a21jtJeNTei7P1pWbK4kinwBJ TM4ijLSp5dptPdnrp/xAnzsljfA/y/Bv/SYcZs0HEfKheNpElHFAANOWEb8l1Yt8FOkA LEkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703574; x=1702308374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dc6Qr+QyoV76QwdroYpOrzxahT28GhtB7MPw3CWaRSA=; b=kzuEWlDeNeU/mLnalq4SnKciaT3XC68kdGW1tWBLzoU6qwEqzKtJOvuP3Ki3BPmrqr VRQ5AJUaLRt1eOaboKXm3Qjrk8WnwKQ/iijE6/4ZWdwP4xwK20s4Sc3PXvyDSVwbsL2m TdBTRdVDcJj4sw46lYInXvfBzlYqWJXXbJcsuM7dch8Aer+5dk29sJP9mEua4gaAkRcd JAv+Mn8UW9hpl25hzmcHedFAIGwKfTvGjdvrN7S7kzhTdMazpoAsruE8k7HkdpKs3bKn oFqYP3xmmE6SH0eT7fgGUOFqNdURaYaGv9BhD6tQHNLyEdFg+Ts1ikR/dfmWrn85+k9l dpDw== X-Gm-Message-State: AOJu0YwwR52a3jLZx/YFrjCxNxKau1wLHdU0S13DeE2Fr4+pN6HZzpFZ r9AlVVO+g/vn4LH5mApaLW553qts/0F75t4tQRY/3g== X-Google-Smtp-Source: AGHT+IHNO+TJouP3Pl7atwrYFiCwQhY0RrACm7PXXvSrpkd5zF9xJAgL+AneFUr/BW8BoWy8K1iNPQ== X-Received: by 2002:a05:6000:71e:b0:333:4cfa:1dc4 with SMTP id bs30-20020a056000071e00b003334cfa1dc4mr930065wrb.75.1701703574030; Mon, 04 Dec 2023 07:26:14 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:13 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 4/9] recipeutils: bbappend_recipe: remove old srcuri entry if parameters are different Date: Mon, 4 Dec 2023 16:25:58 +0100 Message-ID: <20231204152603.831495-5-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191747 Currently we do not add a new src_ury entry if the entry already exists AND the parameters are the same. I believe that when an entry already exist with different parameters, we should remove it and add the new entry otherwise we end up with two entries with different parameters Signed-off-by: Julien Stephan --- meta/lib/oe/recipeutils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 9784ae3b031..8aa82396c86 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -774,14 +774,22 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, else: srcfile = os.path.basename(newfile) srcurientry = 'file://%s' % srcfile + oldentry = None + for uri in rd.getVar('SRC_URI').split(): + if srcurientry in uri: + oldentry = uri if params and params[i]: srcurientry = '%s;%s' % (srcurientry, ';'.join('%s=%s' % (k,v) for k,v in params[i].items())) # Double-check it's not there already # FIXME do we care if the entry is added by another bbappend that might go away? if not srcurientry in rd.getVar('SRC_URI').split(): if machine: + if oldentry: + appendline('SRC_URI:remove%s' % appendoverride, '=', ' ' + oldentry) appendline('SRC_URI:append%s' % appendoverride, '=', ' ' + srcurientry) else: + if oldentry: + appendline('SRC_URI:remove', '=', oldentry) appendline('SRC_URI', '+=', srcurientry) copyfiles[newfile] = srcfile if install: From patchwork Mon Dec 4 15:25:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35626 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3806BC10F07 for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mx.groups.io with SMTP id smtpd.web10.72247.1701703577193655725 for ; Mon, 04 Dec 2023 07:26:17 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=e2ZQvUdC; spf=pass (domain: baylibre.com, ip: 209.85.221.49, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-33318b866a0so4319575f8f.3 for ; Mon, 04 Dec 2023 07:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703575; x=1702308375; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZlVjAap+6hOS2ho6xLXi3UStgBEJ6flR0B+aNPpJvRs=; b=e2ZQvUdCjeVP2XGVdNRBg0mUzYfN+EWGMrwSUTcyPuW4fOIFXN+KT1DM7/Y0QIQgV1 iKoteq3hjfGNmTVNl+r3VNIXhvV0mVJyb29EKudpkt136fjGizLCTNDAFGhCad/6o/SY uDFeS2S7Kc173jdmoTQSmyGwYsYJO9q8FXfRvxpHRDOxlrsJdQ39jaeByYxhXYX0WMjf h3hTVTYGsoIGZKwfUuvEFiLuBrGX7EjV/N87+XlJ5L2zSOhWgLMaoWsxbs1unw0qQHys g/54iSumGBPADfgthTbT1NHKyqVxj5H6fhAxOH8XW8N8xnGQrtkbQDtGu2uRia5M5vQi XC+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703575; x=1702308375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZlVjAap+6hOS2ho6xLXi3UStgBEJ6flR0B+aNPpJvRs=; b=TLi/Z4nh8rViVK0FdyhcmQnaeb/+nTa6qiZShEF2bGTC/6OzkyvwFDpfmEBHRG6o8d Mc2tPJGG4w4cPW1QSwzBmHOAaxEmeqlzJT660dT071kPT2L25/Eb0FLpcUTm0UDtlTC7 v9C6piEB68NzR4euJ/FYgONd1CAgXunpSO4X3OJ+vqSblXAWcaQ13Oae2snB/a23U6QI B/rQG9UwdqtDIh+zeWb0C1V2MaIKCZigmJfm83/HEVMtVBGLK9bDe29gqfcOwik1VsT/ L5IJ9ZzsnPXMcsYRvjfes7qw+cBNqSG0LPusiybuHYoe6wMDiY/IdIOlRR8yfoLaqd4I GsfQ== X-Gm-Message-State: AOJu0YyonHS14llWXjPTupW9go7mMi4M3LGZwe7B8E1SqXteyJi7pVnv a8lQ0s+ZpXXs69IPNGy/fA8k8ZCpev6vuHu0tlqOxw== X-Google-Smtp-Source: AGHT+IGGyciketWDgBYQsU9HLC8fNbS5BA74TLd6+IZ6BjQDblOESDeGtMcJVe+h4NyUh1ZjE1ycjg== X-Received: by 2002:a5d:46cc:0:b0:333:17d2:454a with SMTP id g12-20020a5d46cc000000b0033317d2454amr3226850wrs.4.1701703575025; Mon, 04 Dec 2023 07:26:15 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:14 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 5/9] recipetool: appendsrcfile(s): use params instead of extraline Date: Mon, 4 Dec 2023 16:25:59 +0100 Message-ID: <20231204152603.831495-6-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191748 appendsrc function relies on oe.recipeutils.bbappend_recipe to copy files and add the corresponding entries in SRC_URI. Currently, appendsrc function build itself the new SRC_URI entry to add the correct subdir param, and gives it using the extralines parameter. This has 2 drawbacks: - oe.recipeutils.bbappend_recipe can already do this if we specify the correct params, so we have duplicate code - the duplicated code is not fully functional: for example, it doesn't take into account the -m/--machine parameter So fix this by not using extralines but give correctly formatted params. Also remove the check for already existing entries as oe.recipeutils.bbappend_recipe already implement it The new bbappend file now have the SRC_URI entry after the FILESEXTRAPATHS so fix the selftest. Update test_recipetool_appendsrcfile_existing_in_src_uri_diff_params test because recipetool appendsrcfiles used to not add new src_uri entry if the entry already exist even with different parameters while oe.recipeutils.bbappend_recipe adds it if parameters are different (and remove the old entry) Signed-off-by: Julien Stephan --- meta/lib/oeqa/selftest/cases/recipetool.py | 21 +++++++++++-------- scripts/lib/recipetool/append.py | 24 ++++++++-------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py index 55cbba9ca74..21cb350e8a6 100644 --- a/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/meta/lib/oeqa/selftest/cases/recipetool.py @@ -1054,9 +1054,9 @@ class RecipetoolAppendsrcBase(RecipetoolBase): for uri in src_uri: p = urllib.parse.urlparse(uri) if p.scheme == 'file': - return p.netloc + p.path + return p.netloc + p.path, uri - def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, options=''): + def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, options=''): if newfile is None: newfile = self.testfile @@ -1083,12 +1083,18 @@ class RecipetoolAppendsrcBase(RecipetoolBase): expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', '\n'] + + if remove: + for entry in remove: + expectedlines.extend(['SRC_URI:remove = "%s"\n' % entry, + '\n']) + if has_src_uri: uri = 'file://%s' % filename if expected_subdir: uri += ';subdir=%s' % expected_subdir - expectedlines[0:0] = ['SRC_URI += "%s"\n' % uri, - '\n'] + expectedlines.extend(['SRC_URI += "%s"\n' % uri, + '\n']) return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename]) @@ -1143,18 +1149,17 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase): def test_recipetool_appendsrcfile_existing_in_src_uri(self): testrecipe = 'base-files' - filepath = self._get_first_file_uri(testrecipe) + filepath,_ = self._get_first_file_uri(testrecipe) self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe) self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False) def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self): testrecipe = 'base-files' subdir = 'tmp' - filepath = self._get_first_file_uri(testrecipe) + filepath, srcuri_entry = self._get_first_file_uri(testrecipe) self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe) - output = self._test_appendsrcfile(testrecipe, filepath, subdir, has_src_uri=False) - self.assertTrue(any('with different parameters' in l for l in output)) + self._test_appendsrcfile(testrecipe, filepath, subdir, remove=[srcuri_entry]) def test_recipetool_appendsrcfile_replace_file_srcdir(self): testrecipe = 'bash' diff --git a/scripts/lib/recipetool/append.py b/scripts/lib/recipetool/append.py index 09e314481f1..7e56290a0ab 100644 --- a/scripts/lib/recipetool/append.py +++ b/scripts/lib/recipetool/append.py @@ -300,6 +300,8 @@ def appendfile(args): if st.st_mode & stat.S_IXUSR: perms = '0755' install = {args.newfile: (args.targetpath, perms)} + if sourcepath: + sourcepath = os.path.basename(sourcepath) oe.recipeutils.bbappend_recipe(rd, args.destlayer, {args.newfile: (None, sourcepath)}, install, wildcardver=args.wildcard_version, machine=args.machine) tinfoil.modified_files() return 0 @@ -329,6 +331,7 @@ def appendsrc(args, files, rd, extralines=None): copyfiles = {} extralines = extralines or [] + params = [] for newfile, srcfile in files.items(): src_destdir = os.path.dirname(srcfile) if not args.use_workdir: @@ -339,22 +342,12 @@ def appendsrc(args, files, rd, extralines=None): src_destdir = os.path.join(os.path.relpath(srcdir, workdir), src_destdir) src_destdir = os.path.normpath(src_destdir) - source_uri = 'file://{0}'.format(os.path.basename(srcfile)) if src_destdir and src_destdir != '.': - source_uri += ';subdir={0}'.format(src_destdir) - - simple = bb.fetch.URI(source_uri) - simple.params = {} - simple_str = str(simple) - if simple_str in simplified: - existing = simplified[simple_str] - if source_uri != existing: - logger.warning('{0!r} is already in SRC_URI, with different parameters: {1!r}, not adding'.format(source_uri, existing)) - else: - logger.warning('{0!r} is already in SRC_URI, not adding'.format(source_uri)) + params.append({'subdir': src_destdir}) else: - extralines.append('SRC_URI += {0}'.format(source_uri)) - copyfiles[newfile] = (None, srcfile) + params.append({}) + + copyfiles[newfile] = (None, os.path.basename(srcfile)) dry_run_output = None dry_run_outdir = None @@ -363,7 +356,8 @@ def appendsrc(args, files, rd, extralines=None): dry_run_output = tempfile.TemporaryDirectory(prefix='devtool') dry_run_outdir = dry_run_output.name - appendfile, _ = oe.recipeutils.bbappend_recipe(rd, args.destlayer, copyfiles, None, wildcardver=args.wildcard_version, machine=args.machine, extralines=extralines, redirect_output=dry_run_outdir) + appendfile, _ = oe.recipeutils.bbappend_recipe(rd, args.destlayer, copyfiles, None, wildcardver=args.wildcard_version, machine=args.machine, extralines=extralines, params=params, + redirect_output=dry_run_outdir) if args.dry_run: output = '' appendfilename = os.path.basename(appendfile) From patchwork Mon Dec 4 15:26:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29ED9C10DC1 for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mx.groups.io with SMTP id smtpd.web10.72249.1701703578236799893 for ; Mon, 04 Dec 2023 07:26:18 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=GZt1uYZO; spf=pass (domain: baylibre.com, ip: 209.85.221.45, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3335397607dso376943f8f.1 for ; Mon, 04 Dec 2023 07:26:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703576; x=1702308376; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=liqggH+EgGCA3UCpWpXePVLNfUzms3eiOsEddC9yAyE=; b=GZt1uYZOL1Fw045WpeiGIZO5hmHy7gCTs9MW4nMvuYLUPEaFgFuijlPOC0TzaUbjfg PnFXs1TVVzpQFT+1VbG3ievmsPRKaSRFTSPQiSefBYUfFVNeGa2gqP914QbrfK66sjj5 KXzQhoLf7eaJUizOvdRCWxHe9oFZT0Lr4aHdvi3ZN8VBOaCRFMfUEP5swggpq2QUeVWJ 3EN3nIueth1FNUAPDjOMPAmUiQt7PjQPEamsoXMGDohfFE276IOkUsulZyl4KNvi0pp3 JXfCzdbtnGF4XwXfQfTXj2yH8Gue4JMjGgcHSLfxRLZFZP635/GoE9Z+yUhUtZJc5Waq LasQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703576; x=1702308376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=liqggH+EgGCA3UCpWpXePVLNfUzms3eiOsEddC9yAyE=; b=uS6QPZf7lRANij62JCopaOggVCM8nACcV99Zuw7viAm3P7O/hPWYTMMcSIrhNJx42p 9EDFa7cJHdMPZ16oMNdLMaIKm/fpSdbUVm1+R+K1UvQiB3Q1rJbXSwRpA+9zcwRj3OHP fJhRZqYdASAYNJ8dBTtQZUNP65uQC7e4nN691DWj0OPgMBKeq83UHVoEogVZkb+j+bAs 7avdLtRBcZTpkmVkgUwTe3UAROGjUtJ3euVqQtrTiIT2rlb/+rQ8xA+S2ShfIOfCZP47 D91dWZHqjs1HB7Ry4l5SePsxvu6dtL0nzKdcJOORD1hmxP3jAZ1m3/A++CdQ+5z4GukZ fb4w== X-Gm-Message-State: AOJu0YwyvmY//isIm/JCttHT6eQWuvciPc12SRjMkdzPHRe0aD+N86R7 8/wPjOeT+wlNLphb321jOEM3aHHdBnh3zyCDxBXO6g== X-Google-Smtp-Source: AGHT+IEwOa6w9gJnqipUZm00LQXQPBCGCOjqcq4eN4HAUasNM5JsXAWS5zGwjBb2BmqPm08yM0oTFg== X-Received: by 2002:a05:600c:35d6:b0:40b:5e21:bdb8 with SMTP id r22-20020a05600c35d600b0040b5e21bdb8mr2175149wmq.71.1701703576117; Mon, 04 Dec 2023 07:26:16 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:15 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 6/9] recipeutils: bbappend_recipe: allow to patch the recipe itself Date: Mon, 4 Dec 2023 16:26:00 +0100 Message-ID: <20231204152603.831495-7-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191750 Add a new parameter update_original_recipe to allow to patch a recipe instead of creating/updating a bbappend Signed-off-by: Julien Stephan --- meta/lib/oe/recipeutils.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 8aa82396c86..013b7412742 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -664,7 +664,7 @@ def get_bbappend_path(d, destlayerdir, wildcardver=False): return (appendpath, pathok) -def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, machine=None, extralines=None, removevalues=None, redirect_output=None, params=None): +def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, machine=None, extralines=None, removevalues=None, redirect_output=None, params=None, update_original_recipe=False): """ Writes a bbappend file for a recipe Parameters: @@ -698,19 +698,29 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, params: Parameters to use when adding entries to SRC_URI. If specified, should be a list of dicts with the same length as srcfiles. + update_original_recipe: + Force to update the original recipe instead of creating/updating + a bbapend. destlayerdir must contain the original recipe """ if not removevalues: removevalues = {} recipefile = rd.getVar('FILE') - # Determine how the bbappend should be named - appendpath, pathok = get_bbappend_path(rd, destlayerdir, wildcardver) - if not appendpath: - bb.error('Unable to determine layer directory containing %s' % recipefile) - return (None, None) - if not pathok: - bb.warn('Unable to determine correct subdirectory path for bbappend file - check that what %s adds to BBFILES also matches .bbappend files. Using %s for now, but until you fix this the bbappend will not be applied.' % (os.path.join(destlayerdir, 'conf', 'layer.conf'), os.path.dirname(appendpath))) + if update_original_recipe: + if destlayerdir not in recipefile: + bb.error("destlayerdir %s doesn't contain the original recipe (%s), cannot update it" % (destlayerdir, recipefile)) + return (None, None) + + appendpath = recipefile + else: + # Determine how the bbappend should be named + appendpath, pathok = get_bbappend_path(rd, destlayerdir, wildcardver) + if not appendpath: + bb.error('Unable to determine layer directory containing %s' % recipefile) + return (None, None) + if not pathok: + bb.warn('Unable to determine correct subdirectory path for bbappend file - check that what %s adds to BBFILES also matches .bbappend files. Using %s for now, but until you fix this the bbappend will not be applied.' % (os.path.join(destlayerdir, 'conf', 'layer.conf'), os.path.dirname(appendpath))) appenddir = os.path.dirname(appendpath) if not redirect_output: @@ -755,7 +765,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, bbappendlines.append((varname, op, value)) destsubdir = rd.getVar('PN') - if srcfiles: + if not update_original_recipe and srcfiles: bbappendlines.append(('FILESEXTRAPATHS:prepend', ':=', '${THISDIR}/${PN}:')) appendoverride = '' @@ -789,7 +799,10 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, appendline('SRC_URI:append%s' % appendoverride, '=', ' ' + srcurientry) else: if oldentry: - appendline('SRC_URI:remove', '=', oldentry) + if update_original_recipe: + removevalues['SRC_URI'] = oldentry + else: + appendline('SRC_URI:remove', '=', oldentry) appendline('SRC_URI', '+=', srcurientry) copyfiles[newfile] = srcfile if install: @@ -811,6 +824,8 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, # multiple times per operation when we're handling overrides) if os.path.exists(appendpath) and not os.path.exists(outfile): shutil.copy2(appendpath, outfile) + elif update_original_recipe: + outfile = recipefile else: bb.note('Writing append file %s' % appendpath) outfile = appendpath From patchwork Mon Dec 4 15:26:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35624 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30D1FC10F05 for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.groups.io with SMTP id smtpd.web10.72248.1701703578125144295 for ; Mon, 04 Dec 2023 07:26:18 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=QKCJJ0DK; spf=pass (domain: baylibre.com, ip: 209.85.128.42, mailfrom: jstephan@baylibre.com) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-40c0a0d068bso12426655e9.3 for ; Mon, 04 Dec 2023 07:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703576; x=1702308376; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B7E0X1BrF0yRxoyN/2tLqacemtLMSRM0Alj0fdSRIA8=; b=QKCJJ0DKoQGU+T4Pmt2hEjLnGzWk217XZC2Lnb2tWTM6ldPC4NZzUHYI1vxj/f0bqz VmKhCjeA6AfWXmld8lb3SW9ZumI5yRNo1WBUv5Vj57+NqzvI/sPxIlLKscog99cqHJ0v YiMO2KAIuK99fxYg5pI2wSK+OMmBKMAOUgVD2pSJ7WnE3K6GKfCSBkb4RtvWQAHRiFDe V/O54pMj2jSvsxLHGSvxBFXm03Ih2NE1qGQrlREp2SQ2AZCvxKv2yKJL1RWqeQdilbma QEUvHhudb1Zqu81p/waFSlVmdIQNGOElIOhYSVWps2NCz0YadPTJ8vRtD+BAchrbK5F1 inhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703576; x=1702308376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B7E0X1BrF0yRxoyN/2tLqacemtLMSRM0Alj0fdSRIA8=; b=Snj2GDvOMSawgfZU++XXeZu6o1a9YpV4H4OI4jdL4qFmrIzYFVhiK3p920xZhIPbDi y/RLc6zP98zIyeVwLdM7XT9+mBC8Gm3YTQOq2E1GtxOvz/GxxhVwk4/EB2CXh87LfwVR N9AlRUsRii4gQs8t5NDNxgEwSm4y7oFxk73/yG+/Q5r12v1N3IyAU4Gf13vPgL7dKzg/ boesn+AP2oi57MGjoGCXHft/pr7gQEuZ+4iAIiABC63zRLyvmdWLlbrKMGcqrNs0lfMB LHZuhozbwyGhbdJQ+Zmo28OFj2n4yZPmRf4rCnqOlyorDctUve+YQWH51b4dDVDzGmos h5rw== X-Gm-Message-State: AOJu0YyhGevjxx43+P4hO1O9GFEZiHvZebFOK6UTcI6xBpwfVDvVYA0+ GYt2GG8jTUhqKBaMWOpltRO4fYFyBFufrCpZF7j1NA== X-Google-Smtp-Source: AGHT+IEZGdJ994mKGDtoY91Bq5nK6X9BulSm9201o2gGAGqWWHOLCudjMsXSjYfFqq5SfjLwkO4q1w== X-Received: by 2002:a1c:7716:0:b0:40b:50f5:3e6e with SMTP id t22-20020a1c7716000000b0040b50f53e6emr3204340wmi.24.1701703576506; Mon, 04 Dec 2023 07:26:16 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:16 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 7/9] recipetool: appendsrcfile(s): add a mode to update the recipe itself Date: Mon, 4 Dec 2023 16:26:01 +0100 Message-ID: <20231204152603.831495-8-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191749 Add a new option -u/--update-recipe to update the recipe itself instead of creating/updating a bbappend file Signed-off-by: Julien Stephan --- scripts/lib/recipetool/append.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/lib/recipetool/append.py b/scripts/lib/recipetool/append.py index 7e56290a0ab..66ed160a0a6 100644 --- a/scripts/lib/recipetool/append.py +++ b/scripts/lib/recipetool/append.py @@ -357,7 +357,9 @@ def appendsrc(args, files, rd, extralines=None): dry_run_outdir = dry_run_output.name appendfile, _ = oe.recipeutils.bbappend_recipe(rd, args.destlayer, copyfiles, None, wildcardver=args.wildcard_version, machine=args.machine, extralines=extralines, params=params, - redirect_output=dry_run_outdir) + redirect_output=dry_run_outdir, update_original_recipe=args.update_recipe) + if not appendfile: + return if args.dry_run: output = '' appendfilename = os.path.basename(appendfile) @@ -459,6 +461,7 @@ def register_commands(subparsers): help='Create/update a bbappend to add or replace source files', description='Creates a bbappend (or updates an existing one) to add or replace the specified file in the recipe sources, either those in WORKDIR or those in the source tree. This command lets you specify multiple files with a destination directory, so cannot specify the destination filename. See the `appendsrcfile` command for the other behavior.') parser.add_argument('-D', '--destdir', help='Destination directory (relative to S or WORKDIR, defaults to ".")', default='', type=destination_path) + parser.add_argument('-u', '--update-recipe', help='Update recipe instead of creating (or updating) a bbapend file. DESTLAYER must contains the recipe to update', action='store_true') parser.add_argument('-n', '--dry-run', help='Dry run mode', action='store_true') parser.add_argument('files', nargs='+', metavar='FILE', help='File(s) to be added to the recipe sources (WORKDIR or S)', type=existing_path) parser.set_defaults(func=lambda a: appendsrcfiles(parser, a), parserecipes=True) @@ -467,6 +470,7 @@ def register_commands(subparsers): parents=[common_src], help='Create/update a bbappend to add or replace a source file', description='Creates a bbappend (or updates an existing one) to add or replace the specified files in the recipe sources, either those in WORKDIR or those in the source tree. This command lets you specify the destination filename, not just destination directory, but only works for one file. See the `appendsrcfiles` command for the other behavior.') + parser.add_argument('-u', '--update-recipe', help='Update recipe instead of creating (or updating) a bbapend file. DESTLAYER must contains the recipe to update', action='store_true') parser.add_argument('-n', '--dry-run', help='Dry run mode', action='store_true') parser.add_argument('file', metavar='FILE', help='File to be added to the recipe sources (WORKDIR or S)', type=existing_path) parser.add_argument('destfile', metavar='DESTFILE', nargs='?', help='Destination path (relative to S or WORKDIR, optional)', type=destination_path) From patchwork Mon Dec 4 15:26:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C122C10DCE for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mx.groups.io with SMTP id smtpd.web10.72251.1701703579322707912 for ; Mon, 04 Dec 2023 07:26:19 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=v/SltEoZ; spf=pass (domain: baylibre.com, ip: 209.85.128.52, mailfrom: jstephan@baylibre.com) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-40a4848c6e1so47618955e9.1 for ; Mon, 04 Dec 2023 07:26:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703577; x=1702308377; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z9Zb84Ec/4iGGHrwB2lZjLIhO9h38MYcxk9KrWHn4E0=; b=v/SltEoZluLuze1P9ibxZIFeG6D/SA2Ww7j5uIVS3vxk3buUKl+rQ+cqE3KJ3kQ+QH kjsWDSY7jZyxd3zSzt/84X1+670Y9Ped1jM4HfQhJDHBumYhXm9Ru8GO/SXKOafMxOYP Q+ZrCHvg7+9iwLpp6Fh+TP+5aHxCfkQ/1qJx5DzJJL/o5WVpq4vFmI/lmuNWScq9eKlW A0Q8WdiUN2ByFR847WkIK+XEaulFPpjc6qZhzAQ4mNwMkFR1QWWp3Y0JGUKXGeBBf3ht RaVuajY93JneEeYliNmElE6jAiISxpUVJ6R/HHgvCj+a4nkSYnK7sDV7xRPS8sjW/q0O WchA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703577; x=1702308377; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z9Zb84Ec/4iGGHrwB2lZjLIhO9h38MYcxk9KrWHn4E0=; b=vrgUB3cdiCsc4kN0iaVDcX5Nim37Kcvhamz2yeZJaKWCVyFkk9+ELJwZw6MV38Cghx 8w+15PXh979+VwcdJxAfY2grk6HNYu48XkmcRmAWopYlff5D6nVYALnTTxFEMmmiHuKW wRYCexyx/o7uuccc5Ign59LplPabIdvuMiegwEumBF+nAUEDwzyDnNfAQSHFvEsK5ULy pwg18g4g/yGKn8k/r3lZ+qQRoK5u9hKOKd1qrytdahb0uhCwWLpNsEmGkAX24q4brztm ijbX1C1u9iF3YuixYsKtzsSESxKMoca8Mbvq7uyUgShUN5IBNo0oWXZ3dPdkdN/f/0xl ExLA== X-Gm-Message-State: AOJu0Yx24XpeX/+Y+pVttCme65qXJpABQQV3vJs82aCDD68m5I7ZxONk kEoTb0uOU3zrANDQ+cKjecEB3IhPLKo+BAScPW9RDw== X-Google-Smtp-Source: AGHT+IEwyQ64FJSo0ZsrB0yPQUeFQLniHi8MRQrrHlyKOok+Kuoryp+2vRCKiNV6JeWlQfiGw017+A== X-Received: by 2002:a05:600c:1d95:b0:40b:5e21:bdd7 with SMTP id p21-20020a05600c1d9500b0040b5e21bdd7mr2454236wms.102.1701703577244; Mon, 04 Dec 2023 07:26:17 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:16 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 8/9] oeqa/selftest/recipetool: appendsrfile: add test for machine Date: Mon, 4 Dec 2023 16:26:02 +0100 Message-ID: <20231204152603.831495-9-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191751 Add a new test for machine specific bbappend override Signed-off-by: Julien Stephan --- meta/lib/oeqa/selftest/cases/recipetool.py | 44 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py index 21cb350e8a6..c55025e7df6 100644 --- a/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/meta/lib/oeqa/selftest/cases/recipetool.py @@ -1056,7 +1056,7 @@ class RecipetoolAppendsrcBase(RecipetoolBase): if p.scheme == 'file': return p.netloc + p.path, uri - def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, options=''): + def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, machine=None , options=''): if newfile is None: newfile = self.testfile @@ -1084,17 +1084,39 @@ class RecipetoolAppendsrcBase(RecipetoolBase): expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n', '\n'] + override = "" + if machine: + options += ' -m %s' % machine + override = ':append:%s' % machine + expectedlines.extend(['PACKAGE_ARCH = "${MACHINE_ARCH}"\n', + '\n']) + if remove: for entry in remove: - expectedlines.extend(['SRC_URI:remove = "%s"\n' % entry, + if machine: + entry_remove_line = 'SRC_URI:remove:%s = " %s"\n' % (machine, entry) + else: + entry_remove_line = 'SRC_URI:remove = "%s"\n' % entry + + expectedlines.extend([entry_remove_line, '\n']) if has_src_uri: uri = 'file://%s' % filename if expected_subdir: uri += ';subdir=%s' % expected_subdir - expectedlines.extend(['SRC_URI += "%s"\n' % uri, - '\n']) + if machine: + src_uri_line = 'SRC_URI%s = " %s"\n' % (override, uri) + else: + src_uri_line = 'SRC_URI += "%s"\n' % uri + + expectedlines.extend([src_uri_line, '\n']) + + with open("/tmp/tmp.txt", "w") as file: + print(expectedlines, file=file) + + if machine: + filename = '%s/%s' % (machine, filename) return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename]) @@ -1153,13 +1175,23 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase): self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe) self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False) - def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self): + def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self, machine=None): testrecipe = 'base-files' subdir = 'tmp' filepath, srcuri_entry = self._get_first_file_uri(testrecipe) self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe) - self._test_appendsrcfile(testrecipe, filepath, subdir, remove=[srcuri_entry]) + self._test_appendsrcfile(testrecipe, filepath, subdir, machine=machine, remove=[srcuri_entry]) + + def test_recipetool_appendsrcfile_machine(self): + # A very basic test + self._test_appendsrcfile('base-files', 'a-file', machine='mymachine') + + # Force cleaning the output of previous test + self.tearDownLocal() + + # A more complex test: existing entry in src_uri with different param + self.test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(machine='mymachine') def test_recipetool_appendsrcfile_replace_file_srcdir(self): testrecipe = 'bash' From patchwork Mon Dec 4 15:26:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1648FC46CA0 for ; Mon, 4 Dec 2023 15:26:22 +0000 (UTC) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.groups.io with SMTP id smtpd.web11.71455.1701703580534360315 for ; Mon, 04 Dec 2023 07:26:20 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=IFcjoy8a; spf=pass (domain: baylibre.com, ip: 209.85.128.44, mailfrom: jstephan@baylibre.com) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-40b399a6529so35194565e9.1 for ; Mon, 04 Dec 2023 07:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701703578; x=1702308378; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CWxlOCe/hdZJ+F4EXIapSccS7y66VxWLnP8DNmgSPhk=; b=IFcjoy8aeHa4x1AnPtD2vnLsKSlUU1+iDT2oR7/HM0HEiIZeK1rJe8eDZpKgH368Yf U7qrmvwE4KUqMI9ynYqp/GTAKg6xuMOfUGaBTSTzei7q9jjg83HaebPoIIzN8gCj6rBf WaMF94ml7s7dryQfd1E39cApwvuYOWO48WHoeO18Sjb8KxkXut+MOzO8rU0xivI0jC3z cFP0crmJEh2SysIOYdPkLIBDhGWSb3AXyulFT5YxcsJHNfTKn1U29a1m3sR7IgghcNXs jZnBgwB0AHBYxKE+DR1BKzIXFcr+jpXdKXR4OoFonDJ5w1CuS+L6/m+t6xahCJzHcd/m 5OjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701703578; x=1702308378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CWxlOCe/hdZJ+F4EXIapSccS7y66VxWLnP8DNmgSPhk=; b=gzgr9rAEzDqY9YKfjPmJFZu8zNwWhA7IrZ7itSjO9ByObsr4EhxbSjeKZGB/HSlOpr 8oYYbPfmQ6rXmyXJ+gs03bZuuRtXhAkcPEImmgCRAl7r48DD2iq8F9yZTIqfINm6H6y5 ztAVBB03wAOUPOZ7rt3dkQHfKKShEOONP3TNVHaEAi+gD2i4T7m3VL5sOH1CFqf5mDU8 YfYqEVv1Qt9+1rX3wRcrn47xvxpRsZQbsTrYvxzIIhoUVL2VJJcr97QVm9+CIMUtRBsT TpKiqvJ13GxMiPQ6HfV0XR21njOHjb/7SWWpaqfg1MTcuEQ9xoOBHYs2Lk3JzOWrKzbd rS8A== X-Gm-Message-State: AOJu0YyKhoJmHCBlbkFKJ0LffhlxGMhzUXdSS9HHpnQxqwCmYpUYmq7z y9hAmep23JJyq0b8+COTJVUTYe5GVhO9xYM/muv9kg== X-Google-Smtp-Source: AGHT+IHcRjAeDeqlBqoCEos2NoXjl+m1uSbtC8czp4WBI0eilRvOf78TJTPpYiKVDqk+sTxs02Cu9A== X-Received: by 2002:a05:600c:816:b0:40b:5e4a:2345 with SMTP id k22-20020a05600c081600b0040b5e4a2345mr2906566wmp.71.1701703578290; Mon, 04 Dec 2023 07:26:18 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id w7-20020a5d6087000000b0033340937da6sm5257341wrt.95.2023.12.04.07.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:26:17 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v2 9/9] oeqa/selftest/recipetool: appendsrc: add test for update mode Date: Mon, 4 Dec 2023 16:26:03 +0100 Message-ID: <20231204152603.831495-10-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204152603.831495-1-jstephan@baylibre.com> References: <20231204152603.831495-1-jstephan@baylibre.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 04 Dec 2023 15:26:22 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191752 add a basic test for testing the update mode of recipetool appendsrcfile(s) Signed-off-by: Julien Stephan --- meta/lib/oeqa/selftest/cases/recipetool.py | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py index c55025e7df6..0a82b081a2d 100644 --- a/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/meta/lib/oeqa/selftest/cases/recipetool.py @@ -1193,6 +1193,34 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase): # A more complex test: existing entry in src_uri with different param self.test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(machine='mymachine') + def test_recipetool_appendsrcfile_update_recipe_basic(self): + testrecipe = "base-files" + recipefile = get_bb_var('FILE', testrecipe) + result = runCmd('bitbake-layers show-layers') + layerrecipe = None + for line in result.output.splitlines()[3:]: + with open("/tmp/juju.txt", "a") as file: + layer = line.split()[1] + print(layer, file=file) + if layer in recipefile: + layerrecipe = layer + break + self.assertTrue(layerrecipe, 'Unable to find the layer containing %s' % testrecipe) + cmd = 'recipetool appendsrcfile -u %s %s %s' % (layerrecipe, testrecipe, self.testfile) + result = runCmd(cmd) + self.assertNotIn('Traceback', result.output) + self.add_command_to_tearDown('cd %s; rm -f %s/%s; git checkout .' % (os.path.dirname(recipefile), testrecipe, os.path.basename(self.testfile))) + + expected_status = [(' M', '.*/%s$' % os.path.basename(recipefile)), + ('??', '.*/%s/%s/%s$' % (testrecipe, testrecipe, os.path.basename(self.testfile)))] + self._check_repo_status(os.path.dirname(recipefile), expected_status) + result = runCmd('git diff %s' % os.path.basename(recipefile), cwd=os.path.dirname(recipefile)) + removelines = [] + addlines = [ + 'file://%s \\\\' % os.path.basename(self.testfile), + ] + self._check_diff(result.output, addlines, removelines) + def test_recipetool_appendsrcfile_replace_file_srcdir(self): testrecipe = 'bash' filepath = 'Makefile.in'