public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Srinuvasan Arjunan <srinuvasan_a@mentor.com>,
	isar-users@googlegroups.com
Cc: Srinuvasan A <srinuvasan.a@siemens.com>
Subject: Re: [RFC][PATCH] Add sbuildchroot class
Date: Fri, 8 Dec 2023 15:15:01 +0100	[thread overview]
Message-ID: <f9598980-eac9-4bd9-857d-f0bb1e0f5146@siemens.com> (raw)
In-Reply-To: <20231128071401.1894962-1-srinuvasan_a@mentor.com>

On 28.11.23 08:14, Srinuvasan Arjunan wrote:
> From: Srinuvasan A <srinuvasan.a@siemens.com>
> 
> In present implementation we are using sbuild/schroot to build the
> packages, this schroot created via sessions during package build, and
> immediatley vanish once build the packages.
> 
> Some of the downstream projects uses this chroot at many
> places for doing some postprocessing the meta data based on the chroot
> path, but unfortunately we cannot refer this path due to creating the
> chroot via session.

Can you be more specific in the use cases?

> 
> Hence install the required packages in persistence sbuildchroot, to
> access isar-apt and other directories we introduces the sbuildchroot
> class.

Did no one commented yet that we already have SBUILD_FLAVOR to
pre-install common packages into reusable sbuild schroots?

Jan

> 
> Signed-off-by: Srinuvasan A <srinuvasan.a@siemens.com>
> ---
>  meta/classes/sbuildchroot.bbclass | 101 ++++++++++++++++++++++++++++++
>  1 file changed, 101 insertions(+)
>  create mode 100644 meta/classes/sbuildchroot.bbclass
> 
> diff --git a/meta/classes/sbuildchroot.bbclass b/meta/classes/sbuildchroot.bbclass
> new file mode 100644
> index 00000000..edddd566
> --- /dev/null
> +++ b/meta/classes/sbuildchroot.bbclass
> @@ -0,0 +1,101 @@
> +# This software is a part of ISAR.
> +# Copyright (C) 2018 Siemens AG
> +#
> +# SPDX-License-Identifier: MIT
> +
> +inherit crossvars
> +
> +MOUNT_LOCKFILE = "${SCHROOT_DIR}.lock"
> +
> +sbuildchroot_do_mounts() {
> +    if [ "${USE_CCACHE}" = "1" ]; then
> +        mkdir -p "${CCACHE_DIR}"
> +        if [ "${CCACHE_DEBUG}" = "1" ]; then
> +            mkdir -p "${CCACHE_DIR}/debug"
> +        fi
> +    fi
> +
> +    sudo -s <<'EOSUDO'
> +        ( flock 9
> +        set -e
> +
> +        mountpoint -q '${SCHROOT_DIR}/isar-apt' ||
> +            mount --bind '${REPO_ISAR_DIR}/${DISTRO}' '${SCHROOT_DIR}/isar-apt'
> +        if [ "${USE_CCACHE}" = "1" ]; then
> +            mkdir -p '${SCHROOT_DIR}/ccache'
> +            mountpoint -q '${SCHROOT_DIR}/ccache' ||
> +                mount --bind '${CCACHE_DIR}' '${SCHROOT_DIR}/ccache'
> +        fi
> +        mountpoint -q '${SCHROOT_DIR}/dev' ||
> +            ( mount -o bind,private /dev '${SCHROOT_DIR}/dev' &&
> +              mount -t tmpfs none '${SCHROOT_DIR}/dev/shm' &&
> +              mount --bind /dev/pts '${SCHROOT_DIR}/dev/pts' )
> +        mountpoint -q '${SCHROOT_DIR}/proc' ||
> +            mount -t proc none '${SCHROOT_DIR}/proc'
> +        mountpoint -q '${SCHROOT_DIR}/sys' ||
> +            mount --rbind /sys '${SCHROOT_DIR}/sys'
> +        mount --make-rslave '${SCHROOT_DIR}/sys'
> +
> +        # Mount base-apt if 'ISAR_USE_CACHED_BASE_REPO' is set
> +        if [ "${@repr(bb.utils.to_boolean(d.getVar('ISAR_USE_CACHED_BASE_REPO')))}" = 'True' ]
> +        then
> +            mkdir -p '${SCHROOT_DIR}/base-apt'
> +            mountpoint -q '${SCHROOT_DIR}/base-apt' || \
> +                mount --bind '${REPO_BASE_DIR}' '${SCHROOT_DIR}/base-apt'
> +        fi
> +
> +        # Refresh or remove /etc/resolv.conf at this chance
> +        if [ "${@repr(bb.utils.to_boolean(d.getVar('BB_NO_NETWORK')))}" = 'True' ]
> +        then
> +            rm -rf '${SCHROOT_DIR}/etc/resolv.conf'
> +        else
> +            cp -L /etc/resolv.conf '${SCHROOT_DIR}/etc'
> +        fi
> +
> +        ) 9>'${MOUNT_LOCKFILE}'
> +EOSUDO
> +}
> +
> +add_isar_apt() {
> +    sudo -s <<'EOSUDO'
> +    set -e
> +
> +    mkdir -p '${SCHROOT_DIR}/etc/apt/sources.list.d'
> +    echo 'deb [trusted=yes] file:///isar-apt ${DEBDISTRONAME} main' > \
> +        '${SCHROOT_DIR}/etc/apt/sources.list.d/isar-apt.list'
> +    echo 'deb-src [trusted=yes] file:///isar-apt ${DEBDISTRONAME} main' >> \
> +        '${SCHROOT_DIR}/etc/apt/sources.list.d/isar-apt.list'
> +
> +    mkdir -p '${SCHROOT_DIR}/etc/apt/preferences.d'
> +    cat << EOF > '${SCHROOT_DIR}/etc/apt/preferences.d/isar-apt'
> +Package: *
> +Pin: release n=${DEBDISTRONAME}
> +Pin-Priority: 1000
> +EOF
> +EOSUDO
> +}
> +
> +cleanup_isar_apt() {
> +    sudo -s <<'EOSUDO'
> +        set -e
> +        rm -f "${SCHROOT_DIR}/etc/apt/sources.list.d/isar-apt.list"
> +        rm -f "${SCHROOT_DIR}/etc/apt/preferences.d/isar-apt"
> +        rm -f "${SCHROOT_DIR}/etc/apt/sources.list.d/base-apt.list"
> +        rm -f "${SCHROOT_DIR}/etc/apt/apt.conf.d/50isar"
> +EOSUDO
> +}
> +
> +image_do_mounts() {
> +    sudo flock ${MOUNT_LOCKFILE} -c ' \
> +        mkdir -p "${BUILDROOT_DEPLOY}" "${BUILDROOT_ROOTFS}" "${BUILDROOT_WORK}"
> +        mount --bind "${DEPLOY_DIR_IMAGE}" "${BUILDROOT_DEPLOY}"
> +        mount --bind "${IMAGE_ROOTFS}" "${BUILDROOT_ROOTFS}"
> +        mount --bind "${WORKDIR}" "${BUILDROOT_WORK}"
> +    '
> +    sbuildchroot_do_mounts
> +}
> +
> +BUILDROOT = "${SCHROOT_DIR}${PP}"
> +BUILDROOT_DEPLOY = "${SCHROOT_DIR}${PP_DEPLOY}"
> +BUILDROOT_ROOTFS = "${SCHROOT_DIR}${PP_ROOTFS}"
> +BUILDROOT_WORK = "${SCHROOT_DIR}${PP_WORK}"

-- 
Siemens AG, Technology
Linux Expert Center


  parent reply	other threads:[~2023-12-08 14:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-28  7:14 Srinuvasan Arjunan
2023-12-08 14:13 ` Srinuvasan Arjunan
2023-12-08 14:15 ` Jan Kiszka [this message]
2023-12-12  4:55   ` Srinuvasan Arjunan
2023-12-12  5:08     ` Jan Kiszka
2023-12-12  5:18       ` Srinuvasan Arjunan

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=f9598980-eac9-4bd9-857d-f0bb1e0f5146@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=srinuvasan.a@siemens.com \
    --cc=srinuvasan_a@mentor.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