public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Alexander Smirnov <asmirnov@ilbers.de>, isar-users@googlegroups.com
Subject: Re: [PATCH 2/4] buildchroot: Enable isar-apt
Date: Sun, 4 Feb 2018 13:06:56 +0100	[thread overview]
Message-ID: <625d5ca7-af13-37f1-a59d-1b2535b36808@siemens.com> (raw)
In-Reply-To: <20180201112944.7877-3-asmirnov@ilbers.de>

On 2018-02-01 12:29, Alexander Smirnov wrote:
> This patch provides access to isar-apt from buildchroot. It does the
> following:
>  - mount isar-apt during buildchroot building.
>  - umount isar-apt using bitbake events.
> 
> Also it needs to keep Isar build tree clean from any mounts despite on whether
> build succeed of failed. bitbake provides various events that could trigger
> custom python hooks. In this patch BuildCompleted event is used, which happened
> when bitbake finished its execution despite on the result.
> 
> Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
> ---
>  meta-isar/conf/local.conf.sample                     |  3 +++
>  meta/classes/isar-events.bbclass                     | 20 ++++++++++++++++++++
>  meta/recipes-devtools/buildchroot/buildchroot.bb     |  7 +++++++
>  .../buildchroot/files/multistrap.conf.in             |  8 +++++++-
>  4 files changed, 37 insertions(+), 1 deletion(-)
>  create mode 100644 meta/classes/isar-events.bbclass
> 
> diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
> index 2ae43e7..fc760ed 100644
> --- a/meta-isar/conf/local.conf.sample
> +++ b/meta-isar/conf/local.conf.sample
> @@ -158,3 +158,6 @@ IMAGE_INSTALL = "example-hello example-raw"
>  #
>  # Default parallel jobs for bitbake:
>  BB_NUMBER_THREADS = "4"
> +
> +# Add event handlers for bitbake
> +INHERIT += "isar-events"
> diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
> new file mode 100644
> index 0000000..55fc106
> --- /dev/null
> +++ b/meta/classes/isar-events.bbclass
> @@ -0,0 +1,20 @@
> +# Isar event handlers.
> +#
> +# This software is a part of ISAR.
> +# Copyright (C) 2015-2017 ilbers GmbH
> +
> +addhandler isar_handler
> +
> +python isar_handler () {
> +    import subprocess
> +
> +    devnull = open(os.devnull, 'w')
> +
> +    if isinstance(e, bb.event.BuildCompleted):
> +        bchroot = d.getVar('BUILDCHROOT_DIR', True)
> +
> +        # Clean up buildchroot
> +        subprocess.call('/usr/bin/sudo /bin/umount ' + bchroot + '/isar-apt || /bin/true', stdout=devnull, stderr=devnull, shell=True)
> +
> +    devnull.close()
> +}
> diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb b/meta/recipes-devtools/buildchroot/buildchroot.bb
> index 51f9d5d..cb90148 100644
> --- a/meta/recipes-devtools/buildchroot/buildchroot.bb
> +++ b/meta/recipes-devtools/buildchroot/buildchroot.bb
> @@ -33,6 +33,7 @@ WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>  
>  do_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
>  do_build[dirs] = "${WORKDIR}/hooks_multistrap"
> +do_build[depends] = "isar-apt:do_cache_config"
>  
>  do_build() {
>      E="${@ bb.utils.export_proxies(d)}"
> @@ -58,6 +59,9 @@ do_build() {
>          -e 's|##DIR_HOOKS##|./'"$WORKDIR_REL"'/hooks_multistrap|g' \
>             "${WORKDIR}/multistrap.conf.in" > "${WORKDIR}/multistrap.conf"
>  
> +    [ ! -d ${BUILDCHROOT_DIR}/isar-apt ] && install -d -m 555 ${BUILDCHROOT_DIR}/isar-apt
> +    sudo mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt
> +

You likely also want to update the cleanup hook to unmount that again...

Jan

>      [ ! -d ${BUILDCHROOT_DIR}/proc ] && install -d -m 555 ${BUILDCHROOT_DIR}/proc
>      sudo mount -t proc none ${BUILDCHROOT_DIR}/proc
>      _do_build_cleanup() {
> @@ -73,6 +77,9 @@ do_build() {
>      # Install package builder script
>      sudo install -m 755 ${WORKDIR}/build.sh ${BUILDCHROOT_DIR}
>  
> +    # Create share point for isar-apt
> +    sudo install -d ${BUILDCHROOT_DIR}/isar-apt
> +
>      # Configure root filesystem
>      sudo chroot ${BUILDCHROOT_DIR} /configscript.sh
>      _do_build_cleanup
> diff --git a/meta/recipes-devtools/buildchroot/files/multistrap.conf.in b/meta/recipes-devtools/buildchroot/files/multistrap.conf.in
> index a0b28e3..480a4b8 100644
> --- a/meta/recipes-devtools/buildchroot/files/multistrap.conf.in
> +++ b/meta/recipes-devtools/buildchroot/files/multistrap.conf.in
> @@ -6,7 +6,7 @@ noauth=true
>  unpack=true
>  ignorenativearch=true
>  bootstrap=##DISTRO_MULTICONF_BOOTSTRAP##
> -aptsources=##DISTRO_MULTICONF_APTSOURCES##
> +aptsources=isar-apt ##DISTRO_MULTICONF_APTSOURCES##
>  configscript=##CONFIG_SCRIPT##
>  setupscript=##SETUP_SCRIPT##
>  hookdir=##DIR_HOOKS##
> @@ -29,3 +29,9 @@ source=##DISTRO_APT_SOURCE_SEC##
>  suite=##DISTRO_SUITE##/updates
>  components=##DISTRO_COMPONENTS##
>  omitdebsrc=true
> +
> +[isar-apt]
> +source=file:///isar-apt
> +suite=isar
> +components=main
> +omitdebsrc=true
> 


  reply	other threads:[~2018-02-04 12:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 11:29 [PATCH 0/4] Rework isar-apt Alexander Smirnov
2018-02-01 11:29 ` [PATCH 1/4] isar-apt: Introduce separate recipe Alexander Smirnov
2018-02-01 11:29 ` [PATCH 2/4] buildchroot: Enable isar-apt Alexander Smirnov
2018-02-04 12:06   ` Jan Kiszka [this message]
2018-02-01 11:29 ` [PATCH 3/4] build.sh: Update apt sources Alexander Smirnov
2018-02-01 11:40   ` Jan Kiszka
2018-02-01 11:48     ` Alexander Smirnov
2018-02-01 13:13       ` Jan Kiszka
2018-02-01 13:43         ` Alexander Smirnov
2018-02-01 14:28           ` Jan Kiszka
2018-02-01 11:29 ` [PATCH 4/4] build.sh: Force 'yes' for apt Alexander Smirnov
2018-02-01 11:41   ` Jan Kiszka
2018-02-01 12:27     ` Alexander Smirnov
2018-02-01 16:14 ` [PATCH 0/4] Rework isar-apt Jan Kiszka
2018-02-01 16:22   ` Alexander Smirnov
2018-02-01 16:25     ` Jan Kiszka
2018-02-01 16:54       ` Alexander Smirnov
2018-02-01 17:03         ` Jan Kiszka
2018-02-01 20:32           ` Alexander Smirnov
2018-02-01 18:37       ` Claudius Heine
2018-02-01 19:37         ` Alexander Smirnov
2018-02-01 20:09           ` Claudius Heine
2018-02-01 20:13             ` Claudius Heine

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=625d5ca7-af13-37f1-a59d-1b2535b36808@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=asmirnov@ilbers.de \
    --cc=isar-users@googlegroups.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