[packages/open62541] - new

qboosh qboosh at pld-linux.org
Sun Jul 3 16:31:43 CEST 2022


commit 0ad170dfd66e6a76ba729117c3d394844339c2bc
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sun Jul 3 16:33:09 2022 +0200

    - new

 open62541-bpf.patch            |  29 +++++++
 open62541-libwebsockets4.patch |  13 +++
 open62541-types.patch          |  78 ++++++++++++++++++
 open62541-visibility.patch     |  57 +++++++++++++
 open62541.spec                 | 182 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 359 insertions(+)
---
diff --git a/open62541.spec b/open62541.spec
new file mode 100644
index 0000000..fe42eb0
--- /dev/null
+++ b/open62541.spec
@@ -0,0 +1,182 @@
+# TODO: MQTT
+#
+# Conditional build:
+%bcond_without	apidocs		# API documentation
+#
+Summary:	Open source C implementation of OPC UA
+Summary(pl.UTF-8):	Mająca otwarte źródła, napisana w C implementacja OPC UA
+Name:		open62541
+Version:	1.3.2
+Release:	1
+License:	MPL v2.0
+Group:		Libraries
+#Source0Download: https://github.com/open62541/open62541/releases
+Source0:	https://github.com/open62541/open62541/archive/v%{version}/%{name}-%{version}.tar.gz
+# Source0-md5:	9fecf3e64983e372f4c20066180829ea
+Patch0:		%{name}-types.patch
+Patch1:		%{name}-bpf.patch
+Patch2:		%{name}-libwebsockets4.patch
+Patch3:		%{name}-visibility.patch
+URL:		http://www.open62541.org/
+BuildRequires:	cmake >= 3.0
+BuildRequires:	libwebsockets-devel
+BuildRequires:	openssl-devel
+BuildRequires:	p11-kit-devel
+BuildRequires:	python3 >= 1:3
+BuildRequires:	tpm2-pkcs11-devel
+%if %{with apidocs}
+BuildRequires:	python3-sphinx_rtd_theme
+BuildRequires:	sphinx-pdg >= 2
+%endif
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+open62541 is an open source and free implementation of OPC UA (OPC
+Unified Architecture) written in the common subset of the C99 and
+C++98 languages. The library is usable with all major compilers and
+provides the necessary tools to implement dedicated OPC UA clients and
+servers, or to integrate OPC UA-based communication into existing
+applications. open62541 library is platform independent. All
+platform-specific functionality is implemented via exchangeable
+plugins. Plugin implementations are provided for the major operating
+systems.
+
+%description -l pl.UTF-8
+open62541 to wolnodostępna, otwarta implementacja OPC UA (OPC Unified
+Architecture), napisana we wspólnym podzbiorze języków C99 i C++98.
+Biblioteka jest używalna ze wszystkimi głównymi kompilatorami,
+dostarcza narzędzia potrzebne do implementacji dedykowanych klientów i
+serwerów OPC UA lub integracji komunikacji opartej o OPC UA w
+istniejących aplikacjach. Biblioteka open62541 jest niezależna od
+platformy. Zała funkcjonalność zależna od platformy jest
+implementowana poprzez wymienne wtyczki. Implementacje wtyczek dla
+wszystkich głównych systemów są dostarczone.
+
+%package devel
+Summary:	Header files for open62541 library
+Summary(pl.UTF-8):	Pliki nagłówkowe biblioteki open62541
+Group:		Development/Libraries
+Requires:	%{name} = %{version}-%{release}
+
+%description devel
+Header files for open62541 library.
+
+%description devel -l pl.UTF-8
+Pliki nagłówkowe biblioteki open62541.
+
+%package apidocs
+Summary:	API documentation for open62541 library
+Summary(pl.UTF-8):	Dokumentacja API biblioteki open62541
+Group:		Documentation
+BuildArch:	noarch
+
+%description apidocs
+API documentation for open62541 library.
+
+%description apidocs -l pl.UTF-8
+Dokumentacja API biblioteki open62541.
+
+%prep
+%setup -q
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+
+# not for gcc
+%{__sed} -i -e '/check_add_.*-Wno-static-in-inline/d' CMakeLists.txt
+
+%{__sed} -i -e '1s,/usr/bin/env python,%{__python},' \
+	tools/*.py \
+	tools/nodeset_compiler/nodeset_testing.py
+
+%{__sed} -i -e '1s,/usr/bin/env python3,%{__python3},' \
+	tools/certs/create_self-signed.py \
+	tools/nodeset_compiler/nodeset_compiler.py
+
+# not executable directly, drop shebangs
+%{__sed} -i -e '1s,.*/usr/bin/env python.*,,' \
+	tools/nodeset_compiler/{backend_open62541,backend_open62541_nodes,datatypes,nodes,nodeset}.py
+
+%build
+install -d build
+cd build
+# tpm2 support needs pkcs11.h from tpm2-pkcs11, which is in fast p11-kit include file
+CFLAGS="%{rpmcflags} -I/usr/include/p11-kit-1/p11-kit -Wno-error=maybe-uninitialized"
+LDFLAGS="%{rpmldflags} -L%{_libdir}/pkcs11"
+%cmake .. \
+	-DCMAKE_INSTALL_INCLUDEDIR=include \
+	-DCMAKE_INSTALL_INCLUDEDIR=%{_lib} \
+	-DTPM2_LIB=%{_libdir}/pkcs11/libtpm2_pkcs11.so \
+	-DUA_BUILD_TOOLS=ON \
+	-DUA_ENABLE_DISCOVERY=ON \
+	-DUA_ENABLE_ENCRYPTION=MBEDTLS \
+	-DUA_ENABLE_ENCRYPTION_TPM2=ON \
+	-DUA_ENABLE_JSON_ENCODING=ON \
+	-DUA_ENABLE_PUBSUB=ON \
+	-DUA_ENABLE_PUBSUB_ENCRYPTION=ON \
+	-DUA_ENABLE_PUBSUB_ETH_UADP=ON \
+	-DUA_ENABLE_WEBSOCKET_SERVER=ON \
+	-DUA_MULTITHREADING=100
+
+# -DUA_ENABLE_DISCOVERY_MULTICAST=ON requires deps/mdnsd
+# -DUA_ENABLE_PUBSUB_MQTT requires deps/mqtt-c
+# -DUA_NAMESPACE_ZERO=FULL requires deps/ua_nodeset
+
+%{__make}
+
+%if %{with apidocs}
+%{__make} doc
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%{__make} -C build install \
+	DESTDIR=$RPM_BUILD_ROOT
+
+# tests
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/open62541/tools/nodeset_compiler/nodeset_testing.py
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post	-p /sbin/ldconfig
+%postun	-p /sbin/ldconfig
+
+%files
+%defattr(644,root,root,755)
+%doc AUTHORS CHANGELOG FEATURES.md README.md
+%attr(755,root,root) %{_libdir}/libopen62541.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libopen62541.so.1
+%dir %{_datadir}/open62541
+%dir %{_datadir}/open62541/tools
+%attr(755,root,root) %{_datadir}/open62541/tools/generate_*.py
+%dir %{_datadir}/open62541/tools/certs
+%attr(755,root,root) %{_datadir}/open62541/tools/certs/create_self-signed.py
+%{_datadir}/open62541/tools/certs/localhost.cnf
+%dir %{_datadir}/open62541/tools/nodeset_compiler
+%attr(755,root,root) %{_datadir}/open62541/tools/nodeset_compiler/nodeset_compiler.py
+%{_datadir}/open62541/tools/nodeset_compiler/[!n]*.py
+%{_datadir}/open62541/tools/nodeset_compiler/nodes.py
+%{_datadir}/open62541/tools/nodeset_compiler/nodeset.py
+%{_datadir}/open62541/tools/nodeset_compiler/__pycache__
+%{_datadir}/open62541/tools/nodeset_compiler/NodeID_NS0_Base.txt
+%doc %{_datadir}/open62541/tools/nodeset_compiler/README.md
+%{_datadir}/open62541/tools/schema
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libopen62541.so
+%{_includedir}/open62541
+%{_includedir}/aa_tree.h
+%{_includedir}/ms_stdint.h
+%{_includedir}/ziptree.h
+%{_pkgconfigdir}/open62541.pc
+%{_libdir}/cmake/open62541
+
+%if %{with apidocs}
+%files apidocs
+%defattr(644,root,root,755)
+%doc build/doc/{_images,_static,*.html,*.js}
+%endif
diff --git a/open62541-bpf.patch b/open62541-bpf.patch
new file mode 100644
index 0000000..3846d0e
--- /dev/null
+++ b/open62541-bpf.patch
@@ -0,0 +1,29 @@
+--- open62541-1.3.2/plugins/ua_pubsub_ethernet.c.orig	2022-06-24 11:05:00.000000000 +0200
++++ open62541-1.3.2/plugins/ua_pubsub_ethernet.c	2022-07-02 18:26:09.914301766 +0200
+@@ -14,6 +14,9 @@
+ #include <open62541/plugin/log_stdout.h>
+ #include <open62541/plugin/pubsub_ethernet.h>
+ 
++// disable -Werror for xsk declarations (libbpf 0.7+)
++#pragma GCC diagnostic warning "-Wdeprecated-declarations"
++
+ #define RECEIVE_MSG_BUFFER_SIZE   4096
+ static UA_THREAD_LOCAL UA_Byte ReceiveMsgBufferETH[RECEIVE_MSG_BUFFER_SIZE];
+ 
+@@ -50,6 +53,7 @@ static UA_THREAD_LOCAL UA_Byte ReceiveMs
+ #       include <bpf/libbpf.h>
+ #       ifndef asm
+ #           define asm __asm__
++#           define typeof __typeof__
+ #       endif
+ #       include <bpf/xsk.h>
+ #   endif
+@@ -477,7 +481,7 @@ UA_PubSubChannelEthernetXDP_receive(UA_P
+     UA_UInt64 ret;
+     UA_UInt32 rcvd;
+     UA_Byte *pkt, *buf;
+-    ssize_t len;
++    size_t len;
+ 
+     xdp_socket = channelDataEthernet->xdpsocket;
+     message->length = 0;
diff --git a/open62541-libwebsockets4.patch b/open62541-libwebsockets4.patch
new file mode 100644
index 0000000..d59ea89
--- /dev/null
+++ b/open62541-libwebsockets4.patch
@@ -0,0 +1,13 @@
+ws_ping_pong_interval was added in libwebsockets 3 and removed in libwebsockets 4
+--- open62541-1.3.2/arch/network_ws.c.orig	2022-06-24 11:05:00.000000000 +0200
++++ open62541-1.3.2/arch/network_ws.c	2022-07-02 20:26:37.311814259 +0200
+@@ -292,7 +292,9 @@ ServerNetworkLayerWS_start(UA_ServerNetw
+     info.port = layer->port;
+     info.protocols = protocols;
+     info.vhost_name = (char *)nl->discoveryUrl.data;
++#if LWS_LIBRARY_VERSION_MAJOR == 3
+     info.ws_ping_pong_interval = 10;
++#endif
+     info.options = LWS_SERVER_OPTION_HTTP_HEADERS_SECURITY_BEST_PRACTICES_ENFORCE;
+     info.pvo = &pvo;
+     info.user = layer;
diff --git a/open62541-types.patch b/open62541-types.patch
new file mode 100644
index 0000000..de7c886
--- /dev/null
+++ b/open62541-types.patch
@@ -0,0 +1,78 @@
+--- open62541-1.3.2/tools/tpm_keystore/cert_encrypt_tpm.c.orig	2022-06-24 11:05:00.000000000 +0200
++++ open62541-1.3.2/tools/tpm_keystore/cert_encrypt_tpm.c	2022-07-02 17:39:33.382785211 +0200
+@@ -21,7 +21,7 @@ typedef enum { B_FALSE, B_TRUE } boolean
+ 
+ typedef struct binary_data binary_data;
+ struct binary_data {
+-  long length;
++  size_t length;
+   void *data;
+ };
+ 
+@@ -101,9 +101,9 @@ static CK_RV encrypt(int slotNum, unsign
+     unsigned int expected_md_len = 32;
+     binary_data *out_data = *encrypted_data;
+     uint32_t i;
+-    CK_RV rv;
++    CK_RV rv = 0;
+ 
+-    CK_BYTE *data_encrypted;
++    CK_BYTE *data_encrypted = NULL;
+     CK_ULONG clear_data_length;
+     CK_ULONG encrypted_data_length = 0;
+     CK_ULONG enclen = 16;
+@@ -212,7 +212,7 @@ static CK_RV encrypt(int slotNum, unsign
+     /* Add 16 bytes because encrypt final does not accept the data bytes */
+     clear_data_length +=16;
+ 
+-    CK_BYTE_PTR ptr_clear_data;
++    CK_BYTE_PTR ptr_clear_data = NULL;
+     ptr_clear_data = (CK_BYTE *)(malloc(clear_data_length * sizeof(CK_BYTE)));
+     memset(ptr_clear_data, 0, clear_data_length);
+     /* Copy the data into the bytes that will be encrypted */
+@@ -253,7 +253,7 @@ static CK_RV encrypt(int slotNum, unsign
+     /* Add 56 more bytes. 16 bytes will hold the iv
+        The next 8 bytes will be an unsigned long (uint64_t) that indicates the original data length
+        The last 32 bytes are for the HMAC */
+-    long out_data_length = (long)(encrypted_data_length + (long unsigned int)iv_data->length + sizeof(uint64_t) + expected_md_len);
++    size_t out_data_length = (size_t)(encrypted_data_length + (long unsigned int)iv_data->length + sizeof(uint64_t) + expected_md_len);
+     if (out_data->data) {
+         free(out_data->data);
+         out_data->length = 0;
+@@ -325,7 +325,7 @@ static binary_data* read_input_file(cons
+                             /* Read the whole file to buffer */
+                             const long length = (const long)fread(buff, 1, (size_t)end_position, f_in);
+                             if (length == end_position) {
+-                                data->length = end_position;
++                                data->length = (size_t)end_position;
+                                 data->data = buff;
+ 
+                                 fclose(f_in);
+--- open62541-1.3.2/plugins/crypto/pkcs11/securitypolicy_pubsub_aes128ctr_tpm.c.orig	2022-07-02 17:51:35.142208438 +0200
++++ open62541-1.3.2/plugins/crypto/pkcs11/securitypolicy_pubsub_aes128ctr_tpm.c	2022-07-02 17:51:38.458857136 +0200
+@@ -351,8 +351,10 @@ sign_sp_pubsub_aes128ctr_tpm(PUBSUB_AES1
+     }
+ 
+     /* Signs data in a single part, where the signature is an appendix to the data */
++    unsigned long siglen = signature->length;
+     rv = (UA_StatusCode)C_Sign(cc->policyContext->sessionHandle, data->data, data->length,
+-                              (CK_BYTE_PTR)signature->data, &signature->length);
++                              (CK_BYTE_PTR)signature->data, &siglen);
++    signature->length = siglen;
+     if (rv != UA_STATUSCODE_GOOD) {
+         UA_LOG_ERROR(cc->policyContext->securityPolicy->logger, UA_LOGCATEGORY_SECURITYPOLICY,
+                      "Signing failed 0x%.8lX", (long unsigned int)rv);
+--- open62541-1.3.2/plugins/crypto/pkcs11/securitypolicy_pubsub_aes256ctr_tpm.c.orig	2022-06-24 11:05:00.000000000 +0200
++++ open62541-1.3.2/plugins/crypto/pkcs11/securitypolicy_pubsub_aes256ctr_tpm.c	2022-07-02 17:52:12.062008426 +0200
+@@ -357,8 +357,10 @@ sign_sp_pubsub_aes256ctr_tpm(PUBSUB_AES2
+     }
+ 
+     /* Signs data in a single part, where the signature is an appendix to the data */
++    unsigned long siglen = signature->length;
+     rv = (UA_StatusCode)C_Sign(cc->policyContext->sessionHandle, data->data, data->length,
+-                              (CK_BYTE_PTR)signature->data, &signature->length);
++                              (CK_BYTE_PTR)signature->data, &siglen);
++    signature->length = siglen;
+     if (rv != UA_STATUSCODE_GOOD) {
+         UA_LOG_ERROR(cc->policyContext->securityPolicy->logger, UA_LOGCATEGORY_SECURITYPOLICY,
+                      "Signing failed 0x%.8lX", (long unsigned int)rv);
diff --git a/open62541-visibility.patch b/open62541-visibility.patch
new file mode 100644
index 0000000..a7d7d62
--- /dev/null
+++ b/open62541-visibility.patch
@@ -0,0 +1,57 @@
+ua2json tool requires UA_NetworkMessage_* visible from library
+--- open62541-1.3.2/src/pubsub/ua_pubsub_networkmessage.h.orig	2022-06-24 11:05:00.000000000 +0200
++++ open62541-1.3.2/src/pubsub/ua_pubsub_networkmessage.h	2022-07-03 07:55:24.911256767 +0200
+@@ -270,6 +270,7 @@ UA_NetworkMessage_updateBufferedNwMessag
+ 
+ /* If dataToEncryptStart not-NULL, then it will be set to the start-position of
+  * the payload in the buffer. */
++UA_EXPORT
+ UA_StatusCode
+ UA_NetworkMessage_encodeBinary(const UA_NetworkMessage* src,
+                                UA_Byte **bufPos, const UA_Byte *bufEnd,
+@@ -300,6 +301,7 @@ UA_NetworkMessage_decodePayload(const UA
+ UA_StatusCode
+ UA_NetworkMessage_decodeFooters(const UA_ByteString *src, size_t *offset, UA_NetworkMessage *dst);
+ 
++UA_EXPORT
+ UA_StatusCode
+ UA_NetworkMessage_decodeBinary(const UA_ByteString *src, size_t *offset,
+                                UA_NetworkMessage* dst);
+@@ -308,6 +310,7 @@ UA_NetworkMessage_decodeBinary(const UA_
+ UA_StatusCode
+ UA_NetworkMessageHeader_decodeBinary(const UA_ByteString *src, size_t *offset, UA_NetworkMessage *dst);
+ 
++UA_EXPORT
+ size_t
+ UA_NetworkMessage_calcSizeBinary(UA_NetworkMessage *p,
+                                  UA_NetworkMessageOffsetBuffer *offsetBuffer);
+@@ -321,6 +324,7 @@ UA_NetworkMessage_signEncrypt(UA_Network
+                               UA_Byte *sigStart);
+ #endif
+ 
++UA_EXPORT
+ void
+ UA_NetworkMessage_clear(UA_NetworkMessage* p);
+ 
+@@ -329,18 +333,21 @@ UA_NetworkMessage_delete(UA_NetworkMessa
+ 
+ 
+ #ifdef UA_ENABLE_JSON_ENCODING
++UA_EXPORT
+ UA_StatusCode
+ UA_NetworkMessage_encodeJson(const UA_NetworkMessage *src,
+                              UA_Byte **bufPos, const UA_Byte **bufEnd, UA_String *namespaces,
+                              size_t namespaceSize, UA_String *serverUris,
+                              size_t serverUriSize, UA_Boolean useReversible);
+ 
++UA_EXPORT
+ size_t
+ UA_NetworkMessage_calcSizeJson(const UA_NetworkMessage *src,
+                                UA_String *namespaces, size_t namespaceSize,
+                                UA_String *serverUris, size_t serverUriSize,
+                                UA_Boolean useReversible);
+ 
++UA_EXPORT
+ UA_StatusCode UA_NetworkMessage_decodeJson(UA_NetworkMessage *dst, const UA_ByteString *src);
+ #endif
+ 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/open62541.git/commitdiff/0ad170dfd66e6a76ba729117c3d394844339c2bc



More information about the pld-cvs-commit mailing list