mkfs-utils: also set $E2FSPROGS_FAKE_TIME if $SOURCE_DATE_EPOCH is set
Follow-up for 7bf0d0c46e.
To support e2fsprogs older than v1.47.1 (released 2024-05-21).
Suggested-by: ZauberNerd <zaubernerd@zaubernerd.de>
This commit is contained in:
+13
-1
@@ -453,12 +453,24 @@ int make_filesystem(
|
||||
|
||||
if (sector_size > 0) {
|
||||
if (strv_extend(&env, "MKE2FS_DEVICE_SECTSIZE") < 0)
|
||||
return log_oom();
|
||||
return log_oom();
|
||||
|
||||
if (strv_extendf(&env, "%"PRIu64, sector_size) < 0)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
/* e2fsprogs supports $SOURCE_DATE_EPOCH since v1.47.1. For older versions, we need to set
|
||||
* $E2FSPROGS_FAKE_TIME. See the following:
|
||||
* https://github.com/tytso/e2fsprogs/commit/b6e2913061577ad981464e435026d71a48fd5caf
|
||||
* Note, $E2FSPROGS_FAKE_TIME and $SOURCE_DATE_EPOCH are mostly equivalent, except for the
|
||||
* 0 value handling, where $E2FSPROGS_FAKE_TIME=0 is ignored and the current time is used,
|
||||
* but $SOURCE_DATE_EPOCH=0 sets 1970-01-01 as the timestamp. */
|
||||
if (!secure_getenv("E2FSPROGS_FAKE_TIME")) { /* honor $E2FSPROGS_FAKE_TIME if already set */
|
||||
const char *e = secure_getenv("SOURCE_DATE_EPOCH");
|
||||
if (e && strv_extend_strv(&env, STRV_MAKE("E2FSPROGS_FAKE_TIME", e), /* filter_duplicates= */ false) < 0)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
} else if (streq(fstype, "btrfs")) {
|
||||
argv = strv_new(mkfs,
|
||||
"-L", label,
|
||||
|
||||
@@ -1896,7 +1896,7 @@ testcase_luks2_integrity() {
|
||||
}
|
||||
|
||||
testcase_ext_reproducibility() {
|
||||
local defs imgs
|
||||
local defs imgs ts
|
||||
|
||||
# Online mode mounts the filesystem which updates inode timestamps non-deterministically
|
||||
if [[ "$OFFLINE" != "yes" ]]; then
|
||||
@@ -1916,21 +1916,28 @@ Format=ext4
|
||||
EOF
|
||||
|
||||
# Build the image twice with the same seed and verify they are identical
|
||||
systemd-repart --offline="$OFFLINE" \
|
||||
--definitions="$defs" \
|
||||
--empty=create \
|
||||
--size=50M \
|
||||
--seed="$seed" \
|
||||
--dry-run=no \
|
||||
"$imgs/test1.img"
|
||||
ts=$(date +%s)
|
||||
env SOURCE_DATE_EPOCH="$ts" \
|
||||
systemd-repart \
|
||||
--offline="$OFFLINE" \
|
||||
--definitions="$defs" \
|
||||
--empty=create \
|
||||
--size=50M \
|
||||
--seed="$seed" \
|
||||
--dry-run=no \
|
||||
"$imgs/test1.img"
|
||||
|
||||
systemd-repart --offline="$OFFLINE" \
|
||||
--definitions="$defs" \
|
||||
--empty=create \
|
||||
--size=50M \
|
||||
--seed="$seed" \
|
||||
--dry-run=no \
|
||||
"$imgs/test2.img"
|
||||
sleep 2
|
||||
|
||||
env SOURCE_DATE_EPOCH="$ts" \
|
||||
systemd-repart \
|
||||
--offline="$OFFLINE" \
|
||||
--definitions="$defs" \
|
||||
--empty=create \
|
||||
--size=50M \
|
||||
--seed="$seed" \
|
||||
--dry-run=no \
|
||||
"$imgs/test2.img"
|
||||
|
||||
cmp "$imgs/test1.img" "$imgs/test2.img"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user