public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: [PATCH v2 4/6] Set up target image fstab prior to installing any packages
Date: Thu,  7 Jun 2018 16:30:57 +0200	[thread overview]
Message-ID: <a961383c8f086800b14883c9e5305108ae8e95b5.1528381858.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1528381858.git.jan.kiszka@siemens.com>
In-Reply-To: <cover.1528381858.git.jan.kiszka@siemens.com>

From: Jan Kiszka <jan.kiszka@siemens.com>

Package postinst hooks may need the fstab or may want to modify it,
including customization packages or the upcoming u-boot-script
generator. So extract the already identical setup pattern from the
distro config scripts, generate the fstab prior to calling
setup_root_file_system and let the latter inject the file before
starting the package installation. By specifying "-" as fstab file, we
can skip the injection for the buildchroot which does not need it.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../recipes-core/images/files/debian-configscript.sh | 14 --------------
 .../images/files/raspbian-configscript.sh            | 14 --------------
 meta-isar/recipes-core/images/isar-image-base.bb     | 20 +++++++++++++++-----
 meta/classes/isar-bootstrap-helper.bbclass           |  3 +++
 4 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
index 136918c..bcd5507 100755
--- a/meta-isar/recipes-core/images/files/debian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
@@ -7,20 +7,6 @@ set -e
 
 readonly MACHINE_SERIAL="$1"
 readonly BAUDRATE_TTY="$2"
-readonly ROOTFS_DEV="$3"
-readonly ROOTFS_TYPE="$4"
-
-cat > /etc/fstab << EOF
-# Begin /etc/fstab
-/dev/$ROOTFS_DEV	/		$ROOTFS_TYPE		defaults		1	1
-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
 
 # Create console device
 if [ ! -e /dev/console ]; then
diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
index 04ea571..3631c26 100644
--- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
+++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
@@ -7,20 +7,6 @@ set -e
 
 readonly MACHINE_SERIAL="$1"
 readonly BAUDRATE_TTY="$2"
-readonly ROOTFS_DEV="$3"
-readonly ROOTFS_TYPE="$4"
-
-cat > /etc/fstab << EOF
-# Begin /etc/fstab
-/dev/$ROOTFS_DEV	/		$ROOTFS_TYPE		defaults		1	1
-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
 
 # Enable tty conditionally, systemd does not have the file but its own magic
 if [ -f /etc/inittab ]; then
diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index 891f80a..6cdc6b2 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -28,15 +28,25 @@ do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
                              ${IMAGE_ROOTFS}/isar-apt"
 
 do_rootfs() {
-    setup_root_file_system --clean "${IMAGE_ROOTFS}" \
-        ${IMAGE_PREINSTALL} ${IMAGE_INSTALL}
+    cat > ${WORKDIR}/fstab << EOF
+# Begin /etc/fstab
+/dev/${ROOTFS_DEV}	/		${ROOTFS_TYPE}		defaults		1	1
+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 --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} \
-                                                         ${ROOTFS_DEV} \
-                                                         ${ROOTFS_TYPE}
+                                                         ${BAUDRATE_TTY}
 
     # Cleanup
     sudo rm "${IMAGE_ROOTFS}/${DISTRO_CONFIG_SCRIPT}"
diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
index 91dfc1a..3c10fc7 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -16,9 +16,11 @@ def reverse_bb_array(d, varname):
 
 setup_root_file_system() {
     CLEAN=""
+    FSTAB=""
     while true; do
         case "$1" in
         --clean) CLEAN=1 ;;
+        --fstab) FSTAB=$2; shift ;;
         -*) bbfatal "$0: invalid option specified: $1" ;;
         *) break ;;
         esac
@@ -33,6 +35,7 @@ setup_root_file_system() {
     sudo cp -Trpfx \
         "${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \
         "$ROOTFSDIR"
+    [ -n "${FSTAB}" ] && cat ${FSTAB} | sudo tee "$ROOTFSDIR/etc/fstab"
 
     echo "deb [trusted=yes] file:///isar-apt ${DEBDISTRONAME} main" | \
         sudo tee "$ROOTFSDIR/etc/apt/sources.list.d/isar-apt.list" >/dev/null
-- 
2.13.7


  parent reply	other threads:[~2018-06-07 14:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 14:30 [PATCH v2 0/6] Enable U-Boot-based images, add Banana Pi demo Jan Kiszka
2018-06-07 14:30 ` [PATCH v2 1/6] Add DISTRO and DISTRO_ARCH as OVERRIDES suffixes Jan Kiszka
2018-06-07 14:30 ` [PATCH v2 2/6] buildchroot: Break up wic build deps into common and arch-specific ones Jan Kiszka
2018-06-07 14:30 ` [PATCH v2 3/6] isar-bootstrap: Use options for setup_root_file_system() Jan Kiszka
2018-06-07 14:30 ` Jan Kiszka [this message]
2018-06-07 14:30 ` [PATCH v2 5/6] Add u-boot script generator Jan Kiszka
2018-06-07 14:30 ` [PATCH v2 6/6] Add Banana Pi SD-card image Jan Kiszka
2018-06-07 17:59 ` [PATCH v2 0/6] Enable U-Boot-based images, add Banana Pi demo Maxim Yu. Osipov
2018-06-11  5:38   ` Jan Kiszka
2018-06-08 18:10 ` 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=a961383c8f086800b14883c9e5305108ae8e95b5.1528381858.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@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