All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel Gomez" <daniel@qtec.com>
To: openembedded-core@lists.openembedded.org
Cc: dagmcr@gmail.com, Daniel Gomez <daniel@qtec.com>
Subject: [OE-core][RFC][PATCH][dunfell] wic: direct: Use stock fstab in partitions
Date: Thu,  5 Aug 2021 17:03:07 +0200	[thread overview]
Message-ID: <20210805150307.56631-1-daniel@qtec.com> (raw)

Be able to get the stock fstab in partitions.

Functionality reverted at commit id:
ce682a73b7447652f898ce1d1d0416a456df5416

Signed-off-by: Daniel Gomez <daniel@qtec.com>
---

Hi,

I'm trying to get back the stock fstab file in a rootfs partition
image (wic plugin) and I'd like to know what you think about it.

Functionality was included before commit-id
ce682a73b7447652f898ce1d1d0416a456df5416 and removed afterwards. Would
it be possible to add it again? What would be needed to re-add it?

Thanks in advance,
Daniel

Here the relevant information:

wks definition:
part /boot/bootloader --source qbootimg-pcbios --active --align 1024 --use-uuid --fsoptions defaults,ro
part /export --source rootfs --rootfs-dir=hockeycam-image  --fstype=ext4 --label export --align 1024 --use-uuid --fsoptions defaults,ro --extra-space 400M
part /media/rw --fstype=ext4 --label rwfs --align 1024 --use-uuid --size 200
part / --source rootfs --fstype=ext4 --label rootfs --align 1024 --use-uuid --fsoptions defaults,ro --extra-space 400M

bootloader --timeout=1 --append="ro rootfstype=ext4 qtec_mem.size=64" --source qbootimg-pcbios

/export/etc/fstab before:
# stock fstab - you probably want to override this with a machine specific one

/dev/root            /                    auto       ro              1  0
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,ptmxmode=0666,gid=5      0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0

# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1       /media/card          auto       defaults,sync,noauto  0  0

/dev/sdb /mnt auto defaults 0 0
UUID=D339-7B77  /boot/bootloader        vfat    defaults,ro     0       0
UUID=31f46be1-d9fb-4081-bd53-2c2727e7854b       /export ext4    defaults,ro     0       0
UUID=d8e8f5d4-897e-48cd-9188-33598363f706       /media/rw       ext4    defaults        0       0

/export/etc/fstab after:
# stock fstab - you probably want to override this with a machine specific one

/dev/root            /                    auto       ro              1  0
proc                 /proc                proc       defaults              0  0
devpts               /dev/pts             devpts     mode=0620,ptmxmode=0666,gid=5      0  0
tmpfs                /run                 tmpfs      mode=0755,nodev,nosuid,strictatime 0  0
tmpfs                /var/volatile        tmpfs      defaults              0  0

# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1       /media/card          auto       defaults,sync,noauto  0  0

10.100.10.100:/mnt/rw /media/rw   nfs        defaults   0 0


 scripts/lib/wic/plugins/imager/direct.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 7e1c1c03ab..1bb9d38524 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -111,7 +111,15 @@ class DirectPlugin(ImagerPlugin):

         with open(fstab_path) as fstab:
             fstab_lines = fstab.readlines()
+            self.original_fstab = fstab_lines.copy()

+        if self._update_fstab(fstab_lines, self.parts):
+            with open(fstab_path, "w") as fstab:
+                fstab.writelines(fstab_lines)
+        else:
+            self.original_fstab = None
+
+    def _update_fstab(self, fstab_lines, parts):
         updated = False
         for part in self.parts:
             if not part.realnum or not part.mountpoint \
@@ -142,10 +150,7 @@ class DirectPlugin(ImagerPlugin):
             fstab_lines.append(line)
             updated = True

-        if updated:
-            self.updated_fstab_path = os.path.join(self.workdir, "fstab")
-            with open(self.updated_fstab_path, "w") as f:
-                f.writelines(fstab_lines)
+        return updated

     def _full_path(self, path, name, extention):
         """ Construct full file path to a file we generate. """
@@ -274,6 +279,13 @@ class DirectPlugin(ImagerPlugin):
             if os.path.isfile(path):
                 shutil.move(path, os.path.join(self.outdir, fname))

+
+        # Restore original fstab
+        if self.original_fstab:
+            fstab_path = self.rootfs_dir.get("ROOTFS_DIR") + "/etc/fstab"
+            with open(fstab_path, "w") as fstab:
+                fstab.writelines(self.original_fstab)
+
         # remove work directory
         shutil.rmtree(self.workdir, ignore_errors=True)

--
2.30.2


             reply	other threads:[~2021-08-05 15:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05 15:03 Daniel Gomez [this message]
2021-08-05 15:31 ` [OE-core][RFC][PATCH][dunfell] wic: direct: Use stock fstab in partitions Richard Purdie
2021-08-06  9:23   ` [OE-core][RFC][PATCH][dunfell] wic: Add --use-stock-fstab option Daniel Gomez
2021-08-06 10:02     ` Richard Purdie
2021-08-06 10:29     ` Paul Barker
2021-08-06 13:27       ` Daniel Gomez
2021-08-06  9:35   ` [OE-core][RFC][PATCH][dunfell] wic: direct: Use stock fstab in partitions Daniel Gomez

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=20210805150307.56631-1-daniel@qtec.com \
    --to=daniel@qtec.com \
    --cc=dagmcr@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.