diff options
author | Vincenzo Mantova <1962985+xworld21@users.noreply.github.com> | 2023-07-10 21:28:36 +0100 |
---|---|---|
committer | Vincenzo Mantova <1962985+xworld21@users.noreply.github.com> | 2023-07-29 18:10:45 +0200 |
commit | 39750551aa6aa0ea758af5457ea74f7bdfe7eb93 (patch) | |
tree | 4f1d65e95886313601c57f8a389a10fceb2f0802 /pkgs/test | |
parent | 1ab65c8c809f83901c22534723be09c15d187180 (diff) |
tests.texlive.shebangs: init, check that all shebangs are in Nix
Diffstat (limited to 'pkgs/test')
-rw-r--r-- | pkgs/test/texlive/default.nix | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/pkgs/test/texlive/default.nix b/pkgs/test/texlive/default.nix index 5119b6e85704e..5de8d9f26e4ad 100644 --- a/pkgs/test/texlive/default.nix +++ b/pkgs/test/texlive/default.nix @@ -427,6 +427,37 @@ [[ $failedCount = 0 ]] ''; + # check that all scripts have a Nix shebang + shebangs = let + allPackages = with lib; concatLists (catAttrs "pkgs" (filter isAttrs (attrValues texlive))); + binPackages = lib.filter (p: p.tlType == "bin") allPackages; + in + runCommand "texlive-test-shebangs" { } + ('' + echo "checking that all texlive scripts shebangs are in '$NIX_STORE'" + declare -i scriptCount=0 invalidCount=0 + '' + + (lib.concatMapStrings + (pkg: '' + for bin in '${pkg.outPath}'/bin/* ; do + grep -I -q . "$bin" || continue # ignore binary files + scriptCount=$((scriptCount + 1)) + read -r cmdline < "$bin" + read -r interp <<< "$cmdline" + if [[ "$interp" != "#!$NIX_STORE"/* && "$interp" != "#! $NIX_STORE"/* ]] ; then + echo "error: non-nix shebang '$interp' in script '$bin'" + invalidCount=$((invalidCount + 1)) + fi + done + '') + binPackages) + + '' + echo "checked $scriptCount scripts, found $invalidCount non-nix shebangs" + [[ $invalidCount -gt 0 ]] && exit 1 + mkdir -p "$out" + '' + ); + # verify that the precomputed licensing information in default.nix # does indeed match the metadata of the individual packages. # |