public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: claudius.heine.ext@siemens.com
To: isar-users@googlegroups.com
Cc: Claudius Heine <ch@denx.de>
Subject: [PATCH v2 7/8] meta/classes/image*: refactor image pipeline and image.bbclass
Date: Tue,  9 Apr 2019 14:29:14 +0200	[thread overview]
Message-ID: <20190409122915.14249-8-claudius.heine.ext@siemens.com> (raw)
In-Reply-To: <20190409122915.14249-1-claudius.heine.ext@siemens.com>

From: Claudius Heine <ch@denx.de>

The new pipeline is roughly as follows:

 0. `do_unpack`
 1. `do_rootfs_install`
 2. `do_rootfs_postprocess`
 3. `do_rootfs`
 4. `do_image_tools`
 5. `do_image`
 6. `do_deploy`
 x. `do_build`

This commit also splits the image.bbclass functionality up into
additional bbclass files to improve independant development.

Signed-off-by: Claudius Heine <ch@denx.de>
---
 meta/classes/ext4-img.bbclass              |   2 +-
 meta/classes/fit-img.bbclass               |   2 +-
 meta/classes/image-cache-extension.bbclass |  26 +++++
 meta/classes/image-sdk-extension.bbclass   |  36 ++++++
 meta/classes/image-tools-extension.bbclass |  43 +++++++
 meta/classes/image.bbclass                 | 127 ++++++---------------
 meta/classes/targz-img.bbclass             |   2 +-
 meta/classes/ubi-img.bbclass               |   2 +-
 meta/classes/ubifs-img.bbclass             |   2 +-
 meta/classes/wic-img.bbclass               |   4 +-
 10 files changed, 146 insertions(+), 100 deletions(-)
 create mode 100644 meta/classes/image-cache-extension.bbclass
 create mode 100644 meta/classes/image-sdk-extension.bbclass
 create mode 100644 meta/classes/image-tools-extension.bbclass

diff --git a/meta/classes/ext4-img.bbclass b/meta/classes/ext4-img.bbclass
index 4c698e5..4e810cf 100644
--- a/meta/classes/ext4-img.bbclass
+++ b/meta/classes/ext4-img.bbclass
@@ -17,5 +17,5 @@ do_ext4_image() {
                 -F -d '${PP_ROOTFS}' '${PP_DEPLOY}/${EXT4_IMAGE_FILE}'
 }
 
-addtask ext4_image before do_build after do_copy_boot_files do_install_imager_deps
+addtask ext4_image before do_image after do_image_tools
 do_ext4_image[prefuncs] = 'set_image_size'
diff --git a/meta/classes/fit-img.bbclass b/meta/classes/fit-img.bbclass
index e8026c4..221ac3f 100644
--- a/meta/classes/fit-img.bbclass
+++ b/meta/classes/fit-img.bbclass
@@ -24,4 +24,4 @@ do_fit_image() {
     sudo chroot ${BUILDCHROOT_DIR} /usr/bin/mkimage ${MKIMAGE_ARGS} \
                 -f '${PP_WORK}/${FIT_IMAGE_SOURCE}' '${PP_DEPLOY}/${FIT_IMAGE_FILE}'
 }
-addtask fit_image before do_build after do_copy_boot_files do_install_imager_deps do_unpack do_transform_template
+addtask fit_image before do_image after do_image_tools do_transform_template
diff --git a/meta/classes/image-cache-extension.bbclass b/meta/classes/image-cache-extension.bbclass
new file mode 100644
index 0000000..af17e0b
--- /dev/null
+++ b/meta/classes/image-cache-extension.bbclass
@@ -0,0 +1,26 @@
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2019
+#
+# SPDX-License-Identifier: MIT
+#
+# This class extends the image.bbclass to supply the creation of cache repositories
+
+inherit base-apt-helper
+
+do_cache_base_repo[depends] = "base-apt:do_cache_config"
+do_cache_base_repo[lockfiles] = "${REPO_BASE_DIR}/isar.lock"
+do_cache_base_repo[stamp-extra-info] = "${DISTRO}-${MACHINE}"
+do_cache_base_repo() {
+    if [ -d ${WORKDIR}/apt_cache ]; then
+        populate_base_apt ${WORKDIR}/apt_cache
+    fi
+
+    if [ -d ${BUILDCHROOT_HOST_DIR}/var/cache/apt ]; then
+        populate_base_apt ${BUILDCHROOT_HOST_DIR}/var/cache/apt
+    fi
+
+    if [ -d ${BUILDCHROOT_TARGET_DIR}/var/cache/apt ]; then
+        populate_base_apt ${BUILDCHROOT_TARGET_DIR}/var/cache/apt
+    fi
+}
+addtask cache_base_repo after do_rootfs do_install_imager_deps
diff --git a/meta/classes/image-sdk-extension.bbclass b/meta/classes/image-sdk-extension.bbclass
new file mode 100644
index 0000000..1838080
--- /dev/null
+++ b/meta/classes/image-sdk-extension.bbclass
@@ -0,0 +1,36 @@
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2019
+#
+# SPDX-License-Identifier: MIT
+#
+# This class extends the image.bbclass to supply the creation of a sdk
+
+SDKCHROOT_DIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/sdkchroot-${HOST_DISTRO}-${HOST_ARCH}"
+
+do_populate_sdk[stamp-extra-info] = "${DISTRO}-${MACHINE}"
+do_populate_sdk[depends] = "sdkchroot:do_build"
+do_populate_sdk() {
+    # Copy isar-apt with deployed Isar packages
+    sudo cp -Trpfx ${REPO_ISAR_DIR}/${DISTRO}  ${SDKCHROOT_DIR}/rootfs/isar-apt
+
+    # Purge apt cache to make image slimmer
+    sudo rm -rf ${SDKCHROOT_DIR}/rootfs/var/cache/apt/*
+
+    sudo umount -R ${SDKCHROOT_DIR}/rootfs/dev || true
+    sudo umount ${SDKCHROOT_DIR}/rootfs/proc || true
+    sudo umount -R ${SDKCHROOT_DIR}/rootfs/sys || true
+
+    # Remove setup scripts
+    sudo rm -f ${SDKCHROOT_DIR}/rootfs/chroot-setup.sh ${SDKCHROOT_DIR}/rootfs/configscript.sh
+
+    # Copy mount_chroot.sh for convenience
+    sudo cp ${ISARROOT}/scripts/mount_chroot.sh ${SDKCHROOT_DIR}/rootfs
+
+    # Create SDK archive
+    sudo tar -C ${SDKCHROOT_DIR} --transform="s|^rootfs|sdk-${DISTRO}-${DISTRO_ARCH}|" \
+        -c rootfs | xz -T0 > ${DEPLOY_DIR_IMAGE}/sdk-${DISTRO}-${DISTRO_ARCH}.tar.xz
+
+    # Install deployment link for local use
+    ln -Tfsr ${SDKCHROOT_DIR}/rootfs ${DEPLOY_DIR_IMAGE}/sdk-${DISTRO}-${DISTRO_ARCH}
+}
+addtask populate_sdk after do_rootfs
diff --git a/meta/classes/image-tools-extension.bbclass b/meta/classes/image-tools-extension.bbclass
new file mode 100644
index 0000000..b8672d5
--- /dev/null
+++ b/meta/classes/image-tools-extension.bbclass
@@ -0,0 +1,43 @@
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2019
+#
+# SPDX-License-Identifier: MIT
+#
+# This file extends the image.bbclass to supply tools for futher imager functions
+
+# Imager are expected to run natively, thus will use the target buildchroot.
+ISAR_CROSS_COMPILE = "0"
+
+inherit buildchroot
+
+IMAGER_INSTALL ??= ""
+IMAGER_BUILD_DEPS ??= ""
+DEPENDS += "${IMAGER_BUILD_DEPS}"
+
+python () {
+    if d.getVar('IMAGE_TYPE', True) == 'wic-img':
+        d.appendVar('IMAGER_INSTALL',
+                    ' ' + d.getVar('WIC_IMAGER_INSTALL', True))
+}
+
+do_install_imager_deps[depends] = "buildchroot-target:do_build"
+do_install_imager_deps[deptask] = "do_deploy_deb"
+do_install_imager_deps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
+do_install_imager_deps() {
+    if [ -z "${@d.getVar("IMAGER_INSTALL", True).strip()}" ]; then
+        exit
+    fi
+
+    buildchroot_do_mounts
+
+    E="${@bb.utils.export_proxies(d)}"
+    sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' \
+        apt-get update \
+            -o Dir::Etc::sourcelist="sources.list.d/isar-apt.list" \
+            -o Dir::Etc::sourceparts="-" \
+            -o APT::Get::List-Cleanup="0"
+        apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
+            --allow-unauthenticated --allow-downgrades install \
+            ${IMAGER_INSTALL}'
+}
+addtask install_imager_deps before do_image_tools
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 660f85c..bbfb80d 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -53,8 +53,10 @@ image_do_mounts() {
     buildchroot_do_mounts
 }
 
-inherit ${IMAGE_TYPE}
 inherit isar-bootstrap-helper
+inherit image-sdk-extension
+inherit image-cache-extension
+inherit image-tools-extension
 
 # Extra space for rootfs in MB
 ROOTFS_EXTRA ?= "64"
@@ -173,18 +175,17 @@ isar_image_cleanup() {
     '
 }
 
-do_rootfs[depends] = "isar-apt:do_cache_config isar-bootstrap-target:do_bootstrap"
-
-do_rootfs[deptask] = "do_deploy_deb"
-do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
+do_rootfs_install[depends] = "isar-apt:do_cache_config isar-bootstrap-target:do_bootstrap"
+do_rootfs_install[deptask] = "do_deploy_deb"
+do_rootfs_install[root_cleandirs] = "${IMAGE_ROOTFS} \
                              ${IMAGE_ROOTFS}/isar-apt"
-do_rootfs() {
+do_rootfs_install() {
     isar_image_gen_fstab
     isar_image_gen_rootfs
     isar_image_conf_rootfs
     isar_image_cleanup
 }
-addtask rootfs before do_build after do_unpack
+addtask rootfs_install before do_build after do_unpack
 
 do_mark_rootfs() {
     BUILD_ID=$(get_build_id)
@@ -192,9 +193,9 @@ do_mark_rootfs() {
         --build-id "${BUILD_ID}" --variant "${DESCRIPTION}" \
         "${IMAGE_ROOTFS}"
 }
+addtask mark_rootfs before do_rootfs_postprocess after do_rootfs_install
 
-addtask mark_rootfs before do_copy_boot_files do_transform_template after do_rootfs
-
+do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
 do_copy_boot_files() {
     if [ -n "${KERNEL_IMAGE}" ]; then
         cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'vmlinuz')[0]} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}
@@ -216,97 +217,37 @@ do_copy_boot_files() {
         cp -f "$dtb" "${DEPLOY_DIR_IMAGE}/${DTB_FILE}"
     fi
 }
+addtask copy_boot_files before do_rootfs_postprocess after do_rootfs_install
 
-addtask copy_boot_files before do_build after do_rootfs
-do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
-
-SDKCHROOT_DIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/sdkchroot-${HOST_DISTRO}-${HOST_ARCH}"
-
-do_populate_sdk() {
-    # Copy isar-apt with deployed Isar packages
-    sudo cp -Trpfx ${REPO_ISAR_DIR}/${DISTRO}  ${SDKCHROOT_DIR}/rootfs/isar-apt
-
-    # Purge apt cache to make image slimmer
-    sudo rm -rf ${SDKCHROOT_DIR}/rootfs/var/cache/apt/*
-
-    sudo umount -R ${SDKCHROOT_DIR}/rootfs/dev || true
-    sudo umount ${SDKCHROOT_DIR}/rootfs/proc || true
-    sudo umount -R ${SDKCHROOT_DIR}/rootfs/sys || true
-
-    # Remove setup scripts
-    sudo rm -f ${SDKCHROOT_DIR}/rootfs/chroot-setup.sh ${SDKCHROOT_DIR}/rootfs/configscript.sh
-
-    # Copy mount_chroot.sh for convenience
-    sudo cp ${ISARROOT}/scripts/mount_chroot.sh ${SDKCHROOT_DIR}/rootfs
-
-    # Create SDK archive
-    sudo tar -C ${SDKCHROOT_DIR} --transform="s|^rootfs|sdk-${DISTRO}-${DISTRO_ARCH}|" \
-        -c rootfs | xz -T0 > ${DEPLOY_DIR_IMAGE}/sdk-${DISTRO}-${DISTRO_ARCH}.tar.xz
-
-    # Install deployment link for local use
-    ln -Tfsr ${SDKCHROOT_DIR}/rootfs ${DEPLOY_DIR_IMAGE}/sdk-${DISTRO}-${DISTRO_ARCH}
+python do_rootfs_postprocess() {
+    """Virtual task"""
+    pass
 }
+addtask rootfs_postprocess before do_build after do_rootfs_install
 
-do_populate_sdk[depends] = "sdkchroot:do_build"
-
-addtask populate_sdk after do_rootfs
-
-inherit base-apt-helper
-
-do_cache_base_repo[depends] = "base-apt:do_cache_config"
-do_cache_base_repo[lockfiles] = "${REPO_BASE_DIR}/isar.lock"
-
-do_cache_base_repo() {
-    if [ -d ${WORKDIR}/apt_cache ]; then
-        populate_base_apt ${WORKDIR}/apt_cache
-    fi
-
-    if [ -d ${BUILDCHROOT_HOST_DIR}/var/cache/apt ]; then
-        populate_base_apt ${BUILDCHROOT_HOST_DIR}/var/cache/apt
-    fi
-
-    if [ -d ${BUILDCHROOT_TARGET_DIR}/var/cache/apt ]; then
-        populate_base_apt ${BUILDCHROOT_TARGET_DIR}/var/cache/apt
-    fi
+python do_rootfs() {
+    """Virtual task"""
+    pass
 }
+addtask rootfs before do_build after do_rootfs_postprocess
 
-addtask cache_base_repo after do_rootfs do_install_imager_deps
-
-# Imager are expected to run natively, thus will use the target buildchroot.
-ISAR_CROSS_COMPILE = "0"
-
-inherit buildchroot
-
-IMAGER_INSTALL ??= ""
-IMAGER_BUILD_DEPS ??= ""
-DEPENDS += "${IMAGER_BUILD_DEPS}"
-
-python () {
-    if d.getVar('IMAGE_TYPE', True) == 'wic-img':
-        d.appendVar('IMAGER_INSTALL',
-                    ' ' + d.getVar('WIC_IMAGER_INSTALL', True))
+python do_image_tools() {
+    """Virtual task"""
+    pass
 }
+addtask image_tools before do_build after do_rootfs
 
-do_install_imager_deps() {
-    if [ -z "${@d.getVar("IMAGER_INSTALL", True).strip()}" ]; then
-        exit
-    fi
-
-    buildchroot_do_mounts
-
-    E="${@bb.utils.export_proxies(d)}"
-    sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' \
-        apt-get update \
-            -o Dir::Etc::sourcelist="sources.list.d/isar-apt.list" \
-            -o Dir::Etc::sourceparts="-" \
-            -o APT::Get::List-Cleanup="0"
-        apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
-            --allow-unauthenticated --allow-downgrades install \
-            ${IMAGER_INSTALL}'
+python do_image() {
+    """Virtual task"""
+    pass
 }
+addtask image before do_build after do_image_tools
 
-do_install_imager_deps[depends] = "buildchroot-target:do_build"
-do_install_imager_deps[deptask] = "do_deploy_deb"
-do_install_imager_deps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
+python do_deploy() {
+    """Virtual task"""
+    pass
+}
+addtask deploy before do_build after do_image
 
-addtask install_imager_deps before do_build
+# Last so that the image type can overwrite tasks if needed
+inherit ${IMAGE_TYPE}
diff --git a/meta/classes/targz-img.bbclass b/meta/classes/targz-img.bbclass
index 5141a93..d9dadae 100644
--- a/meta/classes/targz-img.bbclass
+++ b/meta/classes/targz-img.bbclass
@@ -10,4 +10,4 @@ do_targz_image() {
     sudo tar -cvzf ${TARGZ_IMAGE_FILE} --one-file-system -C ${IMAGE_ROOTFS} .
 }
 
-addtask targz_image before do_build after do_mark_rootfs
+addtask targz_image before do_image after do_image_tools
diff --git a/meta/classes/ubi-img.bbclass b/meta/classes/ubi-img.bbclass
index a34c465..2cf3344 100644
--- a/meta/classes/ubi-img.bbclass
+++ b/meta/classes/ubi-img.bbclass
@@ -27,4 +27,4 @@ do_ubi_image() {
     sudo chroot ${BUILDCHROOT_DIR} /usr/sbin/ubinize ${UBINIZE_ARGS} \
                 -o '${PP_DEPLOY}/${UBI_IMAGE_FILE}' '${PP_WORK}/${UBINIZE_CFG}'
 }
-addtask ubi_image before do_build after do_copy_boot_files do_install_imager_deps do_unpack do_transform_template
+addtask ubi_image before do_image after do_image_tools do_transform_template
diff --git a/meta/classes/ubifs-img.bbclass b/meta/classes/ubifs-img.bbclass
index bf019a8..4297d21 100644
--- a/meta/classes/ubifs-img.bbclass
+++ b/meta/classes/ubifs-img.bbclass
@@ -23,4 +23,4 @@ do_ubifs_image() {
                 -r '${PP_ROOTFS}' '${PP_DEPLOY}/${UBIFS_IMAGE_FILE}'
 }
 
-addtask ubifs_image before do_build after do_copy_boot_files do_install_imager_deps
+addtask ubifs_image before do_image after do_image_tools
diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
index 7a4a29b..86a918d 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -121,7 +121,7 @@ python do_rootfs_wicenv () {
 
 }
 
-addtask do_rootfs_wicenv after do_copy_boot_files before do_wic_image
+addtask do_rootfs_wicenv after do_rootfs before do_wic_image
 do_rootfs_wicenv[vardeps] += "${WICVARS}"
 do_rootfs_wicenv[prefuncs] = 'set_image_size'
 
@@ -155,4 +155,4 @@ EOSUDO
 do_wic_image[file-checksums] += "${WKS_FILE_CHECKSUM}"
 do_wic_image[depends] = "buildchroot-target:do_build"
 
-addtask wic_image before do_build after do_install_imager_deps
+addtask wic_image before do_image after do_image_tools
-- 
2.20.1


  parent reply	other threads:[~2019-04-09 12:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-09 12:29 [PATCH v2 0/8] Implement ROOTFS postprocess commands claudius.heine.ext
2019-04-09 12:29 ` [PATCH v2 1/8] image.bbclass: make KERNEL_IMAGE & INITRD_IMAGE variable fixed claudius.heine.ext
2019-04-09 12:29 ` [PATCH v2 2/8] image.bbclass: limit `du` to only one file system claudius.heine.ext
2019-04-09 12:29 ` [PATCH v2 3/8] meta/classes/targz-img: limit tarball creation to " claudius.heine.ext
2019-04-09 12:29 ` [PATCH v2 4/8] meta/classes/buildchroot: add check before each mounting and quotes claudius.heine.ext
2019-04-09 12:29 ` [PATCH v2 5/8] meta/image classes: refactor task stamps claudius.heine.ext
2019-04-09 12:29 ` [PATCH v2 6/8] meta/classes/*-img: remove 'inherit image' statements claudius.heine.ext
2019-04-09 12:29 ` claudius.heine.ext [this message]
2019-04-09 12:29 ` [PATCH v2 8/8] meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND claudius.heine.ext
2019-04-16  5:05 ` [PATCH v2 0/8] Implement ROOTFS postprocess commands 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=20190409122915.14249-8-claudius.heine.ext@siemens.com \
    --to=claudius.heine.ext@siemens.com \
    --cc=ch@denx.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