From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [RFC 03/15] isar-bootstrap: Export bootstrap to schroot config
Date: Mon, 26 Jul 2021 16:46:24 +0300 [thread overview]
Message-ID: <20210726134636.30800-4-amikan@ilbers.de> (raw)
In-Reply-To: <20210726134636.30800-1-amikan@ilbers.de>
To use isar-bootstrap with sbuild and schroot tools we need to export
the path to schroot config.
We also need to put isar-apt and downloads into fstab for sbuild
profile to have it mounted inside schroot.
Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
meta/classes/sbuild.bbclass | 17 ++++++
.../isar-bootstrap/isar-bootstrap.inc | 54 ++++++++++++++++++-
2 files changed, 69 insertions(+), 2 deletions(-)
create mode 100644 meta/classes/sbuild.bbclass
diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass
new file mode 100644
index 0000000..ed2d0cf
--- /dev/null
+++ b/meta/classes/sbuild.bbclass
@@ -0,0 +1,17 @@
+# This software is a part of ISAR.
+# Copyright (C) 2021 ilbers GmbH
+
+SCHROOT_CONF ?= "/etc/schroot"
+
+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"):
+ d.setVar('SBUILD_HOST_ARCH', distro_arch)
+ else:
+ d.setVar('SBUILD_HOST_ARCH', d.getVar('HOST_ARCH'))
+}
+
+SBUILD_CHROOT ?= "${DEBDISTRONAME}-${@os.getlogin()}-${DISTRO}-${SBUILD_HOST_ARCH}"
+SBUILD_CHROOT_RW ?= "${DEBDISTRONAME}-${@os.getlogin()}-${DISTRO}-${SBUILD_HOST_ARCH}-rw"
diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
index 0edefc5..b4f352b 100644
--- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc
@@ -23,11 +23,12 @@ APTSRCS_INIT = "${WORKDIR}/apt-sources-init"
DISTRO_BOOTSTRAP_KEYFILES = ""
THIRD_PARTY_APT_KEYFILES = ""
DEPLOY_ISAR_BOOTSTRAP ?= ""
-DISTRO_BOOTSTRAP_BASE_PACKAGES = "locales"
+DISTRO_BOOTSTRAP_BASE_PACKAGES = "locales,fakeroot,build-essential,debhelper"
DISTRO_BOOTSTRAP_BASE_PACKAGES_append_gnupg = ",gnupg"
DISTRO_BOOTSTRAP_BASE_PACKAGES_append_https-support = "${@https_support(d)}"
inherit deb-dl-dir
+inherit sbuild
python () {
distro_bootstrap_keys = (d.getVar("DISTRO_BOOTSTRAP_KEYS") or "").split()
@@ -254,8 +255,9 @@ isar_bootstrap() {
if [ "${ISAR_USE_CACHED_BASE_REPO}" = "1" -a -z "${BASE_REPO_KEY}" ]; then
debootstrap_args="$debootstrap_args --no-check-gpg"
fi
+ user_name=$(id -un)
E="${@ isar_export_proxies(d)}"
- export IS_HOST debootstrap_args E
+ export IS_HOST debootstrap_args E user_name
if [ ! -e "${DEPLOY_ISAR_BOOTSTRAP}" ]; then
sudo rm -rf --one-file-system "${ROOTFSDIR}"
if [ "${IS_HOST}" ];then
@@ -266,6 +268,7 @@ isar_bootstrap() {
sudo -E -s <<'EOSUDO'
set -e
+ BOOTSTRAP_ARCH=${HOST_ARCH}
if [ ${IS_HOST} ]; then
${DEBOOTSTRAP} $debootstrap_args \
${@get_distro_components_argument(d, True)} \
@@ -281,6 +284,53 @@ isar_bootstrap() {
"${ROOTFSDIR}" \
"${@get_distro_source(d, False)}" \
${DISTRO_DEBOOTSTRAP_SCRIPT}
+ BOOTSTRAP_ARCH=${DISTRO_ARCH}
+ fi
+
+ cat << EOF > "${SCHROOT_CONF}/chroot.d/${DEBDISTRONAME}-${user_name}-${DISTRO}-${BOOTSTRAP_ARCH}"
+[${DEBDISTRONAME}-${user_name}-${DISTRO}-${BOOTSTRAP_ARCH}]
+type=directory
+directory=${ROOTFSDIR}
+profile=${DEBDISTRONAME}-${user_name}
+users=${user_name}
+groups=root,sbuild
+root-users=${user_name}
+root-groups=root,sbuild
+source-root-users=${user_name}
+source-root-groups=root,sbuild
+union-type=overlay
+preserve-environment=true
+
+[${DEBDISTRONAME}-${user_name}-${DISTRO}-${BOOTSTRAP_ARCH}-rw]
+type=directory
+directory=${ROOTFSDIR}
+profile=${DEBDISTRONAME}-${user_name}
+users=${user_name}
+groups=root,sbuild
+root-users=${user_name}
+root-groups=root,sbuild
+preserve-environment=true
+EOF
+
+ mkdir -p '${ROOTFSDIR}/etc/apt/preferences.d'
+ cat << EOF > '${ROOTFSDIR}/etc/apt/preferences.d/isar-apt'
+Package: *
+Pin: release n=${DEBDISTRONAME}
+Pin-Priority: 1000
+EOF
+
+ # Prepare mount points
+ if [ ! -d "${SCHROOT_CONF}/${DEBDISTRONAME}-${user_name}" ]; then
+ cp -r "${SCHROOT_CONF}/sbuild" "${SCHROOT_CONF}/${DEBDISTRONAME}-${user_name}"
+ fi
+ sbuild_fstab="${SCHROOT_CONF}/${DEBDISTRONAME}-${user_name}/fstab"
+
+ fstab_isarapt="${DEPLOY_DIR}/isar-apt /isar-apt none rw,bind 0 0"
+ grep -qxF "${fstab_isarapt}" ${sbuild_fstab} || echo "${fstab_isarapt}" >> ${sbuild_fstab}
+
+ if [ -d ${DL_DIR} ]; then
+ fstab_downloads="${DL_DIR} /downloads none rw,bind 0 0"
+ grep -qxF "${fstab_downloads}" ${sbuild_fstab} || echo "${fstab_downloads}" >> ${sbuild_fstab}
fi
# Install apt config
--
2.25.1
next prev parent reply other threads:[~2021-07-26 13:46 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 ` Anton Mikanovich [this message]
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 ` [RFC 13/15] img: Use schroot for image prepare Anton Mikanovich
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-4-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