From patchwork Tue Dec 5 14:56:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35699 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 0E1F2C4167B for ; Tue, 5 Dec 2023 14:56:51 +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.101429.1701788206597176109 for ; Tue, 05 Dec 2023 06:56:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=n5R/9oZQ; 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-3333131e08dso4329914f8f.2 for ; Tue, 05 Dec 2023 06:56:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788204; x=1702393004; 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=oyrxp4HY1RDWuQUHFFLL/K1O/fmAKmFzoC9Fnl5D99Q=; b=n5R/9oZQQId2fs+gVH1Qf54QoRXC93WgsFclxetoPYz0gNDnWf8SzLF4xBhFy97Evm MWVWfcCNmCi81SzCtM1aqIduGvUicFbEG35y75HpC8KUhuSu5SAD2FJS+82cTxh/dabf qWZeBJmQ2OOCV1RvL+Z8d3vW5ggK76y5gmHgILBIstWvpE0uRionMhzGeb+9ii49N2eC l+HwEFOHTjtXignwkUMCCN0SSaYrE6OY3LYha2c6cd3aq8iIbDR91yCECWSdCcH05WCE Zqnw1oHj5ljrPdGs2ijIc9ZMkMxbE7tcghztqlNwuPs0fxlF+JomsyUTtu0vl5L4YXhH hjew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788204; x=1702393004; 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=oyrxp4HY1RDWuQUHFFLL/K1O/fmAKmFzoC9Fnl5D99Q=; b=sEB+bsRXobL6ncOs/ucI4NbrFuW7ROPyWyVAwC2q/F77qwAfUvP1kpGVcHyY2gv++2 Z1oRJ5BoxzwJKDvZ4086LuJ2GFUorP/md4RaC55qKeLatzIbR7taUmQE1Iclh3YsZ4R4 eort5mAONTIt+JVphpKYXxWYJ/hXG1gpdOF86EGDvd8UWWWHzGg3NDjNkZIOTsENK45Q 3aLv8y43lk2KvHHXdTr+vwUU1yLK9zoVFRpPHd5GCKTXNtdWlTuE3vQPdwu+hWVRD3AW aIn1XBWMbweQmZJaHqFsPudpjDC3WrmZ7LSLdwca78diIjOH+ZbvU3sbo4ualPl5S9tc kwXg== X-Gm-Message-State: AOJu0YyUn4uwXApgAIHIqpS1H4Bzuq6shHxxAqeFMDNMl4q0MjIaJrk6 ePGR2gFo/wwBlsS08s8lq29P2RM6T/0KV4dSotBE9w== X-Google-Smtp-Source: AGHT+IGz040QoWdT/Vq5eQXcQFwWC9U6pGGAe8ZNt0Pyce3Q3h/E7KIaKEkYGVsvfw6OnxqZILWgZA== X-Received: by 2002:a5d:62c2:0:b0:332:ca69:2fb5 with SMTP id o2-20020a5d62c2000000b00332ca692fb5mr3737082wrv.11.1701788204387; Tue, 05 Dec 2023 06:56:44 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:44 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 01/10] recipetool: appendsrcfile(s): add dry-run mode Date: Tue, 5 Dec 2023 15:56:27 +0100 Message-ID: <20231205145636.960819-2-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:56:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191829 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 4b6a7112c2b..58512e9e4b4 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] = {'path' : 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 Tue Dec 5 14:56:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35703 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 45633C10F07 for ; Tue, 5 Dec 2023 14:56:51 +0000 (UTC) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mx.groups.io with SMTP id smtpd.web10.102643.1701788206946868454 for ; Tue, 05 Dec 2023 06:56:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=r2FZe/H9; spf=pass (domain: baylibre.com, ip: 209.85.221.41, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-33349b3f99aso1833427f8f.0 for ; Tue, 05 Dec 2023 06:56:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788205; x=1702393005; 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=YW8I10SphgwVLiPfFzoRVuNLZ7M+DbpYVIH2mODBBFo=; b=r2FZe/H9F1yrs9VSJftH3mOZqgJFs9RebeRICsLMkdL9oKGykSrIZKsqAAeIvFF2gE hE79Ij/9uQo1OWXLqN1UXoWjAizhqRvFScZhaGUm7a+P8joPA236MhT2+2UH33sUaQls q0DGDyLZ5DggNmH2zEZH8mBw+cfc7MPZBRkHUOHC32MIg7e0M51xBZYFTxEaugUdiOtD y0LXxg7gnwM1f82DcPavDXkHh8ha1pCH7dScG+WPOlbgchys7/5HR+Gl/Fo8qF1v6NDV Ha1CeZYR2aOfRj5PIoJLu17QYd5j49S+Y5uyLzFINqsmoalbf4gSVeluXgeUIOsSkmDb aV2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788205; x=1702393005; 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=YW8I10SphgwVLiPfFzoRVuNLZ7M+DbpYVIH2mODBBFo=; b=Op3IT9ktl7RE/VQqtFcRxGCTwCWGVH3vPK7pdOI+gBsK7HFTw7INeZn15tX+8cbzJh qUNqVqzDLUnZ5hnO2OW7U0qtD9l5vF1SNnO5w9hrunKrEqxYrx16uE1Qpx5MAQztYbAW uiSSK/hzM9dw0KP91hTJ8K//5NHa3YvmXMDSskfbKbNnAsuL4lqX3RlsCXqs++SLswxi T5lKflAVzg2Ca63BNJXYJiL/n0HE4VzgbyVRGz8m8ngJpWLfADghN/4cG3cpDGqv/p3b 8e8V3kajPYo2TKpOwrAsyxfHpqqy2n4HBrSiHcSR8OQaH9M6bZYRS4c3xUQLfSURcYHN 2Asw== X-Gm-Message-State: AOJu0YyD6A+7ohK5wLtvUE+jxCiClE6vF3PMFWRDGXGX5S82RYlkcml2 SAEmo/V09SzdoYQ8kstHkrTy/fZzONYh0/NuHNBEcQ== X-Google-Smtp-Source: AGHT+IElUyy3IzRlKIhT6fRGVy/Z0TtS1PyrrQkR9iE9rajwNkzD2OMmw6QuDVFFFmDOK429SvST9A== X-Received: by 2002:a5d:58d9:0:b0:333:2fd2:51ff with SMTP id o25-20020a5d58d9000000b003332fd251ffmr4324470wrf.120.1701788205353; Tue, 05 Dec 2023 06:56:45 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:44 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 02/10] recipeutils: bbappend_recipe: fix undefined variable Date: Tue, 5 Dec 2023 15:56:28 +0100 Message-ID: <20231205145636.960819-3-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:56:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191830 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 25b159bc1bc..0aa6d0593ed 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 Tue Dec 5 14:56:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35702 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 132D1C10F04 for ; Tue, 5 Dec 2023 14:56:51 +0000 (UTC) Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mx.groups.io with SMTP id smtpd.web10.102646.1701788207840589358 for ; Tue, 05 Dec 2023 06:56:48 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=P6mHyx0G; spf=pass (domain: baylibre.com, ip: 209.85.221.43, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3332fc9b9b2so3850019f8f.1 for ; Tue, 05 Dec 2023 06:56:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788206; x=1702393006; 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=C+F67wpL35q/ZKAODwIUa1poeIOQktkVrGJ+0bl7lno=; b=P6mHyx0G4DDbOoFa+C2CB/jXvvQbvTWs/eW3VKqSIhcq9UGU4WZz9rBXWMha5lMzxY 0YjmEnMpr64V6ngxrHvemMT0S9SGV+ScVQ45xOh2V9Rk2gclSeAcnqQHUoktueV3isSi Vb+ENC2RNDW2J3KOWrK61qJ/glRcyd79y5UqJ/Ykj7drOfaq4cjj37E/oWArUxEs+Zjp /cf3wySiD1bSopfX4xJ2IYDGuAU9b4p2IBgpdoL8nFrVj0QB9jgifsTB0LoihmBUrCPO QcbzG03nefM8ClMy7Dc7NoMfdWU54F8YyAIxw+VQJVZjaqJT/xFhfP0ZBf/WYI7iWml6 oUAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788206; x=1702393006; 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=C+F67wpL35q/ZKAODwIUa1poeIOQktkVrGJ+0bl7lno=; b=bz538++xgRuvJSJc6o95O+Or8Wm9lbEBMgoZAa+TFPfrRyRLizQpECzBu6yoHOnX2D ZOs4SqRLCF7IlylCJBXhoTabXFT4U3BmIk2W9McNKBBGtYY96ABvXb+0K84kWWk9XNEq 8JbxFvbioUn0q3j9qj6brj2L6KXhrt9C3rSxA5F7KcwMVhJNF8CAWfoLEGeHhcUWB0E/ +kr4A4+PkvwfmXHghnRtBzeTRj3oQ8GsXhGu+nTbDoJcEUeUGVh3s+lQvkcnJmArOaXT kd56tZJ4U8cl2eiAdRhjV/asR2LdZzpgD93LpvEX5Uv0FCBGjUZ0Qj0IFBPelbgHJMfx lEhA== X-Gm-Message-State: AOJu0YyW4fOk51+YhHVVGfnD4zWjLkqgtwcMDyz+dY03TLy3JTa6lAiO iU9fkKqHEV2FWykONzsH1SAXuUa5KTz7HrsuK+LZEQ== X-Google-Smtp-Source: AGHT+IHUUOoCEdeZafgID5+/tz2x2NdVh0z6iDxMPOmnfpAcSNSJqrdMpFQ8anowO69O0wE0eT+f/A== X-Received: by 2002:a5d:61d0:0:b0:333:3117:c470 with SMTP id q16-20020a5d61d0000000b003333117c470mr1962398wrv.257.1701788205911; Tue, 05 Dec 2023 06:56:45 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:45 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 03/10] recipeutils: bbappend_recipe: fix docstring Date: Tue, 5 Dec 2023 15:56:29 +0100 Message-ID: <20231205145636.960819-4-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:56:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191832 Add missing patchdir key in docstring description for srcfiles parameters. Also fix typo: value --> key in srcfile docstring description Signed-off-by: Julien Stephan --- meta/lib/oe/recipeutils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 0aa6d0593ed..01c9ad190fe 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -671,10 +671,12 @@ 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 + 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 - dict with 'path' key containing the original filename as it - would appear in SRC_URI or None if it isn't already present. + dict with following optional keys: + path: the original filename as it would appear in SRC_URI + or None if it isn't already present. + patchdir: the patchdir parameter 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: From patchwork Tue Dec 5 14:56:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35700 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 21401C07E97 for ; Tue, 5 Dec 2023 14:56:51 +0000 (UTC) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mx.groups.io with SMTP id smtpd.web10.102647.1701788208568919011 for ; Tue, 05 Dec 2023 06:56:48 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=Sbu6GrwN; spf=pass (domain: baylibre.com, ip: 209.85.221.51, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-332c46d5988so4570523f8f.1 for ; Tue, 05 Dec 2023 06:56:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788206; x=1702393006; 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=NUSeIOJHjslk5M3M8769+rPHIE5kbg8mkMrYJdMCf5c=; b=Sbu6GrwNBvsjrsrVeR3j/QOnW06GR8PVsLqC/yYZJa8dZo3y8N6okeHfCa31xJxvsq t0DokIYPJQLqTF4G+jijEzf7V+QTPLEXBkEufguGQMKK4pvN2wm7WFZnx+34J5wmfZIm CowAmG2Jmmb74VR7ptH8nXkgQxd5TyYo+Zkb4WJnHULmINg8sWefx6K+uFuyWgDNwaJG t9JOVAnvbawUj32GgmlccoOtZHFgP1z1/8oeyJtfaBjlpJunKBHoYCm+i3c09nLNy0NA VFMETy4szjePEz8cT7f18cUjQBEAzWIGWpsdM8SyrJMoKGE9MCNl8PLV1lvhEVoRiofY i4Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788206; x=1702393006; 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=NUSeIOJHjslk5M3M8769+rPHIE5kbg8mkMrYJdMCf5c=; b=h4b2PJXEQakNOqIf9QDD2CAJyTm4tPb4mtGfJoWD6tDQ8FcVVHSvqRrfoqnrr+XOgp J6gyfHwpCzH7d+55jmAE5i88VzCP7KAXKQFeBtAy3jWmTLjV9Gy33bMH3H5zvjVVVFpT kKoiQStnJro+KiR7asP6bAadCXjtt2k4TdwFQEhoUqNF84/ICNrR2khchhipxemNoAc3 eiTSb76S7kMIlCgoDyS3as8aNcRSbeiBsatOuUSCAz60BUtUDMS8mvgAJhr/6whFOXye iZOfizn877gHn4RgvjDuAjnHm90RCRj/QWuTFKrEIWotgqcuBEI3AvN43ejdcy8DDeYl 44qw== X-Gm-Message-State: AOJu0YzRzq8Pf9pw6LqpJNGqN8Y32YeRB6WSHm8n3n+E6CIwb03BNF64 tnvr0tQTlwIP/SOVKzF4ZwOguKZqP6UnVAHg6SMRhg== X-Google-Smtp-Source: AGHT+IFUnp2pXN4qKnIp7vth77jHtK5FL6FLlR9mmho+YFIe7hQA3OG4WdomiViBHGoTq4bTKoo8hw== X-Received: by 2002:adf:ee82:0:b0:333:2fd2:5d52 with SMTP id b2-20020adfee82000000b003332fd25d52mr4820085wro.132.1701788206495; Tue, 05 Dec 2023 06:56:46 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:46 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 04/10] recipeutils: bbappend_recipe: add a way to specify the name of the file to add Date: Tue, 5 Dec 2023 15:56:30 +0100 Message-ID: <20231205145636.960819-5-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:56:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191833 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 a dict Add a new optionnal entry "newname" to specify the name of the newly added file Signed-off-by: Julien Stephan --- meta/lib/oe/recipeutils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index 01c9ad190fe..1d793693bfd 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -677,6 +677,8 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, path: the original filename as it would appear in SRC_URI or None if it isn't already present. patchdir: the patchdir parameter + newname: the name to give to the new added file. None to use + the default value: basename(path) 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: @@ -769,7 +771,10 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False, for i, (newfile, param) in enumerate(srcfiles.items()): srcurientry = None if not 'path' in param or not param['path']: - srcfile = os.path.basename(newfile) + if 'newname' in param and param['newname']: + srcfile = param['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())) From patchwork Tue Dec 5 14:56:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35701 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 29A8FC46CA0 for ; Tue, 5 Dec 2023 14:56:51 +0000 (UTC) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mx.groups.io with SMTP id smtpd.web11.101430.1701788209726171302 for ; Tue, 05 Dec 2023 06:56:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=FYASao7/; spf=pass (domain: baylibre.com, ip: 209.85.221.50, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-332c7d4a6a7so5016051f8f.2 for ; Tue, 05 Dec 2023 06:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788207; x=1702393007; 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=R+3figiPx80GXRWVP2kog25nPpVCg8Mmn1SmSOOGvZE=; b=FYASao7/tSJjC7ZVG8h1mkL8uoV39OFh8mec3cryijk4uoSyJ9Ef79m235Ng9B/Jvb qugkjmcy5ufiJOZxZV9Vjgr5aJCe1ufwCoZM3ucmLdaBqHiQNVHGduKT9TpyIiYBJwr4 eKQNoTJxP2khYRwK+Uup2xBm/5Jf5pt+LURVCJ6U5ihOuMKsu/D0XggECFsKwrt4RPEU +okRYsBiTCsZRG7ltnUmMX7NCTGodl2+5ZGUIqa98yCm53AkqSSQjr/Ncu7TgSeXVMMc 6XW9RU31NV4rL9a1HCjNvbV1ffaDTI5lwMoB7kNfGKJ661Wq1u1lPEjK3dH0S8DiqdTN xNbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788207; x=1702393007; 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=R+3figiPx80GXRWVP2kog25nPpVCg8Mmn1SmSOOGvZE=; b=vlKkmTtXr8rG6Fi9Q7OmeWecJUwc9k4qLNbdtEbLAQi3A5EVRCQ36dOhfsElZvW8Ho 37zWOKLwprtWXKnqCQj8Aaj4unwwNf1ngWFvWaE78rYXJTZKmz95DtjmJqgWW6tNmw6J ZxVUR0Q4plaCcD2p0xTc5A5vx3AbSBxUAAPbUtALfj//pE8Uf2zwFsafnYnXpoDw5H8D LPiK1k13QCVJFrfEW3ONboFFv+jRU8ccBpft4IxiB8zZvImtHif1WEzJ28HYxqFXmhIr Ri4vSuWFQsg/k/ZmM3EUNJh8nPB9EApofT+xhftjBXhq1t0gmbB7sXb/TOu3DkmwQrM/ W06A== X-Gm-Message-State: AOJu0YyOZQIhvZav8ST1hdH4HT+UZ5oepQVWdKcOQDFzQazfWJJa53QT DbhrBhRZAerBz+L2ro71fj3OTMLtzMXRDKHUKRymtw== X-Google-Smtp-Source: AGHT+IEMOcshiAcSWj46gVwq7Hl8sddfyQhy0BH0+alc0uyQIu8wWU7X3uYsL/UQ3tMW2aN1webruA== X-Received: by 2002:a5d:5f96:0:b0:333:4ac2:fe2d with SMTP id dr22-20020a5d5f96000000b003334ac2fe2dmr1767030wrb.54.1701788207501; Tue, 05 Dec 2023 06:56:47 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:46 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 05/10] recipeutils: bbappend_recipe: remove old srcuri entry if parameters are different Date: Tue, 5 Dec 2023 15:56:31 +0100 Message-ID: <20231205145636.960819-6-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:56:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191834 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 1d793693bfd..d86873056fe 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py @@ -776,14 +776,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) param['path'] = srcfile else: From patchwork Tue Dec 5 14:56:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35704 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 33F8AC10F05 for ; Tue, 5 Dec 2023 14:56:51 +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.102649.1701788210245441974 for ; Tue, 05 Dec 2023 06:56:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=skUnNV+d; 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-40b399a6529so42491385e9.1 for ; Tue, 05 Dec 2023 06:56:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788208; x=1702393008; 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=PmVI/2gYBIerRxaLZ8/yoIeLVOQwnF80cKFsru12uu8=; b=skUnNV+d3PekuO5A7975dtIjObXoZhahmu7LhbC2jHxnQDtSQlxdCMmxYwp3UMh420 hD35O/XDPa1TsBdQV4xcv2ZwI3L/JW2Re60D0fRl9bojJPa3gd9YUdiiUx1PRH7OG2dA 0I4X2AxCdOqmcsHVQmmSBOUeTnn232kknucM/ko9MLzEJ8hyfF/TSDrygTiLUN6QeOoG ymwKxxS9fQqui40s72I0eIATrbb2FEbXFkMZa3kMMGljp46M0fV0VioG/UMpWxnpKM6X N0ve5b4+ZZize9W1fo6ObJy/+QGGg8DWdT9IEl+RdbMwmt9nc/1EDw81ESbWN57YYCOH qAVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788208; x=1702393008; 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=PmVI/2gYBIerRxaLZ8/yoIeLVOQwnF80cKFsru12uu8=; b=ZoaoN2s2UJ/b/P8Tca36FcEO4bKtQC34BS2DtP3mJcmQ+BmD98+vmnwylII64UWpat cC1l5GwzHMfiyuBtE7/UEzRtXJgYSQNa8k+ToTf/qsrJCw0zIAXvG6r+0/6m+QBia31M flc4+mmqR33aRaWLE+h50wPgKrF8w9GNSeXl2qIPspQ2nGm2GvheTSud149r8kcBvdvA LX9Wu0QYF9XM4DGIEwzxc6e7d/FFflk0uhVuwyeM+Yjx/Na4o9uWtY9hXqlKd6hckdto 0+5zmlNJJ3OhmDGjHYqs0Hibq3W05OHqbISbj/0lO0Nc9NNBMiILDIC0OpJufkcx9HiC hVsQ== X-Gm-Message-State: AOJu0Yxz+haBPHPZY23gBUtGSucg9WRHaHR7szjlcS/0KAGmzsXlapLW r0w1Ozdm3MJQkdnZyQbq/rtefcS3woClyWJEzVEvUQ== X-Google-Smtp-Source: AGHT+IFJSBYuWrKgA4alJU6e6u3U4tR6EP1EXrMy6i6yZTCdwg8oNTOWJj3/1YHm2+328Hj3lzvkQw== X-Received: by 2002:a05:600c:2259:b0:40b:5e56:7b39 with SMTP id a25-20020a05600c225900b0040b5e567b39mr604320wmm.130.1701788207870; Tue, 05 Dec 2023 06:56:47 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:47 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 06/10] recipetool: appendsrcfile(s): use params instead of extraline Date: Tue, 5 Dec 2023 15:56:32 +0100 Message-ID: <20231205145636.960819-7-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:56:51 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191835 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 | 26 +++++++++------------- 2 files changed, 23 insertions(+), 24 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 58512e9e4b4..fc3cc4a0b7f 100644 --- a/scripts/lib/recipetool/append.py +++ b/scripts/lib/recipetool/append.py @@ -300,7 +300,9 @@ 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: {'path' : sourcepath}}, install, wildcardver=args.wildcard_version, machine=args.machine) + if sourcepath: + sourcepath = os.path.basename(sourcepath) + oe.recipeutils.bbappend_recipe(rd, args.destlayer, {args.newfile: {'newname' : sourcepath}}, install, wildcardver=args.wildcard_version, machine=args.machine) tinfoil.modified_files() return 0 else: @@ -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] = {'path' : srcfile} + params.append({}) + + copyfiles[newfile] = {'newname' : 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 Tue Dec 5 14:56:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35708 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 3ACDFC4167B for ; Tue, 5 Dec 2023 14:57:01 +0000 (UTC) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mx.groups.io with SMTP id smtpd.web10.102651.1701788211249722619 for ; Tue, 05 Dec 2023 06:56:51 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=NzmvXtqM; spf=pass (domain: baylibre.com, ip: 209.85.221.46, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3316c6e299eso5026770f8f.1 for ; Tue, 05 Dec 2023 06:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788209; x=1702393009; 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=BVPsC0HTKfjpGujZfVkG8OPHgXuOSbDa2N5RmWsNBTU=; b=NzmvXtqMtPfc9uoExit+6z+uIiAQucdrO3BRHQ+cpzdtqwq+na9MDUxvRRNGPmc+qj 0kafpIkCjotEO3cq0qJXZ7+hItJWraoH+PgTiREdISlAXsAY6O+GMI1Sg3q58WbWoqGh MSG2A9CR+JeS1CG9KMCLMv/FkLqn3/fvpcjgC+XwElSOVHnnWYsaFpbc12jt1sNO/6qv McmSjiUp1Dh21/pTX91aMKkx0e+Nr93Sc1Mag9UElYT7VgpYX6zMrK7tdPOKdu6zT7HS iVzplDFe6wFv2MHDTSfcrtrFa2ICPatQR5hn2+fAj4HkEPSW4vFObSPFAfxIELj3JxJv KxyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788209; x=1702393009; 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=BVPsC0HTKfjpGujZfVkG8OPHgXuOSbDa2N5RmWsNBTU=; b=AeXe2H3BqEvJG7w9eVuaWrMlv9SnBNBJmEg0OGRYiIbNGseTJR/DiB6w+iZtZHgRBT aNg+Aumano2/vHrL3DjsUA/pvVP5874UgluaWCRvxCdSWlek99YrYcb0QW0cgz2az1QP UqBAMikEuga76MCdzkaleNG11Ji5YTnsI+t5ZLKhHwaJ3g0fTlzq8eNz7Eo+1+ciYUX8 lIOeq7lRGlDE22aNdj8aRpvD+WIwYWyMHd19srsAh/Fz+6/LoukSB7Pjd3pQS4i99Lqg aJGSDVnsrC4pBK9PKrqORnHqc15+N8OHOVgvilDoJfXR6IcMET3+3QqIJHybItYCI8Yr au2g== X-Gm-Message-State: AOJu0YzobHV7j7LLrLCOcqYnkrNWiKyJGMAXfGtg92bGr9ezWmokhCTP 4b7T3df5xW8t23xi3WWCuBZ1kq/hvdujhFi7W8coXA== X-Google-Smtp-Source: AGHT+IHqO0a2grsLQA4l4pOF4Xfqs4E6wl0QjnP6sicoMPudNlaS1RFTzrYll9vCOuR6JTbgD9aT9w== X-Received: by 2002:a5d:50c2:0:b0:333:2fc4:456 with SMTP id f2-20020a5d50c2000000b003332fc40456mr2660357wrt.79.1701788209206; Tue, 05 Dec 2023 06:56:49 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:48 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 07/10] recipeutils: bbappend_recipe: allow to patch the recipe itself Date: Tue, 5 Dec 2023 15:56:33 +0100 Message-ID: <20231205145636.960819-8-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:57:01 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191836 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 d86873056fe..ae02af0feeb 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: @@ -701,19 +701,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: @@ -758,7 +768,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 = '' @@ -791,7 +801,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) param['path'] = srcfile else: @@ -816,6 +829,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 Tue Dec 5 14:56:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35710 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 540E8C07E97 for ; Tue, 5 Dec 2023 14:57:01 +0000 (UTC) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.groups.io with SMTP id smtpd.web10.102653.1701788212261075963 for ; Tue, 05 Dec 2023 06:56:52 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=xHNhchHm; spf=pass (domain: baylibre.com, ip: 209.85.128.43, mailfrom: jstephan@baylibre.com) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-40b479ec4a3so56972685e9.2 for ; Tue, 05 Dec 2023 06:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788210; x=1702393010; 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=jaM1y6GJfxFWYeJtjpQbVhu13+8lNFtoz2xL337IAAk=; b=xHNhchHmn3wFpiP7EkRFWavwvUBPRKE05pCPrGtko5fu2TwEUmyM3C/VPAngKmO+Ps yFyPQ1PY07APB+OK1hhEC2uuushizAPsIDO4gBozv4epvLeE/xmMATOYv0zg0ycQhWuC PPqIkXRk1LsrCOCOqbU5Qd4qGVXUDh3+AWYkYJmK3FpvgcZWjM81APBGxX5MjzJcJhG/ z5XOIaqqEEOUQ442shEqqN0HgClSl3Ww/wc/XK3o/MGsaZOLlJgFwQvz6zsjYgzdC7Yy 9yma1MZOSLPP6CGmVsbxrW9fM6MYAtgVYpB3mWmgV3XsvGLm3oiZBi2/NNUyOdm7y4cN A+QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788210; x=1702393010; 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=jaM1y6GJfxFWYeJtjpQbVhu13+8lNFtoz2xL337IAAk=; b=o6IukZrs7z/Y09cVaA4/6E8n1HJs+qMCnHCxOKMYMXB4833CMe6XTBV5WXyTGB7evz MUFdIiC3wt8gWZt5J3zPYq7hDOFJebBAJcZ3ikCxEP4BbwM53zDSuUio5QrNn7ijbX7L lsItvZH/2zsLfqsCZ73uPLs+UyVrS1FXz1QMQofSSE2rSCZLAKwQjRPOeaRdOf3g34N/ W/EMHvgamAMSSkoqxbRZ3EpxMb8kxaugS5URgfLqGum7m5OetbyWpHnT+83vIn+bwcos AopoKwmMVQcgMRUMecPQTGEy6gsPmgMXKrTaby3EF8zeE0nEO4l1TuU+B4klY+bgUvn5 Vx8Q== X-Gm-Message-State: AOJu0Yw6Th3smDhx2OVS+E9/azSMQvHVY9kr2NhxtwGNV6TWR8EwCkYq m4ujhkg5EyeT3w8Cfcm4I/fQNoiHnpOHTCEIvwN8gg== X-Google-Smtp-Source: AGHT+IEunwtjcg44Ce2WNo5jZ+AUWnNl5jH3xYrW314G1A2Xpahn0Pr7Rkk1KgsUml7/sikecKBg4g== X-Received: by 2002:a05:600c:42c1:b0:40b:5e22:971 with SMTP id j1-20020a05600c42c100b0040b5e220971mr4181234wme.96.1701788210204; Tue, 05 Dec 2023 06:56:50 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:49 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 08/10] recipetool: appendsrcfile(s): add a mode to update the recipe itself Date: Tue, 5 Dec 2023 15:56:34 +0100 Message-ID: <20231205145636.960819-9-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:57:01 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191837 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 fc3cc4a0b7f..341e8933057 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 Tue Dec 5 14:56:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35709 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 3AD23C46CA3 for ; Tue, 5 Dec 2023 14:57:01 +0000 (UTC) Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by mx.groups.io with SMTP id smtpd.web11.101433.1701788212901086162 for ; Tue, 05 Dec 2023 06:56:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=gM8FqKHt; spf=pass (domain: baylibre.com, ip: 209.85.128.54, mailfrom: jstephan@baylibre.com) Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40c032962c5so41084725e9.3 for ; Tue, 05 Dec 2023 06:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788211; x=1702393011; 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=gM8FqKHtJ7w7SYf0gXcxogqCCjOcQtyvII2eIfdTUzAyXrtpTOwDRfrZAtJ9rXf82+ QOlE6zmS9TYKlQ4sV1bjSMznbwd9boW3rNh7RrlUfejS7pvsrSNzNoy1cPizt6Qk6hi/ za5hoJjA5nS43T4+XjRH6v8xRoN2e3zFyJL5AfjsquIegBzWAdHq8ed/6/ChevMCfnQT EAJ3V0+3yCe17/G2/8cPy1tg60cCiH4vs15Bv/sBFznAfaAFOXJj8VxpQ/X8R9M/TvhZ QsBOE2lSpGIP3FQo1+gh/MBI/CITB3C03dXDchedgx5yunQ7ES91EhWraUPtICeWEOMR WmLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788211; x=1702393011; 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=I+7TAINtpZTTD1roqyXo2Xhdt2dnUCnvLp2anIekGXFJXzTF3yMyT4+j0JL2+WWjpE kaDup91OP5eJdw9qJ8i8p4opbUyxIwJ/XxhAbwJPv/pwaLd6M9F0dkfoUwZbm9Ggf9Pa RgsS5syI6wc7rgABdGSmEku2O9RxOCM/EJBDKlgPPVT9LNPJ6WD5UjANRcd8XnvUQoKq TdxN+TnF9AW+QGvcymggKscBRrJjvMLKugh83risxHoZi+GtXFM6Ng7qhBgHrKXeJnSY 8bmpRsPfdzP6t9QDovLz5FgtCJXonsIabI3dhe7GZz7w+88i37jlxlBHzgVIz8pAb7U/ 1M1g== X-Gm-Message-State: AOJu0Yw+SmD8f+BkeoVymOicmRYCK//yQvP8N+HTDo5MeDszztPrKP3p Y6BdSF2UrzI/RUI0ad5TJGYC4avQUscseXNkZhIaew== X-Google-Smtp-Source: AGHT+IHuaP4LF9fJoVWFwOwWOJSKmnRQfUtOUrO+7fYB/RvgqCJE9JwF15afou2rwtlJDaKs3452QQ== X-Received: by 2002:a7b:c8d1:0:b0:40b:5e59:99d6 with SMTP id f17-20020a7bc8d1000000b0040b5e5999d6mr338615wml.246.1701788211182; Tue, 05 Dec 2023 06:56:51 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:50 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 09/10] oeqa/selftest/recipetool: appendsrfile: add test for machine Date: Tue, 5 Dec 2023 15:56:35 +0100 Message-ID: <20231205145636.960819-10-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:57:01 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191838 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 Tue Dec 5 14:56:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Stephan X-Patchwork-Id: 35711 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 45C18C10F04 for ; Tue, 5 Dec 2023 14:57:01 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web10.102656.1701788213495136709 for ; Tue, 05 Dec 2023 06:56:53 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=hhieskrC; spf=pass (domain: baylibre.com, ip: 209.85.221.42, mailfrom: jstephan@baylibre.com) Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-333536432e0so1254565f8f.3 for ; Tue, 05 Dec 2023 06:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701788211; x=1702393011; 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=hhieskrCtctJ0z4F23zHM8RGuuhi4FIwZLjZxXWxKEFqsI0yydMpMRRq/Y+deUj7Jy IUqG8r5Pbf98TJN2+Zzlmu0g4kGGYsqU77dmlJLg5KB+EGiNIjvrHpIIKTH0aNBptt5N FZNBNSQxS77l+h0VHk9ytBG/eEbDXFzgF1nA0EgEoXxYdOynYU1KL+ZnXYGYzSIXWHzD ExcsLNnNf3twDmmnVjzQHE7z0Irl94tY1QYsXEN8D+IuurMeez9oQ53EsVVKOkaiiogc eTdiForgjPUlk5377fBpCpj6npNAVQbvtxFGnDLpvTpBXe8Y/fbeKZKbV7ZmM9lUzGxD qxOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788211; x=1702393011; 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=Fc26lKlWa5vRjb+oiv3X6UEHQVyJV1UIGHm6G44rHOqcPIYqucUXqqb1hq/UPeDrsO N2xeojpZ5y+DUErxMohzC4xZ9xdoq3byPZkeBHXIFveEALl+k6Wsw+fwL2lXSpYa8uU9 CvSAg21bBDaE4j1l5YPW/ReYpcebHDJuAd/ysBCvAIiT8PJIfODXp/AmSF2zEWtNXULh dObu7laCCM6Rr7L8DQRvNwx0yAe3aocTj0l0qIiEjO9gUcCCGc7YjQdEdO+KsfiVSeuz Al3/0BouTXNN8pA/TVX9nbPV62qIIQjSaGsnDlG/PJewWFRqHHPObOcFSZkcOKqGv23g UWrg== X-Gm-Message-State: AOJu0YxRF9OLhJh335G9YazanZbsBJnAN4HzbOMzpO8RNJL3wGYPmYbM AYOiwvcGeMD1GUoLRjXEpNeMIbfI9tS2J7DNr3ISUQ== X-Google-Smtp-Source: AGHT+IHjd7laiQRpDSj4svFiM+ryDThwFRRLvubMJLczmo9sOmodxKFem9rBkDR9gywjOFobvXUQQA== X-Received: by 2002:a05:600c:452:b0:40b:5e1c:5c1d with SMTP id s18-20020a05600c045200b0040b5e1c5c1dmr548228wmb.50.1701788211533; Tue, 05 Dec 2023 06:56:51 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:55f:21e0:9e19:4376:dea6:dbfa]) by smtp.gmail.com with ESMTPSA id cp6-20020a056000400600b003334520e49bsm6750082wrb.53.2023.12.05.06.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:51 -0800 (PST) From: Julien Stephan To: openembedded-core@lists.openembedded.org Cc: Julien Stephan Subject: [PATCH v3 10/10] oeqa/selftest/recipetool: appendsrc: add test for update mode Date: Tue, 5 Dec 2023 15:56:36 +0100 Message-ID: <20231205145636.960819-11-jstephan@baylibre.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231205145636.960819-1-jstephan@baylibre.com> References: <20231205145636.960819-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 ; Tue, 05 Dec 2023 14:57:01 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/191839 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'