about summary refs log tree commit diff
path: root/pkgs/test/texlive
diff options
context:
space:
mode:
authorVincenzo Mantova <1962985+xworld21@users.noreply.github.com>2023-07-10 21:28:36 +0100
committerVincenzo Mantova <1962985+xworld21@users.noreply.github.com>2023-07-29 18:10:45 +0200
commit39750551aa6aa0ea758af5457ea74f7bdfe7eb93 (patch)
tree4f1d65e95886313601c57f8a389a10fceb2f0802 /pkgs/test/texlive
parent1ab65c8c809f83901c22534723be09c15d187180 (diff)
tests.texlive.shebangs: init, check that all shebangs are in Nix
Diffstat (limited to 'pkgs/test/texlive')
-rw-r--r--pkgs/test/texlive/default.nix31
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.
   #