## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 12;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global forgeurl https://gitlab.com/CalcProgrammer1/%{upstream_package_name}
%global commit e300b48f5b966fca97de16381541448c44b1f59d
#%%global tag release_%%{version}
# Workaround for incorrect package suffix name with forge macros
# (.20231017gitrelease.0.9 for example)
#%%global distprefix %%{nil}

# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch: %{ix86}

%global upstream_package_name OpenRGB

Name:           openrgb
Version:        0.9
%forgemeta
Release:        %autorelease
Summary:        Open source RGB lighting control

# Entire source code is GPL-2.0-only except some bundled libs:
#   * GPL-3.0-or-later:
#     - hueplusplus-1.0.0
#     - libcmmk
License:        GPL-2.0-only AND GPL-3.0-or-later
URL:            https://openrgb.org
Source0:        %{forgesource}

BuildRequires:  desktop-file-utils
BuildRequires:  gcc-c++
BuildRequires:  libappstream-glib
BuildRequires:  mbedtls-devel
BuildRequires:  systemd-rpm-macros

BuildRequires:  pkgconfig(hidapi-libusb)
BuildRequires:  pkgconfig(libusb)

BuildRequires:  cmake
BuildRequires:  cmake(Qt5)
BuildRequires:  cmake(Qt5LinguistTools)

Requires:       %{name}-udev-rules = %{version}-%{release}
Requires:       hicolor-icon-theme

Provides:       bundled(hueplusplus) = 1.0.0
Provides:       bundled(libcmmk)

%description
Visit our website at https://openrgb.org!

One of the biggest complaints about RGB is the software ecosystem surrounding
it.  Every manufacturer has their own app, their own brand, their own style.
If you want to mix and match devices, you end up with a ton of conflicting,
functionally identical apps competing for your background resources.  On top
of that, these apps are proprietary and Windows-only.  Some even require
online accounts.  What if there was a way to control all of your RGB devices
from a single app, on both Windows and Linux, without any nonsense?  That is
what OpenRGB sets out to achieve.  One app to rule them all.

Features
  * Set colors and select effect modes for a wide variety of RGB hardware
  * Save and load profiles
  * Control lighting from third party software using the OpenRGB SDK
  * Command line interface
  * Connect multiple instances of OpenRGB to synchronize lighting across
    multiple PCs
  * Can operate standalone or in a client/headless server configuration
  * View device information
  * No official/manufacturer software required
  * Graphical view of device LEDs makes creating custom patterns easy


# Separate Udev rules package is useful for Flatpak package and others
%package        udev-rules
Summary:        Udev rules for %{name}
BuildArch:      noarch

Requires:       systemd-udev
Suggests:       %{name} = %{version}-%{release}

%description    udev-rules
Udev rules for %{name}.


%prep
%forgeautosetup -p1

# Remove some bundled libs
pushd dependencies
rm -rf       \
  hidapi     \
  hidapi-win \
  libusb-*   \
  mbedtls-*  \
  %{nil}
popd

mkdir -p %{_target_platform}


%build
pushd %{_target_platform}
%qmake_qt5                        \
    PREFIX=%{buildroot}%{_prefix} \
    ..                            \
    %{nil}
popd
%make_build -C %{_target_platform}


%install
%make_install -C %{_target_platform}


%check
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.xml
desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop


# Need to manually reload udev rules to get working app right after installing
# package
%post -n %{name}-udev-rules
if [ -S /run/udev/control ]; then
    udevadm control --reload
    udevadm trigger
fi


%files
%doc README.md
%{_bindir}/%{name}
%{_datadir}/icons/hicolor/*/apps/*.png
%{_datadir}/applications/*.desktop
%{_metainfodir}/*.metainfo.xml

%files udev-rules
%license LICENSE
%{_udevrulesdir}/60-%{name}.rules


%changelog
## START: Generated by rpmautospec
* Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.9-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Tue Jul 02 2024 Richard W.M. Jones <rjones@redhat.com> - 0.9-11
- Move to latest package

* Mon Feb 05 2024 Artem Polishchuk <ego.cordatus@gmail.com> - 0.9-10
- build: Fix license listing separator

* Mon Feb 05 2024 Artem Polishchuk <ego.cordatus@gmail.com> - 0.9-9
- build: Workaround for incorrect package suffix name

* Sun Feb 04 2024 Artem Polishchuk <ego.cordatus@gmail.com> - 0.9-8
- packit: Update config

* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.9-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.9-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Tue Oct 17 2023 Artem Polishchuk <ego.cordatus@gmail.com> - 0.9-5
- build: Add Packit config

* Tue Oct 17 2023 Artem Polishchuk <ego.cordatus@gmail.com> - 0.9-4
- build: Use forge macros

* Tue Oct 17 2023 Artem Polishchuk <ego.cordatus@gmail.com> - 0.9-3
- license: Convert to SPDX

* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Mon Jul 10 2023 Artem Polishchuk <ego.cordatus@gmail.com> - 0.9-1
- chore: Update to 0.9

* Wed Mar 15 2023 Artem Polishchuk <ego.cordatus@gmail.com> - 0.8-4
- build: Fix FTBFS 38 #2171634

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Mon Nov 28 2022 Artem Polishchuk <ego.cordatus@gmail.com> - 0.8-2
- build: ExcludeArch: %%{ix86}

* Mon Nov 28 2022 Artem Polishchuk <ego.cordatus@gmail.com> - 0.8-1
- build: Update to 0.8

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.7-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed May 11 2022 Artem Polishchuk <ego.cordatus@gmail.com> - 0.7-4
- build: Add upstream patch to fix LTO issue

* Sat Apr 30 2022 Artem Polishchuk <ego.cordatus@gmail.com> - 0.7-2
- build: Trigger udev reload for udev-rules sub-package

* Sun Jan 02 2022 Artem Polishchuk <ego.cordatus@gmail.com> - 0.7-1
- Initial package

## END: Generated by rpmautospec