public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Henning Schild <henning.schild@siemens.com>
To: "'Felix Moessbauer' via isar-users" <isar-users@googlegroups.com>
Cc: Felix Moessbauer <felix.moessbauer@siemens.com>, jan.kiszka@siemens.com
Subject: Re: [PATCH 1/2] add support for derived sbuild chroots
Date: Wed, 21 Jun 2023 15:54:50 +0200	[thread overview]
Message-ID: <20230621155450.3502b1dd@md1za8fc.ad001.siemens.net> (raw)
In-Reply-To: <20230413070026.3511123-1-felix.moessbauer@siemens.com>

Am Thu, 13 Apr 2023 07:00:25 +0000
schrieb "'Felix Moessbauer' via isar-users"
<isar-users@googlegroups.com>:

> This patch adds support to create derived sbuild chroots to speedup
> the build process. For packages that share a large set of common build
> dependencies, a derived sbuild chroot can be created to avoid the
> overhead of installing all base build-deps on each sbuild invocation.
> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>  doc/user_manual.md                            | 27
> +++++++++++++++++++ meta/classes/crossvars.bbclass                |
> 11 +++++--- .../sbuild-chroot/sbuild-chroot.inc           |  7 ++++-
>  3 files changed, 41 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/user_manual.md b/doc/user_manual.md
> index 92075a88..e7a16e78 100644
> --- a/doc/user_manual.md
> +++ b/doc/user_manual.md
> @@ -1348,3 +1348,30 @@ To enable it, add the below line to your
> local.conf file. ```
>  BASE_REPO_FEATURES = "cache-deb-src"
>  ```
> +
> +## Use a custom sbuild chroot to speedup build
> +
> +### Motivation
> +
> +There are use-cases, where many packages need to be compiled but all
> of them +need a similar base of build dependencies. In case the
> baseline is quite big, +this adds a significant overhead as the build
> dependencies are installed individually +for each and every package.
> +
> +### Solution
> +
> +By creating a dedicated sbuild chroot for this use-case, the
> baseline can be installed +first and then all package builds of this
> type can use it. For that, create a +new recipe with the name
> `sbuild-chroot-<host|target>-<flavor>`. In that recipe, +define the
> following: +
> +```
> +require recipes-devtools/sbuild-chroot/sbuild-chroot-<host|target>.bb
> +
> +SBUILD_FLAVOR = "<your flavor, e.g. clang>"
> +SBUILD_CHROOT_PREINSTALL_COMMON += "<base packages>"

in fact i would recommend a new variable here

SBUILD_CHROOT_PREINSTALL_EXTRA which defaults to ""

Henning

> +```
> +
> +Then, in the dpkg recipe of your package, simply set `SBUILD_FLAVOR
> = "<your flavor>"`. +To install additional packages into the sbuild
> chroot, add them to `SBUILD_CHROOT_PREINSTALL_COMMON`. +An full
> example is provided by the `samefile` recipe. diff --git
> a/meta/classes/crossvars.bbclass b/meta/classes/crossvars.bbclass
> index 201d460f..8d1da09c 100644 --- a/meta/classes/crossvars.bbclass
> +++ b/meta/classes/crossvars.bbclass
> @@ -10,22 +10,27 @@ python __anonymous() {
>      d.setVar('SCHROOT_USER', pwd.getpwuid(os.geteuid()).pw_name)
>  
>      mode = d.getVar('ISAR_CROSS_COMPILE')
> +
> +    # support derived schroots
> +    flavor = d.getVar('SBUILD_FLAVOR')
> +    flavor_suffix = ('-' + flavor) if flavor else ''
> +
>      distro_arch = d.getVar('DISTRO_ARCH')
>      if mode == "0" or d.getVar('HOST_ARCH') == distro_arch or
> distro_arch == None: d.setVar('BUILD_HOST_ARCH', distro_arch)
>          schroot_dir = d.getVar('SCHROOT_TARGET_DIR', False)
> -        sbuild_dep = "sbuild-chroot-target:do_build"
> +        sbuild_dep = "sbuild-chroot-target" + flavor_suffix +
> ":do_build" buildchroot_dir = d.getVar('BUILDCHROOT_TARGET_DIR',
> False) buildchroot_dep = "buildchroot-target:do_build"
>          sdk_toolchain = "build-essential"
>      else:
>          d.setVar('BUILD_HOST_ARCH', d.getVar('HOST_ARCH'))
>          schroot_dir = d.getVar('SCHROOT_HOST_DIR', False)
> -        sbuild_dep = "sbuild-chroot-host:do_build"
> +        sbuild_dep = "sbuild-chroot-host" + flavor_suffix +
> ":do_build" buildchroot_dir = d.getVar('BUILDCHROOT_HOST_DIR', False)
>          buildchroot_dep = "buildchroot-host:do_build"
>          sdk_toolchain = "crossbuild-essential-" + distro_arch
> -    d.setVar('SCHROOT_DIR', schroot_dir)
> +    d.setVar('SCHROOT_DIR', schroot_dir + flavor_suffix)
>      d.setVar('SCHROOT_DEP', sbuild_dep)
>      d.setVar('BUILDCHROOT_DIR', buildchroot_dir)
>      d.setVar('BUILDCHROOT_DEP', buildchroot_dep)
> diff --git a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc
> b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc index
> fd8bb648..b786eef5 100644 ---
> a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc +++
> b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc @@ -11,6
> +11,11 @@ PV = "1.0" inherit rootfs
>  inherit compat
>  
> +# set the flavor to create derived sbuild chroots
> +# this maps to a schroot created by a recipe named
> sbuild-chroot-<host|target>-<flavor> +SBUILD_FLAVOR ??= ""
> +SBUILD_SCHROOT_SUFFIX = "${@ ('-' + d.getVar('SBUILD_FLAVOR')) if
> d.getVar('SBUILD_FLAVOR') else ''}" +
>  python() {
>      distro_gcc = d.getVar('DISTRO_GCC')
>      distro_arch = d.getVar('DISTRO_ARCH')
> @@ -52,7 +57,7 @@ ROOTFS_PACKAGES = "${SBUILD_CHROOT_PREINSTALL}"
>  # We don't need /etc/apt/sources.list.d/isar-apt.list' while it's
> handled by sbuild ROOTFS_CONFIGURE_COMMAND:remove =
> "rootfs_configure_isar_apt" 
> -DEPLOY_SCHROOT = "${@d.getVar('SCHROOT_' +
> d.getVar('SBUILD_VARIANT').upper() + '_DIR')}" +DEPLOY_SCHROOT =
> "${@d.getVar('SCHROOT_' + d.getVar('SBUILD_VARIANT').upper() +
> '_DIR')}${SBUILD_SCHROOT_SUFFIX}" do_sbuildchroot_deploy[dirs] =
> "${DEPLOY_DIR}/schroot-${SBUILD_VARIANT}" do_sbuildchroot_deploy() {


      parent reply	other threads:[~2023-06-21 13:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13  7:00 Felix Moessbauer
2023-04-13  7:00 ` [PATCH 2/2] add example how to use " Felix Moessbauer
2023-04-14  8:46   ` Jan Kiszka
2023-06-21 12:33   ` Henning Schild
2023-05-29  7:14 ` [PATCH 1/2] add support for " Uladzimir Bely
2023-06-13  6:24 ` Uladzimir Bely
2023-06-19  5:58   ` Jan Kiszka
2023-06-19 13:10     ` Moessbauer Felix
2023-06-20  6:25       ` Uladzimir Bely
2023-06-20  8:05         ` Uladzimir Bely
2023-06-20  8:51           ` Moessbauer Felix
2023-06-21 12:42     ` Henning Schild
2023-06-21 13:22       ` Moessbauer Felix
2023-06-21 13:34         ` Henning Schild
2023-06-21 13:54 ` Henning Schild [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230621155450.3502b1dd@md1za8fc.ad001.siemens.net \
    --to=henning.schild@siemens.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox