File kodi.spec of Package kodi

#
# spec file for package kodi
#
# Copyright (c) 2015 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/
#
#%define _lto_cflags %{nil} 

%define _kodi_addons_dir %{_datadir}/kodi/addons
%define _git_version $(echo %{version} | grep -o -E '2024.*')
%define _ffmpeg_version 7.1
%define _dav1d_version 1.5.0
%define _libudfread_version 1.1.2
%define _python_version 3.13
%define _python_package 313

Name:            kodi
Version:         22.x
Release:         0
Summary:         Open source (GPL) software media center
License:         GPL-2.0-or-later
Group:           Productivity/Multimedia/Video/Players
Url:             https://www.kodi.tv
Source0:         %{name}-%{version}.tar.xz
Source2:         %{name}.service
Source3:         %{name}-rpmlintrc
Source4:         30-%{name}-power-options.rules
Source6:         override.conf
Source7:         system-user-%{name}.conf
Source8:         %{name}.logrotate
Source9:         https://ffmpeg.org/releases/ffmpeg-%{_ffmpeg_version}.tar.xz
Source10:        http://mirrors.kodi.tv/build-deps/sources/libudfread-%{_libudfread_version}.tar.gz
Source11:        https://code.videolan.org/videolan/dav1d/-/archive/1.4.0/dav1d-%{_dav1d_version}.tar.gz
Source12:        https://mirrors.kodi.tv/build-deps/sources/crossguid-ca1bf4b810e2d188d04cb6286f957008ee1b7681.tar.gz
Source13:	     https://github.com/xbmc/libdvdnav/archive/refs/tags/6.1.1-Next-Nexus-Alpha2-2.tar.gz
Source14:        https://github.com/xbmc/libdvdread/archive/refs/tags/6.1.3-Next-Nexus-Alpha2-2.tar.gz
Patch1:          001_%{name}_crossguid.patch
Patch2:          002_%{name}_python3_interpreter.patch
Patch3:          003_%{name}_move_logdir.patch
Patch4:          004_%{name}_move_userhome.patch
Patch5:          005_%{name}_move_temp.patch
Patch6:          006_%{name}_move_masterprofile.patch
Patch9:          009_%{name}_dav1d_version_hash.patch
Patch20:         020_%{name}_ffmpeg_pkgconfig.patch
Patch21:         021_%{name}_ffmpeg_version.patch
# https://github.com/LibreELEC/LibreELEC.tv/commit/df99a7e8973bc1e5f66d4b953e82a28d7346b798
Patch40:         kodi-995.21-keymaps-change-remote-poweroff-action-to-show-shutdo.patch
# https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/mediacenter/kodi/patches/wayland/kodi-999.16-PR20632-base-m_bFullScreenRoot-setting-on-res-infos-bFullScreen.patch
Patch41:         kodi-999.16-PR20632-base-m_bFullScreenRoot-setting-on-res-infos-bFullScreen.patch
# https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/mediacenter/kodi/patches/cec-framework/kodi-100.17-tinker-s-cec-disable-polling.patch
Patch42:         kodi-100.17-tinker-s-cec-disable-polling.patch
BuildRequires:   pkgconfig(libpng)
BuildRequires:   pkgconfig(libjpeg)
BuildRequires:   pkgconfig(lzo2)
BuildRequires:   pkgconfig(flatbuffers)
BuildRequires:   pkgconfig(RapidJSON) >= 1.0.2
BuildRequires:   pkgconfig(alsa)
BuildRequires:   pkgconfig(avahi-client)
BuildRequires:   pkgconfig(avahi-compat-libdns_sd)
BuildRequires:   pkgconfig(bluez)
BuildRequires:   pkgconfig(dbus-1)
BuildRequires:   pkgconfig(fmt) >= 9.1.0
BuildRequires:   pkgconfig(libidn2)
BuildRequires:   pkgconfig(freetype2)
BuildRequires:   pkgconfig(fribidi)
BuildRequires:   pkgconfig(lcms2)
BuildRequires:   pkgconfig(libass)
BuildRequires:   pkgconfig(libbluray)
BuildRequires:   pkgconfig(libcap)
BuildRequires:   pkgconfig(libcdio)
BuildRequires:   pkgconfig(libcec)
BuildRequires:   pkgconfig(libcpluff)
BuildRequires:   pkgconfig(libcurl)
BuildRequires:   pkgconfig(libdrm) >= 2.4.74
BuildRequires:   pkgconfig(libiso9660)
BuildRequires:   pkgconfig(libmicrohttpd) >= 0.9.40
BuildRequires:   pkgconfig(libnfs) >= 5.0
BuildRequires:   pkgconfig(libpcrecpp)
BuildRequires:   pkgconfig(libudev)
BuildRequires:   pkgconfig(egl)
BuildRequires:   pkgconfig(xkbcommon)
BuildRequires:   pkgconfig(libdrm)
BuildRequires:   pkgconfig(libva)
BuildRequires:   pkgconfig(libva-drm)
BuildRequires:   pkgconfig(gl)
BuildRequires:   pkgconfig(glu)
BuildRequires:   pkgconfig(xrandr)
BuildRequires:   pkgconfig(wayland-protocols)
BuildRequires:   pkgconfig(libva-wayland)
BuildRequires:   pkgconfig(wayland-scanner)
BuildRequires:   pkgconfig(wayland-scanner++)
BuildRequires:   pkgconfig(wayland-protocols)
BuildRequires:   pkgconfig(wayland-client)
BuildRequires:   pkgconfig(wayland-client++)
BuildRequires:   pkgconfig(wayland-cursor++)
BuildRequires:   pkgconfig(wayland-egl++)
BuildRequires:   pkgconfig(gbm)
BuildRequires:   pkgconfig(libxml-2.0)
BuildRequires:   pkgconfig(libxslt)
BuildRequires:   pkgconfig(lirc)
BuildRequires:   pkgconfig(lzo2)
BuildRequires:   pkgconfig(openssl)
BuildRequires:   python%{_python_package}-devel
BuildRequires:   pkgconfig(smbclient)
BuildRequires:   pkgconfig(sqlite3)
BuildRequires:   pkgconfig(taglib) >= 1.9.0
BuildRequires:   pkgconfig(uuid)
BuildRequires:   pkgconfig(zlib)
BuildRequires:   pkgconfig(libiso9660) >= 2.1.0
BuildRequires:   pkgconfig(libinput)
BuildRequires:   pkgconfig(libdisplay-info)
BuildRequires:   pkgconfig(dav1d)
BuildRequires:   Mesa-libEGL-devel
BuildRequires:   Mesa-libGLESv2-devel
BuildRequires:   Mesa-libGLESv3-devel
BuildRequires:   spdlog-devel >= 1.10.0
BuildRequires:   libunistring-devel
BuildRequires:   giflib-devel
BuildRequires:   fstrcmp-devel
BuildRequires:   java-devel
BuildRequires:   libmariadbd-devel
BuildRequires:   sndio-devel
BuildRequires:   tinyxml-devel
BuildRequires:   pkgconfig(tinyxml2)
BuildRequires:	 cmake >= 3.12
BuildRequires:	 fdupes
BuildRequires:   automake
BuildRequires:   libtool
BuildRequires:   ninja
BuildRequires:   meson
%if 0%{?suse_version} < 1599 
BuildRequires:   gcc13
BuildRequires:   gcc13-c++
%else
BuildRequires:   gcc-c++
%endif
BuildRequires:	 dos2unix
BuildRequires:   pkg-config
BuildRequires:   doxygen
BuildRequires:   graphviz
BuildRequires:   swig
BuildRequires:   gtest
BuildRequires:   polkit
BuildRequires:   git
BuildRequires:   sysuser-tools
BuildRequires:   desktop-file-utils
BuildRequires:   nasm
BuildRequires:   autoconf
BuildRequires:   waylandpp
BuildRequires:   unzip
BuildRequires:   groovy >= 4.0
BuildRequires:   apache-commons-lang3
BuildRequires:   apache-commons-text
BuildRequires:   mold
BuildRequires:   pkgconfig(exiv2)
BuildRequires:   group(audio)
BuildRequires:   group(kvm)
# Required for some addons
Requires:        python%{_python_package}-mysql-connector-python
Requires:        python%{_python_package}-Pillow
Requires:        python%{_python_package}-ijson
Requires:        python%{_python_package}-requests
Requires:        python%{_python_package}-defusedxml
Requires:        python%{_python_package}-numpy
Requires:        python%{_python_package}-requests-futures
Requires:        python%{_python_package}-future
Requires:        python%{_python_package}-pycryptodome
Requires:        libnfs >= 5.0
Requires:        samba-client
Requires:        polkit
Requires:        user(kodi) group(kodi)
Requires(post):  %fillup_prereq
Recommends:      kodi-eventclient-hama-mce
Recommends:      mariadb
Suggests:        logrotate
Conflicts:       kodi-gbm kodi-rpi
%{?systemd_requires}

%description
Kodi is an award-winning free and open source software media player and entertainment hub for digital media.
Available as a native application for Android, Linux, BSD, macOS, iOS, tvOS and Windows operating systems,
Kodi runs on most common processor architectures.
Created in 2003 by a group of like minded programmers, Kodi is a non-profit project run by the XBMC Foundation
and developed by volunteers located around the world.
More than 500 software developers have contributed to Kodi to date, and 100-plus translators have worked to expand its reach,
making it available in more than 70 languages.

%package devel
Summary:        Header files to build Kodi add-ons
Group:          Development/Libraries/C and C++
Requires:       cmake >= 3.12

%description devel
Header files to build Kodi add-ons

%package   addons-devel
Summary:   Development files to build external binary addons
BuildArch: noarch
Group:     Development/Libraries/C and C++
Requires:  cmake >= 3.12
Suggests:  %{name}-ffmpeg-devel

%description addons-devel
Development files to build external binary addons

%package -n system-user-%{name}
Summary:        System user and group %{name}
BuildArch:      noarch
%if %{with systemd}
%{?sysusers_requires}
%endif

%description -n system-user-%{name}
System user and group used by %{name}

%prep
%autosetup -n %{name}-%{version} -p1

rm -f $(find . -name ".gitignore")

%build
# avoid long delays when powerkit isn't running
sed -i \
    -e '/dbus_connection_send_with_reply_and_block/s:-1:3000:' \
    xbmc/platform/linux/*.cpp

# Fix wrong line encoding
dos2unix addons/service.xbmc.versioncheck/resources/lib/version_check/service.py
dos2unix addons/service.xbmc.versioncheck/resources/lib/version_check/viewer.py

%sysusers_generate_pre %{SOURCE7} %{name}

%if 0%{?suse_version} < 1599
test -x "$(type -p gcc-13)" && export CC="$_"
test -x "$(type -p g++-13)" && export CXX="$_"
%endif

%cmake \
    -DVERBOSE=ON \
    -DCMAKE_C_FLAGS="%optflags -fPIC" \
    -DCMAKE_CXX_FLAGS="%optflags" \
    -DCMAKE_EXE_LINKER_FLAGS="%optflags" \
    -DCMAKE_BUILD_TYPE=Release \
    -DPYTHON_VER=%{_python_version} \
    -DPYTHON_EXECUTABLE="%{_bindir}/python%{_python_version}" \
    -DPYTHON_LIBRARY="%{_libdir}/libpython%{_python_version}.so" \
    -DPYTHON_INCLUDE_DIR="%{_includedir}/python%{_python_version}" \
    -DCORE_SYSTEM_NAME=linux \
    -DAPP_RENDER_SYSTEM=gles \
    -DCORE_PLATFORM_NAME=gbm \
    -DENABLE_SSE=ON \
    -DENABLE_SSE2=ON \
    -DENABLE_SSE3=ON \
    -DENABLE_SSSE3=ON \
    -DENABLE_SSE4_1=ON \
    -DENABLE_SSE4_2=ON \
    -DENABLE_AVX=ON \
    -DENABLE_AVX2=ON \
    -DGIT_VERSION="%{_git_version}" \
    -DENABLE_EVENTCLIENTS=ON \
    -DENABLE_INTERNAL_CROSSGUID=ON \
    -DCROSSGUID_URL="%{SOURCE12}" \
    -DENABLE_INTERNAL_CDIO=OFF \
    -DENABLE_INTERNAL_FLATBUFFERS=OFF \
    -DENABLE_INTERNAL_FMT=OFF \
    -DENABLE_INTERNAL_FSTRCMP=OFF \
    -DENABLE_INTERNAL_RapidJSON=OFF \
    -DENABLE_INTERNAL_SPDLOG=OFF \
    -DENABLE_INTERNAL_DAV1D=ON \
    -DDAV1D_URL="%{SOURCE11}" \
    -DENABLE_INTERNAL_UDFREAD=ON \
    -DUDFREAD_URL="%{SOURCE10}" \
    -Dgroovy_SOURCE_DIR="%{_datadir}/groovy" \
    -Dapache-commons-lang_SOURCE_DIR="%{_javadir}" \
    -Dapache-commons-text_SOURCE_DIR="%{_javadir}/apache-commons-text" \
    -DENABLE_INTERNAL_GTEST=OFF \
    -DENABLE_INTERNAL_KISSFFT=OFF \
    -DENABLE_INTERNAL_TINYXML2=OFF \
    -DENABLE_AIRTUNES=OFF \
    -DENABLE_DVDCSS=OFF \
    -DENABLE_PULSEAUDIO=OFF \
    -DENABLE_PIPEWIRE=OFF \
    -DENABLE_MYSQLCLIENT=OFF \
    -DENABLE_MARIADBCLIENT=ON \
    -DENABLE_GOLD=OFF \
    -DENABLE_MOLD=ON \
    -DENABLE_INTERNAL_FFMPEG=ON \
    -DFFMPEG_URL="%{SOURCE9}" \
    -DLIBDVDNAV_URL="%{SOURCE13}" \
    -DLIBDVDREAD_URL="%{SOURCE14}" \
    -DENABLE_INTERNAL_CEC=OFF \
    -DENABLE_INTERNAL_NFS=OFF \
    -DENABLE_INTERNAL_PCRE=OFF \
    -DENABLE_INTERNAL_TAGLIB=OFF \
    -DENABLE_VAAPI=ON \
    -DENABLE_VDPAU=OFF \
    -DUSE_LTO=ON \
    -DBUILD_SHARED_LIBS=1 \
    -DENABLE_TESTING=OFF \
    -DENABLE_DEBUGFISSION=OFF

%cmake_build

%install
%cmake_install

# system-wide service
install -D -m 0644 %{SOURCE2} %{buildroot}/%{_unitdir}/%{name}.service
%if 0%{?suse_version} <= 1600
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif

# Kodi-Home
install -d -m 750  %{buildroot}/var/lib/%{name}

# PolicyKit
install -d -m 750  %{buildroot}/%{_sysconfdir}/polkit-1/rules.d/
install -m 644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/polkit-1/rules.d/

# Nice-Level
install -d -m 0755 %{buildroot}/%{_unitdir}/%{name}.service.d
install -m 644 %{SOURCE6} %{buildroot}/%{_unitdir}/%{name}.service.d

# System user
install -d -m 0755 %{buildroot}%{_sysusersdir}
install -m 644 %{SOURCE7} %{buildroot}%{_sysusersdir}/system-user-%{name}.conf

# Log-Directory
install -d -m 0775 %{buildroot}/var/log/%{name}

# fix permissions
chmod +x %{buildroot}%{_kodi_addons_dir}/service.xbmc.versioncheck/resources/lib/version_check/service.py
chmod +x %{buildroot}%{_kodi_addons_dir}/service.xbmc.versioncheck/resources/lib/version_check/viewer.py

# remove the doc files from unversioned /usr/share/doc/kodi, they should be in versioned docdir
rm -r %{buildroot}/%{_datadir}/doc/

# remove win32 source files
rm -f %{buildroot}%{_kodi_addons_dir}/library.kodi.addon/dlfcn-win32.cpp
rm -f %{buildroot}%{_kodi_addons_dir}/library.kodi.addon/dlfcn-win32.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.xbmc.addon/dlfcn-win32.cpp
rm -f %{buildroot}%{_kodi_addons_dir}/library.xbmc.addon/dlfcn-win32.h

# remove duplicate header files
rm -f %{buildroot}%{_kodi_addons_dir}/library.kodi.addon/libXBMC_addon.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.xbmc.addon/libXBMC_addon.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.kodi.codec/libXBMC_codec.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.xbmc.codec/libXBMC_codec.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.kodi.gui/libXBMC_gui.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.xbmc.gui/libXBMC_gui.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.kodi.pvr/libXBMC_pvr.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.xbmc.pvr/libXBMC_pvr.h
rm -f %{buildroot}%{_kodi_addons_dir}/library.kodi.guilib/libKODI_guilib.h

# copy manpages
install -m 644 -D docs/manpages/kodi-standalone.1 %{buildroot}%{_mandir}/man1/kodi-standalone.1
install -m 644 -D docs/manpages/kodi.bin.1 %{buildroot}%{_mandir}/man1/kodi.1

# desktop-file
desktop-file-install \
 --dir=%{buildroot}%{_datadir}/applications \
 %{buildroot}%{_datadir}/applications/kodi.desktop

# Logrotate
install -d -m 0755 %{buildroot}/%{_sysconfdir}/logrotate.d
install -m 644 %{SOURCE8} %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}

# addons-devel
install -d -m 0755 %{buildroot}/%{_datadir}/kodi/xbmc/xbmc/addons
install -m 644 -D xbmc/addons/CMakeLists.txt %{buildroot}/%{_datadir}/kodi/xbmc/xbmc/addons/CMakeLists.txt
install -m 644 -D xbmc/addons/AddonBindings.cmake %{buildroot}/%{_datadir}/kodi/xbmc/xbmc/addons/AddonBindings.cmake
cp -r xbmc/addons/kodi-dev-kit %{buildroot}/%{_datadir}/kodi/xbmc/xbmc/addons/kodi-dev-kit
install -d -m 0755 %{buildroot}/%{_datadir}/kodi/xbmc/xbmc/interfaces/json-rpc/schema
install -m 644 -D xbmc/interfaces/json-rpc/schema/version.txt %{buildroot}/%{_datadir}/kodi/xbmc/xbmc/interfaces/json-rpc/schema/version.txt
install -d -m 0755 %{buildroot}/%{_datadir}/kodi/xbmc/cmake
install -m 644 -D cmake/KodiConfig.cmake.in %{buildroot}/%{_datadir}/kodi/xbmc/cmake/KodiConfig.cmake.in
cp -r cmake/addons %{buildroot}/%{_datadir}/kodi/xbmc/cmake/addons
cp -r cmake/scripts %{buildroot}/%{_datadir}/kodi/xbmc/cmake/scripts
install -m 644 -D version.txt %{buildroot}/%{_datadir}/kodi/xbmc/version.txt

%fdupes %{buildroot}/%{_datadir}/kodi/
%fdupes %{buildroot}/%{_kodi_addons_dir}

%pre -n system-user-%{name} -f %{name}.pre
%pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service
%fillup_only -n %{name}

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%defattr(-,root,root,-)
%{_bindir}/*
%{_datadir}/%{name}
%exclude %{_datadir}/%{name}/xbmc
%exclude %{_datadir}/%{name}/cmake
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor
%{_datadir}/pixmaps/*
%{_datadir}/xsessions/*.desktop
%dir %{_datadir}/wayland-sessions 
%{_datadir}/wayland-sessions/kodi-gbm.desktop
%{_datadir}/metainfo/org.xbmc.kodi.metainfo.xml
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/%{name}*
%dir %{_libdir}/%{name}/system
%{_libdir}/%{name}/system/*.so
%dir %{_libdir}/python3.*/site-packages/%{name}
%{_libdir}/python3.*/site-packages/%{name}/*
%dir /usr/lib/firewalld
%dir /usr/lib/firewalld/services
/usr/lib/firewalld/services/%{name}-*.xml
%{_unitdir}/%{name}.service
%if 0%{?suse_version} <= 1600
%{_sbindir}/rc%{name}
%endif
%dir %{_unitdir}/%{name}.service.d
%config(noreplace) %{_unitdir}/%{name}.service.d/override.conf
%{_mandir}/man1/kodi.1.gz
%{_mandir}/man1/kodi-standalone.1.gz
%defattr(0750,kodi,kodi)
%dir /var/lib/kodi
%defattr(0644,root,root)
%config  %{_sysconfdir}/polkit-1/rules.d/30-%{name}-power-options.rules
%dir %attr(0770,root,kodi) /var/log/%{name}
%config %{_sysconfdir}/logrotate.d/%{name}
%dir %{_libdir}/%{name}/system/players
%dir %{_libdir}/%{name}/system/players/VideoPlayer
%{_libdir}/%{name}/system/players/VideoPlayer/libdvdnav-x86_64-linux.so

%files devel
%defattr(-,root,root,-)
%{_includedir}/%{name}
%{_datadir}/%{name}/cmake
%dir %{_libdir}/%{name}/cmake
%{_libdir}/%{name}/cmake/*

%files addons-devel
%defattr(-,root,root,-)
%dir %{_datadir}/%{name}/xbmc 
%{_datadir}/%{name}/xbmc

%files -n system-user-%{name}
%defattr(-,root,root)
%{_sysusersdir}/system-user-%{name}.conf

%changelog
openSUSE Build Service is sponsored by