]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkfs-util: set timezone to UTC when copying files into fat partition
authorMalte Poll <1780588+malt3@users.noreply.github.com>
Fri, 20 Oct 2023 12:59:41 +0000 (12:59 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 20 Oct 2023 15:15:52 +0000 (16:15 +0100)
mcopy will set the modification time of created directories to the mtime
of the source directories but converts it to the timezone of the host.
This behavior is identical to Windows / DOS:

>  The FAT file system stores time values based on the local time of the computer.

-- https://learn.microsoft.com/en-us/windows/win32/sysinfo/file-times

To achieve reproducible builds, mcopy should be invoked with TZ=UTC.

Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
src/shared/mkfs-util.c

index 89384d92df1ef47970658c4a21b1b7d9d1eebf44..e8356de2b7434d3c7c92eb463f9bc06b0c773921 100644 (file)
@@ -161,7 +161,7 @@ static int do_mcopy(const char *node, const char *root) {
         if (r == 0) {
                 /* Avoid failures caused by mismatch in expectations between mkfs.vfat and mcopy by disabling
                  * the stricter mcopy checks using MTOOLS_SKIP_CHECK. */
-                execve(mcopy, argv, STRV_MAKE("MTOOLS_SKIP_CHECK=1", strv_find_prefix(environ, "SOURCE_DATE_EPOCH=")));
+                execve(mcopy, argv, STRV_MAKE("MTOOLS_SKIP_CHECK=1", "TZ=UTC", strv_find_prefix(environ, "SOURCE_DATE_EPOCH=")));
 
                 log_error_errno(errno, "Failed to execute mcopy: %m");