Unverified Commit 321f80c3 authored by 7c6f434c's avatar 7c6f434c Committed by GitHub
Browse files

botan3: optionally expose botan-test and test vectors (#460893)

parents d99f539c dc52cea1
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@
  # useful, but have to disable tests for now, as /dev/tpmrm0 is not accessible
  withTpm2 ? false,
  policy ? null,
  # create additional "selftests" output and put botan-test binary together with
  # test vectors there. Useful to perform initial botan self-tests before using it
  exposeSelftests ? false,
}@args:

assert lib.assertOneOf "policy" policy [
@@ -65,6 +68,9 @@ stdenv.mkDerivation (finalAttrs: {
    "dev"
    "doc"
    "man"
  ]
  ++ lib.optionals exposeSelftests [
    "selftests"
  ];

  src = fetchurl {
@@ -102,7 +108,7 @@ stdenv.mkDerivation (finalAttrs: {
  buildTargets = [
    "cli"
  ]
  ++ lib.optionals finalAttrs.finalPackage.doCheck [ "tests" ]
  ++ lib.optionals (finalAttrs.finalPackage.doCheck || exposeSelftests) [ "tests" ]
  ++ lib.optionals static [ "static" ]
  ++ lib.optionals (!static) [ "shared" ];

@@ -156,7 +162,18 @@ stdenv.mkDerivation (finalAttrs: {
    fi
  '';

  postInstall = ''
  postInstall =
    lib.optionalString exposeSelftests ''
      mkdir -p $selftests/bin
      install -Dpm755 -D botan-test $selftests/bin/botan-test

      # don't copy leading source folder structure
      pushd src/tests/data &> /dev/null
      find . -type d -exec install -d $selftests/test-data/{} \;
      find . -type f -exec install -Dpm644 {} $selftests/test-data/{} \;
      popd &> /dev/null
    ''
    + ''
      cd "$out"/lib/pkgconfig
      ln -s botan-*.pc botan.pc || true
    '';