meson: a variety of build portability fixes (#40012)

This is for packaging systemd in Chimera Linux, which uses BSD-style
userland tools, alongside musl.
This commit is contained in:
Yu Watanabe
2025-12-09 14:35:22 +09:00
committed by GitHub
2 changed files with 15 additions and 9 deletions
+13 -7
View File
@@ -659,10 +659,6 @@ foreach prog : progs
conf.set_quoted(name, path)
endforeach
if run_command(ln, '--relative', '--help', check : false).returncode() != 0
error('ln does not support --relative (added in coreutils 8.16)')
endif
#####################################################################
gperf_test_format = '''
@@ -779,7 +775,13 @@ if time_epoch <= 0
if time_epoch == ''
NEWS = files('NEWS')
time_epoch = run_command(stat, '-c', '%Y', NEWS,
check : true).stdout()
check : false)
if time_epoch.returncode() != 0
# If the above fails, maybe the stat(1) uses BSD-style syntax
time_epoch = run_command(stat, '-f', '%m', NEWS,
check : true)
endif
time_epoch = time_epoch.stdout()
endif
time_epoch = time_epoch.strip().to_int()
endif
@@ -3026,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,
+2 -2
View File
@@ -8,7 +8,7 @@ ENABLED="$3"
if ! ((ENABLED)) || ! [[ -d .git ]] || ! command -v git >/dev/null || git describe --tags --exact-match &>/dev/null
then
sed "$INPUT" -e "s/@VCS_TAG@//"
sed -e "s/@VCS_TAG@//" "$INPUT"
exit 0
fi
@@ -20,4 +20,4 @@ fi
TAG="-g$(git describe --abbrev=7 --match="" --always $DIRTY)"
sed "$INPUT" -e "s/@VCS_TAG@/$TAG/"
sed -e "s/@VCS_TAG@/$TAG/" "$INPUT"