All of lore.kernel.org
 help / color / mirror / Atom feed
* [OE-core][RFC][PATCH][dunfell] wic: direct: Use stock fstab in partitions
@ 2021-08-05 15:03 Daniel Gomez
  2021-08-05 15:31 ` Richard Purdie
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Gomez @ 2021-08-05 15:03 UTC (permalink / raw)
  To: openembedded-core; +Cc: dagmcr, Daniel Gomez

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-06 13:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-05 15:03 [OE-core][RFC][PATCH][dunfell] wic: direct: Use stock fstab in partitions Daniel Gomez
2021-08-05 15:31 ` 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

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.