]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: try BSD-style date(1) for alt_time_epoch as a fallback
authorq66 <q66@chimera-linux.org>
Sat, 6 Dec 2025 16:56:47 +0000 (17:56 +0100)
committerq66 <q66@chimera-linux.org>
Mon, 8 Dec 2025 20:35:28 +0000 (21:35 +0100)
If we fail to calculate alt_time_epoch using the GNU-style syntax,
try if BSD-style syntax does not work. Fail for real if that does
not work either.

meson.build

index 8d312dd70c1227f7e0bf3035f1ae3dd5d80e3cd2..547543b9c55360b047b9530c6800645e37632bc2 100644 (file)
@@ -3028,8 +3028,12 @@ if conf.get('ENABLE_HWDB') == 1
         alias_target('hwdb', auto_suspend_rules, executables_by_name.get('systemd-hwdb'), hwdb_units)
 endif
 
-alt_time_epoch = run_command('date', '-Is', '-u', '-d', f'@@time_epoch@',
-                             check : true).stdout().strip()
+alt_time_epoch = run_command('date', '-Is', '-u', '-d', f'@@time_epoch@', check : false)
+if alt_time_epoch.returncode() != 0
+        # If the above fails, maybe the date(1) uses BSD-style syntax
+        alt_time_epoch = run_command('date', '-Iseconds', '-u', '-r', f'@time_epoch@', check : true)
+endif
+alt_time_epoch = alt_time_epoch.stdout().strip()
 
 summary({
         'split bin-sbin'                            : split_bin,