fix el7 and el9 build errors in RPM SPEC file

This commit is contained in:
Syping 2024-03-14 03:30:45 +01:00
parent 382f029c3b
commit 9380dd14ea

View file

@ -1,5 +1,10 @@
%global _lto_cflags %{?_lto_cflags} -ffat-lto-objects
%global dtb_cmake_args -DCMAKE_BUILD_TYPE=Release -DWITH_DPP_STATIC_BUNDLE=TRUE -DWITH_SYSTEMD=TRUE
%if 0%{?rhel} && 0%{?rhel} < 8
%global cmake %{?cmake3}
%global cmake_build %{?cmake3_build}
%global cmake_install %{?cmake3_install}
%endif
Name: dtranslatebot
Version: 0.2.0
@ -7,21 +12,30 @@ Release: 1%{?dist}
Summary: Discord Translation Bot
License: BSD-2-Clause
URL: https://github.com/Syping/%{name}
Source0: %{name}_%{version}.tar.gz
Source0: %{name}-%{version}.tar.gz
Source1: %{name}.json
Source2: %{name}.service
Source3: %{name}.sysusersd
BuildRequires: cmake >= 3.16
BuildRequires: make
BuildRequires: perl
%if 0%{?rhel} && 0%{?rhel} < 9
BuildRequires: perl-IPC-Cmd
%if 0%{?rhel} && 0%{?rhel} < 8
BuildRequires: cmake3 >= 3.16
BuildRequires: devtoolset-9-annobin
BuildRequires: devtoolset-9-gcc-c++
%else
%if 0%{?rhel} && 0%{?rhel} == 8
BuildRequires: cmake >= 3.16
BuildRequires: gcc-toolset-9-annobin
BuildRequires: gcc-toolset-9-gcc-c++
%else
BuildRequires: cmake >= 3.16
BuildRequires: annobin
BuildRequires: gcc-c++
%endif
%if 0%{?rhel}
%endif
%if 0%{?rhel} && 0%{?rhel} < 9
BuildRequires: epel-rpm-macros-systemd
%endif
BuildRequires: systemd-rpm-macros
@ -35,22 +49,22 @@ dtranslatebot is a Discord Bot which translate incoming Discord messages to Disc
%setup -q
%build
%if 0%{?rhel} && 0%{?rhel} < 9
%if 0%{?rhel} && 0%{?rhel} < 8
source /opt/rh/devtoolset-9/enable
%else
%if 0%{?rhel} && 0%{?rhel} == 8
source /opt/rh/gcc-toolset-9/enable
%endif
%cmake %{?dtb_cmake_args}
%if 0%{?cmake_build:1}
%cmake_build
%else
%make_build
%endif
%cmake \
-DCMAKE_BUILD_TYPE=Release \
-DPERL_EXECUTABLE=%{_bindir}/perl \
-DWITH_DPP_STATIC_BUNDLE=TRUE \
-DWITH_SYSTEMD=TRUE
%cmake_build
%install
%if 0%{?cmake_install:1}
%cmake_install
%else
%make_install
%endif
mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/%{name}.json
install -p -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service