public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: dani.barra25@gmail.com
To: openembedded-core@lists.openembedded.org
Cc: hongxu.jia@windriver.com, trevor.woerner@linaro.org,
	Daniel Andrade <dani.barra25@gmail.com>
Subject: [PATCH 1/1] wic: Content of the temporary updated fstab should be copied into the original not replacing it entirely.
Date: Tue,  2 Sep 2025 20:05:55 +0100	[thread overview]
Message-ID: <20250902190555.7929-2-dani.barra25@gmail.com> (raw)
In-Reply-To: <20250902190555.7929-1-dani.barra25@gmail.com>

From: Daniel Andrade <dani.barra25@gmail.com>

Fixes [15947]
The current functionality to update fstab generates a new temporary fstab with the new partition configuration.
However, this file does not retain any metadata being it a completely new file.
Because of this, when the rootfs plugin under `poky/scripts/lib/wic/plugins/source/rootfs.py` copies the file, it overrides the original fstab metadata.
The patch removes implementation of msdos/ext code for fstab since it is not possible to append content without rewriting the file to preserve metadata.

The timestamp applied to fstab is not the same as every other file.
It seems like the `SOURCE_DATE_EPOCH` variable goes to the fallback timestamp SOURCE_DATE_EPOCH_FALLBACK.
Since that variable is used everywhere, it is not the same value as REPRODUCIBLE_TIMESTAMP_ROOTFS under poky/meta/conf/bitbake.conf that is applied in every other file.

Signed-off-by: Daniel Andrade <dani.barra25@gmail.com>
---
 meta/conf/bitbake.conf                   |  4 +++-
 scripts/lib/wic/partition.py             | 15 +--------------
 scripts/lib/wic/plugins/source/rootfs.py |  4 ++--
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index acf4e2d153..0581fc3564 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -684,8 +684,10 @@ export PYTHONHASHSEED = "0"
 export PERL_HASH_SEED = "0"
 export SOURCE_DATE_EPOCH ?= "${@get_source_date_epoch_value(d)}"
 # A SOURCE_DATE_EPOCH of '0' might be misinterpreted as no SDE
+# If these 2 are misaligned, when generating fstab later on wic, the timestamps will never match because
+# The repeatibility uses the REPRODUCIBLE_TIMESTAMP_ROOTFS while wic uses SOURCE_DATE_EPOCH (therefore its fallback)
 SOURCE_DATE_EPOCH_FALLBACK ??= "1302044400"
-REPRODUCIBLE_TIMESTAMP_ROOTFS ??= "1520598896"
+REPRODUCIBLE_TIMESTAMP_ROOTFS ??= "1302044400"
 
 ##################################################################
 # Settings used by bitbake-layers.
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index bf2c34d594..82d754835c 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -131,7 +131,7 @@ class Partition():
         partition command parameters.
         """
         self.updated_fstab_path = updated_fstab_path
-        if self.updated_fstab_path and not (self.fstype.startswith("ext") or self.fstype == "msdos"):
+        if self.updated_fstab_path:
             self.update_fstab_in_rootfs = True
 
         if not self.source:
@@ -295,15 +295,6 @@ class Partition():
             (self.fstype, extraopts, rootfs, label_str, self.fsuuid, rootfs_dir)
         exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
 
-        if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update:
-            debugfs_script_path = os.path.join(cr_workdir, "debugfs_script")
-            with open(debugfs_script_path, "w") as f:
-                f.write("cd etc\n")
-                f.write("rm fstab\n")
-                f.write("write %s fstab\n" % (self.updated_fstab_path))
-            debugfs_cmd = "debugfs -w -f %s %s" % (debugfs_script_path, rootfs)
-            exec_native_cmd(debugfs_cmd, native_sysroot)
-
         mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs)
         exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
 
@@ -400,10 +391,6 @@ class Partition():
         mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir)
         exec_native_cmd(mcopy_cmd, native_sysroot)
 
-        if self.updated_fstab_path and self.has_fstab and not self.no_fstab_update:
-            mcopy_cmd = "mcopy -m -i %s %s ::/etc/fstab" % (rootfs, self.updated_fstab_path)
-            exec_native_cmd(mcopy_cmd, native_sysroot)
-
         chmod_cmd = "chmod 644 %s" % rootfs
         exec_cmd(chmod_cmd)
 
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index e29f3a4c2f..3848af2a91 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -223,8 +223,8 @@ class RootfsPlugin(SourcePlugin):
             part.has_fstab = os.path.exists(os.path.join(new_rootfs, "etc/fstab"))
             if part.update_fstab_in_rootfs and part.has_fstab and not part.no_fstab_update:
                 fstab_path = os.path.join(new_rootfs, "etc/fstab")
-                # Assume that fstab should always be owned by root with fixed permissions
-                install_cmd = "install -m 0644 -p %s %s" % (part.updated_fstab_path, fstab_path)
+                # We dont want any metadata of the updated fstab, just the one that already existed
+                install_cmd = "cp --no-preserve=all %s %s" % (part.updated_fstab_path, fstab_path)
                 if new_pseudo:
                     pseudo = cls.__get_pseudo(native_sysroot, new_rootfs, new_pseudo)
                 else:


  reply	other threads:[~2025-09-03 11:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02 19:05 [PATCH 0/1] wic: updated fstab does not preserve metadata of the original file dani.barra25
2025-09-02 19:05 ` dani.barra25 [this message]
2025-10-11 13:18   ` [OE-core] [PATCH 1/1] wic: Content of the temporary updated fstab should be copied into the original not replacing it entirely Mathieu Dubois-Briand
2025-10-17 11:04     ` dani.barra25
2025-10-17 11:04       ` [PATCH 1/1] Fstab: Fix xattrs not being maintained on fstab file when using wic fstab update funtionalities dani.barra25
2025-10-19 10:02         ` Mathieu Dubois-Briand
     [not found]           ` <20251019153922.27208-1-dani.barra25@gmail.com>
2025-10-19 15:39             ` [PATCH] Fstab xattrs: This update ensures that fstab xattrs are correctly updated without adding a lock to the database dani.barra25
2025-10-20 12:09               ` [OE-core] " Alexander Kanavin
2025-10-20 13:18                 ` Daniel Andrade
2025-10-23 13:04                 ` Ross Burton
2025-10-19 15:41           ` [PATCH 1/1] Fstab: Fix xattrs not being maintained on fstab file when using wic fstab update funtionalities Daniel Andrade
2025-09-04 15:58 ` [OE-core] [PATCH 0/1] wic: updated fstab does not preserve metadata of the original file Mathieu Dubois-Briand
2025-09-11 16:56   ` Randy MacLeod
2025-09-13 10:02     ` Daniel Andrade
2025-09-23 15:05       ` Daniel Andrade
2025-09-23 18:44         ` Mathieu Dubois-Briand
2025-09-24 16:04           ` Daniel Andrade
2025-09-25  8:57             ` Mathieu Dubois-Briand
2025-09-25 11:11               ` Mathieu Dubois-Briand
2025-09-25 11:40                 ` Daniel Andrade

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=20250902190555.7929-2-dani.barra25@gmail.com \
    --to=dani.barra25@gmail.com \
    --cc=hongxu.jia@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=trevor.woerner@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox