public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Henning Schild <henning.schild@siemens.com>
To: isar-users@googlegroups.com
Cc: Henning Schild <henning.schild@siemens.com>
Subject: [PATCH 2/3] classes: move rootfs into image class and split into tasks
Date: Tue,  1 Aug 2017 17:24:07 +0200	[thread overview]
Message-ID: <f2c84cbfeca24375a3dadda87b842cf8a4bae7b3.1501600807.git.henning.schild@siemens.com> (raw)
In-Reply-To: <cover.1501600807.git.henning.schild@siemens.com>
In-Reply-To: <cover.1501600807.git.henning.schild@siemens.com>

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta-isar/recipes-core/images/isar-image-base.bb | 39 ----------------
 meta/classes/image.bbclass                       | 58 +++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 41 deletions(-)

diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index 25682ed..5de30ac 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -18,42 +18,3 @@ DEPENDS += "${IMAGE_INSTALL}"
 
 IMAGE_PREINSTALL += "apt \
                      dbus"
-
-WORKDIR = "${TMPDIR}/work/${PN}/${MACHINE}"
-S = "${WORKDIR}/rootfs"
-IMAGE_ROOTFS = "${S}"
-
-do_rootfs[stamp-extra-info] = "${MACHINE}"
-
-do_rootfs() {
-    install -d -m 755 ${WORKDIR}/hooks_multistrap
-
-    # Copy config file
-    install -m 644 ${FILESDIR}/multistrap.conf.in ${WORKDIR}/multistrap.conf
-    install -m 755 ${FILESDIR}/${DISTRO_CONFIG_SCRIPT} ${WORKDIR}/configscript.sh
-    install -m 755 ${FILESDIR}/setup.sh ${WORKDIR}
-    install -m 755 ${FILESDIR}/download_dev-random ${WORKDIR}/hooks_multistrap/
-
-    # Adjust multistrap config
-    sed -i 's|##IMAGE_PREINSTALL##|${IMAGE_PREINSTALL}|' ${WORKDIR}/multistrap.conf
-    sed -i 's|##DISTRO##|${DISTRO}|' ${WORKDIR}/multistrap.conf
-    sed -i 's|##DISTRO_APT_SOURCE##|${DISTRO_APT_SOURCE}|' ${WORKDIR}/multistrap.conf
-    sed -i 's|##DISTRO_SUITE##|${DISTRO_SUITE}|' ${WORKDIR}/multistrap.conf
-    sed -i 's|##DISTRO_COMPONENTS##|${DISTRO_COMPONENTS}|' ${WORKDIR}/multistrap.conf
-    sed -i 's|##CONFIG_SCRIPT##|./tmp/work/${PN}/${MACHINE}/configscript.sh|' ${WORKDIR}/multistrap.conf
-    sed -i 's|##SETUP_SCRIPT##|./tmp/work/${PN}/${MACHINE}/setup.sh|' ${WORKDIR}/multistrap.conf
-    sed -i 's|##DIR_HOOKS##|./tmp/work/${PN}/${MACHINE}/hooks_multistrap|' ${WORKDIR}/multistrap.conf
-
-    # Multistrap config use relative paths, so ensure that we are in the right folder
-    cd ${TOPDIR}
-
-    # Create root filesystem
-    sudo multistrap -a ${DISTRO_ARCH} -d "${S}" -f "${WORKDIR}/multistrap.conf" || true
-
-    # Configure root filesystem
-    sudo chroot ${S} /configscript.sh ${MACHINE_SERIAL} ${BAUDRATE_TTY} \
-        ${ROOTFS_DEV}
-    sudo rm ${S}/configscript.sh
-}
-
-addtask rootfs before do_populate
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 3faa609..ab3d1ff 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -6,7 +6,60 @@ INITRD_IMAGE ?= ""
 
 IMAGE_INSTALL ?= ""
 
-do_populate[stamp-extra-info] = "${MACHINE}"
+WORKDIR = "${TMPDIR}/work/${PN}/${MACHINE}"
+S = "${WORKDIR}/rootfs"
+
+do_multistrap_conf() {
+    # Copy config file
+    install -m 644 ${FILESDIR}/multistrap.conf.in ${WORKDIR}/multistrap.conf
+    install -m 755 ${FILESDIR}/${DISTRO_CONFIG_SCRIPT} \
+        ${WORKDIR}/configscript.sh
+    install -m 755 ${FILESDIR}/setup.sh ${WORKDIR}
+    install -m 755 ${FILESDIR}/download_dev-random \
+        ${WORKDIR}/hooks_multistrap/
+
+    # Adjust multistrap config
+    sed -i 's|##IMAGE_PREINSTALL##|${IMAGE_PREINSTALL}|' \
+        ${WORKDIR}/multistrap.conf
+    sed -i 's|##DISTRO##|${DISTRO}|' ${WORKDIR}/multistrap.conf
+    sed -i 's|##DISTRO_APT_SOURCE##|${DISTRO_APT_SOURCE}|' \
+        ${WORKDIR}/multistrap.conf
+    sed -i 's|##DISTRO_SUITE##|${DISTRO_SUITE}|' ${WORKDIR}/multistrap.conf
+    sed -i 's|##DISTRO_COMPONENTS##|${DISTRO_COMPONENTS}|' \
+        ${WORKDIR}/multistrap.conf
+    sed -i 's|##CONFIG_SCRIPT##|./tmp/work/${PN}/${MACHINE}/configscript.sh|' \
+        ${WORKDIR}/multistrap.conf
+    sed -i 's|##SETUP_SCRIPT##|./tmp/work/${PN}/${MACHINE}/setup.sh|' \
+        ${WORKDIR}/multistrap.conf
+    sed -i 's|##DIR_HOOKS##|./tmp/work/${PN}/${MACHINE}/hooks_multistrap|' \
+        ${WORKDIR}/multistrap.conf
+}
+
+addtask multistrap_conf before do_build
+do_multistrap_conf[stamp-extra-info] = "${MACHINE}"
+do_multistrap_conf[dirs] = "${WORKDIR}/hooks_multistrap"
+
+do_multistrap() {
+    cd ${TOPDIR}
+
+    # Create root filesystem
+    sudo multistrap -a ${DISTRO_ARCH} -d "${S}" -f \
+        "${WORKDIR}/multistrap.conf" || true
+}
+
+addtask multistrap after do_multistrap_conf before do_build
+do_multistrap[stamp-extra-info] = "${MACHINE}"
+
+do_configure() {
+    cd ${TOPDIR}
+    # Configure root filesystem
+    sudo chroot ${S} /configscript.sh ${MACHINE_SERIAL} \
+        ${BAUDRATE_TTY} ${ROOTFS_DEV}
+    sudo rm ${S}/configscript.sh
+}
+
+addtask configure after do_multistrap before do_build
+do_configure[stamp-extra-info] = "${MACHINE}"
 
 # Install Debian packages, that were built from sources
 do_populate() {
@@ -23,5 +76,6 @@ do_populate() {
     fi
 }
 
-addtask populate before do_build
+addtask populate after do_configure before do_build
 do_populate[deptask] = "do_build"
+do_populate[stamp-extra-info] = "${MACHINE}"
-- 
2.13.0


  parent reply	other threads:[~2017-08-01 15:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-01 15:24 [PATCH 0/3] use local repo for multistrap and drop "dpkg -i" Henning Schild
2017-08-01 15:24 ` [PATCH 1/3] classes: images: remove cyclic "inherit" Henning Schild
2017-08-01 15:24 ` Henning Schild [this message]
2017-08-01 15:24 ` [PATCH 3/3] classes: image: remove populate and replace it with a custom repo Henning Schild
2017-08-09  6:21   ` Henning Schild
2017-08-02  6:16 ` [PATCH 0/3] use local repo for multistrap and drop "dpkg -i" Jan Kiszka
2017-08-02  7:04   ` Claudius Heine
2017-08-02  8:15     ` Henning Schild
2017-08-02  8:11   ` Henning Schild
2017-08-02  8:12 ` Henning Schild
2017-08-03 19:17   ` Henning Schild
2017-08-10 12:46 ` Baurzhan Ismagulov
2017-08-11  8:13   ` Henning Schild
2017-08-11 15:36     ` Baurzhan Ismagulov

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=f2c84cbfeca24375a3dadda87b842cf8a4bae7b3.1501600807.git.henning.schild@siemens.com \
    --to=henning.schild@siemens.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