diff options
author | Graham Christensen <graham@grahamc.com> | 2018-09-18 11:08:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-18 11:08:08 -0400 |
commit | 11c76c932fa7b0e41c01061e7d4fa9548333a6b4 (patch) | |
tree | 75e48ebf8cb2010d6b638eebc1ed4637b2ea0c91 | |
parent | 0a308534615dc3cbb37f3c9400323a9089083343 (diff) | |
parent | 301109a2dd1099d673cf805f50f303b180e5d58d (diff) | |
download | nixlib-11c76c932fa7b0e41c01061e7d4fa9548333a6b4.tar nixlib-11c76c932fa7b0e41c01061e7d4fa9548333a6b4.tar.gz nixlib-11c76c932fa7b0e41c01061e7d4fa9548333a6b4.tar.bz2 nixlib-11c76c932fa7b0e41c01061e7d4fa9548333a6b4.tar.lz nixlib-11c76c932fa7b0e41c01061e7d4fa9548333a6b4.tar.xz nixlib-11c76c932fa7b0e41c01061e7d4fa9548333a6b4.tar.zst nixlib-11c76c932fa7b0e41c01061e7d4fa9548333a6b4.zip |
Merge pull request #46834 from grahamc/check-outputs-in-meta
stdenv: Validate meta.outputsToInstall
-rw-r--r-- | pkgs/development/libraries/elf-header/default.nix | 1 | ||||
-rw-r--r-- | pkgs/stdenv/generic/check-meta.nix | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/pkgs/development/libraries/elf-header/default.nix b/pkgs/development/libraries/elf-header/default.nix index 48e5b73d9e72..ab8c217dce43 100644 --- a/pkgs/development/libraries/elf-header/default.nix +++ b/pkgs/development/libraries/elf-header/default.nix @@ -32,6 +32,7 @@ stdenvNoCC.mkDerivation { ''; meta = libc.meta // { + outputsToInstall = [ "out" ]; description = "The datastructures of ELF according to the target platform's libc"; longDescription = '' The Executable and Linkable Format (ELF, formerly named Extensible Linking diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index a5c8ca705231..28b69f5c2dc9 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -81,6 +81,7 @@ let unsupported = remediate_whitelist "UnsupportedSystem"; blacklisted = x: ""; insecure = remediate_insecure; + broken-outputs = remediateOutputsToInstall; unknown-meta = x: ""; }; remediate_whitelist = allow_attr: attrs: @@ -125,6 +126,20 @@ let ''; + remediateOutputsToInstall = attrs: let + expectedOutputs = attrs.meta.outputsToInstall or []; + actualOutputs = attrs.outputs or [ "out" ]; + missingOutputs = builtins.filter (output: ! builtins.elem output actualOutputs) expectedOutputs; + in '' + The package ${attrs.name} has set meta.outputsToInstall to: ${builtins.concatStringsSep ", " expectedOutputs} + + however ${attrs.name} only has the outputs: ${builtins.concatStringsSep ", " actualOutputs} + + and is missing the following ouputs: + + ${lib.concatStrings (builtins.map (output: " - ${output}\n") missingOutputs)} + ''; + handleEvalIssue = attrs: { reason , errormsg ? "" }: let msg = '' @@ -185,6 +200,14 @@ let in anyMatch (attrs.meta.platforms or lib.platforms.all) && ! anyMatch (attrs.meta.badPlatforms or []); + checkOutputsToInstall = attrs: let + expectedOutputs = attrs.meta.outputsToInstall or []; + actualOutputs = attrs.outputs or [ "out" ]; + missingOutputs = builtins.filter (output: ! builtins.elem output actualOutputs) expectedOutputs; + in if shouldCheckMeta + then builtins.length missingOutputs > 0 + else false; + # Check if a derivation is valid, that is whether it passes checks for # e.g brokenness or license. # @@ -202,6 +225,8 @@ let { valid = false; reason = "unsupported"; errormsg = "is not supported on ‘${hostPlatform.config}’"; } else if !(hasAllowedInsecure attrs) then { valid = false; reason = "insecure"; errormsg = "is marked as insecure"; } + else if checkOutputsToInstall attrs then + { valid = false; reason = "broken-outputs"; errormsg = "has invalid meta.outputsToInstall"; } else let res = checkMeta (attrs.meta or {}); in if res != [] then { valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; } else { valid = true; }; |