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 1/2] meta: merges isar-image into image class
Date: Thu, 21 Mar 2019 12:57:39 +0100	[thread overview]
Message-ID: <20190321115740.17459-2-claudius.heine.ext@siemens.com> (raw)
In-Reply-To: <20190321115740.17459-1-claudius.heine.ext@siemens.com>

From: Claudius Heine <ch@denx.de>

(no functional change intended)

Signed-off-by: Claudius Heine <ch@denx.de>
---
 doc/user_manual.md              |  2 +-
 meta/classes/image.bbclass      | 86 +++++++++++++++++++++++++++++--
 meta/classes/isar-image.bbclass | 90 +--------------------------------
 3 files changed, 86 insertions(+), 92 deletions(-)

diff --git a/doc/user_manual.md b/doc/user_manual.md
index 6fe4d83..9ea3f42 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -516,7 +516,7 @@ 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
+A custom image recipe may be created to assemble packages of your choice into a root file-system image. The `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.
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index bebac6b..3ba755f 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -25,6 +25,24 @@ BUILDROOT_DEPLOY = "${BUILDCHROOT_DIR}${PP_DEPLOY}"
 BUILDROOT_ROOTFS = "${BUILDCHROOT_DIR}${PP_ROOTFS}"
 BUILDROOT_WORK = "${BUILDCHROOT_DIR}${PP_WORK}"
 
+def cfg_script(d):
+    cf = d.getVar('DISTRO_CONFIG_SCRIPT', True) or ''
+    if cf:
+        return 'file://' + cf
+    return ''
+
+FILESPATH =. "${LAYERDIR_core}/conf/distro:"
+SRC_URI += "${@ cfg_script(d) }"
+
+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}"
+
 image_do_mounts() {
     sudo flock ${MOUNT_LOCKFILE} -c ' \
         mkdir -p "${BUILDROOT_DEPLOY}" "${BUILDROOT_ROOTFS}" "${BUILDROOT_WORK}"
@@ -36,6 +54,7 @@ image_do_mounts() {
 }
 
 inherit ${IMAGE_TYPE}
+inherit isar-bootstrap-helper
 
 # Extra space for rootfs in MB
 ROOTFS_EXTRA ?= "64"
@@ -97,18 +116,79 @@ python set_image_size () {
     d.setVarFlag('ROOTFS_SIZE', 'export', '1')
 }
 
+isar_image_gen_fstab() {
+    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
+}
+
+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"
+    '
+}
+
 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"
+do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
+                             ${IMAGE_ROOTFS}/isar-apt"
 do_rootfs() {
-    die "No root filesystem function defined, please implement in your recipe"
+    isar_image_gen_fstab
+    isar_image_gen_rootfs
+    isar_image_conf_rootfs
+    isar_image_cleanup
 }
-
 addtask rootfs before do_build after do_unpack
-do_rootfs[deptask] = "do_deploy_deb"
 
 do_mark_rootfs() {
     BUILD_ID=$(get_build_id)
diff --git a/meta/classes/isar-image.bbclass b/meta/classes/isar-image.bbclass
index e7a5dee..1d5870b 100644
--- a/meta/classes/isar-image.bbclass
+++ b/meta/classes/isar-image.bbclass
@@ -1,92 +1,6 @@
-# Root filesystem for target installation
+# Class for backwards compatibility of images that use it
 #
 # This software is a part of ISAR.
 # Copyright (C) 2015-2018 ilbers GmbH
-
+# Copyright (c) Siemens AG, 2019
 inherit image
-inherit isar-bootstrap-helper
-
-def cfg_script(d):
-    cf = d.getVar('DISTRO_CONFIG_SCRIPT', True) or ''
-    if cf:
-        return 'file://' + cf
-    return ''
-
-FILESPATH =. "${LAYERDIR_core}/conf/distro:"
-SRC_URI += "${@ cfg_script(d) }"
-
-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}"
-
-do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
-                             ${IMAGE_ROOTFS}/isar-apt"
-
-isar_image_gen_fstab() {
-    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
-}
-
-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"
-    '
-}
-
-do_rootfs() {
-    isar_image_gen_fstab
-    isar_image_gen_rootfs
-    isar_image_conf_rootfs
-    isar_image_cleanup
-}
-- 
2.20.1


  reply	other threads:[~2019-03-21 11:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 11:57 [PATCH v2 0/2] Move " claudius.heine.ext
2019-03-21 11:57 ` claudius.heine.ext [this message]
2019-03-21 11:57 ` [PATCH v2 2/2] deprecate isar-image claudius.heine.ext
2019-03-28 12:45 ` [PATCH v2 0/2] Move isar-image into 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=20190321115740.17459-2-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