# Generated by rust2rpm 24
# XXX: sccache_cargo and system test sets are failing
%bcond_with check
%ifarch x86_64
%bcond_without dist_server
%endif

%global crate sccache

Name:           rust-sccache
Version:        0.4.1
Release:        0.1%{?dist}
Summary:        Ccache-like tool

License:        Apache-2.0
URL:            https://crates.io/crates/sccache
Source:         %{crates_source}

Source100:      %{crate}-scheduler.service
Source101:      %{crate}-server.service
Source102:      scheduler.conf
Source103:      server.conf
# Automatically generated patch to strip foreign dependencies
Patch:          sccache-fix-metadata.diff

BuildRequires:  cargo-rpm-macros >= 24
BuildRequires:  systemd-rpm-macros

%global _description %{expand:
Sccache is a ccache-like tool. It is used as a compiler wrapper and
avoids compilation when possible, storing a cache in a remote storage
using the S3 API.}

%description %{_description}

%package     -n %{crate}
Summary:        %{summary}

%description -n %{crate} %{_description}

%files       -n %{crate}
%license LICENSE
%doc README.md
%doc docs/*
%{_bindir}/sccache

%if %{with dist_server}
%package     -n %{crate}-dist
Summary:        %{summary}
Requires:       bubblewrap

%description -n %{crate}-dist %{_description}
This package contains distributed compilation server and scheduler part of sccache.

%files       -n %{crate}-dist
%license LICENSE
%doc README.md
%doc docs/*
%{_bindir}/sccache-dist
%dir %{_sharedstatedir}/%{crate}
%dir %{_sysconfdir}/%{crate}
%config(noreplace) %{_sysconfdir}/%{crate}/scheduler.conf
%config(noreplace) %{_sysconfdir}/%{crate}/server.conf
%{_unitdir}/%{crate}-scheduler.service
%{_unitdir}/%{crate}-server.service

%post -n %{crate}-dist
%systemd_post %{crate}-scheduler.service %{crate}-server.service

%preun -n %{crate}-dist
%systemd_preun %{crate}-scheduler.service %{crate}-server.service

%postun -n %{crate}-dist
%systemd_postun %{crate}-scheduler.service %{crate}-server.service
%endif

%package        devel
Summary:        %{summary}
BuildArch:      noarch

%description    devel %{_description}

This package contains library source intended for building other packages which
use the "%{crate}" crate.

%files          devel
%license %{crate_instdir}/LICENSE
%doc %{crate_instdir}/CODE_OF_CONDUCT.md
%doc %{crate_instdir}/README.md
%{crate_instdir}/

%package     -n %{name}+default-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+default-devel %{_description}

This package contains library source intended for building other packages which
use the "default" feature of the "%{crate}" crate.

%files       -n %{name}+default-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+all-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+all-devel %{_description}

This package contains library source intended for building other packages which
use the "all" feature of the "%{crate}" crate.

%files       -n %{name}+all-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+azure-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+azure-devel %{_description}

This package contains library source intended for building other packages which
use the "azure" feature of the "%{crate}" crate.

%files       -n %{name}+azure-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+crossbeam-utils-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+crossbeam-utils-devel %{_description}

This package contains library source intended for building other packages which
use the "crossbeam-utils" feature of the "%{crate}" crate.

%files       -n %{name}+crossbeam-utils-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+dist-client-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+dist-client-devel %{_description}

This package contains library source intended for building other packages which
use the "dist-client" feature of the "%{crate}" crate.

%files       -n %{name}+dist-client-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+dist-server-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+dist-server-devel %{_description}

This package contains library source intended for building other packages which
use the "dist-server" feature of the "%{crate}" crate.

%files       -n %{name}+dist-server-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+dist-tests-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+dist-tests-devel %{_description}

This package contains library source intended for building other packages which
use the "dist-tests" feature of the "%{crate}" crate.

%files       -n %{name}+dist-tests-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+flate2-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+flate2-devel %{_description}

This package contains library source intended for building other packages which
use the "flate2" feature of the "%{crate}" crate.

%files       -n %{name}+flate2-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+gcs-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+gcs-devel %{_description}

This package contains library source intended for building other packages which
use the "gcs" feature of the "%{crate}" crate.

%files       -n %{name}+gcs-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+gha-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+gha-devel %{_description}

This package contains library source intended for building other packages which
use the "gha" feature of the "%{crate}" crate.

%files       -n %{name}+gha-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+hyper-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+hyper-devel %{_description}

This package contains library source intended for building other packages which
use the "hyper" feature of the "%{crate}" crate.

%files       -n %{name}+hyper-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+jsonwebtoken-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+jsonwebtoken-devel %{_description}

This package contains library source intended for building other packages which
use the "jsonwebtoken" feature of the "%{crate}" crate.

%files       -n %{name}+jsonwebtoken-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+libmount-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+libmount-devel %{_description}

This package contains library source intended for building other packages which
use the "libmount" feature of the "%{crate}" crate.

%files       -n %{name}+libmount-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+memcached-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+memcached-devel %{_description}

This package contains library source intended for building other packages which
use the "memcached" feature of the "%{crate}" crate.

%files       -n %{name}+memcached-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+native-zlib-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+native-zlib-devel %{_description}

This package contains library source intended for building other packages which
use the "native-zlib" feature of the "%{crate}" crate.

%files       -n %{name}+native-zlib-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+nix-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+nix-devel %{_description}

This package contains library source intended for building other packages which
use the "nix" feature of the "%{crate}" crate.

%files       -n %{name}+nix-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+opendal-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+opendal-devel %{_description}

This package contains library source intended for building other packages which
use the "opendal" feature of the "%{crate}" crate.

%files       -n %{name}+opendal-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+openssl-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+openssl-devel %{_description}

This package contains library source intended for building other packages which
use the "openssl" feature of the "%{crate}" crate.

%files       -n %{name}+openssl-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+redis-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+redis-devel %{_description}

This package contains library source intended for building other packages which
use the "redis" feature of the "%{crate}" crate.

%files       -n %{name}+redis-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+reqsign-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+reqsign-devel %{_description}

This package contains library source intended for building other packages which
use the "reqsign" feature of the "%{crate}" crate.

%files       -n %{name}+reqsign-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+reqwest-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+reqwest-devel %{_description}

This package contains library source intended for building other packages which
use the "reqwest" feature of the "%{crate}" crate.

%files       -n %{name}+reqwest-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+rouille-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+rouille-devel %{_description}

This package contains library source intended for building other packages which
use the "rouille" feature of the "%{crate}" crate.

%files       -n %{name}+rouille-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+s3-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+s3-devel %{_description}

This package contains library source intended for building other packages which
use the "s3" feature of the "%{crate}" crate.

%files       -n %{name}+s3-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+sha2-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+sha2-devel %{_description}

This package contains library source intended for building other packages which
use the "sha2" feature of the "%{crate}" crate.

%files       -n %{name}+sha2-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+syslog-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+syslog-devel %{_description}

This package contains library source intended for building other packages which
use the "syslog" feature of the "%{crate}" crate.

%files       -n %{name}+syslog-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+url-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+url-devel %{_description}

This package contains library source intended for building other packages which
use the "url" feature of the "%{crate}" crate.

%files       -n %{name}+url-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+version-compare-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+version-compare-devel %{_description}

This package contains library source intended for building other packages which
use the "version-compare" feature of the "%{crate}" crate.

%files       -n %{name}+version-compare-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+void-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+void-devel %{_description}

This package contains library source intended for building other packages which
use the "void" feature of the "%{crate}" crate.

%files       -n %{name}+void-devel
%ghost %{crate_instdir}/Cargo.toml

%package     -n %{name}+webdav-devel
Summary:        %{summary}
BuildArch:      noarch

%description -n %{name}+webdav-devel %{_description}

This package contains library source intended for building other packages which
use the "webdav" feature of the "%{crate}" crate.

%files       -n %{name}+webdav-devel
%ghost %{crate_instdir}/Cargo.toml

%prep
%autosetup -n %{crate}-%{version_no_tilde} -p1
%cargo_prep
# This test requires thirtyfour_sync, network and a browser
rm -f tests/oauth.rs

%generate_buildrequires
%cargo_generate_buildrequires %{?with_dist_server:-f dist-server}

%build
%cargo_build %{?with_dist_server:-f dist-server}

%install
%cargo_install %{?with_dist_server:-f dist-server}

%if %{with dist_server}
install -d -m 750 -pv %{buildroot}%{_sharedstatedir}/%{crate}
install -D -m 644 -pv %{SOURCE100} %{buildroot}%{_unitdir}/%{crate}-scheduler.service
install -D -m 644 -pv %{SOURCE101} %{buildroot}%{_unitdir}/%{crate}-server.service
# configs contain secret keys and tokens, thus 0600
install -D -m 600 -pv %{SOURCE102} %{buildroot}%{_sysconfdir}/%{crate}/scheduler.conf
install -D -m 600 -pv %{SOURCE103} %{buildroot}%{_sysconfdir}/%{crate}/server.conf
%endif

%if %{with check}
%check
%cargo_test %{?with_dist_server:-f dist-server}
%endif

%changelog
* Mon Mar 27 2023 Aleksei Bavshin <alebastr@fedoraproject.org> - 0.4.1-0.1
- Update to 0.4.1

* Sat Mar 25 2023 Aleksei Bavshin <alebastr@fedoraproject.org> - 0.4.0-0.1
- Initial package