tests.texlive.fixedHashes: init (#248746)

The assertion that all TeX Live packages have a fixed hash is time
consuming and should only be checked when running tests.
This commit is contained in:
Vincenzo Mantova 2023-08-26 22:12:41 +01:00 committed by GitHub
parent a7253c72bb
commit 4e49e4928d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 5 deletions

View File

@ -511,4 +511,25 @@
echo "$errorText"
false
'');
# verify that all fixed hashes are present
# this is effectively an eval-time assertion, converted into a derivation for
# ease of testing
fixedHashes = with lib; let
combine = findFirst (p: (head p.pkgs).pname == "combine") { pkgs = []; } (head texlive.collection-latexextra.pkgs).tlDeps;
all = concatLists (map (p: p.pkgs or []) (attrValues (removeAttrs texlive [ "bin" "combine" "combined" "tlpdb" ]))) ++ combine.pkgs;
fods = filter (p: isDerivation p && p.tlType != "bin") all;
errorText = concatMapStrings (p: optionalString (! p ? outputHash) "${p.pname + optionalString (p.tlType != "run") ("." + p.tlType)} does not have a fixed output hash\n") fods;
in runCommand "texlive-test-fixed-hashes" {
inherit errorText;
passAsFile = [ "errorText" ];
} ''
if [[ -s "$errorTextPath" ]] ; then
cat "$errorTextPath"
echo Failed: some TeX Live packages do not have fixed output hashes. Please read UPGRADING.md for how to generate a new fixed-hashes.nix.
exit 1
else
touch "$out"
fi
'';
}

View File

@ -496,11 +496,7 @@ let
assertions = with lib;
assertMsg (tlpdbVersion.year == version.texliveYear) "TeX Live year in texlive does not match tlpdb.nix, refusing to evaluate" &&
assertMsg (tlpdbVersion.frozen == version.final) "TeX Live final status in texlive does not match tlpdb.nix, refusing to evaluate" &&
(!useFixedHashes ||
(let all = concatLists (catAttrs "pkgs" (attrValues tl));
fods = filter (p: isDerivation p && p.tlType != "bin") all;
in builtins.all (p: assertMsg (p ? outputHash) "The TeX Live package '${p.pname + lib.optionalString (p.tlType != "run") ("." + p.tlType)}' does not have a fixed output hash. Please read UPGRADING.md on how to build a new 'fixed-hashes.nix'.") fods));
assertMsg (tlpdbVersion.frozen == version.final) "TeX Live final status in texlive does not match tlpdb.nix, refusing to evaluate";
in
tl // {