File anyrun.spec of Package anyrun

Name:           anyrun
#               This will be set by osc services, that will run after this.
Version:        0+git1771833858_a289cd0
Release:        0
Summary:        A wayland native krunner-like runner, made with customizability in mind
License:        GPL-3.0+
Group:          System/GUI/Other
Url:            https://github.com/Kirottu/anyrun
Source0:        %{name}-%{version}.tar.zst
Source1:        vendor.tar.zst
# cargo vendor > cargo_config
Source2:        cargo_config
# cargo generate-lockfile
Source3:        Cargo.lock
Patch0:  plugin-dir.patch
%if 0%{?suse_version}
BuildRequires:  cargo
BuildRequires:  cargo-packaging
%endif
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
%global __brp_mangle_shebangs /usr/bin/true
BuildRequires: cargo-rpm-macros
%endif
BuildRequires: pkgconfig(gdk-pixbuf-2.0)
BuildRequires: pkgconfig(pango)
BuildRequires: pkgconfig(atk)
BuildRequires: pkgconfig(gtk4)
BuildRequires: pkgconfig(gtk4-layer-shell-0)
# Disable this line if you wish to support all platforms.
# In most situations, you will likely only target tier1 arches for user facing components.
#ExclusiveArch:  %{rust_tier1_arches}

%description
A wayland native krunner-like runner, made with customizability in mind.

%prep
# The number passed to -a (a stands for "after") should be equivalent to the Source tag number
# of the vendor tarball, 1 in this case (from Source1).
%autosetup -a1 -N

find -name main.rs
#patch -P0 -p1
rm -f .cargo/config.toml
install -D -m 644 %{SOURCE2} .cargo/config.toml
install -D -m 644 %{SOURCE3} Cargo.lock
# Remove exec bits to prevent an issue in fedora shebang checking. Uncomment only if required.
# find vendor -type f -name \*.rs -exec chmod -x '{}' \;

%if 0%{?fedora}
/usr/bin/mkdir -p target/rpm
/usr/bin/ln -s rpm target/release
cat >> Cargo.toml <<'EOF'
[build]
rustc = "/usr/bin/rustc"
rustdoc = "/usr/bin/rustdoc"

[profile.rpm]
inherits = "release"
opt-level = 3
codegen-units = 1
debug = 2
strip = "none"
EOF
%endif


%build
%if 0%{?suse_version}
%{cargo_build}
%endif
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
/usr/bin/cargo build -j4 --offline --release
#/usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 'RUSTFLAGS=-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-Wl,-z,relro -Clink-arg=-Wl,-z,now -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn' /usr/bin/cargo build -j4 -Z avoid-dev-deps
%endif

%install
install -d -m 0755 %{buildroot}%{_bindir}
install -d -m 0755 %{buildroot}/usr/lib/anyrun/plugins

install -m 0755 target/release/anyrun %{buildroot}%{_bindir}/anyrun
cp target/release/*.so %{buildroot}/usr/lib/anyrun/plugins
mkdir -p %{buildroot}/%{_sysconfdir}/anyrun
cp examples/config.ron %{buildroot}/%{_sysconfdir}/anyrun/

%check
%if 0%{?suse_version}
%{cargo_test}
%endif
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
/usr/bin/cargo test -j4 --offline --no-fail-fast
%endif

%files
%defattr(-, root, root)
%{_sysconfdir}/anyrun/*.ron
%{_bindir}/%{name}
/usr/lib/anyrun/plugins/*.so
%dir %{_sysconfdir}/anyrun
%dir /usr/lib/anyrun
%dir /usr/lib/anyrun/plugins

%changelog
openSUSE Build Service is sponsored by