public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v2 0/8] Implement ROOTFS postprocess commands
@ 2019-04-09 12:29 claudius.heine.ext
  2019-04-09 12:29 ` [PATCH v2 1/8] image.bbclass: make KERNEL_IMAGE & INITRD_IMAGE variable fixed claudius.heine.ext
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine

From: Claudius Heine <ch@denx.de>

Hi,

this is version 2 of the ROOTFS postprocess patchset.

I merged the 'Clean image pipeline' into this one, since they were developed
and tested together.

Changes from v2:
 - rebased on current next
 - some more cleanup and refactoring patches added
 - some changes to the postprocess patch, to better prepare for the
   preprocessing patchset that will follow soon.

Claudius Heine (8):
  image.bbclass: make KERNEL_IMAGE & INITRD_IMAGE variable fixed
  image.bbclass: limit `du` to only one file system
  meta/classes/targz-img: limit tarball creation to one file system
  meta/classes/buildchroot: add check before each mounting and quotes
  meta/image classes: refactor task stamps
  meta/classes/*-img: remove 'inherit image' statements
  meta/classes/image*: refactor image pipeline and image.bbclass
  meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND

 meta/classes/buildchroot.bbclass              |  25 ++-
 meta/classes/ext4-img.bbclass                 |   4 +-
 meta/classes/fit-img.bbclass                  |   7 +-
 meta/classes/image-cache-extension.bbclass    |  26 +++
 meta/classes/image-postproc-extension.bbclass |  46 ++++
 meta/classes/image-sdk-extension.bbclass      |  36 ++++
 meta/classes/image-tools-extension.bbclass    |  43 ++++
 meta/classes/image.bbclass                    | 203 ++++--------------
 meta/classes/rootfs.bbclass                   |  58 +++++
 meta/classes/targz-img.bbclass                |   6 +-
 meta/classes/ubi-img.bbclass                  |   7 +-
 meta/classes/ubifs-img.bbclass                |   6 +-
 meta/classes/wic-img.bbclass                  |   8 +-
 13 files changed, 267 insertions(+), 208 deletions(-)
 create mode 100644 meta/classes/image-cache-extension.bbclass
 create mode 100644 meta/classes/image-postproc-extension.bbclass
 create mode 100644 meta/classes/image-sdk-extension.bbclass
 create mode 100644 meta/classes/image-tools-extension.bbclass
 create mode 100644 meta/classes/rootfs.bbclass

-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/8] image.bbclass: make KERNEL_IMAGE & INITRD_IMAGE variable fixed
  2019-04-09 12:29 [PATCH v2 0/8] Implement ROOTFS postprocess commands claudius.heine.ext
@ 2019-04-09 12:29 ` claudius.heine.ext
  2019-04-09 12:29 ` [PATCH v2 2/8] image.bbclass: limit `du` to only one file system claudius.heine.ext
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine

From: Claudius Heine <ch@denx.de>

Before the value of those variables where calculated at runtime with the
content of the target root file system. But if the root file system
does not contain the files yet or no longer, this variable will be
empty, even if those files are already copyied to the deploy directory.

Setting this to fixed value allows to use them in every state of the
root file system.

Signed-off-by: Claudius Heine <ch@denx.de>
---
 meta/classes/image.bbclass | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 385fa0e..8ae931c 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -11,8 +11,8 @@ IMAGE_INSTALL += "${@ ("linux-image-" + d.getVar("KERNEL_NAME", True)) if d.getV
 IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}"
 
 # These variables are used by wic and start_vm
-KERNEL_IMAGE ?= "${@get_image_name(d, 'vmlinuz')[1]}"
-INITRD_IMAGE ?= "${@get_image_name(d, 'initrd.img')[1]}"
+KERNEL_IMAGE ?= "vmlinuz"
+INITRD_IMAGE ?= "initrd.img"
 
 # Useful variables for imager implementations:
 PP = "/home/builder/${PN}"
@@ -202,12 +202,10 @@ do_mark_rootfs[stamp-extra-info] = "${DISTRO}-${MACHINE}"
 addtask mark_rootfs before do_copy_boot_files do_transform_template after do_rootfs
 
 do_copy_boot_files() {
-    KERNEL_IMAGE=${@get_image_name(d, 'vmlinuz')[1]}
     if [ -n "${KERNEL_IMAGE}" ]; then
         cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'vmlinuz')[0]} ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE}
     fi
 
-    INITRD_IMAGE=${@get_image_name(d, 'initrd.img')[1]}
     if [ -n "${INITRD_IMAGE}" ]; then
         sudo cp -f ${IMAGE_ROOTFS}/boot/${@get_image_name(d, 'initrd.img')[0]} ${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}
     fi
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 2/8] image.bbclass: limit `du` to only one file system
  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 ` claudius.heine.ext
  2019-04-09 12:29 ` [PATCH v2 3/8] meta/classes/targz-img: limit tarball creation to " claudius.heine.ext
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine, Andreas Reichel

From: Claudius Heine <ch@denx.de>

This prevents ready any mounted `/dev`, `/proc`, `/sys` paths. If they
are still mounted.

Signed-off-by: Claudius Heine <ch@denx.de>
Signed-off-by: Andreas Reichel <andreas.reichel.ext@siemens.com>
---
 meta/classes/image.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 8ae931c..e6e8542 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -87,7 +87,7 @@ def get_rootfs_size(d):
     rootfs_extra = int(d.getVar("ROOTFS_EXTRA", True))
 
     output = subprocess.check_output(
-        ["sudo", "du", "-s", "--block-size=1k", d.getVar("IMAGE_ROOTFS", True)]
+        ["sudo", "du", "-xs", "--block-size=1k", d.getVar("IMAGE_ROOTFS", True)]
     )
     base_size = int(output.split()[0])
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 3/8] meta/classes/targz-img: limit tarball creation to one file system
  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 ` 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
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine

From: Claudius Heine <ch@denx.de>

Signed-off-by: Claudius Heine <ch@denx.de>
---
 meta/classes/targz-img.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/targz-img.bbclass b/meta/classes/targz-img.bbclass
index ef3748e..87042f4 100644
--- a/meta/classes/targz-img.bbclass
+++ b/meta/classes/targz-img.bbclass
@@ -9,7 +9,7 @@ do_targz_image[stamp-extra-info] = "${DISTRO}-${MACHINE}"
 
 do_targz_image() {
     rm -f ${TARGZ_IMAGE_FILE}
-    sudo tar -cvzf ${TARGZ_IMAGE_FILE} -C ${IMAGE_ROOTFS} .
+    sudo tar -cvzf ${TARGZ_IMAGE_FILE} --one-file-system -C ${IMAGE_ROOTFS} .
 }
 
 addtask targz_image before do_build after do_mark_rootfs
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 4/8] meta/classes/buildchroot: add check before each mounting and quotes
  2019-04-09 12:29 [PATCH v2 0/8] Implement ROOTFS postprocess commands claudius.heine.ext
                   ` (2 preceding siblings ...)
  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 ` claudius.heine.ext
  2019-04-09 12:29 ` [PATCH v2 5/8] meta/image classes: refactor task stamps claudius.heine.ext
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine

From: Claudius Heine <ch@denx.de>

Signed-off-by: Claudius Heine <ch@denx.de>
---
 meta/classes/buildchroot.bbclass | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/meta/classes/buildchroot.bbclass b/meta/classes/buildchroot.bbclass
index c017b25..1a87bf4 100644
--- a/meta/classes/buildchroot.bbclass
+++ b/meta/classes/buildchroot.bbclass
@@ -25,18 +25,21 @@ buildchroot_do_mounts() {
     sudo -s <<'EOSUDO'
         ( flock 9
         set -e
-        if ! grep -q ${BUILDCHROOT_DIR}/isar-apt /proc/mounts; then
-            mount --bind ${REPO_ISAR_DIR}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt
-            mount --bind ${DL_DIR} ${BUILDCHROOT_DIR}/downloads
-            mount --rbind /dev ${BUILDCHROOT_DIR}/dev
-            mount --make-rslave ${BUILDCHROOT_DIR}/dev
-            mount -t proc none ${BUILDCHROOT_DIR}/proc
-            mount --rbind /sys ${BUILDCHROOT_DIR}/sys
-            mount --make-rslave ${BUILDCHROOT_DIR}/sys
-        fi
+        mountpoint -q '${BUILDCHROOT_DIR}/isar-apt' ||
+            mount --bind '${REPO_ISAR_DIR}/${DISTRO}' '${BUILDCHROOT_DIR}/isar-apt'
+        mountpoint -q '${BUILDCHROOT_DIR}/downloads' ||
+            mount --bind '${DL_DIR}' '${BUILDCHROOT_DIR}/downloads'
+        mountpoint -q '${BUILDCHROOT_DIR}/dev' ||
+            mount --rbind /dev '${BUILDCHROOT_DIR}/dev'
+        mount --make-rslave '${BUILDCHROOT_DIR}/dev'
+        mountpoint -q '${BUILDCHROOT_DIR}/proc' ||
+            mount -t proc none '${BUILDCHROOT_DIR}/proc'
+        mountpoint -q '${BUILDCHROOT_DIR}/sys' ||
+            mount --rbind /sys '${BUILDCHROOT_DIR}/sys'
+        mount --make-rslave '${BUILDCHROOT_DIR}/sys'
 
         # Refresh /etc/resolv.conf at this chance
-        cp -L /etc/resolv.conf ${BUILDCHROOT_DIR}/etc
-        ) 9>${MOUNT_LOCKFILE}
+        cp -L /etc/resolv.conf '${BUILDCHROOT_DIR}/etc'
+        ) 9>'${MOUNT_LOCKFILE}'
 EOSUDO
 }
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 5/8] meta/image classes: refactor task stamps
  2019-04-09 12:29 [PATCH v2 0/8] Implement ROOTFS postprocess commands claudius.heine.ext
                   ` (3 preceding siblings ...)
  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 ` claudius.heine.ext
  2019-04-09 12:29 ` [PATCH v2 6/8] meta/classes/*-img: remove 'inherit image' statements claudius.heine.ext
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine

From: Claudius Heine <ch@denx.de>

This patch adds 'DISTRO' and 'MACHINE' to 'PF' and removes the 'WORKDIR'
declaration in the 'image.bbclass'. This way each 'PN', 'DISTRO',
'MACHINE' tripel will have their own 'WORKDIR' and 'STAMP' directory.
'stamp-extra-info' settings for 'DISTRO' and 'MACHINE' is no longer
necessary for each task.

Signed-off-by: Claudius Heine <ch@denx.de>
---
 meta/classes/ext4-img.bbclass  |  2 --
 meta/classes/fit-img.bbclass   |  2 --
 meta/classes/image.bbclass     | 16 +++-------------
 meta/classes/targz-img.bbclass |  2 --
 meta/classes/ubi-img.bbclass   |  2 --
 meta/classes/ubifs-img.bbclass |  2 --
 meta/classes/wic-img.bbclass   |  4 ----
 7 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/meta/classes/ext4-img.bbclass b/meta/classes/ext4-img.bbclass
index 2620de9..4c698e5 100644
--- a/meta/classes/ext4-img.bbclass
+++ b/meta/classes/ext4-img.bbclass
@@ -5,8 +5,6 @@ EXT4_IMAGE_FILE = "${IMAGE_FULLNAME}.ext4.img"
 
 IMAGER_INSTALL += "e2fsprogs"
 
-do_ext4_image[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
 # Generate ext4 filesystem image
 do_ext4_image() {
     rm -f '${DEPLOY_DIR_IMAGE}/${EXT4_IMAGE_FILE}'
diff --git a/meta/classes/fit-img.bbclass b/meta/classes/fit-img.bbclass
index edca09f..be0cbfe 100644
--- a/meta/classes/fit-img.bbclass
+++ b/meta/classes/fit-img.bbclass
@@ -13,8 +13,6 @@ FIT_IMAGE_FILE ?= "${IMAGE_FULLNAME}.fit.img"
 
 IMAGER_INSTALL += "u-boot-tools device-tree-compiler"
 
-do_fit_image[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
 # Generate fit image
 do_fit_image() {
     if [ ! -e "${WORKDIR}/${FIT_IMAGE_SOURCE}" ]; then
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index e6e8542..660f85c 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -1,6 +1,8 @@
 # This software is a part of ISAR.
 # Copyright (C) 2015-2017 ilbers GmbH
 
+PF = "${PN}-${DISTRO}-${MACHINE}"
+
 IMAGE_INSTALL ?= ""
 IMAGE_TYPE    ?= "ext4-img"
 IMAGE_ROOTFS   = "${WORKDIR}/rootfs"
@@ -8,7 +10,7 @@ IMAGE_ROOTFS   = "${WORKDIR}/rootfs"
 IMAGE_INSTALL += "${@ ("linux-image-" + d.getVar("KERNEL_NAME", True)) if d.getVar("KERNEL_NAME", True) else ""}"
 
 # Name of the image including distro&machine names
-IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}"
+IMAGE_FULLNAME = "${PF}"
 
 # These variables are used by wic and start_vm
 KERNEL_IMAGE ?= "vmlinuz"
@@ -38,8 +40,6 @@ DEPENDS += "${IMAGE_INSTALL} ${IMAGE_TRANSIENT_PACKAGES}"
 
 IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge isar-cfg-rootpw"
 
-WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${MACHINE}/${PN}"
-
 ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags --dirty --match 'v[0-9].[0-9]*'"
 ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
 
@@ -173,10 +173,6 @@ isar_image_cleanup() {
     '
 }
 
-do_fetch[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-do_unpack[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
-do_rootfs[stamp-extra-info] = "${DISTRO}-${MACHINE}"
 do_rootfs[depends] = "isar-apt:do_cache_config isar-bootstrap-target:do_bootstrap"
 
 do_rootfs[deptask] = "do_deploy_deb"
@@ -197,8 +193,6 @@ do_mark_rootfs() {
         "${IMAGE_ROOTFS}"
 }
 
-do_mark_rootfs[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
 addtask mark_rootfs before do_copy_boot_files do_transform_template after do_rootfs
 
 do_copy_boot_files() {
@@ -225,7 +219,6 @@ do_copy_boot_files() {
 
 addtask copy_boot_files before do_build after do_rootfs
 do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
-do_copy_boot_files[stamp-extra-info] = "${DISTRO}-${MACHINE}"
 
 SDKCHROOT_DIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/sdkchroot-${HOST_DISTRO}-${HOST_ARCH}"
 
@@ -254,7 +247,6 @@ do_populate_sdk() {
     ln -Tfsr ${SDKCHROOT_DIR}/rootfs ${DEPLOY_DIR_IMAGE}/sdk-${DISTRO}-${DISTRO_ARCH}
 }
 
-do_populate_sdk[stamp-extra-info] = "${DISTRO}-${MACHINE}"
 do_populate_sdk[depends] = "sdkchroot:do_build"
 
 addtask populate_sdk after do_rootfs
@@ -263,7 +255,6 @@ 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
@@ -317,6 +308,5 @@ do_install_imager_deps() {
 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[stamp-extra-info] = "${DISTRO}-${MACHINE}"
 
 addtask install_imager_deps before do_build
diff --git a/meta/classes/targz-img.bbclass b/meta/classes/targz-img.bbclass
index 87042f4..5141a93 100644
--- a/meta/classes/targz-img.bbclass
+++ b/meta/classes/targz-img.bbclass
@@ -5,8 +5,6 @@
 
 TARGZ_IMAGE_FILE = "${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.tar.gz"
 
-do_targz_image[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
 do_targz_image() {
     rm -f ${TARGZ_IMAGE_FILE}
     sudo tar -cvzf ${TARGZ_IMAGE_FILE} --one-file-system -C ${IMAGE_ROOTFS} .
diff --git a/meta/classes/ubi-img.bbclass b/meta/classes/ubi-img.bbclass
index f61a940..f34ac84 100644
--- a/meta/classes/ubi-img.bbclass
+++ b/meta/classes/ubi-img.bbclass
@@ -16,8 +16,6 @@ UBI_IMAGE_FILE ?= "${IMAGE_FULLNAME}.ubi.img"
 
 IMAGER_INSTALL += "mtd-utils"
 
-do_ubi_image[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
 # Generate ubi filesystem image
 do_ubi_image() {
     if [ ! -e "${WORKDIR}/${UBINIZE_CFG}" ]; then
diff --git a/meta/classes/ubifs-img.bbclass b/meta/classes/ubifs-img.bbclass
index ed37357..dcf9eb9 100644
--- a/meta/classes/ubifs-img.bbclass
+++ b/meta/classes/ubifs-img.bbclass
@@ -14,8 +14,6 @@ UBIFS_IMAGE_FILE ?= "${IMAGE_FULLNAME}.ubifs.img"
 
 IMAGER_INSTALL += "mtd-utils"
 
-do_ubifs_image[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
 # Generate ubifs filesystem image
 do_ubifs_image() {
     rm -f '${DEPLOY_DIR_IMAGE}/${UBIFS_IMAGE_FILE}'
diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
index 09d9f2e..7a4a29b 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -89,8 +89,6 @@ FAKEROOTCMD ?= "${ISARROOT}/scripts/wic_fakeroot"
 RECIPE_SYSROOT_NATIVE ?= "/"
 BUILDCHROOT_DIR = "${BUILDCHROOT_TARGET_DIR}"
 
-do_wic_image[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-
 WIC_CREATE_EXTRA_ARGS ?= ""
 
 WICVARS += "\
@@ -129,8 +127,6 @@ do_rootfs_wicenv[prefuncs] = 'set_image_size'
 
 WIC_IMAGE_FILE ="${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.wic.img"
 
-do_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
-
 do_wic_image() {
     buildchroot_do_mounts
     sudo -s <<'EOSUDO'
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 6/8] meta/classes/*-img: remove 'inherit image' statements
  2019-04-09 12:29 [PATCH v2 0/8] Implement ROOTFS postprocess commands claudius.heine.ext
                   ` (4 preceding siblings ...)
  2019-04-09 12:29 ` [PATCH v2 5/8] meta/image classes: refactor task stamps claudius.heine.ext
@ 2019-04-09 12:29 ` claudius.heine.ext
  2019-04-09 12:29 ` [PATCH v2 7/8] meta/classes/image*: refactor image pipeline and image.bbclass claudius.heine.ext
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine

From: Claudius Heine <ch@denx.de>

Those statements are not necessary since those files are
included by the 'image.bbclass'

Signed-off-by: Claudius Heine <ch@denx.de>
---
 meta/classes/fit-img.bbclass   | 3 ---
 meta/classes/ubi-img.bbclass   | 3 ---
 meta/classes/ubifs-img.bbclass | 2 --
 3 files changed, 8 deletions(-)

diff --git a/meta/classes/fit-img.bbclass b/meta/classes/fit-img.bbclass
index be0cbfe..e8026c4 100644
--- a/meta/classes/fit-img.bbclass
+++ b/meta/classes/fit-img.bbclass
@@ -6,9 +6,6 @@
 MKIMAGE_ARGS ??= ""
 
 FIT_IMAGE_SOURCE ??= "fitimage.its"
-
-inherit image
-
 FIT_IMAGE_FILE ?= "${IMAGE_FULLNAME}.fit.img"
 
 IMAGER_INSTALL += "u-boot-tools device-tree-compiler"
diff --git a/meta/classes/ubi-img.bbclass b/meta/classes/ubi-img.bbclass
index f34ac84..a34c465 100644
--- a/meta/classes/ubi-img.bbclass
+++ b/meta/classes/ubi-img.bbclass
@@ -9,9 +9,6 @@ python() {
 }
 
 UBINIZE_CFG ??= "ubinize.cfg"
-
-inherit image
-
 UBI_IMAGE_FILE ?= "${IMAGE_FULLNAME}.ubi.img"
 
 IMAGER_INSTALL += "mtd-utils"
diff --git a/meta/classes/ubifs-img.bbclass b/meta/classes/ubifs-img.bbclass
index dcf9eb9..bf019a8 100644
--- a/meta/classes/ubifs-img.bbclass
+++ b/meta/classes/ubifs-img.bbclass
@@ -8,8 +8,6 @@ python() {
         bb.fatal("MKUBIFS_ARGS must be set")
 }
 
-inherit image
-
 UBIFS_IMAGE_FILE ?= "${IMAGE_FULLNAME}.ubifs.img"
 
 IMAGER_INSTALL += "mtd-utils"
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 7/8] meta/classes/image*: refactor image pipeline and image.bbclass
  2019-04-09 12:29 [PATCH v2 0/8] Implement ROOTFS postprocess commands claudius.heine.ext
                   ` (5 preceding siblings ...)
  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
  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
  8 siblings, 0 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 8/8] meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND
  2019-04-09 12:29 [PATCH v2 0/8] Implement ROOTFS postprocess commands claudius.heine.ext
                   ` (6 preceding siblings ...)
  2019-04-09 12:29 ` [PATCH v2 7/8] meta/classes/image*: refactor image pipeline and image.bbclass claudius.heine.ext
@ 2019-04-09 12:29 ` claudius.heine.ext
  2019-04-16  5:05 ` [PATCH v2 0/8] Implement ROOTFS postprocess commands Maxim Yu. Osipov
  8 siblings, 0 replies; 10+ messages in thread
From: claudius.heine.ext @ 2019-04-09 12:29 UTC (permalink / raw)
  To: isar-users; +Cc: Claudius Heine

From: Claudius Heine <ch@denx.de>

Signed-off-by: Claudius Heine <ch@denx.de>
---
 meta/classes/image-postproc-extension.bbclass | 46 +++++++++++
 meta/classes/image.bbclass                    | 76 ++-----------------
 meta/classes/rootfs.bbclass                   | 58 ++++++++++++++
 3 files changed, 112 insertions(+), 68 deletions(-)
 create mode 100644 meta/classes/image-postproc-extension.bbclass
 create mode 100644 meta/classes/rootfs.bbclass

diff --git a/meta/classes/image-postproc-extension.bbclass b/meta/classes/image-postproc-extension.bbclass
new file mode 100644
index 0000000..625ba7d
--- /dev/null
+++ b/meta/classes/image-postproc-extension.bbclass
@@ -0,0 +1,46 @@
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2019
+
+update_etc_os_release() {
+    OS_RELEASE_BUILD_ID=""
+    OS_RELEASE_VARIANT=""
+    while true; do
+        case "$1" in
+        --build-id) OS_RELEASE_BUILD_ID=$2; shift ;;
+        --variant) OS_RELEASE_VARIANT=$2; shift ;;
+        -*) bbfatal "$0: invalid option specified: $1" ;;
+        *) break ;;
+        esac
+        shift
+    done
+
+    if [ -n "${OS_RELEASE_BUILD_ID}" ]; then
+        sudo sed -i '/^BUILD_ID=.*/d' '${IMAGE_ROOTFS}/etc/os-release'
+        echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \
+            sudo tee -a '${IMAGE_ROOTFS}/etc/os-release'
+    fi
+    if [ -n "${OS_RELEASE_VARIANT}" ]; then
+        sudo sed -i '/^VARIANT=.*/d' '${IMAGE_ROOTFS}/etc/os-release'
+        echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \
+            sudo tee -a '${IMAGE_ROOTFS}/etc/os-release'
+    fi
+}
+
+ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_configure image_postprocess_mark"
+
+image_postprocess_configure() {
+    # Configure root filesystem
+    if [ -n "${DISTRO_CONFIG_SCRIPT}" ]; then
+        sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}"
+        TARGET_DISTRO_CONFIG_SCRIPT="$(basename ${DISTRO_CONFIG_SCRIPT})"
+        sudo chroot ${IMAGE_ROOTFS} "/$TARGET_DISTRO_CONFIG_SCRIPT" \
+                                    "${MACHINE_SERIAL}" "${BAUDRATE_TTY}"
+        sudo rm "${IMAGE_ROOTFS}/$TARGET_DISTRO_CONFIG_SCRIPT"
+   fi
+}
+
+image_postprocess_mark() {
+    BUILD_ID=$(get_build_id)
+    update_etc_os_release \
+        --build-id "${BUILD_ID}" --variant "${DESCRIPTION}"
+}
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index bbfb80d..f9a3052 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -54,9 +54,12 @@ image_do_mounts() {
 }
 
 inherit isar-bootstrap-helper
+ROOTFS_FEATURES += "finalize-rootfs"
+inherit rootfs
 inherit image-sdk-extension
 inherit image-cache-extension
 inherit image-tools-extension
+inherit image-postproc-extension
 
 # Extra space for rootfs in MB
 ROOTFS_EXTRA ?= "64"
@@ -118,7 +121,7 @@ python set_image_size () {
     d.setVarFlag('ROOTFS_SIZE', 'export', '1')
 }
 
-isar_image_gen_fstab() {
+do_image_gen_fstab() {
     cat > ${WORKDIR}/fstab << EOF
 # Begin /etc/fstab
 /dev/root	/		auto		defaults		0	0
@@ -131,70 +134,19 @@ devtmpfs	/dev		devtmpfs	mode=0755,nosuid	0	0
 # End /etc/fstab
 EOF
 }
-
-isar_image_gen_rootfs() {
-    setup_root_file_system --clean --keep-apt-cache \
-        --fstab "${WORKDIR}/fstab" \
-        "${IMAGE_ROOTFS}" ${IMAGE_PREINSTALL} ${IMAGE_INSTALL}
-}
-
-isar_image_conf_rootfs() {
-    # Configure root filesystem
-    if [ -n "${DISTRO_CONFIG_SCRIPT}" ]; then
-        sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}"
-        TARGET_DISTRO_CONFIG_SCRIPT="$(basename ${DISTRO_CONFIG_SCRIPT})"
-        sudo chroot ${IMAGE_ROOTFS} "/$TARGET_DISTRO_CONFIG_SCRIPT" \
-                                    "${MACHINE_SERIAL}" "${BAUDRATE_TTY}"
-        sudo rm "${IMAGE_ROOTFS}/$TARGET_DISTRO_CONFIG_SCRIPT"
-   fi
-}
-
-isar_image_cleanup() {
-    # Cleanup
-    sudo sh -c ' \
-        rm "${IMAGE_ROOTFS}/etc/apt/sources.list.d/isar-apt.list"
-        test ! -e "${IMAGE_ROOTFS}/usr/share/doc/qemu-user-static" && \
-            find "${IMAGE_ROOTFS}/usr/bin" \
-                -maxdepth 1 -name 'qemu-*-static' -type f -delete
-             umount -l ${IMAGE_ROOTFS}/isar-apt
-        rmdir ${IMAGE_ROOTFS}/isar-apt
-        umount -l ${IMAGE_ROOTFS}/dev
-        umount -l ${IMAGE_ROOTFS}/proc
-        umount -l ${IMAGE_ROOTFS}/sys
-        rm -f "${IMAGE_ROOTFS}/etc/apt/apt.conf.d/55isar-fallback.conf"
-        if [ "${ISAR_USE_CACHED_BASE_REPO}" = "1" ]; then
-            umount -l ${IMAGE_ROOTFS}/base-apt
-            rmdir ${IMAGE_ROOTFS}/base-apt
-            # Replace the local apt we bootstrapped with the
-            # APT sources initially defined in DISTRO_APT_SOURCES
-            rm -f "${IMAGE_ROOTFS}/etc/apt/sources.list.d/base-apt.list"
-            mv "${IMAGE_ROOTFS}/etc/apt/sources-list" \
-                "${IMAGE_ROOTFS}/etc/apt/sources.list.d/bootstrap.list"
-        fi
-        rm -f "${IMAGE_ROOTFS}/etc/apt/sources-list"
-    '
-}
+addtask image_gen_fstab before do_rootfs_install
 
 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_install() {
-    isar_image_gen_fstab
-    isar_image_gen_rootfs
-    isar_image_conf_rootfs
-    isar_image_cleanup
+    setup_root_file_system --clean --keep-apt-cache \
+        --fstab "${WORKDIR}/fstab" \
+        "${IMAGE_ROOTFS}" ${IMAGE_PREINSTALL} ${IMAGE_INSTALL}
 }
 addtask rootfs_install before do_build after do_unpack
 
-do_mark_rootfs() {
-    BUILD_ID=$(get_build_id)
-    update_etc_os_release \
-        --build-id "${BUILD_ID}" --variant "${DESCRIPTION}" \
-        "${IMAGE_ROOTFS}"
-}
-addtask mark_rootfs before do_rootfs_postprocess after do_rootfs_install
-
 do_copy_boot_files[dirs] = "${DEPLOY_DIR_IMAGE}"
 do_copy_boot_files() {
     if [ -n "${KERNEL_IMAGE}" ]; then
@@ -219,18 +171,6 @@ do_copy_boot_files() {
 }
 addtask copy_boot_files before do_rootfs_postprocess after do_rootfs_install
 
-python do_rootfs_postprocess() {
-    """Virtual task"""
-    pass
-}
-addtask rootfs_postprocess before do_build after do_rootfs_install
-
-python do_rootfs() {
-    """Virtual task"""
-    pass
-}
-addtask rootfs before do_build after do_rootfs_postprocess
-
 python do_image_tools() {
     """Virtual task"""
     pass
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass
new file mode 100644
index 0000000..45b0350
--- /dev/null
+++ b/meta/classes/rootfs.bbclass
@@ -0,0 +1,58 @@
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2019
+
+# Features of the rootfs creation:
+# available features are:
+# 'finalize-rootfs' - delete files needed to chroot into the rootfs
+ROOTFS_FEATURES ?= ""
+
+ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'finalize-rootfs', 'rootfs_postprocess_finalize', '', d)}"
+rootfs_postprocess_finalize() {
+    sudo -s <<'EOSUDO'
+        test ! -e "${ROOTFSDIR}/usr/share/doc/qemu-user-static" && \
+            find "${ROOTFSDIR}/usr/bin" \
+                -maxdepth 1 -name 'qemu-*-static' -type f -delete
+
+        mountpoint -q '${ROOTFSDIR}/isar-apt' && \
+            umount -l ${ROOTFSDIR}/isar-apt
+        rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/isar-apt
+
+        mountpoint -q '${ROOTFSDIR}/base-apt' && \
+            umount -l ${ROOTFSDIR}/base-apt
+        rmdir --ignore-fail-on-non-empty ${ROOTFSDIR}/base-apt
+
+        mountpoint -q '${ROOTFSDIR}/dev' && \
+            umount -l ${ROOTFSDIR}/dev
+        mountpoint -q '${ROOTFSDIR}/sys' && \
+            umount -l ${ROOTFSDIR}/proc
+        mountpoint -q '${ROOTFSDIR}/sys' && \
+            umount -l ${ROOTFSDIR}/sys
+
+        rm -f "${ROOTFSDIR}/etc/apt/apt.conf.d/55isar-fallback.conf"
+
+        rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/isar-apt.list"
+        rm -f "${ROOTFSDIR}/etc/apt/sources.list.d/base-apt.list"
+
+        mv "${ROOTFSDIR}/etc/apt/sources-list" \
+            "${ROOTFSDIR}/etc/apt/sources.list.d/bootstrap.list"
+
+        rm -f "${ROOTFSDIR}/etc/apt/sources-list"
+EOSUDO
+}
+
+do_rootfs_postprocess[vardeps] = "${ROOTFS_POSTPROCESS_COMMAND}"
+python do_rootfs_postprocess() {
+    cmds = d.getVar("ROOTFS_POSTPROCESS_COMMAND")
+    if cmds is None or not cmds.strip():
+        return
+    cmds = cmds.split()
+    for cmd in cmds:
+        bb.build.exec_func(cmd, d)
+}
+addtask rootfs_postprocess before do_rootfs after do_rootfs_install
+
+python do_rootfs() {
+    """Virtual task"""
+    pass
+}
+addtask rootfs before do_build
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 0/8] Implement ROOTFS postprocess commands
  2019-04-09 12:29 [PATCH v2 0/8] Implement ROOTFS postprocess commands claudius.heine.ext
                   ` (7 preceding siblings ...)
  2019-04-09 12:29 ` [PATCH v2 8/8] meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND claudius.heine.ext
@ 2019-04-16  5:05 ` Maxim Yu. Osipov
  8 siblings, 0 replies; 10+ messages in thread
From: Maxim Yu. Osipov @ 2019-04-16  5:05 UTC (permalink / raw)
  To: claudius.heine.ext, isar-users; +Cc: Claudius Heine

On 4/9/19 2:29 PM, claudius.heine.ext@siemens.com wrote:
> From: Claudius Heine <ch@denx.de>
> 
> Hi,
> 
> this is version 2 of the ROOTFS postprocess patchset.
> 
> I merged the 'Clean image pipeline' into this one, since they were developed
> and tested together.
> 
> Changes from v2:
>   - rebased on current next
>   - some more cleanup and refactoring patches added
>   - some changes to the postprocess patch, to better prepare for the
>     preprocessing patchset that will follow soon.

Appplied to the 'next'.

Maxim.

> Claudius Heine (8):
>    image.bbclass: make KERNEL_IMAGE & INITRD_IMAGE variable fixed
>    image.bbclass: limit `du` to only one file system
>    meta/classes/targz-img: limit tarball creation to one file system
>    meta/classes/buildchroot: add check before each mounting and quotes
>    meta/image classes: refactor task stamps
>    meta/classes/*-img: remove 'inherit image' statements
>    meta/classes/image*: refactor image pipeline and image.bbclass
>    meta/classes/image: implement ROOTFS_POSTPROCESS_COMMAND
> 
>   meta/classes/buildchroot.bbclass              |  25 ++-
>   meta/classes/ext4-img.bbclass                 |   4 +-
>   meta/classes/fit-img.bbclass                  |   7 +-
>   meta/classes/image-cache-extension.bbclass    |  26 +++
>   meta/classes/image-postproc-extension.bbclass |  46 ++++
>   meta/classes/image-sdk-extension.bbclass      |  36 ++++
>   meta/classes/image-tools-extension.bbclass    |  43 ++++
>   meta/classes/image.bbclass                    | 203 ++++--------------
>   meta/classes/rootfs.bbclass                   |  58 +++++
>   meta/classes/targz-img.bbclass                |   6 +-
>   meta/classes/ubi-img.bbclass                  |   7 +-
>   meta/classes/ubifs-img.bbclass                |   6 +-
>   meta/classes/wic-img.bbclass                  |   8 +-
>   13 files changed, 267 insertions(+), 208 deletions(-)
>   create mode 100644 meta/classes/image-cache-extension.bbclass
>   create mode 100644 meta/classes/image-postproc-extension.bbclass
>   create mode 100644 meta/classes/image-sdk-extension.bbclass
>   create mode 100644 meta/classes/image-tools-extension.bbclass
>   create mode 100644 meta/classes/rootfs.bbclass
> 


-- 
Maxim Osipov
ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn
Germany
+49 (151) 6517 6917
mosipov@ilbers.de
http://ilbers.de/
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-04-16  5:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 7/8] meta/classes/image*: refactor image pipeline and image.bbclass claudius.heine.ext
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox