2023-02-02 18:25:31 +00:00
|
|
|
|
# Static arguments
|
2023-08-10 07:59:29 +00:00
|
|
|
|
{ lib, runCommand, pkg-config }:
|
2023-02-02 18:25:31 +00:00
|
|
|
|
|
|
|
|
|
# Tester arguments
|
|
|
|
|
{ package,
|
2023-08-10 07:59:29 +00:00
|
|
|
|
moduleNames ? package.meta.pkgConfigModules,
|
|
|
|
|
testName ? "check-pkg-config-${lib.concatStringsSep "-" moduleNames}",
|
2024-05-15 15:35:15 +00:00
|
|
|
|
version ? package.version or null,
|
|
|
|
|
versionCheck ? false,
|
2023-02-02 18:25:31 +00:00
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
runCommand testName {
|
|
|
|
|
nativeBuildInputs = [ pkg-config ];
|
|
|
|
|
buildInputs = [ package ];
|
2024-05-15 15:35:15 +00:00
|
|
|
|
inherit moduleNames version versionCheck;
|
2023-02-02 18:25:31 +00:00
|
|
|
|
meta = {
|
2024-06-20 14:57:18 +00:00
|
|
|
|
description = "Test whether ${package.name} exposes pkg-config modules ${lib.concatStringsSep ", " moduleNames}";
|
2023-02-02 18:25:31 +00:00
|
|
|
|
}
|
|
|
|
|
# Make sure licensing info etc is preserved, as this is a concern for e.g. cache.nixos.org,
|
|
|
|
|
# as hydra can't check this meta info in dependencies.
|
|
|
|
|
# The test itself is just Nixpkgs, with MIT license.
|
|
|
|
|
// builtins.intersectAttrs
|
|
|
|
|
{
|
|
|
|
|
available = throw "unused";
|
|
|
|
|
broken = throw "unused";
|
|
|
|
|
insecure = throw "unused";
|
|
|
|
|
license = throw "unused";
|
|
|
|
|
maintainers = throw "unused";
|
|
|
|
|
platforms = throw "unused";
|
|
|
|
|
unfree = throw "unused";
|
|
|
|
|
unsupported = throw "unused";
|
|
|
|
|
}
|
|
|
|
|
package.meta;
|
|
|
|
|
} ''
|
2024-02-07 01:22:34 +00:00
|
|
|
|
touch "$out"
|
2024-05-15 15:35:15 +00:00
|
|
|
|
notFound=0
|
|
|
|
|
versionMismatch=0
|
2023-08-10 07:59:29 +00:00
|
|
|
|
for moduleName in $moduleNames; do
|
|
|
|
|
echo "checking pkg-config module $moduleName in $buildInputs"
|
|
|
|
|
set +e
|
2024-05-15 15:35:15 +00:00
|
|
|
|
moduleVersion="$($PKG_CONFIG --modversion $moduleName)"
|
2023-08-10 07:59:29 +00:00
|
|
|
|
r=$?
|
|
|
|
|
set -e
|
|
|
|
|
if [[ $r = 0 ]]; then
|
2024-05-15 15:35:15 +00:00
|
|
|
|
if [[ "$moduleVersion" == "$version" ]]; then
|
|
|
|
|
echo "✅ pkg-config module $moduleName exists and has version $moduleVersion"
|
|
|
|
|
else
|
2024-06-05 15:53:02 +00:00
|
|
|
|
echo "${if versionCheck then "❌" else "ℹ️"} pkg-config module $moduleName exists at version $moduleVersion != $version (drv version)"
|
2024-05-15 15:35:15 +00:00
|
|
|
|
((versionMismatch+=1))
|
|
|
|
|
fi
|
2023-08-10 07:59:29 +00:00
|
|
|
|
printf '%s\t%s\n' "$moduleName" "$version" >> "$out"
|
|
|
|
|
else
|
|
|
|
|
echo "❌ pkg-config module $moduleName was not found"
|
2024-05-15 15:35:15 +00:00
|
|
|
|
((notFound+=1))
|
2023-08-10 07:59:29 +00:00
|
|
|
|
fi
|
|
|
|
|
done
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
|
if [[ $notFound -eq 0 ]] && ([[ $versionMismatch -eq 0 ]] || [[ -z "$versionCheck" ]]); then
|
2024-05-15 15:35:15 +00:00
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
if [[ $notFound -ne 0 ]]; then
|
|
|
|
|
echo "$notFound modules not found"
|
|
|
|
|
echo "These modules were available in the input propagation closure:"
|
|
|
|
|
$PKG_CONFIG --list-all
|
|
|
|
|
fi
|
|
|
|
|
if [[ $versionMismatch -ne 0 ]]; then
|
|
|
|
|
echo "$versionMismatch version mismatches"
|
|
|
|
|
fi
|
|
|
|
|
exit 1
|
2023-02-02 18:25:31 +00:00
|
|
|
|
''
|