File xpra.spec of Package xpra-5

# spec file for package xpra
#
# Copyright (c) 2023 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
%ifarch x86_64 ppc64 s390x aarch64 riscv64
%global with_pandoc 1
%endif
%bcond_with pandoc
# -----
# Comes from git tarball setup.py:
# setup.py build --verbose ...
# Xpra version 4.4
#%%define xpra_ver 4.4
# ----
%if 0%{?suse_version} >= 1550
%define ffmpeg_ver 7
%else
%define ffmpeg_ver 4
%endif

# ----
%global __requires_exclude ^typelib\\(GtkosxApplication\\)|typelib\\(GdkGLExt\\)|typelib\\(GtkGLExt\\).*$
Name:           xpra-5
Version:        5.1.2
Release:        0
Summary:        Remote display server for applications and desktops
License:        BSD-3-Clause AND GPL-2.0-or-later AND LGPL-3.0-or-later AND MIT
Group:          System/X11/Utilities
URL:            https://www.xpra.org/
Source0:        xpra-%{version}.tar.gz
Source1:        xpra-icon.png
Source2:        sysconfig.xpra
Patch2:         0001-Add-compatibility-with-FFMPEG-7.0.patch
# ----
BuildRequires:  ImageMagick
BuildRequires:  brotli
BuildRequires:  cups
BuildRequires:  cups-devel
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  ffmpeg-%{ffmpeg_ver}
BuildRequires:  ffmpeg-%{ffmpeg_ver}-libavcodec-devel
BuildRequires:  ffmpeg-%{ffmpeg_ver}-libavformat-devel
BuildRequires:  ffmpeg-%{ffmpeg_ver}-libavutil-devel
BuildRequires:  ffmpeg-%{ffmpeg_ver}-libswresample-devel
BuildRequires:  ffmpeg-%{ffmpeg_ver}-libswscale-devel
BuildRequires:  git-core
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  hicolor-icon-theme
# ----
%define using_release "distribution-release"
BuildRequires:  distribution-release
# ----
BuildRequires:  pam-devel
%if %{with pandoc}
BuildRequires:  pandoc
%endif
BuildRequires:  pkgconfig
BuildRequires:  python3-Cython >= 0.20.0
BuildRequires:  python3-devel
BuildRequires:  python3-gobject-devel
BuildRequires:  python3-pyxdg
BuildRequires:  python3-setuptools
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(libavcodec) >= 58
BuildRequires:  pkgconfig(libavformat) >= 58
BuildRequires:  pkgconfig(liblz4)
BuildRequires:  pkgconfig(libswscale) >= 5
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(libwebp) >= 0.4
# TW can do this, 15.4 can't ...
#BuildRequires:  pkgconfig(pam)
#BuildRequires:  pkgconfig(pam_misc)
BuildRequires:  pkgconfig(py3cairo)
BuildRequires:  procps-devel
BuildRequires:  qrencode-devel
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(vpx) >= 1.4.0
BuildRequires:  pkgconfig(xcomposite)
BuildRequires:  pkgconfig(xdamage)
BuildRequires:  pkgconfig(xkbfile)
BuildRequires:  pkgconfig(xrandr)
BuildRequires:  pkgconfig(xres)
BuildRequires:  pkgconfig(xtst)
Requires:       dbus-1-x11
Requires:       gstreamer-plugins-base
Requires:       gstreamer-plugins-good
Requires:       gstreamer-utils
Requires:       pulseaudio-daemon
Requires:       pulseaudio-utils
Requires:       python3-Pillow
Requires:       python3-cairo
Requires:       python3-dbus-python
Requires:       python3-gobject-Gdk
Requires:       python3-gst
Requires:       python3-lz4
Requires:       python3-opencv
Requires:       python3-pycups
Requires:       python3-rencode
Requires:       shared-mime-info
Requires:       xf86-video-dummy
Requires:       xorg-x11-xauth
Provides:       xpra
Requires(post): %fillup_prereq
Recommends:     lsb-release
Recommends:     pinentry
Recommends:     pulseaudio-module-x11
Recommends:     python3-dnspython
Recommends:     python3-netifaces
Recommends:     python3-opencv
Recommends:     python3-opengl
Recommends:     python3-opengl-accelerate
Recommends:     python3-paramiko
Recommends:     python3-pyinotify
Recommends:     python3-pyxdg
Recommends:     xdg-menu
# Overflow errors on 32-bit
ExcludeArch:    %ix86
%{?systemd_ordering}
%define xpra_ver %{version}
%description
Xpra is "screen for X": it allows you to run X programs, usually on a remote
host, direct their display to your local machine, and then to disconnect from
these programs and reconnect from the same or another machine, without losing
any state. It gives you remote access to individual applications.

Xpra is "rootless" or "seamless": programs you run under it show up on your
desktop as regular programs, managed by your regular window manager.
Sessions can be accessed over SSH, or password protected over plain TCP sockets.
Xpra is usable over reasonably slow links and does its best to adapt to changing
network bandwidth constraints.

%prep

%setup -q -n xpra-%{version}
%patch -P2 -p1
find -name '*.py' \
  -exec sed -i '1{\@^#!/usr/bin/env python@d}' {} +
find \( -name xpraforwarder \
  -o -name auth_dialog \
  -o -name daemonizer \
  -o -name xdg-open \
  -o -name xpra_signal_listener \) \
  -exec sed -i 's@#!%{_bindir}/env python3$@#!%{_bindir}/python3@' {} +
install -m0644 %{SOURCE1} -T fs/share/icons/xpra.png
# misc fixes for SUSE specific differences upstream
baselibexec=$(basename $(rpm -E '%{_libexecdir}'))
sed -e 's|__FILLUPDIR__|%{_fillupdir}|' \
  -e 's|__UNITDIR__|%{_unitdir}|' \
  -e 's|share/doc/xpra|share/doc/packages/xpra|' \
  -e "s|__LIBEXECDIR__|$baselibexec|" \
  -i setup.py

%build

### DEBUGGING
echo "ffmpeg_ver:    %ffmpeg_ver"
echo "suse_version:  %suse_version"
echo "using_release: %using_release"
#####

export CFLAGS="%{optflags}"
#%%if 0%%{?suse_version} <= 1500
export CFLAGS="$CFLAGS -Wno-error=deprecated-declarations"
#%%endif
python3 setup.py clean

python3 setup.py build \
  --verbose \
  --with-enc_ffmpeg \
  --with-vpx \
  --with-dec_avcodec2 \
  --with-csc_swscale \
  --with-webp \
  --with-Xdummy \
  --with-Xdummy_wrapper \
  --with-opengl \
  --with-service \
  --without-cuda_kernels \
  --without-nvenc \
%if !%{with pandoc}
  --without-docs \
%endif
  --without-nvfbc
#%%if %%{ffmpeg_ver} == 4
#  --without-nvfbc
#%%endif
#%%if %%{ffmpeg_ver} == 5
#  --without-nvfbc
#%%endif
#%%if %%{ffmpeg_ver} == 5
#  --without-nvfbc \
#  --without-strict
#%%endif

%install
python3 setup.py install \
  --skip-build \
  --root %{buildroot} \
  --prefix %{_prefix} \
  --with-service \
  --with-Xdummy \
  --with-Xdummy_wrapper \
%if !%{with pandoc}
  --without-docs \
%endif
  --verbose

rm -rf %{buildroot}%{_datadir}/xpra/cuda

%suse_update_desktop_file -r xpra Network RemoteAccess
%suse_update_desktop_file -r xpra-gui Network RemoteAccess
%suse_update_desktop_file -r xpra-launcher Network RemoteAccess

mkdir -pv %{buildroot}%{_sbindir}
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcxpra

%if 0%{?suse_version} > 1500
mkdir -p %{buildroot}%{_pam_vendordir}
mv %{buildroot}%{_sysconfdir}/pam.d/xpra %{buildroot}%{_pam_vendordir}
%endif
%fdupes -s %{buildroot}
# leap 16.0 obs bug workaround
%if %{?suse_version}0 <= 16890
install -Dpm 644 fs/share/icons/xpra-mdns.png %{buildroot}%{_datadir}/pixmaps/xpra-mdns.png
install -Dpm 644 fs/share/icons/xpra-shadow.png %{buildroot}%{_datadir}/pixmaps/xpra-shadow.png
install -Dpm 644 fs/share/icons/xpra.png %{buildroot}%{_datadir}/pixmaps/xpra.png
install -Dpm 644 %{SOURCE2} %{buildroot}%{_datadir}/fillup-templates/sysconfig.xpra
rm -rf %{buildroot}%{_datadir}/icons
rm -f %{buildroot}%{_sysconfdir}/sysconfig/xpra
%endif
#fix shebang for SuSE not link python to python3
sed -i '1s/python/\/usr\/bin\/env\ python3/' %{buildroot}%{_bindir}/run_scaled
sed -i '1s/python/\/usr\/bin\/env\ python3/' %{buildroot}%{_bindir}/xpra
sed -i '1s/python/\/usr\/bin\/env\ python3/' %{buildroot}%{_bindir}/xpra_launcher

%pre
getent group xpra >/dev/null || groupadd -r xpra
mkdir -p %{_rundir}/xpra || exit 1
%service_add_pre xpra.service
%service_add_pre xpra.socket
%if 0%{?suse_version} > 1500
# Prepare for migration to /usr/lib; save any old .rpmsave
for i in pam.d/xpra ; do
     test -f %{_sysconfdir}/${i}.rpmsave && mv -v %{_sysconfdir}/${i}.rpmsave %{_sysconfdir}/${i}.rpmsave.old ||:
done

%posttrans
# Migration to /usr/lib, restore just created .rpmsave
for i in pam.d/xpra ; do
     test -f %{_sysconfdir}/${i}.rpmsave && mv -v %{_sysconfdir}/${i}.rpmsave %{_sysconfdir}/${i} ||:
done
%endif

%post
%service_add_post xpra.service
%service_add_post xpra.socket
%fillup_only xpra
%tmpfiles_create %{_tmpfilesdir}/xpra.conf

%preun
%service_del_preun xpra.service
%service_del_preun xpra.socket

%postun
%service_del_postun xpra.service
%service_del_postun xpra.socket

%files
%if %{with pandoc}
%endif
# leap 16.0 obs bug workaround
%if %{?suse_version}0 <= 16890
#%{_datadir}/icons/xpra-mdns.png
#%{_datadir}/icons/xpra-shadow.png
#%{_datadir}/icons/xpra.png
%{_datadir}/xpra/COPYING
%{_datadir}/xpra/README.md
/lib/systemd/system/xpra.service
/lib/systemd/system/xpra.socket
%else
#%{_prefix}/lib/systemd/system/xpra.service
#%{_prefix}/lib/systemd/system/xpra.socket
#%else
%{_unitdir}/xpra.service
%{_unitdir}/xpra.socket
%endif
%doc docs/README.md docs/CHANGELOG.md
%if %{with pandoc}
%doc %{_defaultdocdir}/xpra
%endif
%license COPYING
%dir %{_datadir}/xpra
%dir %{_sysconfdir}/xpra
%dir %{_sysconfdir}/xpra/conf.d
%dir %{_sysconfdir}/xpra/content-categories
%dir %{_sysconfdir}/xpra/content-parent
%dir %{_sysconfdir}/xpra/content-type
%dir %{_sysconfdir}/xpra/http-headers
%if 0%{?suse_version} > 1500
%{_pam_vendordir}/xpra
%else
%dir %{_sysconfdir}/pam.d
%config(noreplace) %{_sysconfdir}/pam.d/xpra
%endif
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/xpra.conf
%config(noreplace) %{_sysconfdir}/xpra/*.conf
%config(noreplace) %{_sysconfdir}/xpra/conf.d/*.conf
%config(noreplace) %{_sysconfdir}/xpra/content-categories/*.conf
%config(noreplace) %{_sysconfdir}/xpra/content-parent/*.conf
%config(noreplace) %{_sysconfdir}/xpra/content-type/*.conf
%config(noreplace) %{_sysconfdir}/xpra/http-headers/*.txt
%config(noreplace) %{_sysconfdir}/X11/xorg.conf.d/90-xpra-virtual.conf
%{_fillupdir}/sysconfig.xpra
%{_bindir}/run_scaled
%{_bindir}/xpra
%{_bindir}/xpra_Xdummy
%{_bindir}/xpra_launcher
%{_udevrulesdir}/71-xpra-virtual-pointer.rules
%dir %{_libexecdir}/xpra
%{_libexecdir}/xpra/auth_dialog
%{_libexecdir}/xpra/gnome-open
%{_libexecdir}/xpra/gvfs-open
%{_libexecdir}/xpra/xdg-open
%{_libexecdir}/xpra/xpra_signal_listener
%{_libexecdir}/xpra/xpra_udev_product_version
%{_libexecdir}/xpra/xpra_weston_xvfb
%{_sbindir}/rcxpra
%{python3_sitearch}/xpra
%{python3_sitearch}/xpra-%{xpra_ver}-py%{python3_version}.egg-info
%{_datadir}/applications/xpra-gui.desktop
%{_datadir}/applications/xpra-launcher.desktop
%{_datadir}/applications/xpra-shadow.desktop
%{_datadir}/applications/xpra.desktop
%{_datadir}/metainfo/xpra.appdata.xml
%{_datadir}/pixmaps/xpra-mdns.png
%{_datadir}/pixmaps/xpra-shadow.png
%{_datadir}/pixmaps/xpra.png
%{_datadir}/mime/packages/application-x-xpraconfig.xml
%{_datadir}/xpra/autostart.desktop
%{_datadir}/xpra/bell.wav
%{_datadir}/xpra/css
%{_datadir}/xpra/icons
%{_prefix}/lib/cups/backend/xpraforwarder
%{_mandir}/man1/run_scaled.1%{?ext_man}
%{_mandir}/man1/xpra.1%{?ext_man}
%{_mandir}/man1/xpra_launcher.1%{?ext_man}
%{_sysusersdir}/xpra.conf
%{_tmpfilesdir}/xpra.conf
%ghost %dir %{_rundir}/xpra
%ghost %dir %{_rundir}/xpra/proxy

%changelog
openSUSE Build Service is sponsored by