nixpkgs/pkgs/servers/home-assistant/build-custom-component/manifest-requirements-check-hook.sh
Martin Weinelt 843b710779
buildHomeAssistantComponent: restrict manifest locations we consider
A repo can contain many more manifest.json files, as demonstrated by the
hacs component.

Fixes: #429790
2025-08-10 01:25:31 +02:00

43 lines
1.2 KiB
Bash

# shellcheck shell=bash
# Setup hook to check HA manifest requirements
echo "Sourcing manifest-check-hook"
function manifestCheckPhase() {
echo "Executing manifestCheckPhase"
runHook preCheck
args=""
# shellcheck disable=SC2154
for package in "${ignoreVersionRequirement[@]}"; do
args+=" --ignore-version-requirement ${package}"
done
readarray -d '' manifests < <(
find . -type f \( \
-path ./manifest.json \
-o -path './custom_components/*/manifest.json' \
-o -path './custom_components/*/integrations/*/manifest.json' \
\) -print0
)
if [ "${#manifests[@]}" -gt 0 ]; then
# shellcheck disable=SC2068
echo Checking manifests ${manifests[@]}
# shellcheck disable=SC2068,SC2086
@pythonCheckInterpreter@ @checkManifest@ ${manifests[@]} $args
else
# shellcheck disable=SC2154
echo "No component manifests found in $out" >&2
exit 1
fi
runHook postCheck
echo "Finished executing manifestCheckPhase"
}
if [ -z "${dontCheckManifest-}" ] && [ -z "${installCheckPhase-}" ]; then
echo "Using manifestCheckPhase"
appendToVar preDistPhases manifestCheckPhase
fi