File jay.spec of Package jay

#
# spec file for package jay
#
# Copyright (c) 2022 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/
#


%global rustflags '-Clink-arg=-Wl,-z,relro,-z,now'
%global _lto_cflags %nil

Name:           jay
Version:        1.9.0
Release:        0
Summary:        A Wayland compositor written in rust
License:        GPL-3.0-only
URL:            https://github.com/mahkoh/jay
Source0:        %{name}-%{version}.tar.zst
Source1:        vendor.tar.zst
Source2:        jay-run.sh
Source3:        jay.desktop
Source4:        xdg-desktop-portal-jay.service
Source5:        org.freedesktop.impl.portal.desktop.jay.service
%if 0%{?suse_version}
BuildRequires:  cargo-packaging
BuildRequires:  rust+cargo
ExclusiveArch:  %{rust_tier1_arches}
%else
BuildRequires:  rust >= 1.64
BuildRequires:  cargo >= 1.64
%endif
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(cairo)
BuildRequires:  pkgconfig(dbus-1)
BuildRequires:  pkgconfig(dbus-1) >= 1.10
BuildRequires:  pkgconfig(egl)
BuildRequires:  pkgconfig(gbm)
BuildRequires:  pkgconfig(inih)
BuildRequires:  pkgconfig(libinput)
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(libudev)
BuildRequires:  pkgconfig(pango)
BuildRequires:  pkgconfig(pangocairo)
BuildRequires:  pkgconfig(shaderc)
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(wayland-client)
BuildRequires:  pkgconfig(wayland-protocols)
BuildRequires:  pkgconfig(xkbcommon)
BuildRequires:  zstd
BuildRequires:  cmake
BuildRequires:  clang
BuildRequires:  fdupes
Recommends:     pipewire
Recommends:     xorg-x11-server-wayland
Requires:       xdg-desktop-portal
Requires:       dbus-1

%description
Jay is a Wayland compositor written and configured in the rust programming language with hot-reload support.
Jay offers improved flexibility, configurability, stability, and performance.

%prep
%autosetup -a1

%build
export CC=clang
export CXX=clang++
export CFLAGS="%optflags $(pkg-config --libs --cflags shaderc)"
export CXXFLAGS="%optflags $(pkg-config --libs --cflags shaderc)"
export CARGO_HOME="$PWD/.cargo"
%if 0%{?fedora}
unset LIBSSH2_SYS_USE_PKG_CONFIG
export CARGO_AUDITABLE=auditable
export CARGO_FEATURE_VENDORED=1
cargo build --offline --release --all-features --locked
%else
%{cargo_build} --locked
%endif

%install
export CC=clang
export CXX=clang++
export CFLAGS="%optflags $(pkg-config --libs --cflags shaderc)"
export CXXFLAGS="%optflags $(pkg-config --libs --cflags shaderc)"
mkdir -p %{buildroot}%{_libdir}/crates/
export CARGO_HOME="$PWD/.cargo"
%if 0%{?fedora}
unset LIBSSH2_SYS_USE_PKG_CONFIG
export CARGO_AUDITABLE=auditable
export CARGO_FEATURE_VENDORED=1
cargo install --offline --no-track --root="%{buildroot}%{_prefix}" --path . --locked
%else
%{cargo_install} --locked
%endif

install -Dm755 %{SOURCE2} -t %{buildroot}%{_bindir}
install -Dm644 %{SOURCE3} -t %{buildroot}%{_datadir}/wayland-sessions
install -Dm644 etc/%{name}.portal -t %{buildroot}%{_datadir}/xdg-desktop-portal/portals
install -Dm644 etc/%{name}-portals.conf -t %{buildroot}%{_datadir}/xdg-desktop-portal/

install -Dm644 %{SOURCE4} -t %{buildroot}%{_userunitdir}
install -Dm644 %{SOURCE5} -t %{buildroot}%{_datadir}/dbus-1/services

# Although this is discouraged, it would be unwise to make users have the
# trouble of cloning the entire crate for their configs.
cp -rv $PWD \
	%{buildroot}%{_libdir}/crates/jay

pushd %{buildroot}%{_libdir}/crates/jay
rm -rf .github
rm -rf vendor
rm -rf target
rm -rf .cargo
rm -rf .builds
popd
%fdupes -s %{buildroot}/%{_libdir}
%fdupes -s %{buildroot}/%{_datadir}
%fdupes -s %{buildroot}/%{_prefix}

%files
%{_bindir}/jay
%{_bindir}/jay-run.sh
%dir %{_datadir}/wayland-sessions
%dir %{_datadir}/xdg-desktop-portal
%dir %{_libdir}/crates/
%dir %{_libdir}/crates/jay
%{_libdir}/crates/jay/*
%{_datadir}/wayland-sessions/jay.desktop
%{_datadir}/xdg-desktop-portal/%{name}-portals.conf
%dir %{_datadir}/xdg-desktop-portal/portals
%{_datadir}/xdg-desktop-portal/portals/jay.portal
%{_userunitdir}/xdg-desktop-portal-jay.service
%{_datadir}/dbus-1/services/org.freedesktop.impl.portal.desktop.jay.service
%license LICENSE
%doc README.md jay-config

%changelog
openSUSE Build Service is sponsored by