public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Cedric Hombourger <Cedric_Hombourger@mentor.com>
To: <isar-users@googlegroups.com>
Cc: Cedric Hombourger <Cedric_Hombourger@mentor.com>
Subject: [PATCH v2 1/2] isar-image-base: introduce and use isar-image class
Date: Wed, 31 Oct 2018 07:10:24 +0100	[thread overview]
Message-ID: <20181031061025.28840-2-Cedric_Hombourger@mentor.com> (raw)
In-Reply-To: <20181031061025.28840-1-Cedric_Hombourger@mentor.com>

Provide an isar-image class to ease the creation of custom image recipes.
A second objective behind this change is for recipes (.bb files) to only
contain meta-data: no code/scripts.

Signed-off-by: Cedric Hombourger <Cedric_Hombourger@mentor.com>
---
 doc/user_manual.md                                 | 33 ++++++++++++
 meta-isar/classes/isar-image.bbclass               | 59 ++++++++++++++++++++++
 .../files => conf/distro}/debian-configscript.sh   |  0
 .../files => conf/distro}/raspbian-configscript.sh |  0
 meta-isar/recipes-core/images/isar-image-base.bb   | 57 ++-------------------
 5 files changed, 95 insertions(+), 54 deletions(-)
 create mode 100644 meta-isar/classes/isar-image.bbclass
 rename meta-isar/{recipes-core/images/files => conf/distro}/debian-configscript.sh (100%)
 rename meta-isar/{recipes-core/images/files => conf/distro}/raspbian-configscript.sh (100%)

diff --git a/doc/user_manual.md b/doc/user_manual.md
index 42bcd6b..b702c28 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -496,6 +496,39 @@ Packages in the `IMAGE_TRANSIENT_PACKAGES` variable are installed to the image a
 
 ---
 
+## Create a Custom Image Recipe
+
+A custom image recipe may be created to assemble packages of your choice into a root file-system image. The `isar-image` class
+implements a `do_rootfs` function to compile and configure the file-system for you. Prebuilt packages may be selected for
+installation by appending them to the `IMAGE_PREINSTALL` variable while packages created by ISAR should be appended to
+`IMAGE_INSTALL`. A sample image recipe follows.
+
+### Example
+```
+DESCRIPTION = "Sample image recipe for ISAR"
+
+LICENSE = "gpl-2.0"
+LIC_FILES_CHKSUM = "file://${LAYERDIR_isar}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
+
+PV = "1.0"
+
+IMAGE_PREINSTALL = " \
+    openssh-server   \
+"
+
+inherit isar-image
+
+```
+
+### Additional Notes
+
+The distribution selected via the `DISTRO` variable may need to run a post-configuration script after the root file-system
+was assembled. Isar provides scripts for Debian and Raspbian. In the event where a different Debian-based distribution is
+used, your custom image recipe may need to set `DISTRO_CONFIG_SCRIPT` and use `SRC_URI` and `FILESPATH` for the script to
+be copied into the work directory (`WORKDIR`).
+
+---
+
 ## Add a Custom Application
 
 Before creating a new recipe it's highly recommended to take a look into the BitBake user manual mentioned in Terms and Definitions section.
diff --git a/meta-isar/classes/isar-image.bbclass b/meta-isar/classes/isar-image.bbclass
new file mode 100644
index 0000000..ec2b9e3
--- /dev/null
+++ b/meta-isar/classes/isar-image.bbclass
@@ -0,0 +1,59 @@
+# Root filesystem for target installation
+#
+# This software is a part of ISAR.
+# Copyright (C) 2015-2018 ilbers GmbH
+
+inherit image
+inherit isar-bootstrap-helper
+
+FILESPATH =. "${LAYERDIR_isar}/conf/distro:"
+SRC_URI += "${@ 'file://${DISTRO_CONFIG_SCRIPT}' if '${DISTRO_CONFIG_SCRIPT}' else '' }"
+
+DEPENDS += "${IMAGE_INSTALL} ${IMAGE_TRANSIENT_PACKAGES}"
+
+IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
+
+WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
+
+ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags --dirty --match 'v[0-9].[0-9]*'"
+ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
+
+do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
+                             ${IMAGE_ROOTFS}/isar-apt"
+
+do_rootfs() {
+    cat > ${WORKDIR}/fstab << EOF
+# Begin /etc/fstab
+/dev/root	/		auto		defaults		0	0
+proc		/proc		proc		nosuid,noexec,nodev	0	0
+sysfs		/sys		sysfs		nosuid,noexec,nodev	0	0
+devpts		/dev/pts	devpts		gid=5,mode=620		0	0
+tmpfs		/run		tmpfs		defaults		0	0
+devtmpfs	/dev		devtmpfs	mode=0755,nosuid	0	0
+
+# End /etc/fstab
+EOF
+
+    setup_root_file_system --clean --keep-apt-cache \
+        --fstab "${WORKDIR}/fstab" \
+        "${IMAGE_ROOTFS}" ${IMAGE_PREINSTALL} ${IMAGE_INSTALL}
+
+    # Configure root filesystem
+    if [ -n "${DISTRO_CONFIG_SCRIPT}" ]; then
+        sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}"
+        sudo chroot ${IMAGE_ROOTFS} /${DISTRO_CONFIG_SCRIPT} "${MACHINE_SERIAL}" \
+                                                             "${BAUDRATE_TTY}"
+        sudo rm "${IMAGE_ROOTFS}/${DISTRO_CONFIG_SCRIPT}"
+   fi
+
+    # Cleanup
+    sudo rm "${IMAGE_ROOTFS}/etc/apt/sources.list.d/isar-apt.list"
+    test ! -e "${IMAGE_ROOTFS}/usr/share/doc/qemu-user-static" && \
+         sudo find "${IMAGE_ROOTFS}/usr/bin" \
+              -maxdepth 1 -name 'qemu-*-static' -type f -delete
+    sudo umount -l ${IMAGE_ROOTFS}/isar-apt
+    sudo rmdir ${IMAGE_ROOTFS}/isar-apt
+    sudo umount -l ${IMAGE_ROOTFS}/dev
+    sudo umount -l ${IMAGE_ROOTFS}/proc
+    sudo rm -f "${IMAGE_ROOTFS}/etc/apt/apt.conf.d/55isar-fallback.conf"
+}
diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/conf/distro/debian-configscript.sh
similarity index 100%
rename from meta-isar/recipes-core/images/files/debian-configscript.sh
rename to meta-isar/conf/distro/debian-configscript.sh
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/conf/distro/raspbian-configscript.sh
similarity index 100%
rename from meta-isar/recipes-core/images/files/raspbian-configscript.sh
rename to meta-isar/conf/distro/raspbian-configscript.sh
diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index bf606cc..074e566 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -1,64 +1,13 @@
-# Root filesystem for target installation
+# Base image recipe for ISAR
 #
 # This software is a part of ISAR.
-# Copyright (C) 2015-2017 ilbers GmbH
+# Copyright (C) 2015-2018 ilbers GmbH
 
 DESCRIPTION = "Isar target filesystem"
 
 LICENSE = "gpl-2.0"
 LIC_FILES_CHKSUM = "file://${LAYERDIR_isar}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
 
-FILESPATH =. "${LAYERDIR_isar}/recipes-core/images/files:"
-SRC_URI = "file://${DISTRO_CONFIG_SCRIPT}"
-
 PV = "1.0"
 
-inherit image
-inherit isar-bootstrap-helper
-
-DEPENDS += "${IMAGE_INSTALL} ${IMAGE_TRANSIENT_PACKAGES}"
-
-IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
-
-WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
-
-ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags --dirty --match 'v[0-9].[0-9]*'"
-ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
-
-do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
-                             ${IMAGE_ROOTFS}/isar-apt"
-
-do_rootfs() {
-    cat > ${WORKDIR}/fstab << EOF
-# Begin /etc/fstab
-/dev/root	/		auto		defaults		0	0
-proc		/proc		proc		nosuid,noexec,nodev	0	0
-sysfs		/sys		sysfs		nosuid,noexec,nodev	0	0
-devpts		/dev/pts	devpts		gid=5,mode=620		0	0
-tmpfs		/run		tmpfs		defaults		0	0
-devtmpfs	/dev		devtmpfs	mode=0755,nosuid	0	0
-
-# End /etc/fstab
-EOF
-
-    setup_root_file_system --clean --keep-apt-cache \
-        --fstab "${WORKDIR}/fstab" \
-        "${IMAGE_ROOTFS}" ${IMAGE_PREINSTALL} ${IMAGE_INSTALL}
-
-    # Configure root filesystem
-    sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}"
-    sudo chroot ${IMAGE_ROOTFS} /${DISTRO_CONFIG_SCRIPT} ${MACHINE_SERIAL} \
-                                                         ${BAUDRATE_TTY}
-
-    # Cleanup
-    sudo rm "${IMAGE_ROOTFS}/${DISTRO_CONFIG_SCRIPT}"
-    sudo rm "${IMAGE_ROOTFS}/etc/apt/sources.list.d/isar-apt.list"
-    test ! -e "${IMAGE_ROOTFS}/usr/share/doc/qemu-user-static" && \
-         sudo find "${IMAGE_ROOTFS}/usr/bin" \
-              -maxdepth 1 -name 'qemu-*-static' -type f -delete
-    sudo umount -l ${IMAGE_ROOTFS}/isar-apt
-    sudo rmdir ${IMAGE_ROOTFS}/isar-apt
-    sudo umount -l ${IMAGE_ROOTFS}/dev
-    sudo umount -l ${IMAGE_ROOTFS}/proc
-    sudo rm -f "${IMAGE_ROOTFS}/etc/apt/apt.conf.d/55isar-fallback.conf"
-}
+inherit isar-image
-- 
2.11.0


  reply	other threads:[~2018-10-31  6:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 16:12 [PATCH 0/4] add support for OE's ROOTFS_*_COMMAND Cedric Hombourger
2018-10-29 16:13 ` [PATCH 1/4] isar-image-base: introduce and use isar-image class Cedric Hombourger
2018-11-09 13:42   ` Baurzhan Ismagulov
2018-10-29 16:13 ` [PATCH 2/4] isar-image: refactor do_rootfs() Cedric Hombourger
2018-11-29 15:06   ` Jan Kiszka
2018-10-29 16:13 ` [PATCH 3/4] base: add 'lib' folder of each layer to python's module search path Cedric Hombourger
2018-10-29 16:13 ` [PATCH 4/4] isar-image: add support for OE's ROOTFS_*_COMMAND Cedric Hombourger
2018-10-29 16:45 ` [PATCH 0/4] " Henning Schild
2018-10-29 16:55   ` Hombourger, Cedric
2018-10-30  9:25     ` Henning Schild
2018-10-30 11:02       ` Hombourger, Cedric
2018-10-30 12:41         ` Henning Schild
2018-10-30 12:45           ` Hombourger, Cedric
2018-10-31  6:10           ` [PATCH v2 0/2] introduce isar-image class Cedric Hombourger
2018-10-31  6:10             ` Cedric Hombourger [this message]
2018-10-31  6:10             ` [PATCH v2 2/2] isar-image: refactor do_rootfs() Cedric Hombourger
2018-10-31  6:39             ` [PATCH v2 0/2] introduce isar-image class Jan Kiszka
2018-10-31  6:51               ` chombourger
2018-11-01 11:43                 ` Maxim Yu. Osipov
2018-11-09 13:26                 ` Baurzhan Ismagulov
2018-11-01 10:13               ` [PATCH v3 1/2] isar-image-base: introduce and use " Cedric Hombourger
2018-11-01 10:13                 ` [PATCH v3 2/2] isar-image: refactor do_rootfs() Cedric Hombourger
2018-11-07 13:20                   ` Jan Kiszka
2018-11-08  7:59                     ` Hombourger, Cedric
2018-11-08  8:28                       ` Jan Kiszka
2018-11-07 18:45                   ` Henning Schild
2018-11-07 19:46                     ` Cedric Hombourger
2018-11-07 20:16                       ` Cedric Hombourger
2018-11-08  6:52                         ` Jan Kiszka
2018-11-08  8:13                         ` Henning Schild
2018-11-07 13:07                 ` [PATCH v3 1/2] isar-image-base: introduce and use isar-image class 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=20181031061025.28840-2-Cedric_Hombourger@mentor.com \
    --to=cedric_hombourger@mentor.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