From: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
To: <isar-users@googlegroups.com>, <jan.kiszka@siemens.com>,
<henning.schild@siemens.com>
Cc: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
Subject: [RFC PATCH 2/2] buildchroot: Add provision to specify apt preferences
Date: Mon, 29 Nov 2021 20:22:41 +0530 [thread overview]
Message-ID: <20211129145241.2932943-3-Vijaikumar_Kanagarajan@mentor.com> (raw)
In-Reply-To: <20211129145241.2932943-1-Vijaikumar_Kanagarajan@mentor.com>
Add provision to set apt preferences for buildchroot-host and target.
Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
.../buildchroot/buildchroot.inc | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/meta/recipes-devtools/buildchroot/buildchroot.inc b/meta/recipes-devtools/buildchroot/buildchroot.inc
index 726c7bb..fd06b80 100644
--- a/meta/recipes-devtools/buildchroot/buildchroot.inc
+++ b/meta/recipes-devtools/buildchroot/buildchroot.inc
@@ -50,6 +50,36 @@ rootfs_do_mounts_append() {
EOSUDO
}
+BUILDCHROOT_VARS_PREFIX ?= "${@'BUILDCHROOT_HOST_' if d.getVar('BOOTSTRAP_VARIANT') == 'HOST' else 'BUILDCHROOT_TARGET_'}"
+python() {
+ distro_apt_preferences = d.getVar(d.getVar("BUILDCHROOT_VARS_PREFIX") + "APT_PREFERENCES", True) or ""
+ for file in distro_apt_preferences.split():
+ d.appendVar("SRC_URI", " file://%s" % bb.parse.resolve_file(file, d))
+}
+
+APTPREFS = "${WORKDIR}/apt-preferences"
+
+do_buildchroot_prepare[vardeps] += " \
+ APTPREFS \
+ ${BUILDCHROOT_VARS_PREFIX}_APT_PREFERENCES \
+ "
+
+python do_buildchroot_prepare() {
+ apt_preferences_out = d.getVar("APTPREFS", True)
+ apt_preferences_list = (
+ d.getVar(d.getVar("BUILDCHROOT_VARS_PREFIX") + "APT_PREFERENCES", True) or ""
+ ).split()
+ aggregate_files(d, apt_preferences_list, apt_preferences_out)
+}
+addtask buildchroot_prepare before do_rootfs_install after do_unpack
+
+ROOTFS_CONFIGURE_COMMAND += "buildchroot_configure_preferences"
+buildchroot_configure_preferences() {
+ sudo install -v -m644 "${APTPREFS}" \
+ "${BUILDCHROOT_DIR}/etc/apt/preferences.d/buildchroot"
+}
+
+
ROOTFS_POSTPROCESS_COMMAND =+ "buildchroot_install_files"
buildchroot_install_files() {
sudo mkdir -p "${BUILDCHROOT_DIR}/home/builder"
--
2.25.1
next prev parent reply other threads:[~2021-11-29 14:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-29 14:52 [RFC PATCH 0/2] Buildchroot non-determinism Vijai Kumar K
2021-11-29 14:52 ` [RFC PATCH 1/2] meta: Move aggregate_files to base class Vijai Kumar K
2021-11-29 14:52 ` Vijai Kumar K [this message]
2021-11-30 16:45 ` [RFC PATCH 0/2] Buildchroot non-determinism Jan Kiszka
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=20211129145241.2932943-3-Vijaikumar_Kanagarajan@mentor.com \
--to=vijaikumar_kanagarajan@mentor.com \
--cc=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
--cc=jan.kiszka@siemens.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