public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [RFC][PATCH] Add sbuildchroot class
@ 2023-11-28  7:14 Srinuvasan Arjunan
  2023-12-08 14:13 ` Srinuvasan Arjunan
  2023-12-08 14:15 ` Jan Kiszka
  0 siblings, 2 replies; 6+ messages in thread
From: Srinuvasan Arjunan @ 2023-11-28  7:14 UTC (permalink / raw)
  To: isar-users; +Cc: Srinuvasan A

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.

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

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}"
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add sbuildchroot class
  2023-11-28  7:14 [RFC][PATCH] Add sbuildchroot class Srinuvasan Arjunan
@ 2023-12-08 14:13 ` Srinuvasan Arjunan
  2023-12-08 14:15 ` Jan Kiszka
  1 sibling, 0 replies; 6+ messages in thread
From: Srinuvasan Arjunan @ 2023-12-08 14:13 UTC (permalink / raw)
  To: isar-users


[-- Attachment #1.1: Type: text/plain, Size: 4667 bytes --]

Hi All,

             Any thoughts on this RFC, If you need additional use case also 
will provide.

Many thanks,
Srinu

On Tuesday, November 28, 2023 at 12:44:22 PM UTC+5:30 Srinuvasan Arjunan 
wrote:

> From: Srinuvasan A <srinuv...@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.
>
> Hence install the required packages in persistence sbuildchroot, to
> access isar-apt and other directories we introduces the sbuildchroot
> class.
>
> Signed-off-by: Srinuvasan A <srinuv...@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}"
> -- 
> 2.34.1
>
>

[-- Attachment #1.2: Type: text/html, Size: 6397 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add sbuildchroot class
  2023-11-28  7:14 [RFC][PATCH] Add sbuildchroot class Srinuvasan Arjunan
  2023-12-08 14:13 ` Srinuvasan Arjunan
@ 2023-12-08 14:15 ` Jan Kiszka
  2023-12-12  4:55   ` Srinuvasan Arjunan
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2023-12-08 14:15 UTC (permalink / raw)
  To: Srinuvasan Arjunan, isar-users; +Cc: Srinuvasan A

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add sbuildchroot class
  2023-12-08 14:15 ` Jan Kiszka
@ 2023-12-12  4:55   ` Srinuvasan Arjunan
  2023-12-12  5:08     ` Jan Kiszka
  0 siblings, 1 reply; 6+ messages in thread
From: Srinuvasan Arjunan @ 2023-12-12  4:55 UTC (permalink / raw)
  To: isar-users


[-- Attachment #1.1: Type: text/plain, Size: 5499 bytes --]



On Friday, December 8, 2023 at 7:45:06 PM UTC+5:30 Jan Kiszka wrote:

On 28.11.23 08:14, Srinuvasan Arjunan wrote: 
> From: Srinuvasan A <srinuv...@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?


   In our case we need to install the custom packages in buildchroot,
   once we installed the isar-apt packages, later we refer those and do some
   postprocessing before image creation.


   ISAR provides the provision to pre-install the  upstream packages
   not custom packages and this chroot will be used as a base chroot to
    build the packages or imager_run, hence SBUILD_FLAVOR would not be
   helpful atleast for my scenario.


   SBUILD_CHROOT_PREINSTALL_EXTRA variable directly install the upstream 
   packages in rootfs not custom packages.



> 
> 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 <srinuv...@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 


[-- Attachment #1.2: Type: text/html, Size: 8698 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add sbuildchroot class
  2023-12-12  4:55   ` Srinuvasan Arjunan
@ 2023-12-12  5:08     ` Jan Kiszka
  2023-12-12  5:18       ` Srinuvasan Arjunan
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kiszka @ 2023-12-12  5:08 UTC (permalink / raw)
  To: Srinuvasan Arjunan, isar-users

On 12.12.23 05:55, Srinuvasan Arjunan wrote:
> 
> 
> On Friday, December 8, 2023 at 7:45:06 PM UTC+5:30 Jan Kiszka wrote:
> 
>     On 28.11.23 08:14, Srinuvasan Arjunan wrote:
>     > From: Srinuvasan A <srinuv...@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?
> 
> 
>    In our case we need to install the custom packages in buildchroot,
>    once we installed the isar-apt packages, later we refer those and do some
>    postprocessing before image creation.
> 
> 
>    ISAR provides the provision to pre-install the  upstream packages
>    not custom packages and this chroot will be used as a base chroot to
>     build the packages or imager_run, hence SBUILD_FLAVOR would not be
>    helpful atleast for my scenario.
> 
> 
>    SBUILD_CHROOT_PREINSTALL_EXTRA variable directly install the upstream 
>    packages in rootfs not custom packages.
> 

Understood the use case now - but then why not fixing/enhancing the
existing mechanism? We likely need some SBUILD_CHROOT_INSTALL_EXTRA that
establishes the recipe dependency, and then a custom sbuild should also
be able to pull packages from isar-apt. Did you consider this already?

Jan

-- 
Siemens AG, Technology
Linux Expert Center


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFC][PATCH] Add sbuildchroot class
  2023-12-12  5:08     ` Jan Kiszka
@ 2023-12-12  5:18       ` Srinuvasan Arjunan
  0 siblings, 0 replies; 6+ messages in thread
From: Srinuvasan Arjunan @ 2023-12-12  5:18 UTC (permalink / raw)
  To: isar-users


[-- Attachment #1.1: Type: text/plain, Size: 2033 bytes --]



On Tuesday, December 12, 2023 at 10:38:08 AM UTC+5:30 Jan Kiszka wrote:

On 12.12.23 05:55, Srinuvasan Arjunan wrote: 
> 
> 
> On Friday, December 8, 2023 at 7:45:06 PM UTC+5:30 Jan Kiszka wrote: 
> 
> On 28.11.23 08:14, Srinuvasan Arjunan wrote: 
> > From: Srinuvasan A <srinuv...@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? 
> 
> 
>    In our case we need to install the custom packages in buildchroot, 
>    once we installed the isar-apt packages, later we refer those and do 
some 
>    postprocessing before image creation. 
> 
> 
>    ISAR provides the provision to pre-install the  upstream packages 
>    not custom packages and this chroot will be used as a base chroot to 
>     build the packages or imager_run, hence SBUILD_FLAVOR would not be 
>    helpful atleast for my scenario. 
> 
> 
>    SBUILD_CHROOT_PREINSTALL_EXTRA variable directly install the upstream  
>    packages in rootfs not custom packages. 
> 

Understood the use case now - but then why not fixing/enhancing the 
existing mechanism? We likely need some SBUILD_CHROOT_INSTALL_EXTRA that 
establishes the recipe dependency, and then a custom sbuild should also 
be able to pull packages from isar-apt. Did you consider this already?


    Hmm, Understood, but so far i didn't tried this method , i meant pull 
isar-apt packages in custom sbuild  (SBUILD_FLAVOR), i hope this
   will work for my scenario,  Let me try one use cases and update the 
patch ASAP.



Jan 

-- 
Siemens AG, Technology 
Linux Expert Center 


[-- Attachment #1.2: Type: text/html, Size: 2840 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-12  5:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-28  7:14 [RFC][PATCH] Add sbuildchroot class Srinuvasan Arjunan
2023-12-08 14:13 ` Srinuvasan Arjunan
2023-12-08 14:15 ` Jan Kiszka
2023-12-12  4:55   ` Srinuvasan Arjunan
2023-12-12  5:08     ` Jan Kiszka
2023-12-12  5:18       ` Srinuvasan Arjunan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox