public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [RFC 13/15] img: Use schroot for image prepare
Date: Mon, 26 Jul 2021 16:46:34 +0300	[thread overview]
Message-ID: <20210726134636.30800-14-amikan@ilbers.de> (raw)
In-Reply-To: <20210726134636.30800-1-amikan@ilbers.de>

Perform all image generation functions inside schroot.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/ext4-img.bbclass              |  8 ++------
 meta/classes/fit-img.bbclass               | 11 ++++-------
 meta/classes/image-tools-extension.bbclass | 14 ++++----------
 meta/classes/image.bbclass                 | 19 ++-----------------
 meta/classes/ubi-img.bbclass               | 11 ++++-------
 meta/classes/ubifs-img.bbclass             | 11 ++++-------
 6 files changed, 20 insertions(+), 54 deletions(-)

diff --git a/meta/classes/ext4-img.bbclass b/meta/classes/ext4-img.bbclass
index 26e0137..6f89fce 100644
--- a/meta/classes/ext4-img.bbclass
+++ b/meta/classes/ext4-img.bbclass
@@ -13,12 +13,8 @@ do_ext4_image() {
 
     truncate -s ${ROOTFS_SIZE}K '${DEPLOY_DIR_IMAGE}/${EXT4_IMAGE_FILE}'
 
-    image_do_mounts
-
-    sudo chroot ${BUILDCHROOT_DIR} /sbin/mke2fs ${MKE2FS_ARGS} \
-                -F -d '${PP_ROOTFS}' '${PP_DEPLOY}/${EXT4_IMAGE_FILE}'
-
-    image_undo_mounts
+    schroot_run -d ${PP_WORK} -c ${SBUILD_CHROOT} -u root -- /sbin/mke2fs \
+        ${MKE2FS_ARGS} -F -d '${PP_ROOTFS}' '${PP_DEPLOY}/${EXT4_IMAGE_FILE}'
 }
 
 addtask ext4_image before do_image after do_image_tools
diff --git a/meta/classes/fit-img.bbclass b/meta/classes/fit-img.bbclass
index da8e1da..483ef66 100644
--- a/meta/classes/fit-img.bbclass
+++ b/meta/classes/fit-img.bbclass
@@ -18,12 +18,9 @@ do_fit_image() {
 
     rm -f '${DEPLOY_DIR_IMAGE}/${FIT_IMAGE_FILE}'
 
-    image_do_mounts
-
-    # Create fit image using buildchroot tools
-    sudo chroot ${BUILDCHROOT_DIR} /usr/bin/mkimage ${MKIMAGE_ARGS} \
-                -f '${PP_WORK}/${FIT_IMAGE_SOURCE}' '${PP_DEPLOY}/${FIT_IMAGE_FILE}'
-
-    image_undo_mounts
+    # Create fit image using schroot tools
+    schroot_run -d ${PP_WORK} -c ${SBUILD_CHROOT} -- \
+        /usr/bin/mkimage ${MKIMAGE_ARGS} -f '${PP_WORK}/${FIT_IMAGE_SOURCE}' \
+        '${PP_DEPLOY}/${FIT_IMAGE_FILE}'
 }
 addtask fit_image before do_image after do_image_tools do_transform_template
diff --git a/meta/classes/image-tools-extension.bbclass b/meta/classes/image-tools-extension.bbclass
index 4738479..7896695 100644
--- a/meta/classes/image-tools-extension.bbclass
+++ b/meta/classes/image-tools-extension.bbclass
@@ -8,8 +8,6 @@
 # Imager are expected to run natively, thus will use the target buildchroot.
 ISAR_CROSS_COMPILE = "0"
 
-inherit buildchroot
-
 IMAGER_INSTALL ??= ""
 IMAGER_BUILD_DEPS ??= ""
 DEPENDS += "${IMAGER_BUILD_DEPS}"
@@ -22,11 +20,9 @@ do_install_imager_deps() {
         exit
     fi
 
-    buildchroot_do_mounts
-
     E="${@ isar_export_proxies(d)}"
-    deb_dl_dir_import ${BUILDCHROOT_DIR} ${DISTRO}
-    sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' \
+    #TODO deb_dl_dir_import ${BUILDCHROOT_DIR} ${DISTRO}
+    schroot -d / -c ${SBUILD_CHROOT_RW} -u root -- sh -c ' \
         apt-get update \
             -o Dir::Etc::SourceList="sources.list.d/isar-apt.list" \
             -o Dir::Etc::SourceParts="-" \
@@ -35,12 +31,10 @@ do_install_imager_deps() {
             --allow-unauthenticated --allow-downgrades --download-only install \
             ${IMAGER_INSTALL}'
 
-    deb_dl_dir_export ${BUILDCHROOT_DIR} ${DISTRO}
-    sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' \
+    #TODO deb_dl_dir_export ${BUILDCHROOT_DIR} ${DISTRO}
+    schroot -d / -c ${SBUILD_CHROOT_RW} -u root -- sh -c ' \
         apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
             --allow-unauthenticated --allow-downgrades install \
             ${IMAGER_INSTALL}'
-
-    buildchroot_undo_mounts
 }
 addtask install_imager_deps before do_image_tools
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 12d1616..9ca484a 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -52,24 +52,9 @@ DEPENDS += "${IMAGE_INSTALL}"
 ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags --dirty --match 'v[0-9].[0-9]*'"
 ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
 
-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}"
-    '
-    buildchroot_do_mounts
-}
+inherit sbuild
 
-image_undo_mounts() {
-    buildchroot_undo_mounts
-    sudo flock ${MOUNT_LOCKFILE} -c ' \
-        umount "${BUILDROOT_DEPLOY}"
-        umount "${BUILDROOT_ROOTFS}"
-        umount "${BUILDROOT_WORK}"
-    '
-}
+SCHROOT_MOUNTS = "${DEPLOY_DIR_IMAGE}:${PP_DEPLOY} ${IMAGE_ROOTFS}:${PP_ROOTFS} ${WORKDIR}:${PP_WORK}"
 
 ROOTFSDIR = "${IMAGE_ROOTFS}"
 ROOTFS_FEATURES += "clean-package-cache generate-manifest export-dpkg-status"
diff --git a/meta/classes/ubi-img.bbclass b/meta/classes/ubi-img.bbclass
index 0f4c4cb..a753504 100644
--- a/meta/classes/ubi-img.bbclass
+++ b/meta/classes/ubi-img.bbclass
@@ -21,12 +21,9 @@ do_ubi_image() {
 
     rm -f '${DEPLOY_DIR_IMAGE}/${UBI_IMAGE_FILE}'
 
-    image_do_mounts
-
-    # Create ubi image using buildchroot tools
-    sudo chroot ${BUILDCHROOT_DIR} /usr/sbin/ubinize ${UBINIZE_ARGS} \
-                -o '${PP_DEPLOY}/${UBI_IMAGE_FILE}' '${PP_WORK}/${UBINIZE_CFG}'
-
-    image_undo_mounts
+    # Create ubi image using schroot tools
+    schroot_run -d ${PP_WORK} -c ${SBUILD_CHROOT} -- \
+        /usr/sbin/ubinize ${UBINIZE_ARGS} -o '${PP_DEPLOY}/${UBI_IMAGE_FILE}' \
+        '${PP_WORK}/${UBINIZE_CFG}'
 }
 addtask ubi_image before do_image after do_image_tools do_transform_template
diff --git a/meta/classes/ubifs-img.bbclass b/meta/classes/ubifs-img.bbclass
index e422b46..13ce667 100644
--- a/meta/classes/ubifs-img.bbclass
+++ b/meta/classes/ubifs-img.bbclass
@@ -16,13 +16,10 @@ IMAGER_INSTALL += "mtd-utils"
 do_ubifs_image() {
     rm -f '${DEPLOY_DIR_IMAGE}/${UBIFS_IMAGE_FILE}'
 
-    image_do_mounts
-
-    # Create ubifs image using buildchroot tools
-    sudo chroot ${BUILDCHROOT_DIR} /usr/sbin/mkfs.ubifs ${MKUBIFS_ARGS} \
-                -r '${PP_ROOTFS}' '${PP_DEPLOY}/${UBIFS_IMAGE_FILE}'
-
-    image_undo_mounts
+    # Create ubifs image using schroot tools
+    schroot_run -d ${PP_WORK} -c ${SBUILD_CHROOT} -- \
+        /usr/sbin/mkfs.ubifs ${MKUBIFS_ARGS} -r '${PP_ROOTFS}' \
+        '${PP_DEPLOY}/${UBIFS_IMAGE_FILE}'
 }
 
 addtask ubifs_image before do_image after do_image_tools
-- 
2.25.1


  parent reply	other threads:[~2021-07-26 13:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-26 13:46 [RFC 00/15] Sbuild/Schroot migration Anton Mikanovich
2021-07-26 13:46 ` [RFC 01/15] dpkg: Install raw package files to source root Anton Mikanovich
2021-07-26 13:46 ` [RFC 02/15] dpkg-gbp: Use separate export-orig command Anton Mikanovich
2021-07-26 13:46 ` [RFC 03/15] isar-bootstrap: Export bootstrap to schroot config Anton Mikanovich
2021-07-26 13:46 ` [RFC 04/15] linux-module: Do not use shell environment Anton Mikanovich
2021-07-26 14:40   ` Jan Kiszka
2021-07-26 13:46 ` [RFC 05/15] u-boot: " Anton Mikanovich
2021-07-26 14:50   ` Jan Kiszka
2021-07-26 13:46 ` [RFC 06/15] trusted-firmware: " Anton Mikanovich
2021-07-26 13:46 ` [RFC 07/15] optee-os: " Anton Mikanovich
2021-07-26 13:46 ` [RFC 08/15] kselftest: " Anton Mikanovich
2021-07-26 13:46 ` [RFC 09/15] dpkg: Build packages with sbuild Anton Mikanovich
2021-07-26 13:46 ` [RFC 10/15] sbuild: Introduce environment variables export API Anton Mikanovich
2021-07-26 14:47   ` Jan Kiszka
2021-07-26 13:46 ` [RFC 11/15] dpkg: Remove builddeps install task Anton Mikanovich
2021-07-26 13:46 ` [RFC 12/15] dpkg-gbp: Migrate to schroot Anton Mikanovich
2021-07-26 13:46 ` Anton Mikanovich [this message]
2021-07-26 13:46 ` [RFC 14/15] linux-mainline: Move cfg fragment test to debian/rules Anton Mikanovich
2021-07-26 14:48   ` Jan Kiszka
2021-07-26 13:46 ` [RFC 15/15] linux-custom: Prepare kernel config inside sbuild Anton Mikanovich

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=20210726134636.30800-14-amikan@ilbers.de \
    --to=amikan@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