build: Add detection script for a better package maintenance experience

This commit is contained in:
Vladimir Vaskov 2025-01-17 17:56:31 +03:00
parent 5b59b42746
commit 3663272063
No known key found for this signature in database
GPG Key ID: CECAF75A5D478132
2 changed files with 28 additions and 1 deletions

View File

@ -18,7 +18,16 @@ libhandy_dep = dependency('libhandy-1', version: '>=1.1.90', fallback: ['libhand
libnm_dep = dependency('libnm', version: '>=1.14')
phosh_plugins_dep = dependency('phosh-plugins', required: true, method: 'pkg-config')
libphosh_version = get_option('libphosh_version') != '' ? get_option('libphosh_version') : '0.44'
# Detect libphosh API version
# Due to the unstable API, the version changes frequently,
# which makes it difficult to maintain in the package repository.
result = run_command('bash', 'scripts/detect-libphosh-api-version.sh')
if result.returncode() != 0
error(result.stderr())
endif
libphosh_version = result.stdout().strip()
libphosh_dep = dependency('libphosh-' + libphosh_version, required: true, method: 'pkg-config')
plugin_deps = [

View File

@ -0,0 +1,18 @@
#!/bin/bash
pc_file=$(find "/usr/lib64/pkgconfig" -maxdepth 1 -type f -name "libphosh-*.pc" | head -n 1)
if [ -z "$pc_file" ]; then
echo "File libphosh-*.pc not found."
exit 1
fi
version=$(basename "$pc_file" | sed -E 's/^libphosh-([0-9.]+)\.pc$/\1/')
if [ -z "$version" ]; then
echo "Can't detect version of $pc_file."
exit 1
fi
echo $version
exit 0