## 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 by rust2rpm 27
%bcond check 1

%global crate oxipng

Name:           rust-oxipng
Version:        9.1.3
Release:        %autorelease
Summary:        Lossless PNG compression optimizer

License:        MIT
URL:            https://crates.io/crates/oxipng
Source:         %{crates_source}
# * We need the GitHub archive, in addition to the .crate from crates.io,
#   because the crate does not contain the xtask/ directory required for
#   generating a man page. However, because of some dubiously-licensed test
#   files (https://github.com/shssoichiro/oxipng/issues/655), we must use a
#   filtered version of the GitHub archive, obtained by running the script in
#   Source11. We have asked upstream to simply include the contents of xtask/ in
#   the published crates, https://github.com/shssoichiro/oxipng/issues/654.
Source10:       https://github.com/shssoichiro/oxipng/archive/v%{version}/oxipng-%{version}-filtered.tar.gz
# * Script used to obtain Source10: ./get_source %%{version}
Source11:       get_source
# Automatically generated patch to strip dependencies and normalize metadata
Patch:          oxipng-fix-metadata-auto.diff
# * Fix manpage for --zi
Patch10:        https://github.com/shssoichiro/oxipng/pull/653.patch

BuildRequires:  cargo-rpm-macros >= 24

%global _description %{expand:
A lossless PNG compression optimizer.}

%description %{_description}

%package     -n %{crate}
Summary:        %{summary}
# Apache-2.0
# Apache-2.0 OR MIT
# Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
# BSL-1.0
# MIT
# MIT OR Apache-2.0 (duplicate)
# Zlib OR Apache-2.0 OR MIT
License:        %{shrink:
                Apache-2.0 AND
                (Apache-2.0 OR MIT) AND
                (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND
                BSL-1.0 AND
                MIT AND
                (Zlib OR Apache-2.0 OR MIT)
                }
# LICENSE.dependencies contains a full license breakdown

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

%files       -n %{crate}
%license LICENSE
%license LICENSE.dependencies
%doc CHANGELOG.md
%doc MANUAL.txt
%doc README.md
%{_bindir}/oxipng
%{_mandir}/man1/oxipng.1*

%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}/CHANGELOG.md
%doc %{crate_instdir}/MANUAL.txt
%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}+binary-devel
Summary:        %{summary}
BuildArch:      noarch

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

%description -n %{name}+sanity-checks-devel %{_description}

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

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

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

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

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

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

%prep
%autosetup -n %{crate}-%{version} -p1
# Unpacks to oxipng-%%{version}/, *inside* the extracted crate
%setup -q -T -D -a 10 -c -n %{crate}-%{version}

# Required for generating the man page:
#
# Note that the mangen xtask has its own dependencies, so we must run
# %%cargo_generate_buildrequires in the xtask directory if we are to invoke it
# in the build.
mv -v oxipng-%{version}/xtask ./
# We can’t respect upstream’s lock file, though:
rm xtask/Cargo.lock

# Demonstrate that sources from GitHub are not used to build the executable:
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/#_package_sources
rm -r -v oxipng-%{version}
%cargo_prep

%generate_buildrequires
%cargo_generate_buildrequires
pushd xtask >/dev/null
%cargo_generate_buildrequires
popd >/dev/null

%build
%cargo_build
%{cargo_license_summary}
%{cargo_license} > LICENSE.dependencies
# Generate the man page
%{__cargo} run --manifest-path xtask/Cargo.toml -- mangen

%install
%cargo_install
mansrc='target/xtask/mangen/manpages/oxipng.1'
mandest='%{buildroot}%{_mandir}/man1'
install -t "${mandest}" -D -p -m 0644 "${mansrc}"

%if %{with check}
%check
%cargo_test
%endif

%changelog
## START: Generated by rpmautospec
* Sat Nov 30 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 9.1.3-1
- Update to 9.1.3 (close RHBZ#2329572)

* Mon Jul 22 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 9.1.2-3
- Re-enable features that require rust-image 0.25

* Sat Jul 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 9.1.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Mon Jul 15 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 9.1.2-1
- Update to 9.1.2 (close RHBZ#2297884)

* Thu May 23 2024 Fabio Valentini <decathorpe@gmail.com> - 9.1.1-3
- Rebuild with Rust 1.78 to fix incomplete debuginfo and backtraces

* Fri Apr 26 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 9.1.1-2
- Hide the image and sanity-checks crate features

* Wed Apr 24 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 9.1.1-1
- Update to 9.1.1 (close RHBZ#2276572)
- Replace downstream man page with upstream generated man page

* Sat Mar 16 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 9.0.0-4
- Add a man page

* Fri Mar 15 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 9.0.0-3
- Use rust2rpm 26 features to simplify packaging

* Sat Feb 17 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 9.0.0-1
- Unretire and update to 9.0.0 (close RHBZ#2259760)

* Mon May 31 2021 Rémi Lauzier <remilauzier@protonmail.com> - 4.0.3-1
- Initial package

## END: Generated by rpmautospec