From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [PATCH v3 2/6] imager: Migrate from buildchroot to schroot
Date: Mon, 13 Feb 2023 09:40:30 +0200 [thread overview]
Message-ID: <20230213074034.3949-3-amikan@ilbers.de> (raw)
In-Reply-To: <20230213074034.3949-1-amikan@ilbers.de>
Install dependencies and perform all imager actions using schroot
instead of buildchroot. All the changes made during imager task will be
lost after the finish. This requires installing imager dependencies
during every run.
Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
meta/classes/image-tools-extension.bbclass | 94 +++++++++++++++-------
1 file changed, 63 insertions(+), 31 deletions(-)
diff --git a/meta/classes/image-tools-extension.bbclass b/meta/classes/image-tools-extension.bbclass
index 2d3dda4..640c56c 100644
--- a/meta/classes/image-tools-extension.bbclass
+++ b/meta/classes/image-tools-extension.bbclass
@@ -5,43 +5,75 @@
#
# This file extends the image.bbclass to supply tools for futher imager functions
-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"
-do_install_imager_deps[deptask] = "do_deploy_deb"
-do_install_imager_deps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
-do_install_imager_deps[network] = "${TASK_USE_NETWORK_AND_SUDO}"
-do_install_imager_deps() {
- if [ -z "${@d.getVar("IMAGER_INSTALL", True).strip()}" ]; then
- exit
- fi
+SCHROOT_MOUNTS = "${WORKDIR}:${PP_WORK} ${IMAGE_ROOTFS}:${PP_ROOTFS} ${DEPLOY_DIR_IMAGE}:${PP_DEPLOY}"
+SCHROOT_MOUNTS += "${REPO_ISAR_DIR}/${DISTRO}:/isar-apt"
+
+imager_run() {
+ schroot_create_configs
+ insert_mounts
+
+ session_id=$(schroot -q -b -c ${SBUILD_CHROOT})
+ echo "Started session: ${session_id}"
+
+ # setting up error handler
+ imager_cleanup() {
+ set +e
+ schroot -q -f -e -c ${session_id} > /dev/null 2>&1
+ remove_mounts > /dev/null 2>&1
+ schroot_delete_configs > /dev/null 2>&1
+ }
+ trap 'exit 1' INT HUP QUIT TERM ALRM USR1
+ trap 'imager_cleanup' EXIT
+
+ if [ -n "${@d.getVar("IMAGER_INSTALL", True).strip()}" ]; then
+ echo "Installing deps: ${IMAGER_INSTALL}"
+
+ distro="${BASE_DISTRO}-${BASE_DISTRO_CODENAME}"
+ if [ ${ISAR_CROSS_COMPILE} -eq 1 ]; then
+ distro="${HOST_BASE_DISTRO}-${BASE_DISTRO_CODENAME}"
+ fi
- distro="${BASE_DISTRO}-${BASE_DISTRO_CODENAME}"
- if [ ${ISAR_CROSS_COMPILE} -eq 1 ]; then
- distro="${HOST_BASE_DISTRO}-${BASE_DISTRO_CODENAME}"
+ # prepare isar-apt
+ schroot -r -c ${session_id} -d / -u root -- sh -c " \
+ mkdir -p '/etc/apt/sources.list.d'
+ echo 'deb [trusted=yes] file:///isar-apt ${DEBDISTRONAME} main' > \
+ '/etc/apt/sources.list.d/isar-apt.list'
+
+ mkdir -p '/etc/apt/preferences.d'
+ cat << EOF > '/etc/apt/preferences.d/isar-apt'
+Package: *
+Pin: release n=${DEBDISTRONAME}
+Pin-Priority: 1000
+EOF"
+
+ E="${@ isar_export_proxies(d)}"
+ deb_dl_dir_import ${SCHROOT_DIR} ${distro}
+ schroot -r -c ${session_id} -d / -u root -- sh -c " \
+ apt-get update \
+ -o Dir::Etc::SourceList='sources.list.d/isar-apt.list' \
+ -o Dir::Etc::SourceParts='-' \
+ -o APT::Get::List-Cleanup='0'
+ apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
+ --allow-unauthenticated --allow-downgrades --download-only install \
+ ${IMAGER_INSTALL}"
+
+ deb_dl_dir_export ${SCHROOT_DIR} ${distro}
+ schroot -r -c ${session_id} -d / -u root -- sh -c " \
+ apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
+ --allow-unauthenticated --allow-downgrades install \
+ ${IMAGER_INSTALL}"
fi
- buildchroot_do_mounts
-
- E="${@ isar_export_proxies(d)}"
- deb_dl_dir_import ${BUILDCHROOT_DIR} ${distro}
- sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' \
- apt-get update \
- -o Dir::Etc::SourceList="sources.list.d/isar-apt.list" \
- -o Dir::Etc::SourceParts="-" \
- -o APT::Get::List-Cleanup="0"
- apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
- --allow-unauthenticated --allow-downgrades --download-only install \
- ${IMAGER_INSTALL}'
-
- deb_dl_dir_export ${BUILDCHROOT_DIR} ${distro}
- sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' \
- apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
- --allow-unauthenticated --allow-downgrades install \
- ${IMAGER_INSTALL}'
+ schroot -r -c ${session_id} "$@"
+
+ schroot -e -c ${session_id}
+
+ remove_mounts
+ schroot_delete_configs
}
-addtask install_imager_deps before do_image_tools
--
2.34.1
next prev parent reply other threads:[~2023-02-13 7:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 7:40 [PATCH v3 0/6] Imager schroot migration Anton Mikanovich
2023-02-13 7:40 ` [PATCH v3 1/6] isar-apt: Move cleanup to postprocessing Anton Mikanovich
2023-02-13 7:40 ` Anton Mikanovich [this message]
2023-02-13 7:40 ` [PATCH v3 3/6] imager: Move image types to schroot Anton Mikanovich
2023-02-13 7:40 ` [PATCH v3 4/6] imager: Split imager deps between image types Anton Mikanovich
2023-02-13 7:40 ` [PATCH v3 5/6] CI: Fix used chroot recipe name Anton Mikanovich
2023-02-14 9:28 ` Schmidt, Adriaan
2023-02-14 10:30 ` Anton Mikanovich
2023-02-13 7:40 ` [PATCH v3 6/6] meta: Remove buildchroot 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=20230213074034.3949-3-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