2023-10-15 20:40:13 +02:00

269 lines
8.7 KiB
RPMSpec

# disable debuginfo subpackage generation
%define debug_package %{nil}
# disable build-id symlinks
%define _build_id_links none
# don't use changelog date
%global source_date_epoch_from_changelog 0
Name: hyperion
Version: %{_version}
Release: 0%{?dist}
Summary: The successor to Hyperion aka Hyperion Next Generation
License: MIT
URL: https://github.com/hyperion-project/%{name}.ng
Source: %{name}.ng.tar.gz
BuildRoot: %{_tmppath}/%{name}.ng-build
Vendor: Hyperion Project
Packager: Hyperion-Project <admin@hyperion-project.org>
# common build dependencies
BuildRequires: desktop-file-utils
BuildRequires: libappstream-glib
BuildRequires: qt5-qtbase-devel qt5-qtserialport-devel qt5-qtx11extras-devel
BuildRequires: python3-devel
BuildRequires: turbojpeg-devel libjpeg-turbo-devel
BuildRequires: protobuf-devel protobuf-compiler
BuildRequires: flatbuffers-devel flatbuffers-compiler
BuildRequires: mbedtls-devel
BuildRequires: libcec-devel
BuildRequires: openssl-devel
BuildRequires: libusb1-devel
BuildRequires: avahi-libs avahi-compat-libdns_sd-devel
BuildRequires: libXrandr-devel
BuildRequires: xcb-util-image-devel xcb-util-devel
BuildRequires: dbus-devel
BuildRequires: alsa-lib-devel
BuildRequires: systemd
%if 0%{?suse_version} >= 1210
BuildRequires: systemd-rpm-macros
%endif
Requires: desktop-file-utils
Requires: qt5-qtbase qt5-qtserialport qt5-qtx11extras
Requires: python3-libs
Requires: turbojpeg
Requires: libusb
Requires: avahi-libs
Requires: dbus-libs
Requires: libXrandr
Requires: openssl
Requires: protobuf
Requires: flatbuffers
Requires: mbedtls
Requires: libcec
Requires: alsa-lib
Requires: firewalld
BuildArch: %(uname -m)
%description
Hyperion is an opensource Bias or Ambient Lighting implementation
which you might know from TV manufacturers.
It supports many LED devices and video grabbers.
%prep
%setup -qn %{name}.ng
%build
cmake \
-S . -B build \
-DUSE_SYSTEM_PROTO_LIBS=ON \
-DUSE_SYSTEM_FLATBUFFERS_LIBS=ON \
-DUSE_SYSTEM_MBEDTLS_LIBS=ON \
-DENABLE_DEPLOY_DEPENDENCIES=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX:PATH=%{_prefix}
make -C build -j 4
%install
%make_install -C build
# remove user entry (line 12) from systemd file (also in description)
# sed -i '12d' %{buildroot}%{_datadir}/%{name}/service/%{name}.systemd
# sed -i 's/ for user \%i//g' %{buildroot}%{_datadir}/%{name}/service/%{name}.systemd
%check
# check Desktop/AppStream file
desktop-file-validate %{buildroot}%{_datadir}/%{name}/desktop/%{name}.desktop
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/%{name}/desktop/%{name}.metainfo.xml
%pre
# stop running daemon before we install/upgrade
%if 0%{?fedora} || 0%{?rhel} >= 8
if %{_bindir}/pgrep 'hyperiond' &>/dev/null; then
CURRENT_SERVICE=$(systemctl --type service | { grep -o "hyperion.*\.service" || true; });
if [ ! -z "${CURRENT_SERVICE}" ]; then
systemctl stop ${CURRENT_SERVICE} &>/dev/null || :
else
killall hyperiond &>/dev/null || :
fi
fi
# else TODO SUSE
%endif
%post
# initial installation (postun is run when updating)
if [ $1 -eq 1 ]; then
echo "-----------------------------------------------------------------------------"
# service registration if no GUI OS is present
if [ -z "${DISPLAY}" ] && [ -z "${WAYLAND_DISPLAY}" ] && [ -z "${XDG_CURRENT_DESKTOP}" ]; then
%__install -D -m 644 %{_datadir}/%{name}/service/%{name}.systemd %{_unitdir}/%{name}@.service
%if 0%{?fedora} || 0%{?rhel} >= 8
USERNAME=$(logname)
%systemd_post %{name}@.service
systemctl -q enable %{name}@${USERNAME}.service &>/dev/null || :
systemctl start %{name}@${USERNAME} &>/dev/null || :
if [[ "$(type firewall-cmd &>/dev/null; echo $?)" -eq 0 && "$(systemctl is-active firewalld)" == "active" ]]; then
ZONE=$(firewall-cmd --get-default-zone)
firewall-cmd --permanent --zone=${ZONE} --new-service-from-file=%{_datadir}/%{name}/service/%{name}.xml --add-service=%{name} &>/dev/null || :
firewall-cmd --permanent --zone=${ZONE} --add-service=%{name} &>/dev/null || :
firewall-cmd --complete-reload &>/dev/null || :
fi
%endif
%if 0%{?suse_version}
%service_add_post %{name}.service
%endif
echo "---> Hyperion has been installed as service, it will start on each system startup"
else
if test -d /usr/share/icons/hicolor; then
# copy Hyperion icons to the proper freedesktop location
mkdir -p %{_datadir}/icons/hicolor/
cp -rp %{_datadir}/%{name}/icons/* %{_datadir}/icons/hicolor/
# update icon-cache
%if 0%{?suse_version}
%icon_theme_cache_post
%else
# touch it, just in case we cannot find the binary...
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
if hash gtk-update-icon-cache 2>/dev/null; then
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi
%endif
fi
if hash desktop-file-install 2>/dev/null ; then
# install Desktop/AppStream file
%__install -D -m 644 %{_datadir}/%{name}/desktop/%{name}.metainfo.xml %{_metainfodir}/%{name}.metainfo.xml
desktop-file-install --dir=%{_datadir}/applications %{_datadir}/%{name}/desktop/%{name}.desktop
%if 0%{?suse_version}
%desktop_database_post
%endif
fi
echo "---> You can start Hyperion from your menu now"
fi
fi
%preun
# package uninstall
if [ $1 -eq 0 ]; then
if [ -z "${DISPLAY}" ] && [ -z "${WAYLAND_DISPLAY}" ] && [ -z "${XDG_CURRENT_DESKTOP}" ]; then
%if 0%{?fedora} || 0%{?rhel} >= 8
CURRENT_SERVICE=$(systemctl --type service | { grep -o "hyperion.*\.service" || true; });
if [ ! -z "${CURRENT_SERVICE}" ]; then
%systemd_preun ${CURRENT_SERVICE}
fi
rm -v %{_unitdir}/%{name}@.service &>/dev/null || :
systemctl daemon-reload &>/dev/null
if [[ "$(type firewall-cmd &>/dev/null; echo $?)" -eq 0 && "$(systemctl is-active firewalld)" == "active" ]]; then
ZONE=$(firewall-cmd --get-default-zone)
firewall-cmd --permanent --zone=${ZONE} --remove-service=%{name} &>/dev/null || :
rm -v /etc/firewalld/services/%{name}.xml &>/dev/null || :
firewall-cmd --complete-reload &>/dev/null || :
fi
%endif
%if 0%{?suse_version}
%service_del_preun %{name}.service
%endif
else
if test -d /usr/share/icons/hicolor; then
# remove Hyperion icons
for i in 16x16 22x22 24x24 32x32 36x36 48x48 64x64 72x72 96x96 128x128 192x192 256x256 512x512; do
rm -v %{_datadir}/icons/hicolor/${i}/apps/%{name}.png &>/dev/null || :
done
# update icon-cache
%if 0%{?suse_version}
%icon_theme_cache_post
%else
# touch it, just in case we cannot find the binary...
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
if hash gtk-update-icon-cache 2>/dev/null; then
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
fi
%endif
fi
if hash desktop-file-install 2>/dev/null ; then
# remove desktop/appstream file
rm -v /usr/share/applications/%{name}* &>/dev/null || :
rm -v /usr/share/metainfo/%{name}* &>/dev/null || :
# update desktop-database
%if 0%{?suse_version}
%desktop_database_post
%else
if [ -x /usr/bin/update-desktop-database ]; then
update-desktop-database -q /usr/share/applications &>/dev/null || :
fi
%endif
fi
fi
fi
%postun
# package upgrade
if [ $1 -ge 1 ] ; then
if [ -z "${DISPLAY}" ] && [ -z "${WAYLAND_DISPLAY}" ] && [ -z "${XDG_CURRENT_DESKTOP}" ]; then
%if 0%{?fedora} || 0%{?rhel} >= 8
CURRENT_SERVICE=$(systemctl --type service | { grep -o "hyperion.*\.service" || true; });
if [ ! -z "${CURRENT_SERVICE}" ]; then
%systemd_postun_with_restart ${CURRENT_SERVICE}
fi
%endif
%if 0%{?suse_version}
%service_del_postun %{name}.service
%endif
fi
fi
%posttrans
# get current system ip
NET_IP="$( hostname -I | cut -d " " -f1 )"
echo "---> For configuration, visit with your browser: ${NET_IP}:8090"
echo "---> or if already used by another service try: ${NET_IP}:8091"
echo "-----------------------------------------------------------------------------"
echo "Webpage: www.hyperion-project.org"
echo "Forum: www.hyperion-project.org"
echo "Documentation: docs.hyperion-project.org"
echo "-----------------------------------------------------------------------------"
%files
%defattr(-,-,root)
%{_bindir}/*
%{_datadir}/%{name}/
%exclude %{_datadir}/%{name}/service/%{name}.init
%exclude %{_datadir}/%{name}/service/%{name}.initctl
%changelog