From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [RFC 12/15] dpkg-gbp: Migrate to schroot
Date: Mon, 26 Jul 2021 16:46:33 +0300 [thread overview]
Message-ID: <20210726134636.30800-13-amikan@ilbers.de> (raw)
In-Reply-To: <20210726134636.30800-1-amikan@ilbers.de>
Use schroot instead of chroot for git-buildpackage.
Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
meta/classes/dpkg-gbp.bbclass | 15 ++++-------
meta/classes/sbuild.bbclass | 48 +++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/meta/classes/dpkg-gbp.bbclass b/meta/classes/dpkg-gbp.bbclass
index 0c60bda..e4e5ea6 100644
--- a/meta/classes/dpkg-gbp.bbclass
+++ b/meta/classes/dpkg-gbp.bbclass
@@ -13,18 +13,13 @@ GBP_DEPENDS ?= "git-buildpackage pristine-tar"
GBP_EXTRA_OPTIONS ?= "--pristine-tar"
do_prepare_build() {
- deb_dl_dir_import "${BUILDCHROOT_DIR}" "${distro}"
- sudo -E chroot ${BUILDCHROOT_DIR} \
- apt-get install -y -o Debug::pkgProblemResolver=yes \
- --no-install-recommends --download-only ${GBP_DEPENDS}
- deb_dl_dir_export "${BUILDCHROOT_DIR}" "${distro}"
- sudo -E chroot ${BUILDCHROOT_DIR} \
- apt-get install -y -o Debug::pkgProblemResolver=yes \
- --no-install-recommends ${GBP_DEPENDS}
+ schroot_install "${GBP_DEPENDS}"
}
do_prepare_build[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
+SCHROOT_MOUNTS = "${WORKDIR}:${PP}"
+
dpkg_runbuild_prepend() {
- sudo -E chroot --userspec=$( id -u ):$( id -g ) ${BUILDCHROOT_DIR} \
- sh -c "cd ${PP}/${PPS} && gbp export-orig ${GBP_EXTRA_OPTIONS}"
+ schroot_run -d ${PP}/${PPS} -c ${SBUILD_CHROOT} -- \
+ gbp export-orig ${GBP_EXTRA_OPTIONS}
}
diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass
index cc7db66..3eede71 100644
--- a/meta/classes/sbuild.bbclass
+++ b/meta/classes/sbuild.bbclass
@@ -3,6 +3,8 @@
SCHROOT_CONF ?= "/etc/schroot"
+SCHROOT_MOUNTS ?= ""
+
python __anonymous() {
mode = d.getVar('ISAR_CROSS_COMPILE', True)
distro_arch = d.getVar('DISTRO_ARCH')
@@ -28,3 +30,49 @@ sbuild_export() {
fi
export SBUILD_CONFIG="${SBUILD_CONFIG}"
}
+
+schroot_install() {
+ APTS="$1"
+ #TODO deb_dl_dir_import "${BUILDCHROOT_DIR}" "${distro}"
+ schroot -d / -c ${SBUILD_CHROOT_RW} -u root -- \
+ apt install -y -o Debug::pkgProblemResolver=yes \
+ --no-install-recommends --download-only ${APTS}
+ #TODO deb_dl_dir_export "${BUILDCHROOT_DIR}" "${distro}"
+ schroot -d / -c ${SBUILD_CHROOT_RW} -u root -- \
+ apt install -y -o Debug::pkgProblemResolver=yes \
+ --no-install-recommends ${APTS}
+}
+
+SCHROOT_FSTAB ?= "${SCHROOT_CONF}/${DEBDISTRONAME}-${@os.getlogin()}/fstab"
+SCHROOT_LOCKFILE ?= "schroot_fstab.lock"
+
+insert_mounts() {
+ sudo -s <<'EOSUDO'
+ ( flock 9
+ set -e
+ for mp in ${SCHROOT_MOUNTS}; do
+ FSTAB_LINE="${mp%%:*} ${mp#*:} none rw,bind 0 0"
+ grep -qxF "${FSTAB_LINE}" ${SCHROOT_FSTAB} || \
+ echo "${FSTAB_LINE}" >> ${SCHROOT_FSTAB}
+ done
+ ) 9>'${SCHROOT_LOCKFILE}'
+EOSUDO
+}
+
+remove_mounts() {
+ sudo -s <<'EOSUDO'
+ ( flock 9
+ set -e
+ for mp in ${SCHROOT_MOUNTS}; do
+ FSTAB_LINE="${mp%%:*} ${mp#*:} none rw,bind 0 0"
+ sed -i "\|${FSTAB_LINE}|d" ${SCHROOT_FSTAB}
+ done
+ ) 9>'${SCHROOT_LOCKFILE}'
+EOSUDO
+}
+
+schroot_run() {
+ insert_mounts
+ schroot $@
+ remove_mounts
+}
--
2.25.1
next prev 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 ` Anton Mikanovich [this message]
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-13-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