From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: [PATCH 1/5] meta: Factor out buildchroot class
Date: Wed, 5 Sep 2018 20:18:00 +0200 [thread overview]
Message-ID: <b483ca959076dcc7a67e50d023053d6c22727d6d.1536171484.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1536171484.git.jan.kiszka@siemens.com>
In-Reply-To: <cover.1536171484.git.jan.kiszka@siemens.com>
From: Jan Kiszka <jan.kiszka@siemens.com>
This makes commonly useful things like BUILDCHROOT_DIR determination as
well as mounting into the builchroot available for reuse outside of the
dpkg scope.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
meta/classes/buildchroot.bbclass | 33 +++++++++++++++++++++++++++++++++
meta/classes/dpkg-base.bbclass | 33 ++++++---------------------------
2 files changed, 39 insertions(+), 27 deletions(-)
create mode 100644 meta/classes/buildchroot.bbclass
diff --git a/meta/classes/buildchroot.bbclass b/meta/classes/buildchroot.bbclass
new file mode 100644
index 0000000..f67335e
--- /dev/null
+++ b/meta/classes/buildchroot.bbclass
@@ -0,0 +1,33 @@
+# This software is a part of ISAR.
+# Copyright (C) 2018 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+
+ISAR_CROSS_COMPILE ??= "0"
+
+# Add dependency from the correct buildchroot: host or target
+python __anonymous() {
+ mode = d.getVar('ISAR_CROSS_COMPILE', True)
+ if mode == "0":
+ 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.setVarFlag('do_prepare_build', 'depends', dep)
+ d.setVar('BUILDCHROOT_DIR', rootfs)
+}
+
+MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}/mount.lock"
+
+buildchroot_do_mounts() {
+ sudo flock ${MOUNT_LOCKFILE} -c ' \
+ set -e
+ if ! grep -q ${BUILDCHROOT_DIR}/isar-apt /proc/mounts; then
+ mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt
+ mount --bind ${DL_DIR} ${BUILDCHROOT_DIR}/downloads
+ mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${BUILDCHROOT_DIR}/dev
+ mount -t proc none ${BUILDCHROOT_DIR}/proc
+ fi'
+}
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index a2d2ff0..edd111b 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -1,24 +1,12 @@
# This software is a part of ISAR.
-# Copyright (C) 2017 Siemens AG
+# Copyright (C) 2017-2018 Siemens AG
+#
+# SPDX-License-Identifier: MIT
-ISAR_CROSS_COMPILE ??= "0"
+inherit buildchroot
DEPENDS ?= ""
-# Add dependency from the correct buildchroot: host or target
-python __anonymous() {
- mode = d.getVar('ISAR_CROSS_COMPILE', True)
- if mode == "0":
- 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.setVarFlag('do_prepare_build', 'depends', dep)
- d.setVar('BUILDCHROOT_DIR', rootfs)
-}
-
do_adjust_git() {
if [ -f ${S}/.git/objects/info/alternates ]; then
sed -i ${S}/.git/objects/info/alternates \
@@ -45,7 +33,6 @@ def get_package_srcdir(d):
PP = "/home/builder/${PN}"
PPS ?= "${@get_package_srcdir(d)}"
-BUILDROOT = "${BUILDCHROOT_DIR}/${PP}"
do_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
# Empty do_prepare_build() implementation, to be overwritten if needed
@@ -59,21 +46,13 @@ do_prepare_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
# deployed to isar-apt
do_prepare_build[deptask] = "do_deploy_deb"
-MOUNT_LOCKFILE = "${BUILDCHROOT_DIR}/mount.lock"
+BUILDROOT = "${BUILDCHROOT_DIR}/${PP}"
-# Wrap the function dpkg_runbuild with the bind mount for buildroot
dpkg_do_mounts() {
mkdir -p ${BUILDROOT}
sudo mount --bind ${WORKDIR} ${BUILDROOT}
- sudo flock ${MOUNT_LOCKFILE} -c ' \
- set -e
- if ! grep -q ${BUILDCHROOT_DIR}/isar-apt /proc/mounts; then
- mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt
- mount --bind ${DL_DIR} ${BUILDCHROOT_DIR}/downloads
- mount -t devtmpfs -o mode=0755,nosuid devtmpfs ${BUILDCHROOT_DIR}/dev
- mount -t proc none ${BUILDCHROOT_DIR}/proc
- fi'
+ buildchroot_do_mounts
}
dpkg_undo_mounts() {
--
2.16.4
next prev parent reply other threads:[~2018-09-05 18:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-05 18:17 [PATCH 0/5] Refactor bootloader installation, add custom U-Boot include Jan Kiszka
2018-09-05 18:18 ` Jan Kiszka [this message]
2018-09-05 18:18 ` [PATCH 2/5] image: Add imager dependency installation task Jan Kiszka
2018-09-05 18:18 ` [PATCH 3/5] wic-img: Require explicit setting of WKS_FILE Jan Kiszka
2018-09-05 18:18 ` [PATCH 4/5] Install wic and bootloader dependencies via imager_install_deps Jan Kiszka
2018-09-05 18:18 ` [PATCH 5/5] meta: Add custom U-Boot recipe include Jan Kiszka
2018-09-07 18:27 ` [PATCH v2 " Jan Kiszka
2018-09-05 18:19 ` [PATCH 0/5] Refactor bootloader installation, add custom U-Boot include Jan Kiszka
2018-09-11 8:33 ` Maxim Yu. Osipov
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=b483ca959076dcc7a67e50d023053d6c22727d6d.1536171484.git.jan.kiszka@siemens.com \
--to=jan.kiszka@siemens.com \
--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