public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "Maxim Yu. Osipov" <mosipov@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v2 2/7] isar-bootstrap: Add host architecture support
Date: Fri, 22 Jun 2018 14:40:17 +0200	[thread overview]
Message-ID: <20180622124022.30192-3-mosipov@ilbers.de> (raw)
In-Reply-To: <20180622124022.30192-1-mosipov@ilbers.de>

From: Alexander Smirnov <asmirnov@ilbers.de>

Add HOST_* definitions and recipe to generate
ISAR boostrap with the host architecture.
Add corresponding options to setup_root_file_system().
Generate reprepro config for host distro
if it doesn't exist.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
Signed-off-by: Maxim Yu. Osipov <mosipov@ilbers.de>
---
 meta/classes/isar-bootstrap-helper.bbclass         | 22 ++++++-
 .../isar-bootstrap/isar-bootstrap-host.bb          | 75 ++++++++++++++++++++++
 meta/recipes-devtools/isar-apt/isar-apt-host.bb    | 31 +++++++++
 3 files changed, 126 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb
 create mode 100644 meta/recipes-devtools/isar-apt/isar-apt-host.bb

diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
index 3c10fc7..bc23ad2 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -7,6 +7,18 @@
 
 IMAGE_TRANSIENT_PACKAGES ??= ""
 
+def get_deb_host_arch():
+    import subprocess
+    arch =  subprocess.check_output(['dpkg-architecture', '-q', 'DEB_HOST_ARCH'], universal_newlines=True)
+    return str.splitlines(arch)[0]
+
+#Debian Distribution for SDK host
+HOST_DISTRO ?= "debian-stretch"
+#Determine SDK host architecture if not explicitly set
+HOST_ARCH ?= "${@get_deb_host_arch()}"
+
+HOST_DISTRO_APT_SOURCES += "conf/distro/${HOST_DISTRO}.list"
+
 def reverse_bb_array(d, varname):
     array = d.getVar(varname, True)
     if array is None:
@@ -14,13 +26,18 @@ def reverse_bb_array(d, varname):
     array = reversed(array.split())
     return " ".join(i for i in array)
 
+
 setup_root_file_system() {
     CLEAN=""
     FSTAB=""
+    ROOTFS_ARCH="${DISTRO_ARCH}"
+    ROOTFS_DISTRO="${DISTRO}"
     while true; do
         case "$1" in
         --clean) CLEAN=1 ;;
         --fstab) FSTAB=$2; shift ;;
+        --host-arch) ROOTFS_ARCH=${HOST_ARCH} ;;
+        --host-distro) ROOTFS_DISTRO=${HOST_DISTRO} ;;
         -*) bbfatal "$0: invalid option specified: $1" ;;
         *) break ;;
         esac
@@ -33,7 +50,7 @@ setup_root_file_system() {
     CLEAN_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"
 
     sudo cp -Trpfx \
-        "${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \
+        "${DEPLOY_DIR_IMAGE}/isar-bootstrap-$ROOTFS_DISTRO-$ROOTFS_ARCH/" \
         "$ROOTFSDIR"
     [ -n "${FSTAB}" ] && cat ${FSTAB} | sudo tee "$ROOTFSDIR/etc/fstab"
 
@@ -43,7 +60,8 @@ setup_root_file_system() {
     echo "Package: *\nPin: release n=${DEBDISTRONAME}\nPin-Priority: 1000" | \
         sudo tee "$ROOTFSDIR/etc/apt/preferences.d/isar" >/dev/null
 
-    sudo mount --bind ${DEPLOY_DIR_APT}/${DISTRO} $ROOTFSDIR/isar-apt
+    sudo mount --bind ${DEPLOY_DIR_APT}/${ROOTFS_DISTRO} $ROOTFSDIR/isar-apt
+
     sudo mount -t devtmpfs -o mode=0755,nosuid devtmpfs $ROOTFSDIR/dev
     sudo mount -t proc none $ROOTFSDIR/proc
 
diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb b/meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb
new file mode 100644
index 0000000..cca0984
--- /dev/null
+++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb
@@ -0,0 +1,75 @@
+# Minimal host Debian root file system
+#
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2018
+#
+# SPDX-License-Identifier: MIT
+
+Description = "Minimal host Debian root file system"
+
+WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}-${HOST_DISTRO}-${HOST_ARCH}"
+
+include isar-bootstrap.inc
+inherit isar-bootstrap-helper
+
+do_generate_keyring[stamp-extra-info] = "${HOST_DISTRO}-${HOST_ARCH}"
+
+do_apt_config_prepare[stamp-extra-info] = "${HOST_DISTRO}-${HOST_ARCH}"
+do_apt_config_prepare[dirs] = "${WORKDIR}"
+do_apt_config_prepare[vardeps] += "\
+                                   APTPREFS \
+                                   HOST_DISTRO_APT_PREFERENCES \
+                                   DEBDISTRONAME \
+                                   APTSRCS \
+                                   HOST_DISTRO_APT_SOURCES \
+                                  "
+python do_apt_config_prepare() {
+    apt_preferences_out = d.getVar("APTPREFS", True)
+    apt_preferences_list = (d.getVar("HOST_DISTRO_APT_PREFERENCES", True) or ""
+                           ).split()
+    aggregate_files(d, apt_preferences_list, apt_preferences_out)
+
+    apt_sources_out = d.getVar("APTSRCS", True)
+    apt_sources_list = (d.getVar("HOST_DISTRO_APT_SOURCES", True) or "").split()
+
+    aggregate_aptsources_list(d, apt_sources_list, apt_sources_out)
+}
+addtask apt_config_prepare before do_build after do_unpack
+
+do_apt_config_install[stamp-extra-info] = "${HOST_DISTRO}-${HOST_ARCH}"
+
+
+do_bootstrap[stamp-extra-info] = "${HOST_DISTRO}-${HOST_ARCH}"
+do_bootstrap[vardeps] += "HOST_DISTRO_APT_SOURCES"
+do_bootstrap[vardeps] += "DISTRO_APT_PREMIRRORS"
+do_bootstrap() {
+    if [ -e "${ROOTFSDIR}" ]; then
+       sudo umount -l "${ROOTFSDIR}/dev" || true
+       sudo umount -l "${ROOTFSDIR}/proc" || true
+       sudo rm -rf "${ROOTFSDIR}"
+    fi
+    E="${@bb.utils.export_proxies(d)}"
+    sudo -E "${DEBOOTSTRAP}" --verbose \
+                             --variant=minbase \
+                             --include=locales \
+                             ${@get_distro_components_argument(d, True)} \
+                             ${DEBOOTSTRAP_KEYRING} \
+                             "${@get_distro_suite(d, True)}" \
+                             "${ROOTFSDIR}" \
+                             "${@get_distro_source(d, True)}"
+}
+addtask bootstrap before do_build after do_generate_keyring
+
+do_deploy[stamp-extra-info] = "${HOST_DISTRO}-${HOST_ARCH}"
+do_deploy[dirs] = "${DEPLOY_DIR_IMAGE}"
+do_deploy() {
+    ln -Tfsr "${ROOTFSDIR}" "${DEPLOY_DIR_IMAGE}/isar-bootstrap-${HOST_DISTRO}-${HOST_ARCH}"
+}
+addtask deploy before do_build after do_apt_update
+
+do_apt_update[stamp-extra-info] = "${HOST_DISTRO}-${HOST_ARCH}"
+
+CLEANFUNCS = "clean_deploy"
+clean_deploy() {
+     rm -f "${DEPLOY_DIR_IMAGE}/isar-bootstrap}-${HOST_DISTRO}-${HOST_ARCH}"
+}
diff --git a/meta/recipes-devtools/isar-apt/isar-apt-host.bb b/meta/recipes-devtools/isar-apt/isar-apt-host.bb
new file mode 100644
index 0000000..0cf5ce1
--- /dev/null
+++ b/meta/recipes-devtools/isar-apt/isar-apt-host.bb
@@ -0,0 +1,31 @@
+# This software is a part of ISAR.
+# Copyright (C) 2015-2018 ilbers GmbH
+
+inherit isar-bootstrap-helper
+
+SRC_URI = "file://distributions.in"
+
+CACHE_CONF_DIR = "${DEPLOY_DIR_APT}/${HOST_DISTRO}/conf"
+do_cache_config[dirs] = "${CACHE_CONF_DIR}"
+do_cache_config[stamp-extra-info] = "${HOST_DISTRO}"
+do_cache_config[lockfiles] = "${DEPLOY_DIR_APT}/isar.lock"
+
+# Generate reprepro config for current host distro if it doesn't exist. Once it's
+# generated, this task should do nothing.
+do_cache_config() {
+    if [ ! -e "${CACHE_CONF_DIR}/distributions" ]; then
+        sed -e "s#{DISTRO_NAME}#"${DEBDISTRONAME}"#g" \
+            ${WORKDIR}/distributions.in > ${CACHE_CONF_DIR}/distributions
+    fi
+
+    path_cache="${DEPLOY_DIR_APT}/${HOST_DISTRO}"
+    path_databases="${DEPLOY_DIR_DB}/${HOST_DISTRO}"
+
+    if [ ! -d "${path_databases}" ]; then
+        reprepro -b ${path_cache} \
+                 --dbdir ${path_databases} \
+                 export ${DEBDISTRONAME}
+    fi
+}
+
+addtask cache_config after do_unpack
-- 
2.11.0


  parent reply	other threads:[~2018-06-22 12:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22 12:40 [PATCH v2 0/7] Add ISAR SDK support Maxim Yu. Osipov
2018-06-22 12:40 ` [PATCH v2 1/7] isar-bootstrap: Move common part to include Maxim Yu. Osipov
2018-06-22 12:40 ` Maxim Yu. Osipov [this message]
2018-06-22 12:40 ` [PATCH v2 3/7] isar-bootstrap-helper: Add option --copyisarapt to setup_root_file_system() Maxim Yu. Osipov
2018-06-22 12:40 ` [PATCH v2 4/7] sdkchroot: Added recipe-devel to create SDK root filesystem Maxim Yu. Osipov
2018-06-22 12:40 ` [PATCH v2 5/7] meta/class/image: Add populate_sdk task to trigger SDK rootfs creation Maxim Yu. Osipov
2018-06-22 12:40 ` [PATCH v2 6/7] scripts: Add helper scripts to mount/umount chroot directory Maxim Yu. Osipov
2018-06-22 12:40 ` [PATCH v2 7/7] doc: Add description of ISAR SDK root filesystem creation Maxim Yu. Osipov
2018-06-29 12:57 ` [PATCH v2 0/7] Add ISAR SDK support 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=20180622124022.30192-3-mosipov@ilbers.de \
    --to=mosipov@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