File labtool.spec of Package labtool

#
# spec file for package labtool
#
# Copyright (c) 2024 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/


Name:           labtool
Version:        1.2
Release:        0
License:        Apache-2.0
Summary:        Signal analyzer
Url:            https://github.com/embeddedartists/labtool
Group:          Hardware
Source:         https://github.com/embeddedartists/labtool/archive/v%{version}.tar.gz#/labtool-%{version}.tar.gz
# PATCH-FEATURE-UPSTREAM labtool_macosx.patch
Patch0:         labtool_macosx.patch
# PATCH-FIX-UPSTREAM labtool_dfu-util_permissions.patch
Patch1:         labtool_dfu-util_permissions.patch
# PATCH-FIX-UPSTREAM labtool_firmware_path.patch
Patch2:         labtool_firmware_path.patch
# PATCH-FIX-UPSTREAM labtool_dfu-util_wait.patch
Patch3:         labtool_dfu-util_wait.patch
# PATCH-FIX-UPSTREAM labtool_dfu-util_path.patch
Patch4:         labtool_dfu-util_path.patch
# PATCH-FIX-UPSTREAM
Patch5:         https://github.com/embeddedartists/labtool/commit/67847d3fceb664d593e1765c752edea122b8c365.patch#/add_missing_include_qpainterpath.patch
# PATCH-FIX-UPSTREAM
Patch6:         https://github.com/embeddedartists/labtool/commit/d482d65f0c7c527e6e3daf216389a518558333e9.patch#/remove_undefined_Qt_keywords.patch
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libusb-1_0-devel
BuildRequires:  pkgconfig(udev)
BuildRequires:  pkgconfig(libudev)
Requires:       dfu-util
Requires(post): udev
Requires(postun): udev

%define _udevdir %(pkg-config --variable udevdir udev)

%description
LabTool

%prep
%setup -q
%autopatch -p1

# Obsoleted by commit 84ba8292c4d70543f039c46585136ac551cd9ff0
rm -f app/libusbx/Linux/*.a

rm -rf tools/dfu-util-0.7-binaries/

%build
pushd app
qmake-qt5 LabTool.pro
%make_build
popd

cat > 10-labtool.rules <<EOF
# Allow group plugdev to access the LabTool Hardware (1fc9:0018)
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="0018", MODE="664", GROUP="users"

# Allow group plugdev to access the LPC DFU device (1fc9:000c)
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1fc9", ATTRS{idProduct}=="000c", MODE="664", GROUP="users"
EOF

%install
mkdir -p %{buildroot}%{_bindir}
pushd app
install -m 755 LabTool %{buildroot}%{_bindir}/LabTool
popd

mkdir -p %{buildroot}%{_udevdir}/rules.d
install -m 644 10-labtool.rules %{buildroot}%{_udevdir}/rules.d/10-labtool.rules

%post
%udev_rules_update

%postun
%udev_rules_update

%files
%{_bindir}/LabTool
%{_udevdir}/rules.d/10-labtool.rules

%changelog
openSUSE Build Service is sponsored by