From patchwork Fri Feb 16 11:52:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 39520 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 12085C48260 for ; Fri, 16 Feb 2024 11:52:40 +0000 (UTC) Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by mx.groups.io with SMTP id smtpd.web11.16960.1708084355468293304 for ; Fri, 16 Feb 2024 03:52:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jP3vMj9g; spf=pass (domain: gmail.com, ip: 209.85.218.53, mailfrom: alex.kanavin@gmail.com) Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a293f2280c7so271844466b.1 for ; Fri, 16 Feb 2024 03:52:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708084354; x=1708689154; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UvYRXNxLcVS3kULtzyErY8vzRoUEx8cd4VPvNizIwzo=; b=jP3vMj9gq5TN+vfwT49es0gyCsmlWokxjTiH4xPxjrN2XGZ8O6M3TE4FZfOYQX6CQs DtreWDaW1KrIiH3sJb3r28e4L8Ou1fu/o5qaaMBWRLnae2FlP/3GEZ3JIIm+vaQ8clZh wPDWU0o8OBK/PnhYscQLoa+blF+2m/xmenor6UO2DoG1fdVgg7ohnLzREwH4CLbzXW+f PV40zep1nbypbUkkE1+8vgSSywbfw7pNqJY0KV8dXuLfZ8BpV3UEao66IA2oIOIn9wFm wTCQFFMb7/pKj8ve54NGDnxIBxYDO+twf7gOkMIyuPJWjq+ZQzjmbkFclf9e6GtLrviC NH+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708084354; x=1708689154; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UvYRXNxLcVS3kULtzyErY8vzRoUEx8cd4VPvNizIwzo=; b=YKxuhGJ2uHBtePSIcxujZEktD5vyjvzVWxFZxMxueU8frOPPPr/uUMiNwwy4kgujtv O+9vEgOmKZ31WJ9mWYvyaftXwYrTVn2GchDTVWi2l8KAhg89MzlQNmFDJHZ1TCI8kGgr 1Cy3GdegxSopDpLiYhxJVCNc11QowmTHaiJcKDQOtFgxe03CTtSweq03sGE7NMfETsxx gRHSMha1zWAawo+on5m9cXO/g/PbvBbonhWHpOFar7oFdkvgDgZfPMl9gWFWlpCX02dO KYhza6z3qgJ8GkeUaBC+NGwmmBCwfxZ4U7KVyqtK+i9oSDEKZ+3CwYuiTmZIFd7fzhH1 U0aA== X-Gm-Message-State: AOJu0YyIjWa5zA/RX2D9DW6lFobOmXxFN+qPlLCSm9yV+0NrLgsYt/fY MqLKWKNF2tNeTya5noAqtczf/n3Z/28gqKH6r+B4PvwA7XaP3EvJtVmt5jyY X-Google-Smtp-Source: AGHT+IHFMC/xtcbaGh282MOkWW2am12Jrgxr8T5K1Sutj8IFe/8tYrvBP/IRBs5ggzXO/V+EdPz3wQ== X-Received: by 2002:a17:906:2a97:b0:a3d:83e2:bc9 with SMTP id l23-20020a1709062a9700b00a3d83e20bc9mr3336002eje.50.1708084353699; Fri, 16 Feb 2024 03:52:33 -0800 (PST) Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id b16-20020a170906d11000b00a3dbd16d1b0sm845788ejz.54.2024.02.16.03.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:52:33 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: openembedded-core@lists.openembedded.org Cc: Alexander Kanavin Subject: [PATCH 1/5] meta/conf/templates/default/conf-summary.txt: add a template summary Date: Fri, 16 Feb 2024 12:52:18 +0100 Message-Id: <20240216115222.3545462-1-alex@linutronix.de> X-Mailer: git-send-email 2.39.2 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 ; Fri, 16 Feb 2024 11:52:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195758 Existing conf-notes.txt is not adequate in situations where the user needs to select a config template from several, or get an overview of them and is interested only in a brief explanation of what the template is for, but not extended multi-paragraph instructions for how to use it. Such summaries can be provided via conf-summary.txt and this patch adds such a summary for the oe-core default template. Updates to the tools and a tool for selecting templates which will make specific use of the summary will follow. Signed-off-by: Alexander Kanavin --- meta/conf/templates/default/conf-summary.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 meta/conf/templates/default/conf-summary.txt diff --git a/meta/conf/templates/default/conf-summary.txt b/meta/conf/templates/default/conf-summary.txt new file mode 100644 index 00000000000..e49172fa0ce --- /dev/null +++ b/meta/conf/templates/default/conf-summary.txt @@ -0,0 +1 @@ +This is the default build configuration for the openembedded-core layer. From patchwork Fri Feb 16 11:52:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 39523 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 33F21C48BF6 for ; Fri, 16 Feb 2024 11:52:40 +0000 (UTC) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by mx.groups.io with SMTP id smtpd.web11.16961.1708084355923647481 for ; Fri, 16 Feb 2024 03:52:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RD/YI/TE; spf=pass (domain: gmail.com, ip: 209.85.208.52, mailfrom: alex.kanavin@gmail.com) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-55ad2a47b7aso2678495a12.3 for ; Fri, 16 Feb 2024 03:52:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708084354; x=1708689154; 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=4qyBbc7y3p1erSMp5lM8uIMJFpZVsck0VE16hy3eLqk=; b=RD/YI/TE2wU019cAFbYPKulLs/pKxm6kM8j+RlqrOAiFBtig7C6uVf5LFE9IToKcmu C5a/X1ZbXQthRzWP5qMbPnJyQrszOBSOMvhH5MRHiwqAtp2LDgIoENyiE/DMi63UFoax T8BPaKJE4iTelnuCu/lNQ5lT/I8l7E/iHTxjvoanBUEd6NypeHUgQH1x0iwUOrb9OheS ggYC3gECYxrWLTk8O3JQMyDlwWBQnOEz/Mo0sfZ7dwwi17Psz5pEAMTOg3jFWJ8oxg2N JSGNdGf3tyjPuQ8sqZYYTmT69SXKr3psnKXRGAcaFxFTR/XD1uF6kwlyELl0tdMxkkwG HkrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708084354; x=1708689154; 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=4qyBbc7y3p1erSMp5lM8uIMJFpZVsck0VE16hy3eLqk=; b=C+/ZCISnY1K9iIRIKY8Uf6xaFVMyEL/sRiCiy2HO8cFdxOkkifrF80PA9CnMoH8DdI 9/zheSFCKV7ESby9XaLAEw++UvlYFubUqwve1oy/X6NX2wZNoM2GZXJtH3YISRIIHW6l Te7+XtuZjJ2GsjjHYyZ/9UTNTRUk0ztzuwKtDaV2Fd2DkDoyq+EmaxC5owQ8Og2mCG10 XH8YNdQSyROgECR8yW33eNyT7JU0b1yVlAggF5/ppfAU2C7r+6Ct+U3epLONfpz8GAsj p//dxghqsdQ7siLtfLVlYssg8LoE8QjznxHOsReB0sJwwcRBlP5nyoSBioHqRNL7krvy JWkw== X-Gm-Message-State: AOJu0YwyEmfGT3ENjm5rDJJYIyLUmjOlXP5niwYwxEjMGfNbHV3/+hXO zMLocVUjWLqXuN58nrx3aoYT8GS+DxAZIqW48ClXl7HXH6LfFAYBw11nP9J1 X-Google-Smtp-Source: AGHT+IHFZvrQJ+eRtJ08cVwbBsAxr1eq+IGTK2kUMpg0SIlPXYFQ4FLTPpHbY2G0GSpWHgJXhElP1Q== X-Received: by 2002:a17:906:780f:b0:a3d:cf66:51ff with SMTP id u15-20020a170906780f00b00a3dcf6651ffmr1195798ejm.13.1708084354164; Fri, 16 Feb 2024 03:52:34 -0800 (PST) Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id b16-20020a170906d11000b00a3dbd16d1b0sm845788ejz.54.2024.02.16.03.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:52:33 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: openembedded-core@lists.openembedded.org Cc: Alexander Kanavin Subject: [PATCH 2/5] meta/lib/bblayers/buildconf.py: add support for configuration summaries Date: Fri, 16 Feb 2024 12:52:19 +0100 Message-Id: <20240216115222.3545462-2-alex@linutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216115222.3545462-1-alex@linutronix.de> References: <20240216115222.3545462-1-alex@linutronix.de> 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 ; Fri, 16 Feb 2024 11:52:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195759 Signed-off-by: Alexander Kanavin --- meta/lib/bblayers/buildconf.py | 12 +++++++++--- meta/lib/oeqa/selftest/cases/bblayers.py | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/meta/lib/bblayers/buildconf.py b/meta/lib/bblayers/buildconf.py index 87a5e5a55bc..722cf0723c1 100644 --- a/meta/lib/bblayers/buildconf.py +++ b/meta/lib/bblayers/buildconf.py @@ -20,7 +20,10 @@ def plugin_init(plugins): return BuildConfPlugin() class BuildConfPlugin(LayerPlugin): - notes_fixme = """FIXME: Please place here the description of this build configuration. + notes_fixme = """FIXME: Please place here the detailed instructions for using this build configuration. +They will be shown to the users when they set up their builds via TEMPLATECONF. +""" + summary_fixme = """FIXME: Please place here the short summary of what this build configuration is for. It will be shown to the users when they set up their builds via TEMPLATECONF. """ @@ -41,14 +44,17 @@ It will be shown to the users when they set up their builds via TEMPLATECONF. bblayers_data = bblayers_data.replace(abspath, "##OEROOT##/" + relpath) dest.write(bblayers_data) + with open(os.path.join(destdir, "conf-summary.txt"), 'w') as dest: + dest.write(self.summary_fixme) with open(os.path.join(destdir, "conf-notes.txt"), 'w') as dest: dest.write(self.notes_fixme) logger.info("""Configuration template placed into {} -Please review the files in there, and particularly provide a configuration description in {} +Please review the files in there, and particularly provide a configuration summary in {} +and notes in {} You can try out the configuration with TEMPLATECONF={} . {}/oe-init-build-env build-try-{}""" -.format(destdir, os.path.join(destdir, "conf-notes.txt"), destdir, oecorepath, templatename)) +.format(destdir, os.path.join(destdir, "conf-summary.txt"), os.path.join(destdir, "conf-notes.txt"), destdir, oecorepath, templatename)) def do_save_build_conf(self, args): """ Save the currently active build configuration (conf/local.conf, conf/bblayers.conf) as a template into a layer.\n This template can later be used for setting up builds via TEMPLATECONF. """ diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py index 2475a79468f..ca1470ced0a 100644 --- a/meta/lib/oeqa/selftest/cases/bblayers.py +++ b/meta/lib/oeqa/selftest/cases/bblayers.py @@ -121,7 +121,7 @@ class BitbakeLayers(OESelftestTestCase): self.assertEqual(bb_vars['BBFILE_PRIORITY_%s' % layername], str(priority), 'BBFILE_PRIORITY_%s != %d' % (layername, priority)) result = runCmd('bitbake-layers save-build-conf {} {}'.format(layerpath, "buildconf-1")) - for f in ('local.conf.sample', 'bblayers.conf.sample', 'conf-notes.txt'): + for f in ('local.conf.sample', 'bblayers.conf.sample', 'conf-summary.txt', 'conf-notes.txt'): fullpath = os.path.join(layerpath, "conf", "templates", "buildconf-1", f) self.assertTrue(os.path.exists(fullpath), "Template configuration file {} not found".format(fullpath)) From patchwork Fri Feb 16 11:52:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 39522 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 3439CC48BF7 for ; Fri, 16 Feb 2024 11:52:40 +0000 (UTC) Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by mx.groups.io with SMTP id smtpd.web11.16962.1708084356324859604 for ; Fri, 16 Feb 2024 03:52:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ezfne/4N; spf=pass (domain: gmail.com, ip: 209.85.218.52, mailfrom: alex.kanavin@gmail.com) Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a26ed1e05c7so266507966b.2 for ; Fri, 16 Feb 2024 03:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708084354; x=1708689154; 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=EBhXLLV3dRsG/OR5TSIuX3UTVzCbbXcEDhkGoZln/u0=; b=Ezfne/4Nuk5eklHd4KsAV5e7uH85+TUvQXY9w3qmasO4/DoIlJrG7SQ3zYO/Nm1GT3 pSdLvweqrPQQLxtHuhCfISnjT1TQgCifdcNv/x2S+wMUiQ0IgLhDaVnJeeBg3zZkqTT2 r50Z5Ye3mc6VHu9hPvrvdNeH+3EYh+2QRY5OZ3g28c8JXCDGAUvYt07i/DMTCv4KRqU1 xc7QTs8hlqQL9FtxiJTNGqNltRs5Qscs8htXT2y/YO/5jby6rFd6iQKoZApAIxiF02KM vfi+mKSHtOquvQhipe4A4K92LIcRuCM+88+Uz/micXN8TUn42jN9BSgGBBrL+6O26VlT 1p6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708084354; x=1708689154; 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=EBhXLLV3dRsG/OR5TSIuX3UTVzCbbXcEDhkGoZln/u0=; b=jVVwfs29LqhQqYUORWa/SSrpIqKgGDlQZ4K86dKil0GgcvOvUd3OVFBACIRzX8vS7P Lq+v7tr916R1pFiyP+cHxdm8bRdM0rNF2yFTRCxgX/CzFc0BEzJpDI6A4ItwDPqcqTiD fn5n6DHJYgE4CFU56j0nbE5G1d6uMjTIUvDdp+jiNBn2dlGQMFOFhgad5Bc2aQR5HRb4 jct/Hkl9weL1CMLT7zU62jZHafukFULVEub8WJGQjB0T3JmR9RYAsc2FsfIUJXxClRsb y76FihC21XGetaIFAee3CDQel4SDDp1CkkBnSos3E2dbxKIzwO8HF5ePl+ISybJaLg3K c8MQ== X-Gm-Message-State: AOJu0YyQvPi6DSqzVZ/y55Lze1qdtWRuqEzkZSw8diMQl54Kdnx9980F 7/h59raXennfjfrLCE/gJgVZVCo08xYBLBLspRW1uEekessF7RBOOpsyKAOx X-Google-Smtp-Source: AGHT+IHLCP7j2McPx2X0Ij4Byf8CfIQ4W2DIJbB2HjwCnMhyFjERPcjEW+ccPExKvMpWK8v2FOhVEQ== X-Received: by 2002:a17:907:9873:b0:a3d:e22d:3d3d with SMTP id ko19-20020a170907987300b00a3de22d3d3dmr887814ejc.60.1708084354638; Fri, 16 Feb 2024 03:52:34 -0800 (PST) Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id b16-20020a170906d11000b00a3dbd16d1b0sm845788ejz.54.2024.02.16.03.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:52:34 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: openembedded-core@lists.openembedded.org Cc: Alexander Kanavin Subject: [PATCH 3/5] scripts/oe-setup-builddir: add support for configuration summaries Date: Fri, 16 Feb 2024 12:52:20 +0100 Message-Id: <20240216115222.3545462-3-alex@linutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216115222.3545462-1-alex@linutronix.de> References: <20240216115222.3545462-1-alex@linutronix.de> 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 ; Fri, 16 Feb 2024 11:52:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195760 They are handled exactly same as conf-notes.txt. Signed-off-by: Alexander Kanavin --- scripts/oe-setup-builddir | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir index 678aeac4be5..dcb384c33a6 100755 --- a/scripts/oe-setup-builddir +++ b/scripts/oe-setup-builddir @@ -57,6 +57,7 @@ if [ -n "$TEMPLATECONF" ]; then fi OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample" OECORELOCALCONF="$TEMPLATECONF/local.conf.sample" + OECORESUMMARYCONF="$TEMPLATECONF/conf-summary.txt" OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt" fi @@ -98,6 +99,13 @@ EOM SHOWYPDOC=yes fi +if [ -z "$OECORESUMMARYCONF" ]; then + OECORESUMMARYCONF="$OEROOT/meta/conf/templates/default/conf-summary.txt" +fi +if [ ! -r "$BUILDDIR/conf/conf-summary.txt" ]; then + [ ! -r "$OECORESUMMARYCONF" ] || cp "$OECORESUMMARYCONF" "$BUILDDIR/conf/conf-summary.txt" +fi + if [ -z "$OECORENOTESCONF" ]; then OECORENOTESCONF="$OEROOT/meta/conf/templates/default/conf-notes.txt" fi @@ -108,6 +116,7 @@ fi # Prevent disturbing a new GIT clone in same console unset OECORELOCALCONF unset OECORELAYERCONF +unset OECORESUMMARYCONF unset OECORENOTESCONF # Ending the first-time run message. Show the YP Documentation banner. @@ -124,6 +133,7 @@ EOM # unset SHOWYPDOC fi +[ ! -r "$BUILDDIR/conf/conf-summary.txt" ] || cat "$BUILDDIR/conf/conf-summary.txt" [ ! -r "$BUILDDIR/conf/conf-notes.txt" ] || cat "$BUILDDIR/conf/conf-notes.txt" if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then From patchwork Fri Feb 16 11:52:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 39521 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 26AAAC48BF5 for ; Fri, 16 Feb 2024 11:52:40 +0000 (UTC) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mx.groups.io with SMTP id smtpd.web11.16963.1708084357321522010 for ; Fri, 16 Feb 2024 03:52:37 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ajA7YC5m; spf=pass (domain: gmail.com, ip: 209.85.167.53, mailfrom: alex.kanavin@gmail.com) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-51182ece518so2331748e87.3 for ; Fri, 16 Feb 2024 03:52:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708084355; x=1708689155; 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=751Itbck1egTL1dbNxM2i5lUEdCPwCMYZOLd8dGDclI=; b=ajA7YC5mxsHo5FWQZVjwSdLpxUy0Fh9fxSIuwaUTQhcViZ72yFz5K5eecS3jTdc6vm MHTlCqDUlHQIG+6UNE8OhG2BA3JS/2Z0LhDOHI0zz3xuXn/H7jxLeg+zQbQYFwUXr6t0 c6eqwjfoKrZQlMbloXldIak01no23Pp9Se/Lt/0AQDv7bYtgZ1gtyKWwtZFAmVzqvutY 3Gitz/+cJEHNRkFjfxclL/TOcUFVtjOIcRMI/B/KDBHErUQvLXMq7HQCSDsheesJJVA/ QbmyNc4XPRJ+2//zI2Qa+PoewjWEFEdQ/HI2Grwf8gkzx+wjTIBWCu6g2gcyU97QBPKt vLpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708084355; x=1708689155; 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=751Itbck1egTL1dbNxM2i5lUEdCPwCMYZOLd8dGDclI=; b=rh+pySTo2WmixBYH0dfmkULMBLTpIEudJVLc/84Mtr1otqEze/1MLStBMWcnrb7Zg9 52HaULRv11fWiWTJCX4GtvciCn4zbNqArjgG0h2k270lsIp6uOwT+tI+2PVT/64fjOXn z8cfRDXoLTOKDQlK5YXc0hGk+1yDHn9SN1+bowdwh6VQIJ9O6yYRb+p4a2VIytVcn13D 97/FzC9ER2NWwKbwPvxiNn3hIvmH1C6O8AM6wi21LOA1TFc8GUgjxMUmJaNZ9ihidvJB e23TRA6lPO94HWU8LUAv5mvBvFMSFxESbInbRP5TNhrKcyIedrAawTfJkrLQECcmAXoA MYAA== X-Gm-Message-State: AOJu0YzkUPJ5TaHMjeadaQV+CJPC60Gf5azkoAaa2xgrzr4qo4eoV7Ss rZS0A3KO3tHzKbdQatJigu/fF7JqLBoiYG6/HqKtVaS9KORAIExLIeOiR3Gs X-Google-Smtp-Source: AGHT+IGkXl5wA6oWyhUqvTKYGlW+T0Lo8oiaufD360p0xcN87ZMBbvSsa5zewHjVLcKlgXMm8cTa+g== X-Received: by 2002:a19:7008:0:b0:511:a4fd:fc1a with SMTP id h8-20020a197008000000b00511a4fdfc1amr3115483lfc.47.1708084355219; Fri, 16 Feb 2024 03:52:35 -0800 (PST) Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id b16-20020a170906d11000b00a3dbd16d1b0sm845788ejz.54.2024.02.16.03.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:52:34 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: openembedded-core@lists.openembedded.org Cc: Alexander Kanavin Subject: [PATCH 4/5] scripts/oe-setup-layers: write a list of layer paths into the checkout's top dir Date: Fri, 16 Feb 2024 12:52:21 +0100 Message-Id: <20240216115222.3545462-4-alex@linutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216115222.3545462-1-alex@linutronix.de> References: <20240216115222.3545462-1-alex@linutronix.de> 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 ; Fri, 16 Feb 2024 11:52:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195761 This is beneficial for setting up builds, as this list can be used to determine reliably where the actual layers are, and discover available configurations from them. Also adjust the selftest to check the presence of that file rather than any specific layer in a hardcoded location. Sample output (paths are written relative to the file for relocatability and ease of reading): { "layers": [ "meta-openembedded/meta-filesystems", "meta-openembedded/meta-gnome", "meta-openembedded/meta-initramfs", "meta-openembedded/meta-multimedia", "meta-openembedded/meta-networking", "meta-openembedded/meta-oe", "meta-openembedded/meta-perl", "meta-openembedded/meta-python", "meta-openembedded/meta-webserver", "meta-openembedded/meta-xfce", "poky/bitbake/lib/layerindexlib/tests/testdata/layer1", "poky/bitbake/lib/layerindexlib/tests/testdata/layer2", "poky/bitbake/lib/layerindexlib/tests/testdata/layer3", "poky/bitbake/lib/layerindexlib/tests/testdata/layer4", "poky/meta-poky", "poky/meta-selftest", "poky/meta-skeleton", "poky/meta-yocto-bsp", "poky/meta" ], "version": "1.0" } Signed-off-by: Alexander Kanavin --- meta/lib/oeqa/selftest/cases/bblayers.py | 6 ++---- scripts/oe-setup-layers | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py index ca1470ced0a..f2460cb451b 100644 --- a/meta/lib/oeqa/selftest/cases/bblayers.py +++ b/meta/lib/oeqa/selftest/cases/bblayers.py @@ -163,7 +163,5 @@ class BitbakeLayers(OESelftestTestCase): testcheckoutdir = os.path.join(self.builddir, 'test-layer-checkout') result = runCmd('{}/setup-layers --destdir {}'.format(self.testlayer_path, testcheckoutdir)) - # May not necessarily be named 'poky' or 'openembedded-core' - oecoredir = os.listdir(testcheckoutdir)[0] - testcheckoutfile = os.path.join(testcheckoutdir, oecoredir, "oe-init-build-env") - self.assertTrue(os.path.exists(testcheckoutfile), "File {} not found in test layer checkout".format(testcheckoutfile)) + layers_json = os.path.join(testcheckoutdir, ".oe-layers.json") + self.assertTrue(os.path.exists(layers_json), "File {} not found in test layer checkout".format(layers_json)) diff --git a/scripts/oe-setup-layers b/scripts/oe-setup-layers index 6d49688a32c..bee4ef0fec8 100755 --- a/scripts/oe-setup-layers +++ b/scripts/oe-setup-layers @@ -49,11 +49,24 @@ def _is_repo_at_remote_uri(repodir, remote, uri): def _contains_submodules(repodir): return os.path.exists(os.path.join(repodir,".gitmodules")) +def _write_layer_list(dest, repodirs): + layers = [] + for r in repodirs: + for root, dirs, files in os.walk(r): + if os.path.basename(root) == 'conf' and 'layer.conf' in files: + layers.append(os.path.relpath(os.path.dirname(root), dest)) + layers_f = os.path.join(dest, ".oe-layers.json") + print("Writing list of layers into {}".format(layers_f)) + with open(layers_f, 'w') as f: + json.dump({"version":"1.0","layers":layers}, f, sort_keys=True, indent=4) + def _do_checkout(args, json): repos = json['sources'] + repodirs = [] for r_name in repos: r_data = repos[r_name] repodir = os.path.abspath(os.path.join(args['destdir'], r_data['path'])) + repodirs.append(repodir) if 'contains_this_file' in r_data.keys(): force_arg = 'force_bootstraplayer_checkout' @@ -96,6 +109,8 @@ def _do_checkout(args, json): if _contains_submodules(repodir): print("Repo {} contains submodules, use 'git submodule update' to ensure they are up to date".format(repodir)) + _write_layer_list(args['destdir'], repodirs) + parser = argparse.ArgumentParser(description="A self contained python script that fetches all the needed layers and sets them to correct revisions using data in a json format from a separate file. The json data can be created from an active build directory with 'bitbake-layers create-layers-setup destdir' and there's a sample file and a schema in meta/files/") parser.add_argument('--force-bootstraplayer-checkout', action='store_true', From patchwork Fri Feb 16 11:52:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 39524 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 2596AC48BF3 for ; Fri, 16 Feb 2024 11:52:40 +0000 (UTC) Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by mx.groups.io with SMTP id smtpd.web11.16965.1708084357486768509 for ; Fri, 16 Feb 2024 03:52:37 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X3nXU7Mf; spf=pass (domain: gmail.com, ip: 209.85.218.45, mailfrom: alex.kanavin@gmail.com) Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a34c5ca2537so237447966b.0 for ; Fri, 16 Feb 2024 03:52:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708084356; x=1708689156; 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=2AAIpx4ZoXH5Wv9l0P4w+VN7HprSyavphaNRwcZuoAU=; b=X3nXU7MfvqeS5kPIfXgbrDZ/8gf2/dzw1zN/cvO9s9fHnxB0Zo9GjsYY3+363Hbw7W dyaJNh+/e3nd2cQ9MGlTlKeNhs7upz7wTuvPZ5jE/uF1LKHCEZ6etASHP0aXTzZ4mYpf dlYvEataw5QDasXKEO7QntNGJm9dDqdExywF1PBIpKRjFCaeMOxpDtclWa36CjMKRwy1 xOy7KJDVi3MF7J0yX8RsaV6KIYTrFNQ72PUpPIynUS3Cm9UsnalbnUS++CMo58a/LOxV nFcke7QM6+Uymqe6xl7LTa8LieQeAlxv1lbDpEWiLW+2qk2iq0J/9Iodg3YCyG+/fmwr JkiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708084356; x=1708689156; 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=2AAIpx4ZoXH5Wv9l0P4w+VN7HprSyavphaNRwcZuoAU=; b=LLleLI//kk0HbbNU9y4MLV4xOzdfGBFLbWudksKKa5uIcn604f537b1P977B9Nn3ZV JdjNKDKh4hn25bTg8l6Q7xQD9/oK7LIXZ8Hjp33x4PfOzCqRNVIDEJBeK/WOIc82+5Kq l2Su5//KFAPCmhgq2VtMJysAmrFTE9tRkL5y8gaCuMSedTyQn8ybkKEa/S1ucRRe2M7b nREhrocHHvGP2FQqHu54fK4KUU+zT3+kkX6uDlErIhNVXhCNArkOAbrj5/tTJqh32rS0 scBdgiCeLyILbtthAefDJBNeY3af9CdTOPLxIYBkdSauADZ9rARq80f+5nZoWR+90rLS 3Y3Q== X-Gm-Message-State: AOJu0Yzg0USNKCjE8zLghPWAKYbNI0u+UfBFs8CD+/5sZd1Uq1Ejq0uT TSefSgYprBeJm6garkPT0Jw9v+PxtMwf1r7Knwf3yUCLwG9MG3bm2v9Dg3U7 X-Google-Smtp-Source: AGHT+IFFirk9bnu7pNorQxM+n6HtnmG0Mh6uHNfkq80AtwPdTR2nX+842P0IMMi79eBTgamauMNEuQ== X-Received: by 2002:a17:906:b09:b0:a3d:f701:16c0 with SMTP id u9-20020a1709060b0900b00a3df70116c0mr333719ejg.52.1708084355788; Fri, 16 Feb 2024 03:52:35 -0800 (PST) Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id b16-20020a170906d11000b00a3dbd16d1b0sm845788ejz.54.2024.02.16.03.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:52:35 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: openembedded-core@lists.openembedded.org Cc: Alexander Kanavin Subject: [PATCH 5/5] oe-setup-build: add a tool for discovering config templates and setting up builds Date: Fri, 16 Feb 2024 12:52:22 +0100 Message-Id: <20240216115222.3545462-5-alex@linutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216115222.3545462-1-alex@linutronix.de> References: <20240216115222.3545462-1-alex@linutronix.de> 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 ; Fri, 16 Feb 2024 11:52:40 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/195762 This is another piece of the puzzle in setting up builds from nothing without having to write custom scripts or use external tools. After layers have been fetched and placed into their respective locations by oe-setup-layers, one would surely want to proceed to the actual build, and here's how: 1. Without arguments the tool reads available layers from .oe-layers.json file (written out by oe-setup-layers or a fallback under scripts/), prints what templates it has found, and asks the user to select one, as seen below. This will land the user in a shell ready to run bitbake: ============================================= alex@Zen2:/srv/work/alex$ ./setup-build Available build configurations: 1. alex-configuration-gadget This configuration will set up a build for the purposes of supporting gadget. 2. alex-configuration-gizmo This configuration allows building a gizmo. 3. poky-default This is the default build configuration for the Poky reference distribution. Re-run with 'list -v' to see additional information. Please choose a configuration by its number: 1 Running: TEMPLATECONF=/srv/work/alex/meta-alex/conf/templates/configuration-gadget . /srv/work/alex/poky/oe-init-build-env /srv/work/alex/build-alex-configuration-gadget && /bin/bash You had no conf/local.conf file. This configuration file has therefore been created for you from /srv/work/alex/meta-alex/conf/templates/configuration-gadget/local.conf.sample You may wish to edit it to, for example, select a different MACHINE (target hardware). You had no conf/bblayers.conf file. This configuration file has therefore been created for you from /srv/work/alex/meta-alex/conf/templates/configuration-gadget/bblayers.conf.sample To add additional metadata layers into your configuration please add entries to conf/bblayers.conf. The Yocto Project has extensive documentation about OE including a reference manual which can be found at: https://docs.yoctoproject.org For more information about OpenEmbedded see the website: https://www.openembedded.org/ This configuration will set up a build for the purposes of supporting gadget. Please refer to meta-alex/README for additional details and available bitbake targets. ============================================== 2. It is also possible to list available configurations without selecting one using 'setup-build list' or to select and setup one non-interactively with 'setup-build setup'. 3. The full set of command line options is: $ ./setup-build --help usage: setup-build [-h] [--layerlist LAYERLIST] {list,setup} ... A script that discovers available build configurations and sets up a build environment based on one of them. Run without arguments to choose one interactively. positional arguments: {list,setup} list List available configurations setup Set up a build environment and open a shell session with it, ready to run builds. optional arguments: -h, --help show this help message and exit --layerlist LAYERLIST Where to look for available layers (as written out by setup-layers script) (default is /srv/work/alex/.oe-layers.json). $ ./setup-build list --help usage: setup-build list [-h] [-v] optional arguments: -h, --help show this help message and exit -v Print detailed information and usage notes for each available build configuration. $ ./setup-build setup --help usage: setup-build setup [-h] [-c configuration_name] [-b build_path] [--no-shell] optional arguments: -h, --help show this help message and exit -c configuration_name Use a build configuration configuration_name to set up a build environment (run this script with 'list' to see what is available) -b build_path Set up a build directory in build_path (run this script with 'list -v' to see where it would be by default) --no-shell Create a build directory but do not start a shell session with the build environment from it. 4. There's an an added hint in oe-setup-layers about how to proceed (as it is really not user-friendly to fetch the layer repos successfully and then exit without a word), and a symlink to the script from the top level layer checkout directory. 5. The selftest to check layer setup has been adjusted to run a basic check for template discovery and build setup. The revision of poky to be cloned has been bumped to 4.1, as that's the first version with a default template in a standard location. Signed-off-by: Alexander Kanavin --- meta/lib/oeqa/selftest/cases/bblayers.py | 26 ++++- scripts/.oe-layers.json | 7 ++ scripts/oe-setup-build | 122 +++++++++++++++++++++++ scripts/oe-setup-layers | 10 ++ 4 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 scripts/.oe-layers.json create mode 100755 scripts/oe-setup-build diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py index f2460cb451b..e2009496adb 100644 --- a/meta/lib/oeqa/selftest/cases/bblayers.py +++ b/meta/lib/oeqa/selftest/cases/bblayers.py @@ -152,12 +152,12 @@ class BitbakeLayers(OESelftestTestCase): self.validate_layersjson(jsonfile) # The revision-under-test may not necessarily be available on the remote server, - # so replace it with a revision that has a yocto-4.0 tag. + # so replace it with a revision that has a yocto-4.1 tag. import json with open(jsonfile) as f: data = json.load(f) for s in data['sources']: - data['sources'][s]['git-remote']['rev'] = '00cfdde791a0176c134f31e5a09eff725e75b905' + data['sources'][s]['git-remote']['rev'] = '5200799866b92259e855051112520006e1aaaac0' with open(jsonfile, 'w') as f: json.dump(data, f) @@ -165,3 +165,25 @@ class BitbakeLayers(OESelftestTestCase): result = runCmd('{}/setup-layers --destdir {}'.format(self.testlayer_path, testcheckoutdir)) layers_json = os.path.join(testcheckoutdir, ".oe-layers.json") self.assertTrue(os.path.exists(layers_json), "File {} not found in test layer checkout".format(layers_json)) + + # As setup-layers checkout out an old revision of poky, there is no setup-build symlink, + # and we need to run oe-setup-build directly from the current poky tree under test + oe_setup_build = os.path.join(get_bb_var('COREBASE'), 'scripts/oe-setup-build') + oe_setup_build_l = os.path.join(testcheckoutdir, 'setup-build') + os.symlink(oe_setup_build,oe_setup_build_l) + + cmd = '{} --layerlist {} list -v'.format(oe_setup_build_l, layers_json) + result = runCmd(cmd) + cond = "conf/templates/default" in result.output + self.assertTrue(cond, "Incorrect output from {}: {}".format(cmd, result.output)) + + # rather than hardcode the build setup cmdline here, let's actually run what the tool suggests to the user + conf = None + if 'poky-default' in result.output: + conf = 'poky-default' + elif 'meta-default' in result.output: + conf = 'meta-default' + self.assertIsNotNone(conf, "Could not find the configuration to set up a build in the output: {}".format(result.output)) + + cmd = '{} --layerlist {} setup -c {} --no-shell'.format(oe_setup_build_l, layers_json, conf) + result = runCmd(cmd) diff --git a/scripts/.oe-layers.json b/scripts/.oe-layers.json new file mode 100644 index 00000000000..1b00a84b542 --- /dev/null +++ b/scripts/.oe-layers.json @@ -0,0 +1,7 @@ +{ + "layers": [ + "../meta-poky", + "../meta" + ], + "version": "1.0" +} diff --git a/scripts/oe-setup-build b/scripts/oe-setup-build new file mode 100755 index 00000000000..5364f2b4812 --- /dev/null +++ b/scripts/oe-setup-build @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import argparse +import json +import os +import subprocess + +def defaultlayers(): + return os.path.abspath(os.path.join(os.path.dirname(__file__), '.oe-layers.json')) + +def makebuildpath(topdir, template): + return os.path.join(topdir, "build-{}".format(template)) + +def discover_templates(layers_file): + if not os.path.exists(layers_file): + print("List of layers {} does not exist; were the layers set up using the setup-layers script?".format(layers_file)) + return None + + templates = [] + layers_list = json.load(open(layers_file))["layers"] + for layer in layers_list: + template_dir = os.path.join(os.path.dirname(layers_file), layer, 'conf','templates') + if os.path.exists(template_dir): + for d in sorted(os.listdir(template_dir)): + templatepath = os.path.join(template_dir,d) + if not os.path.isfile(os.path.join(templatepath,'local.conf.sample')): + continue + layer_base = os.path.basename(layer) + templatename = "{}-{}".format(layer_base[5:] if layer_base.startswith("meta-") else layer_base, d) + buildpath = makebuildpath(os.getcwd(), templatename) + notespath = os.path.join(template_dir, d, 'conf-notes.txt') + try: notes = open(notespath).read() + except: notes = None + try: summary = open(os.path.join(template_dir, d, 'conf-summary.txt')).read() + except: summary = None + templates.append({"templatename":templatename,"templatepath":templatepath,"buildpath":buildpath,"notespath":notespath,"notes":notes,"summary":summary}) + + return templates + +def print_templates(templates, verbose): + print("Available build configurations:\n") + + for i in range(len(templates)): + t = templates[i] + print("{}. {}".format(i+1, t["templatename"])) + print("{}".format(t["summary"].strip() if t["summary"] else "This configuration does not have a summary.")) + if verbose: + print("Configuration template path:", t["templatepath"]) + print("Build path:", t["buildpath"]) + print("Usage notes:", t["notespath"] if t["notes"] else "This configuration does not have usage notes.") + print("") + if not verbose: + print("Re-run with 'list -v' to see additional information.") + +def list_templates(args): + templates = discover_templates(args.layerlist) + if not templates: + return + + verbose = args.v + print_templates(templates, verbose) + +def find_template(template_name, templates): + print_templates(templates, False) + if not template_name: + n_s = input("Please choose a configuration by its number: ") + try: return templates[int(n_s) - 1] + except: + print("Invalid selection, please try again.") + return None + else: + for t in templates: + if t["templatename"] == template_name: + return t + print("Configuration {} is not one of {}, please try again.".format(tempalte_name, [t["templatename"] for t in templates])) + return None + +def setup_build_env(args): + templates = discover_templates(args.layerlist) + if not templates: + return + + template = find_template(args.c, templates) + if not template: + return + builddir = args.b if args.b else template["buildpath"] + no_shell = args.no_shell + coredir = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) + cmd = "TEMPLATECONF={} . {} {}".format(template["templatepath"], os.path.join(coredir, 'oe-init-build-env'), builddir) + if not no_shell: + cmd = cmd + " && {}".format(os.environ['SHELL']) + print("Running:", cmd) + subprocess.run(cmd, shell=True, executable=os.environ['SHELL']) + +parser = argparse.ArgumentParser(description="A script that discovers available build configurations and sets up a build environment based on one of them. Run without arguments to choose one interactively.") +parser.add_argument("--layerlist", default=defaultlayers(), help='Where to look for available layers (as written out by setup-layers script) (default is {}).'.format(defaultlayers())) + +subparsers = parser.add_subparsers() +parser_list_templates = subparsers.add_parser('list', help='List available configurations') +parser_list_templates.add_argument('-v', action='store_true', + help='Print detailed information and usage notes for each available build configuration.') +parser_list_templates.set_defaults(func=list_templates) + +parser_setup_env = subparsers.add_parser('setup', help='Set up a build environment and open a shell session with it, ready to run builds.') +parser_setup_env.add_argument('-c', metavar='configuration_name', help="Use a build configuration configuration_name to set up a build environment (run this script with 'list' to see what is available)") +parser_setup_env.add_argument('-b', metavar='build_path', help="Set up a build directory in build_path (run this script with 'list -v' to see where it would be by default)") +parser_setup_env.add_argument('--no-shell', action='store_true', + help='Create a build directory but do not start a shell session with the build environment from it.') +parser_setup_env.set_defaults(func=setup_build_env) + +args = parser.parse_args() + +if 'func' in args: + args.func(args) +else: + from argparse import Namespace + setup_build_env(Namespace(layerlist=args.layerlist, c=None, b=None, no_shell=False)) diff --git a/scripts/oe-setup-layers b/scripts/oe-setup-layers index bee4ef0fec8..6fbfefd656f 100755 --- a/scripts/oe-setup-layers +++ b/scripts/oe-setup-layers @@ -63,6 +63,7 @@ def _write_layer_list(dest, repodirs): def _do_checkout(args, json): repos = json['sources'] repodirs = [] + oesetupbuild = None for r_name in repos: r_data = repos[r_name] repodir = os.path.abspath(os.path.join(args['destdir'], r_data['path'])) @@ -108,9 +109,18 @@ def _do_checkout(args, json): if _contains_submodules(repodir): print("Repo {} contains submodules, use 'git submodule update' to ensure they are up to date".format(repodir)) + if os.path.exists(os.path.join(repodir, 'scripts/oe-setup-build')): + oesetupbuild = os.path.join(repodir, 'scripts/oe-setup-build') _write_layer_list(args['destdir'], repodirs) + if oesetupbuild: + oesetupbuild_symlink = os.path.join(args['destdir'], 'setup-build') + if os.path.exists(oesetupbuild_symlink): + os.remove(oesetupbuild_symlink) + os.symlink(os.path.relpath(oesetupbuild,args['destdir']),oesetupbuild_symlink) + print("\nRun '{}' to list available build configuration templates and set up a build from one of them.".format(oesetupbuild_symlink)) + parser = argparse.ArgumentParser(description="A self contained python script that fetches all the needed layers and sets them to correct revisions using data in a json format from a separate file. The json data can be created from an active build directory with 'bitbake-layers create-layers-setup destdir' and there's a sample file and a schema in meta/files/") parser.add_argument('--force-bootstraplayer-checkout', action='store_true',