31 lines
1.2 KiB
Bash
Executable file
31 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Contrat : contrôle local, sans collecte, privilège ni mutation du poste.
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
|
|
status=0
|
|
shopt -s nullglob
|
|
bash_files=("$ROOT"/scripts/*.sh "$ROOT"/tests/*.sh "$ROOT"/tests/*/*.sh "$ROOT"/rootfs/usr/local/sbin/*)
|
|
python_files=("$ROOT"/scripts/*.py "$ROOT"/tests/*/*.py)
|
|
(( ${#bash_files[@]} >= 10 && ${#python_files[@]} >= 2 )) || {
|
|
echo '[!] Scripts attendus absents.' >&2; exit 1;
|
|
}
|
|
for file in "${bash_files[@]}"; do
|
|
[[ -f "$file" && -r "$file" ]] && bash -n "$file" || status=1
|
|
done
|
|
for file in "${python_files[@]}"; do
|
|
[[ -f "$file" && -r "$file" ]] || { status=1; continue; }
|
|
python3 - "$file" <<'PY' || status=1
|
|
import ast,sys
|
|
try: ast.parse(open(sys.argv[1],encoding='utf-8').read(),filename=sys.argv[1])
|
|
except (SyntaxError,OSError) as exc: print(exc,file=sys.stderr); sys.exit(1)
|
|
PY
|
|
done
|
|
python3 "$ROOT/scripts/check-repo-data.py" "$ROOT" || status=1
|
|
git -C "$ROOT" diff --no-ext-diff --check || status=1
|
|
git -C "$ROOT" diff --cached --check || status=1
|
|
if (( status == 0 )); then
|
|
echo '[+] Syntaxe et données du dépôt contrôlées ; aucun système installé ni démarré.'
|
|
else
|
|
echo '[!] Contrôle du dépôt échoué.' >&2
|
|
fi
|
|
exit "$status"
|