## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated using the scripts at https://pagure.io/fedora-cosmic/cosmic-packaging/blob/main/f/scripts
ExcludeArch: %{ix86}
# Generated by rust2rpm 26
%bcond_without check


# While our version corresponds to an upstream tag, we still need to define
# these macros in order to set the VERGEN_GIT_SHA and VERGEN_GIT_COMMIT_DATE
# environment variables in multiple sections of the spec file.
%global commit 311b944d3f549af21a57fd348d0ede8219dd7f9c
%global commitdatestring 2024-11-26 16:33:30 +0100
%global cosmic_minver 1.0.0~alpha.4

Name:           cosmic-randr
Version:        1.0.0~alpha.4
Release:        %autorelease
Summary:        Display configuration command line tool

License:        (0BSD OR Apache-2.0 OR MIT) AND Apache-2.0 AND (Apache-2.0 OR Apache-2.0 WITH LLVM-exception OR MIT) AND (Apache-2.0 OR MIT) AND (Apache-2.0 OR MIT OR Zlib) AND GPL-3.0-only AND ISC AND MIT AND (MIT OR Unlicense) AND MPL-2.0 AND Zlib

URL:            https://github.com/pop-os/cosmic-randr

Source0:        https://github.com/pop-os/cosmic-randr/archive/epoch-%{version_no_tilde}/cosmic-randr-%{version_no_tilde}.tar.gz
# To create the below sources:
# * git clone https://github.com/pop-os/cosmic-randr at the specified commit
# * cargo vendor > vendor-config-%%{version_no_tilde}.toml
# * tar -pczf vendor-%%{version_no_tilde}.tar.gz vendor
Source1:        vendor-%{version_no_tilde}.tar.gz
# * mv vendor-config-%%{version_no_tilde}.toml ..
Source2:        vendor-config-%{version_no_tilde}.toml

BuildRequires:  cargo-rpm-macros >= 25
BuildRequires:  rustc
BuildRequires:  lld
BuildRequires:  cargo
BuildRequires:  wayland-devel
BuildRequires:  just

%global _description %{expand:
Cosmic-randr command line interface.}

%description %{_description}

%prep
%autosetup -n cosmic-randr-epoch-%{version_no_tilde} -p1 -a1
%cargo_prep -N
# Check if .cargo/config.toml exists
if [ -f .cargo/config.toml ]; then
  # If it exists, append the contents of %%{SOURCE2} to .cargo/config.toml
  cat %{SOURCE2} >> .cargo/config.toml
  echo "Appended %{SOURCE2} to .cargo/config.toml"
else
  # If it does not exist, append the contents of %%{SOURCE2} to .cargo/config
  cat %{SOURCE2} >> .cargo/config
  echo "Appended %{SOURCE2} to .cargo/config"
fi

%build
# Set vergen environment variables
export VERGEN_GIT_COMMIT_DATE="date --utc '%{commitdatestring}'"
export VERGEN_GIT_SHA="%{commit}"
%cargo_build
%{cargo_license_summary}
%{cargo_license} > LICENSE.dependencies
%{cargo_vendor_manifest}
sed 's/\(.*\) (.*#\(.*\))/\1+git\2/' -i cargo-vendor.txt

%install
# Set vergen environment variables
export VERGEN_GIT_COMMIT_DATE="date --utc '%{commitdatestring}'"
export VERGEN_GIT_SHA="%{commit}"
just rootdir=%{buildroot} prefix=%{_prefix} install

%if %{with check}
%check
# Set vergen environment variables
export VERGEN_GIT_COMMIT_DATE="date --utc '%{commitdatestring}'"
export VERGEN_GIT_SHA="%{commit}"
%cargo_test
%endif

%files
%license LICENSE
%license LICENSE.dependencies
%license cargo-vendor.txt
%doc README.md
%{_bindir}/cosmic-randr

%changelog
## START: Generated by rpmautospec
* Fri Dec 06 2024 Ryan Brue <ryanbrue.dev@gmail.com> - 1.0.0~alpha.4-1
- "Update to 1.0.0~alpha.4"

* Sat Nov 02 2024 Ryan Brue <ryanbrue.dev@gmail.com> - 1.0.0~alpha.3-1
- "Update to 1.0.0~alpha.3"

* Sat Sep 28 2024 Ryan Brue <ryanbrue.dev@gmail.com> - 1.0.0~alpha.2-1
- Initial commit (1.0.0~alpha.2)
## END: Generated by rpmautospec