about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/xmlsec
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/xmlsec')
-rw-r--r--nixpkgs/pkgs/development/libraries/xmlsec/default.nix91
-rw-r--r--nixpkgs/pkgs/development/libraries/xmlsec/lt_dladdsearchdir.patch16
-rw-r--r--nixpkgs/pkgs/development/libraries/xmlsec/remove_bsd_base64_decode_flag.patch12
3 files changed, 119 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/xmlsec/default.nix b/nixpkgs/pkgs/development/libraries/xmlsec/default.nix
new file mode 100644
index 000000000000..2cf0cc3ef8df
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/xmlsec/default.nix
@@ -0,0 +1,91 @@
+{ stdenv, fetchurl, fetchpatch, libxml2, gnutls, libxslt, pkg-config, libgcrypt, libtool
+, openssl, nss, lib, runCommandCC, writeText }:
+
+lib.fix (self:
+stdenv.mkDerivation rec {
+  pname = "xmlsec";
+  version = "1.2.34";
+
+  src = fetchurl {
+    url = "https://www.aleksey.com/xmlsec/download/xmlsec1-${version}.tar.gz";
+    sha256 = "sha256-Us7UlD81vX0IGKOCmMFSjKSsilRED9cRNKB9LRNwomI=";
+  };
+
+  patches = [
+    ./lt_dladdsearchdir.patch
+
+    # Fix build with libxml2 2.12
+    (fetchpatch {
+      url = "https://github.com/lsh123/xmlsec/commit/ffb327376f5bb69e8dfe7f805529e45a40118c2b.patch";
+      hash = "sha256-o8CLemOiGIHJsYfVQtNzJNVyk03fdmCbvgA8c3OYxo4=";
+    })
+  ] ++ lib.optionals stdenv.isDarwin [ ./remove_bsd_base64_decode_flag.patch ];
+  postPatch = ''
+    substituteAllInPlace src/dl.c
+  '';
+
+  outputs = [ "out" "dev" ];
+
+  nativeBuildInputs = [ pkg-config ];
+
+  buildInputs = [ libxml2 gnutls libgcrypt libtool openssl nss ];
+
+  propagatedBuildInputs = [
+    # required by xmlsec/transforms.h
+    libxslt
+  ];
+
+  enableParallelBuilding = true;
+  doCheck = true;
+  nativeCheckInputs = [ nss.tools ];
+  preCheck = ''
+    substituteInPlace tests/testrun.sh \
+      --replace 'timestamp=`date +%Y%m%d_%H%M%S`' 'timestamp=19700101_000000' \
+      --replace 'TMPFOLDER=/tmp' '$(mktemp -d)'
+  '';
+
+  # enable deprecated soap headers required by lasso
+  # https://dev.entrouvert.org/issues/18771
+  configureFlags = [ "--enable-soap" ];
+
+  # otherwise libxmlsec1-gnutls.so won't find libgcrypt.so, after #909
+  NIX_LDFLAGS = "-lgcrypt";
+
+  postInstall = ''
+    moveToOutput "bin/xmlsec1-config" "$dev"
+    moveToOutput "lib/xmlsec1Conf.sh" "$dev"
+  '';
+
+  passthru.tests.libxmlsec1-crypto = runCommandCC "libxmlsec1-crypto-test"
+    {
+      nativeBuildInputs = [ pkg-config ];
+      buildInputs = [ self libxml2 libxslt libtool ];
+    } ''
+    $CC $(pkg-config --cflags --libs xmlsec1) -o crypto-test ${writeText "crypto-test.c" ''
+      #include <xmlsec/xmlsec.h>
+      #include <xmlsec/crypto.h>
+
+      int main(int argc, char **argv) {
+        return xmlSecInit() ||
+          xmlSecCryptoDLLoadLibrary(argc > 1 ? argv[1] : 0) ||
+          xmlSecCryptoInit();
+      }
+    ''}
+
+    for crypto in "" gcrypt gnutls nss openssl; do
+      ./crypto-test $crypto
+    done
+    touch $out
+  '';
+
+  meta = with lib; {
+    description = "XML Security Library in C based on libxml2";
+    homepage = "https://www.aleksey.com/xmlsec/";
+    downloadPage = "https://www.aleksey.com/xmlsec/download.html";
+    license = licenses.mit;
+    mainProgram = "xmlsec1";
+    maintainers = with maintainers; [ ];
+    platforms = with platforms; linux ++ darwin;
+  };
+}
+)
diff --git a/nixpkgs/pkgs/development/libraries/xmlsec/lt_dladdsearchdir.patch b/nixpkgs/pkgs/development/libraries/xmlsec/lt_dladdsearchdir.patch
new file mode 100644
index 000000000000..17dedb0d6c81
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/xmlsec/lt_dladdsearchdir.patch
@@ -0,0 +1,16 @@
+diff --git a/src/dl.c b/src/dl.c
+index b13f9d46..d761855b 100644
+--- a/src/dl.c
++++ b/src/dl.c
+@@ -346,6 +346,11 @@ xmlSecCryptoDLInit(void) {
+         xmlSecIOError("lt_dlinit", NULL, NULL);
+         return(-1);
+     }
++    ret = lt_dladdsearchdir("@out@/lib");
++    if(ret != 0) {
++      xmlSecIOError("lt_dladdsearchdir", NULL, NULL);
++      return(-1);
++    }
+ #endif /* XMLSEC_DL_LIBLTDL */
+ 
+     return(0);
diff --git a/nixpkgs/pkgs/development/libraries/xmlsec/remove_bsd_base64_decode_flag.patch b/nixpkgs/pkgs/development/libraries/xmlsec/remove_bsd_base64_decode_flag.patch
new file mode 100644
index 000000000000..700fad7e3dd4
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/xmlsec/remove_bsd_base64_decode_flag.patch
@@ -0,0 +1,12 @@
+--- a/tests/testEnc.sh	2020-04-20 14:30:32.000000000 -0400
++++ b/tests/testEnc.sh	2020-10-21 22:09:25.000000000 -0400
+@@ -405,9 +405,6 @@
+             else
+                 # generate binary file out of base64
+                 DECODE="-d"
+-                if [ "`uname`" = "Darwin" ]; then
+-		    DECODE="-D"
+-                fi
+                 cat "$topfolder/$base_test_name.data" | base64 $DECODE > $tmpfile.3
+                 execEncTest "$res_success" \
+                     "" \