%global cmake_template_commit b86318abbf55a657a11a0cf2acce69f221841b22 %global cmake_template_short b86318a %global bearssl_version 0.6 %global mbedtls_version 3.6.5 # EPEL 9's mbedtls (2.28) lacks the multi-part PSA AEAD API a test needs; bundle instead. %if 0%{?rhel} == 9 %global dlms_bundle_mbedtls 1 %endif Name: dlms_parser Version: 2.2.0 Release: 1%{?dist} Summary: Library for parsing DLMS/COSEM push telegrams from smart meters License: Apache-2.0 AND MIT URL: https://github.com/esphome-libs/dlms_parser Source0: https://github.com/esphome-libs/dlms_parser/archive/refs/tags/v%{version}/dlms_parser-%{version}.tar.gz # Statically linked into dlms_decode_readout (see "Provides: bundled()" below). Source1: https://bearssl.org/bearssl-%{bearssl_version}.tar.gz # Build-time only (compiler warning/sanitizer flags); nothing from it ships in the binary. Source2: https://github.com/cpp-best-practices/cmake_template/archive/%{cmake_template_commit}/cmake_template-%{cmake_template_short}.tar.gz # Bundled on EL9 only (see dlms_bundle_mbedtls above); harmless to always declare. Source3: https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-%{mbedtls_version}/mbedtls-%{mbedtls_version}.tar.bz2 # Carried until accepted upstream: build offline from system/pre-fetched deps. Patch0001: 0001-cmake-fix-doctest.cmake-discovery.patch Patch0002: 0002-tests-use-doctest-doctest.h-not-the-legacy-bare-doct.patch Patch0003: 0003-cmake-declare-bearssl-and-cmake_template-instead-of-.patch Patch0004: 0004-cmake-make-sanitizers-and-Werror-optional.patch Patch0005: 0005-cmake-guard-bearssl-s-from-source-add_library-with-i.patch Patch0006: 0006-cmake-add-a-dependency-provider-for-offline-system-p.patch BuildRequires: cmake >= 3.24 BuildRequires: ninja-build BuildRequires: doctest-devel # tools/decode_readout.cpp uses , unavailable in RHEL 9's default gcc 11. %if 0%{?rhel} == 9 BuildRequires: gcc-toolset-14-gcc-c++ BuildRequires: gcc-toolset-14-annobin-plugin-gcc %else BuildRequires: gcc-c++ BuildRequires: mbedtls-devel %endif Provides: bundled(bearssl) = %{bearssl_version} %if 0%{?dlms_bundle_mbedtls} Provides: bundled(mbedtls) = %{mbedtls_version} %endif %description dlms_parser is a C++20 library for parsing DLMS/COSEM push telegrams from electricity meters (HDLC, M-Bus, A-XDR, OBIS), designed for embedded and integration-heavy environments such as ESPHome. This package builds and ships dlms_decode_readout, a command-line tool that decodes a captured telegram dump. %prep %autosetup -p1 -n dlms_parser-%{version} mkdir -p deps tar -xf %{SOURCE1} -C deps mv "deps/bearssl-%{bearssl_version}" deps/bearssl tar -xf %{SOURCE2} -C deps mv "deps/cmake_template-%{cmake_template_commit}" deps/cmake_template %if 0%{?dlms_bundle_mbedtls} tar -xf %{SOURCE3} -C deps mv "deps/mbedtls-%{mbedtls_version}" deps/mbedtls %endif %build %if 0%{?rhel} == 9 . /opt/rh/gcc-toolset-14/enable %endif # Static: no -devel subpackage, so a dangling libdlms_parser.so dependency must be avoided. %cmake \ -G Ninja \ -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=%{_builddir}/%{buildsubdir}/cmake/dependency-provider.cmake \ -DDLMS_DEPS_SOURCE_ROOT=%{_builddir}/%{buildsubdir}/deps \ %if 0%{?dlms_bundle_mbedtls} -DDLMS_USE_SYSTEM_MBEDTLS=OFF \ %endif -DFETCHCONTENT_FULLY_DISCONNECTED=ON \ -DDLMS_ENABLE_SANITIZERS=OFF \ -DDLMS_WARNINGS_AS_ERRORS=OFF \ -DBUILD_SHARED_LIBS=OFF %cmake_build %install install -Dpm0755 %{_vpath_builddir}/decode_readout %{buildroot}%{_bindir}/dlms_decode_readout %check %if 0%{?rhel} == 9 . /opt/rh/gcc-toolset-14/enable %endif %ctest %files %license LICENSE %doc README.md %{_bindir}/dlms_decode_readout %changelog * Fri Sep 25 2026 Jan Kundrát - 2.2.0-1 - Initial offline/COPR packaging