public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 0/6] Imager schroot migration
@ 2022-05-14  7:07 Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 1/6] sbuild: Allow setting custom config paths Anton Mikanovich
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Anton Mikanovich @ 2022-05-14  7:07 UTC (permalink / raw)
  To: isar-users; +Cc: adriaan.schmidt, Anton Mikanovich

This is the first version of full Isar migration from buildchroot to schroot
usage as the next step after moving to sbuild.

Imagers of every target are now running in separate schroot sessions with
independent overlays on top of basic unchanged schroot. It means we need to
open schroot session before any imager task execution and close this session
after the usage. Any changes made inside overlay will be dropped after the
usage to keep basic schroot clean.

We also need to introduce additional cleanup inside isar-events finish handler
to prevent leaving sessions in case we execute only session start task.

There are still couple of issues need to be solved before the usage:
- it works only after reverting of 4e1dacc
- there are no documentaion updates
- only basic build scenarios works, CI still fails

Anton Mikanovich (6):
  sbuild: Allow setting custom config paths
  base: Implement bitbake build ID
  imager: Migrate from buildchroot to schroot
  imager: Move image types to schroot
  events: Cleanup lost schroot sessions if any
  meta: Remove buildchroot

 meta-isar/conf/local.conf.sample              |  2 +-
 meta/classes/base.bbclass                     |  9 ++
 meta/classes/buildchroot.bbclass              | 71 ----------------
 meta/classes/dpkg-base.bbclass                | 28 ------
 meta/classes/image-tools-extension.bbclass    | 80 ++++++++++++++---
 meta/classes/image.bbclass                    | 19 +----
 meta/classes/imagetypes_vm.bbclass            |  7 +-
 meta/classes/imagetypes_wic.bbclass           | 73 +++++-----------
 meta/classes/isar-events.bbclass              | 19 ++++-
 meta/classes/sbuild.bbclass                   | 50 ++++++++---
 meta/conf/bitbake.conf                        |  3 -
 .../buildchroot/buildchroot-host.bb           | 24 ------
 .../buildchroot/buildchroot-target.bb         | 15 ----
 .../buildchroot/buildchroot.inc               | 85 -------------------
 .../buildchroot/files/build.sh                | 17 ----
 .../buildchroot/files/common.sh               | 32 -------
 .../buildchroot/files/configscript.sh         | 15 ----
 .../buildchroot/files/deps.sh                 | 47 ----------
 18 files changed, 161 insertions(+), 435 deletions(-)
 delete mode 100644 meta/classes/buildchroot.bbclass
 delete mode 100644 meta/recipes-devtools/buildchroot/buildchroot-host.bb
 delete mode 100644 meta/recipes-devtools/buildchroot/buildchroot-target.bb
 delete mode 100644 meta/recipes-devtools/buildchroot/buildchroot.inc
 delete mode 100644 meta/recipes-devtools/buildchroot/files/build.sh
 delete mode 100644 meta/recipes-devtools/buildchroot/files/common.sh
 delete mode 100644 meta/recipes-devtools/buildchroot/files/configscript.sh
 delete mode 100644 meta/recipes-devtools/buildchroot/files/deps.sh

-- 
2.17.1


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

* [PATCH 1/6] sbuild: Allow setting custom config paths
  2022-05-14  7:07 [PATCH 0/6] Imager schroot migration Anton Mikanovich
@ 2022-05-14  7:07 ` Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 2/6] base: Implement bitbake build ID Anton Mikanovich
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Anton Mikanovich @ 2022-05-14  7:07 UTC (permalink / raw)
  To: isar-users; +Cc: adriaan.schmidt, Anton Mikanovich

Extend internal schroot APIs to be able to set custom chroot config
name. This will allow to configure/unconfigure schroots from any task.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/sbuild.bbclass | 50 +++++++++++++++++++++++++++----------
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass
index f9bfaaf..2523154 100644
--- a/meta/classes/sbuild.bbclass
+++ b/meta/classes/sbuild.bbclass
@@ -31,10 +31,17 @@ SCHROOT_CONF_FILE ?= "${SCHROOT_CONF}/chroot.d/${SBUILD_CHROOT}"
 SBUILD_CONFIG="${WORKDIR}/sbuild.conf"
 
 schroot_create_configs() {
-    sudo -s <<'EOSUDO'
+    conf_dir="${SBUILD_CONF_DIR}"
+    conf_file="${SCHROOT_CONF_FILE}"
+    if [ -n "$1" ]; then
+        conf_dir="${SCHROOT_CONF}/${1}"
+        conf_file="${SCHROOT_CONF}/chroot.d/${1}"
+    fi
+    export conf_dir conf_file
+    sudo -E -s <<'EOSUDO'
         set -e
 
-        cat << EOF > "${SCHROOT_CONF_FILE}"
+        cat << EOF > "${conf_file}"
 [${SBUILD_CHROOT}]
 type=directory
 directory=${SCHROOT_DIR}
@@ -50,8 +57,8 @@ preserve-environment=true
 EOF
 
         # Prepare mount points
-        cp -rf "${SCHROOT_CONF}/sbuild" "${SBUILD_CONF_DIR}"
-        sbuild_fstab="${SBUILD_CONF_DIR}/fstab"
+        cp -rf "${SCHROOT_CONF}/sbuild" "${conf_dir}"
+        sbuild_fstab="${conf_dir}/fstab"
 
         fstab_baseapt="${REPO_BASE_DIR} /base-apt none rw,bind 0 0"
         grep -qxF "${fstab_baseapt}" ${sbuild_fstab} || echo "${fstab_baseapt}" >> ${sbuild_fstab}
@@ -67,12 +74,19 @@ EOSUDO
 }
 
 schroot_delete_configs() {
-    sudo -s <<'EOSUDO'
+    conf_dir="${SBUILD_CONF_DIR}"
+    conf_file="${SCHROOT_CONF_FILE}"
+    if [ -n "$1" ]; then
+        conf_dir="${SCHROOT_CONF}/${1}"
+        conf_file="${SCHROOT_CONF}/chroot.d/${1}"
+    fi
+    export conf_dir conf_file
+    sudo -E -s <<'EOSUDO'
         set -e
-        if [ -d "${SBUILD_CONF_DIR}" ]; then
-            rm -rf "${SBUILD_CONF_DIR}"
+        if [ -d "${conf_dir}" ]; then
+            rm -rf "${conf_dir}"
         fi
-        rm -f "${SCHROOT_CONF_FILE}"
+        rm -f "${conf_file}"
 EOSUDO
 }
 
@@ -106,22 +120,32 @@ sbuild_export() {
 }
 
 insert_mounts() {
-    sudo -s <<'EOSUDO'
+    conf_dir="${SBUILD_CONF_DIR}"
+    if [ -n "$1" ]; then
+        conf_dir="${SCHROOT_CONF}/${1}"
+    fi
+    export conf_dir
+    sudo -E -s <<'EOSUDO'
         set -e
         for mp in ${SCHROOT_MOUNTS}; do
             FSTAB_LINE="${mp%%:*} ${mp#*:} none rw,bind 0 0"
-            grep -qxF "${FSTAB_LINE}" ${SBUILD_CONF_DIR}/fstab || \
-                echo "${FSTAB_LINE}" >> ${SBUILD_CONF_DIR}/fstab
+            grep -qxF "${FSTAB_LINE}" ${conf_dir}/fstab || \
+                echo "${FSTAB_LINE}" >> ${conf_dir}/fstab
         done
 EOSUDO
 }
 
 remove_mounts() {
-    sudo -s <<'EOSUDO'
+    conf_dir="${SBUILD_CONF_DIR}"
+    if [ -n "$1" ]; then
+        conf_dir="${SCHROOT_CONF}/${1}"
+    fi
+    export conf_dir
+    sudo -E -s <<'EOSUDO'
         set -e
         for mp in ${SCHROOT_MOUNTS}; do
             FSTAB_LINE="${mp%%:*} ${mp#*:} none rw,bind 0 0"
-            sed -i "\|${FSTAB_LINE}|d" ${SBUILD_CONF_DIR}/fstab
+            sed -i "\|${FSTAB_LINE}|d" ${conf_dir}/fstab
         done
 EOSUDO
 }
-- 
2.17.1


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

* [PATCH 2/6] base: Implement bitbake build ID
  2022-05-14  7:07 [PATCH 0/6] Imager schroot migration Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 1/6] sbuild: Allow setting custom config paths Anton Mikanovich
@ 2022-05-14  7:07 ` Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 3/6] imager: Migrate from buildchroot to schroot Anton Mikanovich
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Anton Mikanovich @ 2022-05-14  7:07 UTC (permalink / raw)
  To: isar-users; +Cc: adriaan.schmidt, Anton Mikanovich

Add internal ID which is unique for any single bitabake run.
BITBAKE_BUILD_ID is calculated as a hash of two variables defined by
bitbake itself at build start:
BUILDNAME - defined as "${DATE}${TIME}" of cooker execution.
TOPDIR - build dir where Isar is building.
Both of them guarantee uniqueness by time and directory.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/base.bbclass | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 4ec2c81..f6b6a32 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -278,3 +278,12 @@ def base_set_filespath(path, d):
             if p != "":
                 filespath.append(os.path.join(p, o))
     return ":".join(filespath)
+
+calculate_build_id[vardepsexclude] = "BUILDNAME"
+def calculate_build_id(d):
+    import hashlib
+    build_name = d.getVar("BUILDNAME", True) or ""
+    build_dir = d.getVar("TOPDIR", True) or ""
+    return hashlib.sha1((build_dir + build_name).encode("utf-8")).hexdigest()
+
+BITBAKE_BUILD_ID = "${@ calculate_build_id(d)}"
-- 
2.17.1


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

* [PATCH 3/6] imager: Migrate from buildchroot to schroot
  2022-05-14  7:07 [PATCH 0/6] Imager schroot migration Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 1/6] sbuild: Allow setting custom config paths Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 2/6] base: Implement bitbake build ID Anton Mikanovich
@ 2022-05-14  7:07 ` Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 4/6] imager: Move image types " Anton Mikanovich
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Anton Mikanovich @ 2022-05-14  7:07 UTC (permalink / raw)
  To: isar-users; +Cc: adriaan.schmidt, Anton Mikanovich

Install dependencies and perform all imager actions using one schroot
overlay. This requires to open a session which stays opened until all
the images are ready. This session will be closed then and all the
changes will be lost.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/image-tools-extension.bbclass | 80 +++++++++++++++++++---
 meta/classes/image.bbclass                 |  1 +
 2 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/meta/classes/image-tools-extension.bbclass b/meta/classes/image-tools-extension.bbclass
index b996813..54a6622 100644
--- a/meta/classes/image-tools-extension.bbclass
+++ b/meta/classes/image-tools-extension.bbclass
@@ -5,16 +5,18 @@
 #
 # This file extends the image.bbclass to supply tools for futher imager functions
 
-# Imager are expected to run natively, thus will use the target buildchroot.
+# Imager are expected to run natively, thus will use the target schroot.
 ISAR_CROSS_COMPILE = "0"
 
-inherit buildchroot
+inherit sbuild
 
 IMAGER_INSTALL ??= ""
 IMAGER_BUILD_DEPS ??= ""
 DEPENDS += "${IMAGER_BUILD_DEPS}"
 
-do_install_imager_deps[depends] = "${BUILDCHROOT_DEP} isar-apt:do_cache_config"
+IMAGER_SCHROOT_SESSION_ID = "isar-imager-${SCHROOT_USER}-${PN}-${MACHINE}-${BITBAKE_BUILD_ID}"
+
+do_install_imager_deps[depends] = "${SCHROOT_DEP} isar-apt:do_cache_config"
 do_install_imager_deps[deptask] = "do_deploy_deb"
 do_install_imager_deps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
 do_install_imager_deps() {
@@ -22,11 +24,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 ' \
+    deb_dl_dir_import ${SCHROOT_DIR} ${DISTRO}
+    schroot -r -c ${IMAGER_SCHROOT_SESSION_ID} -d / -u root -- sh -c ' \
         apt-get update \
             -o Dir::Etc::SourceList="sources.list.d/isar-apt.list" \
             -o Dir::Etc::SourceParts="-" \
@@ -35,10 +35,70 @@ 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 ' \
+    deb_dl_dir_export ${SCHROOT_DIR} ${DISTRO}
+    schroot -r -c ${IMAGER_SCHROOT_SESSION_ID} -d / -u root -- sh -c ' \
         apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
             --allow-unauthenticated --allow-downgrades install \
             ${IMAGER_INSTALL}'
 }
-addtask install_imager_deps before do_image_tools
+addtask install_imager_deps before do_image_tools after do_start_imager_session
+
+SCHROOT_MOUNTS = "${WORKDIR}:${PP_WORK} ${IMAGE_ROOTFS}:${PP_ROOTFS} ${DEPLOY_DIR_IMAGE}:${PP_DEPLOY}"
+
+do_start_imager_session[dirs] = "${WORKDIR} ${IMAGE_ROOTFS} ${DEPLOY_DIR_IMAGE}"
+do_start_imager_session[depends] = "${SCHROOT_DEP} isar-apt:do_cache_config"
+do_start_imager_session[nostamp] = "1"
+python do_start_imager_session() {
+    import subprocess
+    bb.build.exec_func("schroot_create_configs", d)
+    bb.build.exec_func("insert_mounts", d)
+    sbuild_chroot = d.getVar("SBUILD_CHROOT", True)
+    session_id = d.getVar("IMAGER_SCHROOT_SESSION_ID", True)
+    try:
+        if subprocess.run("schroot -l --all-sessions | grep %s" % session_id, shell=True).returncode:
+            subprocess.run("schroot -b -c %s -n %s" % (sbuild_chroot, session_id), shell=True, check=True)
+            bb.debug(2, "Open schroot session %s" % session_id)
+        else:
+            subprocess.run("schroot --recover-session -c %s" % session_id, shell=True, check=True)
+            bb.debug(2, "Reuse schroot session %s" % session_id)
+        d.setVar("SCHROOT_OPEN_SESSION_ID", session_id)
+    except subprocess.CalledProcessError as err:
+        subprocess.run("schroot -e -c %s" % session_id, shell=True)
+        bb.build.exec_func("remove_mounts", d)
+        bb.build.exec_func("schroot_delete_configs", d)
+        bb.fatal("Could not create schroot session: %s" % err.output.decode('utf-8') if err.output else "")
+}
+addtask start_imager_session before do_stop_imager_session after do_rootfs_finalize
+
+do_stop_imager_session[depends] = "${SCHROOT_DEP}"
+do_stop_imager_session[nostamp] = "1"
+python do_stop_imager_session() {
+    import subprocess
+    session_id = d.getVar("IMAGER_SCHROOT_SESSION_ID", True)
+    try:
+        id = subprocess.run("schroot -d / -r -c %s -- printenv -0 SCHROOT_ALIAS_NAME" % session_id,
+                            shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
+        bb.debug(2, "Close schroot session %s (%s)" % (session_id, id))
+        subprocess.run("schroot -e -c %s" % session_id, shell=True, check=True)
+    except subprocess.CalledProcessError as err:
+        bb.error("Could not close schroot session %s: %s" % (session_id, err.output.decode('utf-8')) if err.output else "")
+    finally:
+        if 'id' in locals():
+            d.setVar("SBUILD_CHROOT", id)
+            bb.build.exec_func("remove_mounts", d)
+            bb.build.exec_func("schroot_delete_configs", d)
+}
+addtask stop_imager_session before do_deploy after do_image
+
+imager_run() {
+    imager_cleanup() {
+        if id="$(schroot -d / -r -c ${IMAGER_SCHROOT_SESSION_ID} -- printenv -0 SCHROOT_ALIAS_NAME)"; then
+            schroot -e -c ${IMAGER_SCHROOT_SESSION_ID}
+            remove_mounts $id
+            schroot_delete_configs $id
+        fi
+    }
+    trap 'exit 1' INT HUP QUIT TERM ALRM USR1
+    trap 'imager_cleanup' EXIT
+    schroot -r -c ${IMAGER_SCHROOT_SESSION_ID} "$@"
+}
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 26b1b0d..651b252 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -275,6 +275,7 @@ python() {
         d.appendVarFlag(task, 'vardeps', ' ' + ' '.join(vardeps))
         d.appendVarFlag(task, 'vardepsexclude', ' ' + ' '.join(vardepsexclude))
         d.appendVarFlag(task, 'dirs', localdata.expand(' ${DEPLOY_DIR_IMAGE}'))
+        d.appendVarFlag(task, 'deptask', ' do_start_imager_session')
         if task_deps:
             d.appendVarFlag(task, 'depends', task_deps)
         bb.build.addtask(task, 'do_image', after, d)
-- 
2.17.1


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

* [PATCH 4/6] imager: Move image types to schroot
  2022-05-14  7:07 [PATCH 0/6] Imager schroot migration Anton Mikanovich
                   ` (2 preceding siblings ...)
  2022-05-14  7:07 ` [PATCH 3/6] imager: Migrate from buildchroot to schroot Anton Mikanovich
@ 2022-05-14  7:07 ` Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 5/6] events: Cleanup lost schroot sessions if any Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 6/6] meta: Remove buildchroot Anton Mikanovich
  5 siblings, 0 replies; 7+ messages in thread
From: Anton Mikanovich @ 2022-05-14  7:07 UTC (permalink / raw)
  To: isar-users; +Cc: adriaan.schmidt, Anton Mikanovich

Use schroot inside imager session to prepare images.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/image.bbclass          |  3 +-
 meta/classes/imagetypes_vm.bbclass  |  7 +--
 meta/classes/imagetypes_wic.bbclass | 73 +++++++++--------------------
 3 files changed, 25 insertions(+), 58 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 651b252..9b4b67b 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -210,7 +210,7 @@ python() {
         localdata.setVar('IMAGE_FILE_HOST', '${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.${type}')
         #bb.warn("FULLNAME is %s -> %s" % (localdata.getVar('IMAGE_FULLNAME', False), localdata.getVar('IMAGE_FULLNAME', True)))
         localdata.setVar('IMAGE_FILE_CHROOT', '${PP_DEPLOY}/${IMAGE_FULLNAME}.${type}')
-        localdata.setVar('SUDO_CHROOT', localdata.expand('sudo chroot ${BUILDCHROOT_DIR}'))
+        localdata.setVar('SUDO_CHROOT', localdata.expand('imager_run -d ${PP_ROOTFS} -u root --'))
 
         # imager install
         for dep in (d.getVar('IMAGER_INSTALL_' + bt_clean) or '').split():
@@ -219,7 +219,6 @@ python() {
             imager_build_deps.add(dep)
 
         # construct image command
-        cmds.append('\timage_do_mounts')
         image_cmd = localdata.getVar('IMAGE_CMD_' + bt_clean)
         if image_cmd:
             localdata.setVar('type', bt)
diff --git a/meta/classes/imagetypes_vm.bbclass b/meta/classes/imagetypes_vm.bbclass
index 8a676ac..a7090e6 100644
--- a/meta/classes/imagetypes_vm.bbclass
+++ b/meta/classes/imagetypes_vm.bbclass
@@ -4,8 +4,6 @@
 # This class allows to generate images for VMware and VirtualBox
 #
 
-inherit buildchroot
-
 USING_OVA = "${@bb.utils.contains('IMAGE_BASETYPES', 'ova', '1', '0', d)}"
 
 FILESEXTRAPATHS_prepend := "${LAYERDIR_core}/classes/vm-img:"
@@ -38,9 +36,8 @@ CONVERSION_OPTIONS = "${@set_convert_options(d)}"
 
 convert_wic() {
     rm -f '${DEPLOY_DIR_IMAGE}/${VIRTUAL_MACHINE_IMAGE_FILE}'
-    image_do_mounts
     bbnote "Creating ${VIRTUAL_MACHINE_IMAGE_FILE} from ${SOURCE_IMAGE_FILE}"
-    sudo -E  chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} \
+    imager_run -p -d ${PP_WORK} -- \
     /usr/bin/qemu-img convert -f raw -O ${VIRTUAL_MACHINE_IMAGE_TYPE} ${CONVERSION_OPTIONS} \
         '${PP_DEPLOY}/${SOURCE_IMAGE_FILE}' '${VIRTUAL_MACHINE_DISK}'
 }
@@ -83,7 +80,7 @@ IMAGE_CMD_ova() {
     export LAST_CHANGE=$(date -u "+%Y-%m-%dT%H:%M:%SZ")
     export OVA_FIRMWARE_UPPERCASE=$(echo ${OVA_FIRMWARE} | tr '[a-z]' '[A-Z]')
     export OVF_TEMPLATE_STAGE2=$(echo ${OVF_TEMPLATE_FILE} | sed 's/.tmpl$//' )
-    sudo -Es chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} <<'EOSUDO'
+    imager_run -p -d ${PP_WORK} <<'EOSUDO'
         set -e
         export DISK_SIZE_BYTES=$(qemu-img info -f vmdk "${VIRTUAL_MACHINE_DISK}" \
                                  | gawk 'match($0, /^virtual size:.*\(([0-9]+) bytes\)/, a) {print a[1]}')
diff --git a/meta/classes/imagetypes_wic.bbclass b/meta/classes/imagetypes_wic.bbclass
index cfcc94c..9c7a5eb 100644
--- a/meta/classes/imagetypes_wic.bbclass
+++ b/meta/classes/imagetypes_wic.bbclass
@@ -82,8 +82,6 @@ python () {
             bb.build.addtask('do_transform_template', 'do_image_wic', None, d)
 }
 
-inherit buildchroot
-
 IMAGER_INSTALL_wic += "${WIC_IMAGER_INSTALL}"
 # wic comes with reasonable defaults, and the proper interface is the wks file
 ROOTFS_EXTRA ?= "0"
@@ -94,7 +92,6 @@ STAGING_DIR ?= "${TMPDIR}"
 IMAGE_BASENAME ?= "${PN}-${DISTRO}"
 FAKEROOTCMD ?= "${SCRIPTSDIR}/wic_fakeroot"
 RECIPE_SYSROOT_NATIVE ?= "/"
-BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
 
 WIC_CREATE_EXTRA_ARGS ?= ""
 
@@ -142,25 +139,11 @@ check_for_wic_warnings() {
 
 do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}"
 IMAGE_CMD_wic() {
-    wic_do_mounts
     generate_wic_image
     check_for_wic_warnings
 }
 
-wic_do_mounts() {
-    buildchroot_do_mounts
-    sudo -s <<'EOSUDO'
-        ( flock 9
-        set -e
-        for dir in ${BBLAYERS} ${STAGING_DIR} ${SCRIPTSDIR} ${BITBAKEDIR}; do
-            mkdir -p ${BUILDCHROOT_DIR}/$dir
-            if ! mountpoint ${BUILDCHROOT_DIR}/$dir >/dev/null 2>&1; then
-                mount --bind --make-private $dir ${BUILDCHROOT_DIR}/$dir
-            fi
-        done
-        ) 9>${MOUNT_LOCKFILE}
-EOSUDO
-}
+SCHROOT_MOUNTS += "${BBLAYERS} ${STAGING_DIR} ${SCRIPTSDIR} ${BITBAKEDIR}"
 
 generate_wic_image() {
     export FAKEROOTCMD=${FAKEROOTCMD}
@@ -169,43 +152,31 @@ generate_wic_image() {
     mkdir -p ${IMAGE_ROOTFS}/../pseudo
     touch ${IMAGE_ROOTFS}/../pseudo/files.db
 
-    # create the temp dir in the buildchroot to ensure uniqueness
-    WICTMP=$(cd ${BUILDCHROOT_DIR}; mktemp -d -p tmp)
-
-    sudo -E chroot ${BUILDCHROOT_DIR} \
-        sh -c ' \
-          BITBAKEDIR="$1"
-          SCRIPTSDIR="$2"
-          WKS_FULL_PATH="$3"
-          STAGING_DIR="$4"
-          MACHINE="$5"
-          WICTMP="$6"
-          IMAGE_FULLNAME="$7"
-          IMAGE_BASENAME="$8"
-          shift 8
-          # The python path is hard-coded as /usr/bin/python3-native/python3 in wic. Handle that.
-          mkdir -p /usr/bin/python3-native/
-          if [ $(head -1 $(which bmaptool) | grep python3) ];then
+    imager_run -p -d ${PP_WORK} -u root <<'EOSUDO'
+        set -e
+
+        # The python path is hard-coded as /usr/bin/python3-native/python3 in wic. Handle that.
+        mkdir -p /usr/bin/python3-native/
+        if [ $(head -1 $(which bmaptool) | grep python3) ];then
             ln -fs /usr/bin/python3 /usr/bin/python3-native/python3
-          else
+        else
             ln -fs /usr/bin/python2 /usr/bin/python3-native/python3
-          fi
-          export PATH="$BITBAKEDIR/bin:$PATH"
-          "$SCRIPTSDIR"/wic create "$WKS_FULL_PATH" \
-            --vars "$STAGING_DIR/$MACHINE/imgdata/" \
-            -o "/$WICTMP/${IMAGE_FULLNAME}.wic/" \
+        fi
+
+        export PATH="${BITBAKEDIR}/bin:$PATH"
+
+        "${SCRIPTSDIR}"/wic create "${WKS_FULL_PATH}" \
+            --vars "${STAGING_DIR}/${MACHINE}/imgdata/" \
+            -o "/tmp/${IMAGE_FULLNAME}.wic/" \
             --bmap \
-            -e "$IMAGE_BASENAME" $@' \
-              my_script "${BITBAKEDIR}" "${SCRIPTSDIR}" "${WKS_FULL_PATH}" "${STAGING_DIR}" \
-              "${MACHINE}" "${WICTMP}" "${IMAGE_FULLNAME}" "${IMAGE_BASENAME}" \
-              ${WIC_CREATE_EXTRA_ARGS}
+            -e "${IMAGE_BASENAME}" ${WIC_CREATE_EXTRA_ARGS}
+        find "/tmp/${IMAGE_FULLNAME}.wic/" -type f -name "*.direct*" | while read f; do
+            suffix=$(basename $f | sed 's/\(.*\)\(\.direct\)\(.*\)/\3/')
+            mv -f ${f} ${PP_DEPLOY}/${IMAGE_FULLNAME}.wic${suffix}
+        done
+EOSUDO
 
     sudo chown -R $(stat -c "%U" ${LAYERDIR_core}) ${LAYERDIR_core} ${LAYERDIR_isar} ${SCRIPTSDIR} || true
-    sudo chown -R $(id -u):$(id -g) ${BUILDCHROOT_DIR}/${WICTMP}
-    find ${BUILDCHROOT_DIR}/${WICTMP} -type f -name "*.direct*" | while read f; do
-        suffix=$(basename $f | sed 's/\(.*\)\(\.direct\)\(.*\)/\3/')
-        mv -f ${f} "${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.wic${suffix}"
-    done
-    rm -rf ${BUILDCHROOT_DIR}/${WICTMP}
+    sudo chown -R $(id -u):$(id -g) ${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.wic*
     rm -rf ${IMAGE_ROOTFS}/../pseudo
 }
-- 
2.17.1


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

* [PATCH 5/6] events: Cleanup lost schroot sessions if any
  2022-05-14  7:07 [PATCH 0/6] Imager schroot migration Anton Mikanovich
                   ` (3 preceding siblings ...)
  2022-05-14  7:07 ` [PATCH 4/6] imager: Move image types " Anton Mikanovich
@ 2022-05-14  7:07 ` Anton Mikanovich
  2022-05-14  7:07 ` [PATCH 6/6] meta: Remove buildchroot Anton Mikanovich
  5 siblings, 0 replies; 7+ messages in thread
From: Anton Mikanovich @ 2022-05-14  7:07 UTC (permalink / raw)
  To: isar-users; +Cc: adriaan.schmidt, Anton Mikanovich

In case the user will only open imager schroot session but not close it
we need to find and clean it up.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/isar-events.bbclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
index 92aff20..f1e9dcb 100644
--- a/meta/classes/isar-events.bbclass
+++ b/meta/classes/isar-events.bbclass
@@ -4,6 +4,8 @@
 # Copyright (C) 2015-2017 ilbers GmbH
 # Copyright (c) Siemens AG, 2018
 
+inherit sbuild
+
 addhandler build_started
 
 python build_started() {
@@ -51,6 +53,22 @@ python build_completed() {
 
     basepath = tmpdir + '/work/'
 
+    bitbake_id = d.getVar('BITBAKE_BUILD_ID', True)
+    sessions = subprocess.run('schroot -l --all-sessions | grep isar | grep %s' % bitbake_id,
+                              shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
+    for line in sessions.splitlines():
+        session_id = line.split(':', 1)[1]
+        bb.debug(1, 'Closing imager session %s' % session_id)
+        id = subprocess.run("schroot -d / -r -c %s -- printenv -0 SCHROOT_ALIAS_NAME" % session_id,
+                            shell=True, check=True, stdout=subprocess.PIPE).stdout.decode('utf-8')
+        if id:
+            subprocess.run('schroot --recover-session -c %s' % session_id, shell=True, check=True)
+            subprocess.run('schroot -e -c %s' % session_id, shell=True, check=True)
+        if 'id' in locals():
+            d.setVar('SBUILD_CHROOT', id)
+            bb.build.exec_func('remove_mounts', d)
+            bb.build.exec_func('schroot_delete_configs', d)
+
     with open('/proc/mounts') as f:
         for line in f.readlines():
             if basepath in line:
-- 
2.17.1


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

* [PATCH 6/6] meta: Remove buildchroot
  2022-05-14  7:07 [PATCH 0/6] Imager schroot migration Anton Mikanovich
                   ` (4 preceding siblings ...)
  2022-05-14  7:07 ` [PATCH 5/6] events: Cleanup lost schroot sessions if any Anton Mikanovich
@ 2022-05-14  7:07 ` Anton Mikanovich
  5 siblings, 0 replies; 7+ messages in thread
From: Anton Mikanovich @ 2022-05-14  7:07 UTC (permalink / raw)
  To: isar-users; +Cc: adriaan.schmidt, Anton Mikanovich

Buildchroot is not used anywhere so remove it.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta-isar/conf/local.conf.sample              |  2 +-
 meta/classes/buildchroot.bbclass              | 71 ----------------
 meta/classes/dpkg-base.bbclass                | 28 ------
 meta/classes/image.bbclass                    | 15 ----
 meta/classes/isar-events.bbclass              |  1 -
 meta/conf/bitbake.conf                        |  3 -
 .../buildchroot/buildchroot-host.bb           | 24 ------
 .../buildchroot/buildchroot-target.bb         | 15 ----
 .../buildchroot/buildchroot.inc               | 85 -------------------
 .../buildchroot/files/build.sh                | 17 ----
 .../buildchroot/files/common.sh               | 32 -------
 .../buildchroot/files/configscript.sh         | 15 ----
 .../buildchroot/files/deps.sh                 | 47 ----------
 13 files changed, 1 insertion(+), 354 deletions(-)
 delete mode 100644 meta/classes/buildchroot.bbclass
 delete mode 100644 meta/recipes-devtools/buildchroot/buildchroot-host.bb
 delete mode 100644 meta/recipes-devtools/buildchroot/buildchroot-target.bb
 delete mode 100644 meta/recipes-devtools/buildchroot/buildchroot.inc
 delete mode 100644 meta/recipes-devtools/buildchroot/files/build.sh
 delete mode 100644 meta/recipes-devtools/buildchroot/files/common.sh
 delete mode 100644 meta/recipes-devtools/buildchroot/files/configscript.sh
 delete mode 100644 meta/recipes-devtools/buildchroot/files/deps.sh

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 58f3e1a..469f036 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -24,7 +24,7 @@ MACHINE ??= "qemuarm"
 # Isar Configuration Selection
 #
 # You need to select a specific distribution configuration which will used for both:
-# generation of buildchroot environment and target root filesystem.
+# generation of schroot environment and target root filesystem.
 #
 # This sets the default distribution configuration:
 DISTRO ??= "debian-bullseye"
diff --git a/meta/classes/buildchroot.bbclass b/meta/classes/buildchroot.bbclass
deleted file mode 100644
index dd8f420..0000000
--- a/meta/classes/buildchroot.bbclass
+++ /dev/null
@@ -1,71 +0,0 @@
-# This software is a part of ISAR.
-# Copyright (C) 2018 Siemens AG
-#
-# SPDX-License-Identifier: MIT
-
-ISAR_CROSS_COMPILE ??= "0"
-
-# Choose the correct buildchroot: host or target
-python __anonymous() {
-    mode = d.getVar('ISAR_CROSS_COMPILE', True)
-    distro_arch = d.getVar('DISTRO_ARCH')
-    if mode == "0" or d.getVar('HOST_ARCH') ==  distro_arch or \
-       (d.getVar('HOST_DISTRO') == "debian-stretch" and distro_arch == "i386"):
-        dep = "buildchroot-target:do_build"
-        rootfs = d.getVar('BUILDCHROOT_TARGET_DIR', True)
-    else:
-        dep = "buildchroot-host:do_build"
-        rootfs = d.getVar('BUILDCHROOT_HOST_DIR', True)
-
-    d.setVar('BUILDCHROOT_DEP', dep)
-    d.setVar('BUILDCHROOT_DIR', rootfs)
-}
-
-MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}.lock"
-
-buildchroot_do_mounts() {
-    if [ "${USE_CCACHE}" = "1" ]; then
-        mkdir -p ${CCACHE_DIR}
-    fi
-
-    sudo -s <<'EOSUDO'
-        ( flock 9
-        set -e
-
-        mountpoint -q '${BUILDCHROOT_DIR}/isar-apt' ||
-            mount --bind '${REPO_ISAR_DIR}/${DISTRO}' '${BUILDCHROOT_DIR}/isar-apt'
-        mountpoint -q '${BUILDCHROOT_DIR}/downloads' ||
-            mount --bind '${DL_DIR}' '${BUILDCHROOT_DIR}/downloads'
-        if [ "${USE_CCACHE}" = "1" ]; then
-            mkdir -p '${BUILDCHROOT_DIR}/ccache'
-            mountpoint -q '${BUILDCHROOT_DIR}/ccache' ||
-                mount --bind '${CCACHE_DIR}' '${BUILDCHROOT_DIR}/ccache'
-        fi
-        mountpoint -q '${BUILDCHROOT_DIR}/dev' ||
-            mount --rbind /dev '${BUILDCHROOT_DIR}/dev'
-        mount --make-rslave '${BUILDCHROOT_DIR}/dev'
-        mountpoint -q '${BUILDCHROOT_DIR}/proc' ||
-            mount -t proc none '${BUILDCHROOT_DIR}/proc'
-        mountpoint -q '${BUILDCHROOT_DIR}/sys' ||
-            mount --rbind /sys '${BUILDCHROOT_DIR}/sys'
-        mount --make-rslave '${BUILDCHROOT_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 '${BUILDCHROOT_DIR}/base-apt'
-            mountpoint -q '${BUILDCHROOT_DIR}/base-apt' || \
-                mount --bind '${REPO_BASE_DIR}' '${BUILDCHROOT_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 '${BUILDCHROOT_DIR}/etc/resolv.conf'
-        else
-            cp -L /etc/resolv.conf '${BUILDCHROOT_DIR}/etc'
-        fi
-
-        ) 9>'${MOUNT_LOCKFILE}'
-EOSUDO
-}
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index c543eb2..bff9779 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier: MIT
 
 inherit sbuild
-inherit buildchroot
 inherit debianize
 inherit terminal
 inherit repository
@@ -124,9 +123,6 @@ do_apt_fetch() {
 addtask apt_fetch after do_unpack before do_apt_unpack
 do_apt_fetch[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
 
-# Add dependency from the correct buildchroot: host or target
-do_apt_fetch[depends] = "${BUILDCHROOT_DEP}"
-
 # Add dependency from the correct schroot: host or target
 do_apt_fetch[depends] += "${SCHROOT_DEP}"
 
@@ -190,30 +186,6 @@ addtask prepare_build after do_patch do_transform_template before do_dpkg_build
 do_prepare_build[deptask] = "do_deploy_deb"
 do_prepare_build[depends] = "${SCHROOT_DEP}"
 
-BUILDROOT = "${BUILDCHROOT_DIR}/${PP}"
-
-dpkg_do_mounts() {
-    mkdir -p ${BUILDROOT}
-    sudo mount --bind ${WORKDIR} ${BUILDROOT}
-
-    buildchroot_do_mounts
-}
-
-dpkg_undo_mounts() {
-    i=0
-    while ! sudo umount ${BUILDROOT}; do
-        sleep 0.1
-        if [ `expr $i % 100` -eq 0 ] ; then
-            bbwarn "${BUILDROOT}: Couldn't unmount ($i), retrying..."
-        fi
-        if [ $i -ge 10000 ]; then
-            bbfatal "${BUILDROOT}: Couldn't unmount after timeout"
-        fi
-        i=`expr $i + 1`
-    done
-    sudo rmdir ${BUILDROOT}
-}
-
 do_prepare_build_append() {
     # Make a local copy of isar-apt repo that is not affected by other parallel builds
     mkdir -p ${WORKDIR}/isar-apt/${DISTRO}-${DISTRO_ARCH}
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 9b4b67b..b2651a1 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -32,11 +32,6 @@ PP_DEPLOY = "${PP}/deploy"
 PP_ROOTFS = "${PP}/rootfs"
 PP_WORK = "${PP}/work"
 
-BUILDROOT = "${BUILDCHROOT_DIR}${PP}"
-BUILDROOT_DEPLOY = "${BUILDCHROOT_DIR}${PP_DEPLOY}"
-BUILDROOT_ROOTFS = "${BUILDCHROOT_DIR}${PP_ROOTFS}"
-BUILDROOT_WORK = "${BUILDCHROOT_DIR}${PP_WORK}"
-
 python(){
     if (d.getVar('IMAGE_TRANSIENT_PACKAGES')):
         bb.warn("IMAGE_TRANSIENT_PACKAGES is set and no longer supported")
@@ -58,16 +53,6 @@ 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
-}
-
 ROOTFSDIR = "${IMAGE_ROOTFS}"
 ROOTFS_FEATURES += "clean-package-cache generate-manifest export-dpkg-status clean-log-files"
 ROOTFS_PACKAGES += "${IMAGE_PREINSTALL} ${IMAGE_INSTALL}"
diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
index f1e9dcb..cbddff4 100644
--- a/meta/classes/isar-events.bbclass
+++ b/meta/classes/isar-events.bbclass
@@ -11,7 +11,6 @@ addhandler build_started
 python build_started() {
     bb.utils.remove(d.getVar('TMPDIR') + "/work/*/*/*/temp/once.*")
     bb.utils.remove(d.getVar('TMPDIR') + "/work/*/*/*/rootfs.mount")
-    bb.utils.remove(d.getVar('TMPDIR') + "/deploy/buildchroot-*/*.mount")
 }
 build_started[eventmask] = "bb.event.BuildStarted"
 
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 07f199d..ed65984 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -50,14 +50,11 @@ GITPKGV = "${@bb.fetch2.get_srcrev(d, 'gitpkgv_revision')}"
 WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}/${PV}-${PR}"
 GIT_DL_LINK_DIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}"
 DEPLOY_DIR_BOOTSTRAP = "${DEPLOY_DIR}/bootstrap"
-DEPLOY_DIR_BUILDCHROOT = "${DEPLOY_DIR}/buildchroot"
 DEPLOY_DIR_SDKCHROOT = "${DEPLOY_DIR}/sdkchroot"
 DEPLOY_DIR_IMAGE = "${DEPLOY_DIR}/images/${MACHINE}"
 DL_DIR ?= "${TOPDIR}/downloads"
 SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
 SSTATE_MANIFESTS = "${TMPDIR}/sstate-control/${DISTRO}-${DISTRO_ARCH}"
-BUILDCHROOT_HOST_DIR = "${DEPLOY_DIR_BUILDCHROOT}-host/${HOST_DISTRO}-${HOST_ARCH}_${DISTRO}-${DISTRO_ARCH}"
-BUILDCHROOT_TARGET_DIR = "${DEPLOY_DIR_BUILDCHROOT}-target/${DISTRO}-${DISTRO_ARCH}"
 SCHROOT_HOST_DIR = "${DEPLOY_DIR}/schroot-host/${HOST_DISTRO}-${HOST_ARCH}_${DISTRO}-${DISTRO_ARCH}"
 SCHROOT_TARGET_DIR = "${DEPLOY_DIR}/schroot-target/${DISTRO}-${DISTRO_ARCH}"
 SDKCHROOT_DIR = "${DEPLOY_DIR_SDKCHROOT}/${DISTRO}-${DISTRO_ARCH}"
diff --git a/meta/recipes-devtools/buildchroot/buildchroot-host.bb b/meta/recipes-devtools/buildchroot/buildchroot-host.bb
deleted file mode 100644
index d8498a5..0000000
--- a/meta/recipes-devtools/buildchroot/buildchroot-host.bb
+++ /dev/null
@@ -1,24 +0,0 @@
-# Root filesystem for packages building
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2018 ilbers GmbH
-
-DESCRIPTION = "Isar development filesystem for host"
-
-BUILDCHROOT_VARIANT = "host"
-
-require buildchroot.inc
-ROOTFS_ARCH = "${HOST_ARCH}"
-ROOTFS_DISTRO = "${HOST_DISTRO}"
-
-BUILDCHROOT_PREINSTALL ?= " \
-    ${BUILDCHROOT_PREINSTALL_COMMON} \
-    libc6:${DISTRO_ARCH} \
-    crossbuild-essential-${DISTRO_ARCH}"
-
-BUILDCHROOT_PREINSTALL_riscv64 ?= " \
-    ${BUILDCHROOT_PREINSTALL_COMMON} \
-    libc6:${DISTRO_ARCH} \
-    gcc-riscv64-linux-gnu \
-    g++-riscv64-linux-gnu \
-    dpkg-cross"
diff --git a/meta/recipes-devtools/buildchroot/buildchroot-target.bb b/meta/recipes-devtools/buildchroot/buildchroot-target.bb
deleted file mode 100644
index be77044..0000000
--- a/meta/recipes-devtools/buildchroot/buildchroot-target.bb
+++ /dev/null
@@ -1,15 +0,0 @@
-# Root filesystem for packages building
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2018 ilbers GmbH
-
-DESCRIPTION = "Isar development filesystem for target"
-
-BUILDCHROOT_VARIANT = "target"
-
-require buildchroot.inc
-
-BUILDCHROOT_PREINSTALL ?= " \
-    ${BUILDCHROOT_PREINSTALL_COMMON} \
-    gcc \
-    build-essential"
diff --git a/meta/recipes-devtools/buildchroot/buildchroot.inc b/meta/recipes-devtools/buildchroot/buildchroot.inc
deleted file mode 100644
index aa190e9..0000000
--- a/meta/recipes-devtools/buildchroot/buildchroot.inc
+++ /dev/null
@@ -1,85 +0,0 @@
-# Common part for build chroot filesystem.
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2018 ilbers GmbH
-
-LICENSE = "gpl-2.0"
-LIC_FILES_CHKSUM = "file://${LAYERDIR_core}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
-
-FILESPATH_prepend := "${THISDIR}/files:"
-SRC_URI = "file://configscript.sh \
-           file://build.sh \
-           file://common.sh \
-           file://deps.sh"
-PV = "1.0"
-
-inherit rootfs
-
-BUILDCHROOT_DIR = "${WORKDIR}/rootfs"
-ROOTFSDIR = "${BUILDCHROOT_DIR}"
-ROOTFS_PACKAGES = "${BUILDCHROOT_PREINSTALL}"
-ROOTFS_CLEAN_FILES = ""
-ROOTFS_MANIFEST_DEPLOY_DIR = "${DEPLOY_DIR_BUILDCHROOT}"
-ROOTFS_DPKGSTATUS_DEPLOY_DIR = "${DEPLOY_DIR_BUILDCHROOT}"
-ROOTFS_FEATURES += "generate-manifest export-dpkg-status"
-
-BUILDCHROOT_COMPAT_PREINSTALL_compat-arch = " \
-    libc6:${COMPAT_DISTRO_ARCH} \
-    crossbuild-essential-${COMPAT_DISTRO_ARCH}"
-
-BUILDCHROOT_PREINSTALL_COMMON = " \
-    ${BUILDCHROOT_COMPAT_PREINSTALL} \
-    make \
-    debhelper \
-    autotools-dev \
-    ccache \
-    dpkg \
-    locales \
-    docbook-to-man \
-    apt \
-    automake \
-    devscripts \
-    equivs \
-    adduser"
-
-rootfs_do_mounts_append() {
-    sudo -s <<'EOSUDO'
-    set -e
-    mkdir -p '${BUILDCHROOT_DIR}/downloads'
-    mountpoint -q '${BUILDCHROOT_DIR}/downloads' || \
-        mount --bind '${DL_DIR}' '${BUILDCHROOT_DIR}/downloads'
-EOSUDO
-}
-
-ROOTFS_POSTPROCESS_COMMAND =+ "buildchroot_install_files"
-buildchroot_install_files() {
-    sudo mkdir -p "${BUILDCHROOT_DIR}/home/builder"
-    # Install package builder script
-    sudo chmod -R a+rw "${BUILDCHROOT_DIR}/home/builder"
-    sudo install -m 755 -d ${BUILDCHROOT_DIR}/isar
-    sudo install -m 755 ${WORKDIR}/build.sh ${BUILDCHROOT_DIR}/isar/
-    sudo install -m 755 ${WORKDIR}/common.sh ${BUILDCHROOT_DIR}/isar/
-    sudo install -m 755 ${WORKDIR}/deps.sh ${BUILDCHROOT_DIR}/isar/
-
-    sudo ln -sf /downloads/git "${BUILDCHROOT_DIR}/home/.git-downloads"
-
-    # Configure root filesystem
-    sudo install -m 755 ${WORKDIR}/configscript.sh ${BUILDCHROOT_DIR}
-    USER_ID=$(id -u)
-    GROUP_ID=$(id -g)
-    sudo chroot ${BUILDCHROOT_DIR} /configscript.sh $USER_ID $GROUP_ID
-
-}
-
-DEPLOY_BUILDCHROOT = "${@d.getVar('BUILDCHROOT_' + d.getVar('BUILDCHROOT_VARIANT').upper() + '_DIR')}"
-
-do_buildchroot_deploy[dirs] = "${DEPLOY_DIR_BUILDCHROOT}-${BUILDCHROOT_VARIANT}"
-do_buildchroot_deploy() {
-    ln -Tfsr "${ROOTFSDIR}" "${DEPLOY_BUILDCHROOT}"
-}
-addtask buildchroot_deploy before do_build after do_rootfs
-
-CLEANFUNCS = "clean_deploy"
-clean_deploy() {
-    rm -f "${DEPLOY_BUILDCHROOT}"
-}
diff --git a/meta/recipes-devtools/buildchroot/files/build.sh b/meta/recipes-devtools/buildchroot/files/build.sh
deleted file mode 100644
index d4709cf..0000000
--- a/meta/recipes-devtools/buildchroot/files/build.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2017 ilbers GmbH
-# Copyright (c) 2018 Siemens AG
-
-source /isar/common.sh
-
-# If autotools files have been created, update their timestamp to
-# prevent them from being regenerated
-for i in configure aclocal.m4 Makefile.am Makefile.in; do
-    if [ -f "${i}" ]; then
-        touch "${i}"
-    fi
-done
-
-${GBP_PREFIX}dpkg-buildpackage -a$target_arch --source-option=-I
diff --git a/meta/recipes-devtools/buildchroot/files/common.sh b/meta/recipes-devtools/buildchroot/files/common.sh
deleted file mode 100644
index 73226d8..0000000
--- a/meta/recipes-devtools/buildchroot/files/common.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2017 ilbers GmbH
-# Copyright (c) 2018 Siemens AG
-
-set -e
-printenv | grep -q BB_VERBOSE_LOGS && set -x
-
-# assert we are either "root:root" or "builder:<gid of builder>"
-if ([ "$(id -un)" != "builder" ] || [ "$(id -g)" != "$(id -g builder)" ]) &&
-   ([ "$(id -un)" != "root"    ] || [ "$(id -gn)" != "root"    ]); then
-    echo "This script can only be run as root:root or builder:<gid of builder>!" >&2
-    echo "(Currently running as $(id -un)($(id -u)):$(id -gn)($(id -g)))" >&2
-    exit 1
-fi
-
-# Create human-readable names
-target_arch=$2
-
-set_arch="--host-arch $target_arch"
-
-# Go to build directory
-cd "$1"
-
-# To avoid Perl locale warnings:
-export LC_ALL=C
-export LANG=C
-export LANGUAGE=C
-
-# allow for changes to the PATH variable
-export PATH=$PATH_PREPEND:$PATH
diff --git a/meta/recipes-devtools/buildchroot/files/configscript.sh b/meta/recipes-devtools/buildchroot/files/configscript.sh
deleted file mode 100644
index c4d8cf8..0000000
--- a/meta/recipes-devtools/buildchroot/files/configscript.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2018 ilbers GmbH
-
-set -e
-
-debconf-set-selections <<END
-locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
-locales locales/default_environment_locale select en_US.UTF-8
-END
-
-grep -q "builder:x:$2" /etc/group || groupadd -f --system builder -o --gid $2
-grep -q "builder:x:$1" /etc/passwd || useradd --system -o --uid $1 --gid builder --no-create-home --home /home/builder --no-user-group --comment "Isar buildchroot build user" builder
-chown -R builder:builder /home/builder
diff --git a/meta/recipes-devtools/buildchroot/files/deps.sh b/meta/recipes-devtools/buildchroot/files/deps.sh
deleted file mode 100644
index ccfc460..0000000
--- a/meta/recipes-devtools/buildchroot/files/deps.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2017 ilbers GmbH
-# Copyright (c) 2018 Siemens AG
-
-source /isar/common.sh
-
-# Install command to be used by mk-build-deps
-# Notes:
-#   1) everything before the -y switch is unchanged from the defaults
-#   2) we add -y to go non-interactive
-#   3) downgrades shall be allowed in case a package recipe was changed
-install_cmd="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends \
-    -y --allow-downgrades $3"
-
-if [ "$3" != "--download-only" ]; then
-    # Make sure that we have latest isar-apt content.
-    # Options meaning:
-    #   Dir::Etc::SourceList - specifies which source to be used
-    #   Dir::Etc::SourceParts - disables looking for the other sources
-    #   APT::Get::List-Cleanup - do not erase obsolete packages list for
-    #                            upstream in '/var/lib/apt/lists'
-    apt-get update \
-        -o Dir::Etc::SourceList="sources.list.d/isar-apt.list" \
-        -o Dir::Etc::SourceParts="-" \
-        -o APT::Get::List-Cleanup="0"
-fi
-
-control_file=$(pwd)/debian/control
-cd ..
-
-# Install all build deps
-if [ "$3" = "--download-only" ]; then
-    # this will not return 0 even when it worked
-    mk-build-deps $set_arch -t "${install_cmd}" -i -r $control_file &> \
-        mk-build-deps.output || true
-    cat mk-build-deps.output
-    # we assume success when we find this
-    grep "mk-build-deps: Unable to install all build-dep packages" mk-build-deps.output
-    rm -f mk-build-deps.output
-else
-    mk-build-deps $set_arch -t "${install_cmd}" -i -r $control_file
-
-    # Upgrade any already installed packages in case we are partially rebuilding
-    apt-get upgrade -y --allow-downgrades
-fi
-- 
2.17.1


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

end of thread, other threads:[~2022-05-14  7:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-14  7:07 [PATCH 0/6] Imager schroot migration Anton Mikanovich
2022-05-14  7:07 ` [PATCH 1/6] sbuild: Allow setting custom config paths Anton Mikanovich
2022-05-14  7:07 ` [PATCH 2/6] base: Implement bitbake build ID Anton Mikanovich
2022-05-14  7:07 ` [PATCH 3/6] imager: Migrate from buildchroot to schroot Anton Mikanovich
2022-05-14  7:07 ` [PATCH 4/6] imager: Move image types " Anton Mikanovich
2022-05-14  7:07 ` [PATCH 5/6] events: Cleanup lost schroot sessions if any Anton Mikanovich
2022-05-14  7:07 ` [PATCH 6/6] meta: Remove buildchroot Anton Mikanovich

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