]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
meson: Fix unix epoch
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 29 Apr 2022 02:35:21 +0000 (22:35 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 29 Apr 2022 02:54:41 +0000 (22:54 -0400)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
meson.build

index d3b4f590d4f2b86897c532a7d2a10e26087c88de..a835a3e53d009442cf57307d1d6c07ef9256ad6f 100644 (file)
@@ -182,12 +182,16 @@ endif
 
 ## Time EPOCH.
 sh = find_program('sh')
+date = find_program('date')
 git = find_program('git', required: false)
 time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check: true).stdout().strip()
 if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check: false).returncode() == 0
     # If we're in a git repository, use the creation time of the latest git tag.
     latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: true).stdout().strip()
     time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout()
+else
+    # Fallback to current epoch
+    time_epoch = run_command(date, '+%s', check: true).stdout()
 endif
 time_epoch = time_epoch.to_int()
 conf.set('TIME_EPOCH', time_epoch)