Skip to content

Commit

Permalink
Add pkcs11-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mlt committed Nov 22, 2024
1 parent a2d39f8 commit 6b5fc6c
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
63 changes: 63 additions & 0 deletions mingw-w64-pkcs11-provider/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
_realname=pkcs11-provider
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.5.r92.gcff4036
pkgrel=1
pkgdesc="A pkcs#11 provider for OpenSSL 3.0+ (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/latchset/pkcs11-provider'
msys2_references=('archlinux: pkcs11-provider')
license=('COPYING')
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-pkg-config"
"${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-dlfcn"
"git")
depends=("${MINGW_PACKAGE_PREFIX}-openssl")
# optdepends("${MINGW_PACKAGE_PREFIX}-p11-kit: seamless PKCS#11 modules integration")
_commit='cff40360e4b47d38911999c625249683b7445170'
source=("${_realname}"::"git+https://github.com/latchset/pkcs11-provider.git#commit=${_commit}"
"patch.patch")
sha256sums=('54e253b1f2363f4f5fa626394538da62734dd641a47c352b5b9b9970827d0b12'
'91d16126be2d86136a79d285627d263957129b02046269a1c3dfeba38c5016a6')

pkgver() {
cd "${_realname}"

git describe --long "${_commit}" | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//g'
}

prepare() {
cd "${_realname}"

patch -p1 -i ${srcdir}/patch.patch
}

build() {
MSYS2_ARG_CONV_EXCL="--prefix=" \
LDFLAGS="-ldl" CFLAGS="-pthread -Wno-incompatible-pointer-types -D_XOPEN_SOURCE=700" \
meson setup \
--prefix="${MINGW_PREFIX}" \
--wrap-mode=nodownload \
--auto-features=enabled \
--buildtype=release \
"build-${MSYSTEM}" \
"${_realname}"

meson compile -C "build-${MSYSTEM}"
}

check() {
meson test -C "build-${MSYSTEM}"
}

package() {
# meson install -C "build-${MSYSTEM}" --destdir "${pkgdir}"
install -Dm755 "${srcdir}/build-${MSYSTEM}/src/pkcs11.dll" "${pkgdir}${MINGW_PREFIX}/lib/ossl-modules/pkcs11.dll"
# install -Dm644 "${srcdir}/build-${MSYSTEM}/src/pkcs11.dll.a" "${pkgdir}${MINGW_PREFIX}/lib/ossl-modules/pkcs11.dll.a"
install -Dm644 "${srcdir}/${_realname}/docs/provider-pkcs11.7" "${pkgdir}${MINGW_PREFIX}/share/man/man7/provider-pkcs11.7"

install -Dm644 "${srcdir}/${_realname}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
42 changes: 42 additions & 0 deletions mingw-w64-pkcs11-provider/patch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
--- pkcs11-provider-0.5/meson.build.orig 2024-06-05 09:04:12.000000000 -0500
+++ pkcs11-provider-0.5/meson.build 2024-11-21 13:02:07.061978600 -0600
@@ -86,5 +86,4 @@

subdir('src')
subdir('docs')
-subdir('tests')

--- pkcs11-provider-0.5/src/platform/endian.h.orig 2024-06-05 09:04:12.000000000 -0500
+++ pkcs11-provider-0.5/src/platform/endian.h 2024-11-21 12:27:32.809167300 -0600
@@ -59,8 +59,8 @@
#define bswap_32(x) BSWAP_32(x)
#define bswap_64(x) BSWAP_64(x)

-#elif defined(__ANDROID__) || defined(__CYGWIN__) || defined(__GNUC__) || \
- defined(__GNU__)
+#elif defined(__ANDROID__) || defined(__CYGWIN__) || (defined(__GNUC__) || \
+ defined(__GNU__)) && !defined(__MINGW32__)

#include <byteswap.h>
#include <endian.h>
--- pkcs11-provider/src/provider.h.orig 2024-11-21 19:58:48.087544800 -0600
+++ pkcs11-provider/src/provider.h 2024-11-21 19:52:00.823425400 -0600
@@ -9,9 +9,18 @@
#include "config.h"

#include <stdbool.h>
+#if defined(_WIN32) && !defined(_MSC_VER)
+#include <pthread.h>
+#endif
#include <sys/types.h>

+#ifdef _WIN32
+#pragma pack(push, 1)
+#endif
#include "pkcs11.h"
+#ifdef _WIN32
+#pragma pack(pop)
+#endif
#include <openssl/core_dispatch.h>
#include <openssl/core_object.h>
#include <openssl/types.h>

0 comments on commit 6b5fc6c

Please sign in to comment.