From patchwork Mon Mar 27 08:12:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBNYXJ0aW5zb25z?= X-Patchwork-Id: 21810 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 70052C761A6 for ; Mon, 27 Mar 2023 08:12:48 +0000 (UTC) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mx.groups.io with SMTP id smtpd.web11.29697.1679904761215209596 for ; Mon, 27 Mar 2023 01:12:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X5Am4uGu; spf=pass (domain: gmail.com, ip: 209.85.128.41, mailfrom: frederic.martinsons@gmail.com) Received: by mail-wm1-f41.google.com with SMTP id p34so4491182wms.3 for ; Mon, 27 Mar 2023 01:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679904759; 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=6lzaowPBGNyClSitAu7sVLJ9GXQv0xYa51QvIRhfNm0=; b=X5Am4uGusUEqUJHhgtPd+QBWoEqkSvVsZ/9QxSiKo97eQF93gEz+Pv31Wj4uz95aRu ILkb5pRYUcP/2WvPxSK7Rge1T7VnbvkwIXerFJhgNYqqNg//PI4mgdBivCiptCZTqkrn KTghKayt/0eJDoGNvph28WoCCpKs9al4RNgO+9zEdZ6xeYirBS9ttlOmUtaDC9pAABZY 2Bfrxa1UpqZjOQaoalYPOmdzQhfDgi69TjVloJIOJ25aPap98ur+iG1/CBLK63yuWrDp PrdyCwHomUQYvMZPzVM3bflicmbwacyFXBVizv3dvHwr5wMI01Dmk+1+I+Hk8j0SUV7T qLhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679904759; 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=6lzaowPBGNyClSitAu7sVLJ9GXQv0xYa51QvIRhfNm0=; b=W9eaw6jnFoLq9V9ne1pys6eb8v0T2lUSThucGC+KjK5G55OdWNbhByDKE6oN5YM4qT aV8RbaGBQdh16wgNHEgn+nxx+BKZgdbmJUxe7X1XvBfMEqcJA0xusfwdg+L1sWnkUVPi UpCSadzm+0GzvVOVt8yi4nR7HEmfgPf29QwsfRlFqPhzbNZLXKKvLlfqR2qdq+bBt4On HiaJlYzGm7UkkcCQtOwR83PhylvSpa5xm/i+LkTqR/8D8WhFX7RpwpJikdZegX95b+B2 hmHRTQRoSB1m2linnZ0gTi6Ik8fPm9KjrrOmHVAR1LD8ODpXN6uI6XddUDD4q3sj9TGw GMmw== X-Gm-Message-State: AO0yUKVHzwlAexksGN2f1ta5CeVdPVUr9jOQvmk7S3KvkB9hzBbzw/hd lrF0exSLVWBq1Czduu9k3FmD7XY2yTs= X-Google-Smtp-Source: AK7set+KUaTd2pwAs9VoI1y3usrW6VEtyvqAAu4dcdKAWgt6F63KUQJDtMGVZzSRoawjAH3zFLYjMA== X-Received: by 2002:a05:600c:210d:b0:3ed:418a:ec06 with SMTP id u13-20020a05600c210d00b003ed418aec06mr8477454wml.28.1679904759074; Mon, 27 Mar 2023 01:12:39 -0700 (PDT) Received: from work-pc.core.sigfox.net ([2a01:e0a:8d5:c6c0:e313:787e:85a7:511b]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c198e00b003ef6708bc1esm6186380wmq.43.2023.03.27.01.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 01:12:38 -0700 (PDT) From: frederic.martinsons@gmail.com To: openembedded-core@lists.openembedded.org Cc: alex.kiernan@gmail.com Subject: [PATCHV3 1/4] cargo_common.bbclass: Support local github repos Date: Mon, 27 Mar 2023 10:12:32 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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, 27 Mar 2023 08:12:48 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/179141 From: Alex Kiernan Since disable network was added cargo configurations which reference git repos fail as they attempt to fetch across the network as part of do_compile, even if EXTRA_OECARGO_PATHS to add them as part of `paths` is used, as this is documented as only working for packages which exist in crates.io. Add parsing of the SRC_URIs for git repos and include `[patch]` sections to redirect to the checked out source repos which the bitbake fetcher has already populated. There are still cases which don't work - if you have multiple copies of the same repo with different revisions, there's currently no way to represent that and anything using a repo which has a virtual manifest will fail to build (see https://github.com/rust-lang/cargo/issues/4934). Signed-off-by: Alex Kiernan --- meta/classes-recipe/cargo_common.bbclass | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/meta/classes-recipe/cargo_common.bbclass b/meta/classes-recipe/cargo_common.bbclass index f503a001dd..63b1382908 100644 --- a/meta/classes-recipe/cargo_common.bbclass +++ b/meta/classes-recipe/cargo_common.bbclass @@ -116,6 +116,36 @@ cargo_common_do_configure () { EOF } +python cargo_common_do_patch_paths() { + cargo_config = os.path.join(d.getVar("CARGO_HOME"), "config") + if not os.path.exists(cargo_config): + return + + src_uri = (d.getVar('SRC_URI') or "").split() + if len(src_uri) == 0: + return + + patches = dict() + workdir = d.getVar('WORKDIR') + fetcher = bb.fetch2.Fetch(src_uri, d) + for url in fetcher.urls: + ud = fetcher.ud[url] + if ud.type == 'git': + name = ud.parm.get('name') + destsuffix = ud.parm.get('destsuffix') + if name is not None and destsuffix is not None: + repo = '%s://%s%s' % (ud.proto, ud.host, ud.path) + path = '%s = { path = "%s" }' % (name, os.path.join(workdir, destsuffix)) + patches.setdefault(repo, []).append(path) + + with open(cargo_config, "a+") as config: + for k, v in patches.items(): + print('\n[patch."%s"]' % k, file=config) + for name in v: + print(name, file=config) +} +do_configure[postfuncs] += "cargo_common_do_patch_paths" + oe_cargo_fix_env () { export CC="${RUST_TARGET_CC}" export CXX="${RUST_TARGET_CXX}" From patchwork Mon Mar 27 08:12:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBNYXJ0aW5zb25z?= X-Patchwork-Id: 21811 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 8DE02C761AF for ; Mon, 27 Mar 2023 08:12:48 +0000 (UTC) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mx.groups.io with SMTP id smtpd.web11.29698.1679904761586222892 for ; Mon, 27 Mar 2023 01:12:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VtYJBPAh; spf=pass (domain: gmail.com, ip: 209.85.128.49, mailfrom: frederic.martinsons@gmail.com) Received: by mail-wm1-f49.google.com with SMTP id r19-20020a05600c459300b003eb3e2a5e7bso4595390wmo.0 for ; Mon, 27 Mar 2023 01:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679904760; 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=CKr1j1hZIjN/A0KbFl3IZ5cAZYIF8AY0qU7hY1/3eOs=; b=VtYJBPAh7ggpXDRNT8DsRG65CiO2WoVvBwIphCkpaxonfJ32h92W3RV6s9pyKSBvKd CcrNxIBdF9ellTmV9Rb3XHcQJiidQCBP1DcKiG33ZGbWfcGN9I6jnnKtFdL4gW8w3Tud Jbe2QKhzEFIa1q4KfSt1AJQugceJ6CdaBM+p/YG5NK9hJDEHR5WQw95cGee8I9PPaAsn Tzx0WntNvLA3T+GN7MXjHCsoEKP4/OAntRzpMcnTW81v9F+FgPvLHP8tqy7DKNWzh04q QdYOz6j3IUbhVeUwPecHKZ28n1FMrYHp/ddKfb3LyWtBeOG4AbnIYKqYJsRIhSvD1jep ENXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679904760; 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=CKr1j1hZIjN/A0KbFl3IZ5cAZYIF8AY0qU7hY1/3eOs=; b=8NwUqR7kYlsqf5iI0SmAbqcfYKwrlf9wLxANeBe9GU6cbg/b4uS6ovnpqwc/N4D8fL UoZWXTYERBUaqfEvHmA/2pSRs5zb4s1T89kzJHWY/3o1C6VK3bbZ4Ducv1u0t3qCzXPF Vz0Up1ZPL/jKlWhP7nE159Wv4Y0NhwK21kebyitXnwgMINIdZtVcKGiYPmnQC4h3iKrT tguSlaA6qtL+OEubaWnG93Y9cgkT5oW30WfkExA6w7GYqjikcDo6Trd22HD1j1a0L2vQ hblViqOF7zsOWBALBLMo1o3eu2REnUimO/aZXC7qSqryV8Two5OPXQVG2GnymRlAk9BN xYbQ== X-Gm-Message-State: AO0yUKUxu2ucjtH/WOt9jJlle2O/aStRyCzeOHGhdbwTnm0BwKcbUCF4 bv2pI8tOf4QWLBOnNOrYkYZ8TmNixKY= X-Google-Smtp-Source: AK7set9raGDSYwz+5NPw4IebRfaWB7dItfv+T7hxgVyPybn84n+fZHzrV3YI8IVl27I8+hXhlpdjhA== X-Received: by 2002:a1c:7716:0:b0:3ee:526f:b15e with SMTP id t22-20020a1c7716000000b003ee526fb15emr8403010wmi.23.1679904759699; Mon, 27 Mar 2023 01:12:39 -0700 (PDT) Received: from work-pc.core.sigfox.net ([2a01:e0a:8d5:c6c0:e313:787e:85a7:511b]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c198e00b003ef6708bc1esm6186380wmq.43.2023.03.27.01.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 01:12:39 -0700 (PDT) From: frederic.martinsons@gmail.com To: openembedded-core@lists.openembedded.org Cc: alex.kiernan@gmail.com Subject: [PATCHV3 2/4] cargo_common.bbclass: add support of user in url for patch Date: Mon, 27 Mar 2023 10:12:33 +0200 Message-Id: <4ced6feed495f18a54a072713544de6c84964d9d.1679904677.git.frederic.martinsons@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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, 27 Mar 2023 08:12:48 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/179142 From: Frederic Martinsons To handle url like git://git@repo/project Signed-off-by: Frederic Martinsons --- meta/classes-recipe/cargo_common.bbclass | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/cargo_common.bbclass b/meta/classes-recipe/cargo_common.bbclass index 63b1382908..82ab25b59c 100644 --- a/meta/classes-recipe/cargo_common.bbclass +++ b/meta/classes-recipe/cargo_common.bbclass @@ -134,7 +134,10 @@ python cargo_common_do_patch_paths() { name = ud.parm.get('name') destsuffix = ud.parm.get('destsuffix') if name is not None and destsuffix is not None: - repo = '%s://%s%s' % (ud.proto, ud.host, ud.path) + if ud.user: + repo = '%s://%s@%s%s' % (ud.proto, ud.user, ud.host, ud.path) + else: + repo = '%s://%s%s' % (ud.proto, ud.host, ud.path) path = '%s = { path = "%s" }' % (name, os.path.join(workdir, destsuffix)) patches.setdefault(repo, []).append(path) From patchwork Mon Mar 27 08:12:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBNYXJ0aW5zb25z?= X-Patchwork-Id: 21809 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 8E10BC77B62 for ; Mon, 27 Mar 2023 08:12:48 +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.29626.1679904762359498898 for ; Mon, 27 Mar 2023 01:12:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jNrDT20r; spf=pass (domain: gmail.com, ip: 209.85.128.42, mailfrom: frederic.martinsons@gmail.com) Received: by mail-wm1-f42.google.com with SMTP id q7-20020a05600c46c700b003ef6e809574so1286749wmo.4 for ; Mon, 27 Mar 2023 01:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679904760; 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=ol8FfIAHbEw0jNdubbhfpGHjv/EAyiWShTkIPW2gNVQ=; b=jNrDT20r4RsjIVSkPeILd50giwyfyrXYRSYNqVGIDd0Z17W0UPHLFGIAfvFX71OUrG Tc1RQ9qd4zBuFr6qMvKls8eyGw4w3sEykMifJlaLgAQh4ahr1xtU1n0g0tCA6cC2Eulp kOQ+hfhG1qs/HG89n6BdxYNrtgvdAyUE8yuE9jDsmSw5w5yAGbtzACgvQdpCL6PiG6VK b7xMz2FuAFeE21iH+2OdVLwhBGnN0cZWxw6IebOZ9U3HeOu1osicIwUEfej24BbgA8tg dJlfgKrw0sd6XjAK+33WZ7HDOqEJk0ztYSFwJxSYIr3poQamca5tYq72zaekZGstkVk9 d18w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679904760; 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=ol8FfIAHbEw0jNdubbhfpGHjv/EAyiWShTkIPW2gNVQ=; b=U7BdXa4rNI1a31Nl/bmPkTWGF2yKYDLcdN/H2epUfLcAmBhrAdz8cG8PHxyyDl/FE6 1/jzZOCAZHIWr0Al4zhsXXpD/9gip6SzCtG6Pxpjp78jMw1iYtQkK/+CFS2mFLegIyYD ooPJGeuqgzrw4at7wnM1l9kXQxyMNxfQ9qSz4Yx62tLZOkAd1IIIHEfgIVlvJ9v5KKDm D7iK27mkXz79eUXoEzMdRg9gOBWLlEfV6PfKn9KS8QcaJNAifj1ILbnbkXNo7wID0WRH uHfG6JYapw52Wi8EHInY1LZb1ne99KrSAsrhfy9EYHz2jVwmEHyJnTAf4I09H42g7Fwu JegA== X-Gm-Message-State: AO0yUKWX5/RwUfn2sy0fVqcTwiCEcFZDbyfFuLIDSBTwmi5VeYIc0Czd QGcFt1YtykjdsOX6dXKyknkdfHMEWsM= X-Google-Smtp-Source: AK7set/m0Vg3AwpYDCAE11N0qYoUXHtAYE2APt/KEPOSVRi2RA29pe88myy0Us8Tk2q73PhRbOcQKw== X-Received: by 2002:a05:600c:2182:b0:3ef:128d:7151 with SMTP id e2-20020a05600c218200b003ef128d7151mr8628210wme.9.1679904760594; Mon, 27 Mar 2023 01:12:40 -0700 (PDT) Received: from work-pc.core.sigfox.net ([2a01:e0a:8d5:c6c0:e313:787e:85a7:511b]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c198e00b003ef6708bc1esm6186380wmq.43.2023.03.27.01.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 01:12:40 -0700 (PDT) From: frederic.martinsons@gmail.com To: openembedded-core@lists.openembedded.org Cc: alex.kiernan@gmail.com Subject: [PATCHV3 3/4] devtool: add support for multiple git url inside a cargo based recipe Date: Mon, 27 Mar 2023 10:12:34 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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, 27 Mar 2023 08:12:48 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/179143 From: Frederic Martinsons Without that, the possible git urls that are in SRC_URI of a recipe are removed from SRC_URI during devtool process and so the cargo_common_do_patch_paths in cargo_common.bbclass cannot patch these packages to fetch them locally. I use a generic type name because I foresee this change will be useful for recipe that used a package manager (cargo but also npm) see https://bugzilla.yoctoproject.org/show_bug.cgi?id=11015 Signed-off-by: Frederic Martinsons --- meta/classes/externalsrc.bbclass | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass index 26c5803ee6..b00fdba8e9 100644 --- a/meta/classes/externalsrc.bbclass +++ b/meta/classes/externalsrc.bbclass @@ -68,9 +68,7 @@ python () { for url in fetch.urls: url_data = fetch.ud[url] parm = url_data.parm - if (url_data.type == 'file' or - url_data.type == 'npmsw' or url_data.type == 'crate' or - 'type' in parm and parm['type'] == 'kmeta'): + if url_data.type in ['file', 'npmsw', 'crate'] or parm.get('type') in ['kmeta', 'git-dependency']: local_srcuri.append(url) d.setVar('SRC_URI', ' '.join(local_srcuri)) From patchwork Mon Mar 27 08:12:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBNYXJ0aW5zb25z?= X-Patchwork-Id: 21808 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 73A6CC76195 for ; Mon, 27 Mar 2023 08:12:48 +0000 (UTC) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by mx.groups.io with SMTP id smtpd.web11.29699.1679904763583701923 for ; Mon, 27 Mar 2023 01:12:43 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cKYM43KL; spf=pass (domain: gmail.com, ip: 209.85.128.53, mailfrom: frederic.martinsons@gmail.com) Received: by mail-wm1-f53.google.com with SMTP id u1so4478665wmn.5 for ; Mon, 27 Mar 2023 01:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679904762; 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=q2b0TPXaHTFMvF4K3YVDuI9TJZiA28rwMBdM4p9jhj0=; b=cKYM43KLzwunJtRc4P94COzUqRrIp3jK6cXKAuPj5W1B6u8h4JiSFTOZjSThDDKTSk ofvP8jJq6XqD/jPovQxHCQqEyM3Hsw9VZQW2E2ZtmMqgVw2QsCS5is9aJDc/6cYUxQo/ gDpU3IdEcYeNdKt2X69XmqxTXqqHnuto+iSGSAnpVkVUCKuvbDMNXlFNL+k7MFaJUR6x O4rmh0tzaBbfspnB52OwyKt5uChMA+gAYlFx8awtgyUBMT8dz7nYFAoI+VZuc1lo54lP 4onwwI71WAojHDbWHdtdIiOSibFbQvuxYU/xPg4lXraVxSSTwnxPPu32B3apMhk40/9z pHlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679904762; 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=q2b0TPXaHTFMvF4K3YVDuI9TJZiA28rwMBdM4p9jhj0=; b=NruveTPwhP3oUBek9KXJh02SPpebvpWd2hVdr/TT47wYWG3uuUwrD+1jRXy803XXdg 8qWuLAmceD1z250Bb337zOWDFM376RGyvMS97ijuxqJylr1wiEyxmmlylNoYkEtMx6WU Lxa2IpvZ//d0wsq4yaHdx2GbRKCpQwEYvHHUCtPx2GuKeJhRZXBIH294qxSPGYp2RLnG defSQMl6noCzefljdgLp7n2BOTwGCajl+dqegd5ED2zqBidvxW9+B/1MIo7FYYQLkDsJ 5TETQU5khxM8my//o/UqD4FsLCuWyfV6bF2Qxc2ACNZZL3JgxddUo9fu8swPHQZzMML8 19OA== X-Gm-Message-State: AO0yUKVjiPaqKrPvwKw9IpACCGkJ5yz9aRhw1HhmGr4CfnDIJRuVJ+Wn 0szci/5Xa2D99Tj9hbtInZGyTiT01kY= X-Google-Smtp-Source: AK7set9tMxAM6mnhMlCLexI3R5FrSrSm7OXAVPwvA1yW2Lj6ltkHGO+OPrGqBA3ZwkVyM6x9koPEQg== X-Received: by 2002:a05:600c:2205:b0:3ee:8e3d:4b9d with SMTP id z5-20020a05600c220500b003ee8e3d4b9dmr8338743wml.30.1679904761725; Mon, 27 Mar 2023 01:12:41 -0700 (PDT) Received: from work-pc.core.sigfox.net ([2a01:e0a:8d5:c6c0:e313:787e:85a7:511b]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c198e00b003ef6708bc1esm6186380wmq.43.2023.03.27.01.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 01:12:41 -0700 (PDT) From: frederic.martinsons@gmail.com To: openembedded-core@lists.openembedded.org Cc: alex.kiernan@gmail.com Subject: [PATCHV3 4/4] patch: support of git patches when the source uri contained subpath parameter Date: Mon, 27 Mar 2023 10:12:35 +0200 Message-Id: <855931994ea68c0691d0a67ce2ccad947e77229f.1679904677.git.frederic.martinsons@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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, 27 Mar 2023 08:12:48 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/179144 From: Frederic Martinsons This is for a specific case where: - A recipe use a subpath on a git repo (e.g. git://repo.git/projects;subpath=subproject) - The recipe contains a patch to apply - a devtool modify is used on this recipe With these conditions, the patch cannot be applied at all. GitApplyTree class is used for handling patch under devtool, but when subpath is present in SRC_URI, the resulting git tree is dirty (every files and directories which was not in subpath are suppressed) and so "git am" refuse to apply patches. That would not be an issue since the GitApplyTree have a fallback to PatchTree in case of error, but during this error management, there is a "git reset --hard HEAD" call which suppress the subpath operation and finally prevents the patch to be applied even with PatchTree. When devtool is not involved, only PatchTree class is used and the above problem is irrelevant. To support git patching during devtool, the presence of subpath and the dirtyness of the repo are checked. If both conditions are met, we directly call PatchTree like it was already done in case of error during git apply. Signed-off-by: Frederic Martinsons --- meta/lib/oe/patch.py | 57 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index b2dc8d0a90..d047b3b947 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py @@ -499,6 +499,36 @@ class GitApplyTree(PatchTree): finally: shutil.rmtree(tempdir) + def _need_dirty_check(self): + fetch = bb.fetch2.Fetch([], self.d) + check_dirtyness = False + for url in fetch.urls: + url_data = fetch.ud[url] + parm = url_data.parm + # a git url with subpath param will surely be dirty + # since the git tree from which we clone will be emptied + # from all files that are not in the subpath + if url_data.type == 'git' and parm.get('subpath'): + check_dirtyness = True + return check_dirtyness + + def _commitpatch(self, patch, patchfilevar): + output = "" + # Add all files + shellcmd = ["git", "add", "-f", "-A", "."] + output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) + # Exclude the patches directory + shellcmd = ["git", "reset", "HEAD", self.patchdir] + output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) + # Commit the result + (tmpfile, shellcmd) = self.prepareCommit(patch['file'], self.commituser, self.commitemail) + try: + shellcmd.insert(0, patchfilevar) + output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) + finally: + os.remove(tmpfile) + return output + def _applypatch(self, patch, force = False, reverse = False, run = True): import shutil @@ -534,6 +564,19 @@ class GitApplyTree(PatchTree): shutil.copy2(commithook, applyhook) try: patchfilevar = 'PATCHFILE="%s"' % os.path.basename(patch['file']) + if self._need_dirty_check(): + # Check dirtyness of the tree + try: + output = runcmd(["git", "--work-tree=%s" % reporoot, "status", "--short"]) + except CmdError: + pass + else: + if output: + # The tree is dirty, not need to try to apply patches with git anymore + # since they fail, fallback directly to patch + output = PatchTree._applypatch(self, patch, force, reverse, run) + output += self._commitpatch(patch, patchfilevar) + return output try: shellcmd = [patchfilevar, "git", "--work-tree=%s" % reporoot] self.gitCommandUserOptions(shellcmd, self.commituser, self.commitemail) @@ -560,19 +603,7 @@ class GitApplyTree(PatchTree): except CmdError: # Fall back to patch output = PatchTree._applypatch(self, patch, force, reverse, run) - # Add all files - shellcmd = ["git", "add", "-f", "-A", "."] - output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) - # Exclude the patches directory - shellcmd = ["git", "reset", "HEAD", self.patchdir] - output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) - # Commit the result - (tmpfile, shellcmd) = self.prepareCommit(patch['file'], self.commituser, self.commitemail) - try: - shellcmd.insert(0, patchfilevar) - output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) - finally: - os.remove(tmpfile) + output += self._commitpatch(patch, patchfilevar) return output finally: shutil.rmtree(hooks_dir)