# Generated by rust2rpm 24
%bcond_without check

%global dracutmodulesdir %(pkg-config --variable=dracutmodulesdir dracut || echo '/usr/lib/dracut/modules.d')

%global crate afterburn

Name:           rust-afterburn
Version: 5.7.0.86.gdced773
Release:        4%{?dist}
Summary:        Simple cloud provider agent

License:        Apache-2.0
URL:            https://crates.io/crates/afterburn
Source0:        %{crates_source}
# not used on Fedora
# Source1:        https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz

# build(deps): bump mailparse from 0.15.0 to 0.16.1
# (Only the Cargo.toml portion, not the Cargo.lock portion)
# Allows (but does not require) mailparse 0.16.
# Patch:          afterburn-5.7.0-mailparse.0.16.patch

ExcludeArch:    %{ix86}

%if 0%{?rhel}
BuildRequires:  rust-toolset
BuildRequires:  openssl-devel
# This is needed because the cc crate, which is
# used for linking final build results of crates,
# does not work without it.
BuildRequires:  glibc-devel 
%else
BuildRequires:  rust-packaging >= 23
%endif
BuildRequires:  systemd

%global _description %{expand:
A simple cloud provider agent.}

%description %{_description}

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

# (Apache-2.0 OR MIT) AND BSD-3-Clause
# 0BSD
# Apache-2.0
# Apache-2.0 OR BSL-1.0
# Apache-2.0 OR ISC OR MIT
# Apache-2.0 OR MIT
# Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
# BSD-2-Clause OR Apache-2.0 OR MIT
# BSD-3-Clause
# MIT
# MIT OR Apache-2.0
# MIT OR Apache-2.0 OR Zlib
# MPL-2.0 OR MIT OR Apache-2.0
# Unlicense OR MIT
# Zlib
# Zlib OR Apache-2.0 OR MIT
License:        Apache-2.0 AND 0BSD AND BSD-3-Clause AND MIT AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (MIT OR Apache-2.0 OR Zlib) AND (MPL-2.0 OR MIT OR Apache-2.0) AND (Unlicense OR MIT) AND Zlib
# LICENSE.dependencies contains a full license breakdown

%{?systemd_requires}

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

%files       -n %{crate}
%license COPYRIGHT
%license LICENSE
%license NOTICE
%license LICENSE.dependencies
%if 0%{?rhel}
%license cargo-vendor.txt
%endif
%doc README.md
%doc code-of-conduct.md
%{_bindir}/afterburn
%{_unitdir}/afterburn.service
%{_unitdir}/afterburn-checkin.service
%{_unitdir}/afterburn-firstboot-checkin.service
%{_unitdir}/afterburn-sshkeys@.service
%{_unitdir}/afterburn-sshkeys.target

%post        -n %{crate}
%systemd_post afterburn.service
%systemd_post afterburn-checkin.service
%systemd_post afterburn-firstboot-checkin.service
%systemd_post afterburn-sshkeys@.service

%preun       -n %{crate}
%systemd_preun afterburn.service
%systemd_preun afterburn-checkin.service
%systemd_preun afterburn-firstboot-checkin.service
%systemd_preun afterburn-sshkeys@.service

%postun      -n %{crate}
%systemd_postun afterburn.service
%systemd_postun afterburn-checkin.service
%systemd_postun afterburn-firstboot-checkin.service
%systemd_postun afterburn-sshkeys@.service

%package     -n %{crate}-dracut
Summary:        Dracut modules for afterburn
BuildRequires:  pkgconfig(dracut)
Requires:       %{crate}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires:       dracut
Requires:       dracut-network

%description -n %{crate}-dracut
Dracut module that enables afterburn and corresponding services
to run in the initramfs on boot.

%files       -n %{crate}-dracut
%{dracutmodulesdir}/30afterburn/

%prep
%autosetup -n %{crate}-%{version_no_tilde} -p1 %{?rhel:-a1}
%if 0%{?rhel}
%cargo_prep -v vendor
# avoid brp-mangle-shebangs error from sources with executable bit
chmod -x vendor/ipnet/src/*.rs
%else
%cargo_prep
%endif
# afterburn-sshkeys@.service is by default enabled for the 'core' user in
# Fedora CoreOS.
# Based on https://github.com/coreos/afterburn/blob/master/Makefile.
sed -e 's,@DEFAULT_INSTANCE@,core,' < \
  systemd/afterburn-sshkeys@.service.in > \
  systemd/afterburn-sshkeys@.service

%if !0%{?rhel}
%generate_buildrequires
%cargo_generate_buildrequires
%endif

%build
%cargo_build
%{?cargo_license_summary}
%{?cargo_license} > LICENSE.dependencies
%if 0%{?rhel}
%cargo_vendor_manifest
%endif

%install
%if 0%{?rhel}
%make_install INSTALL="install -p -c"
%else
%cargo_install
install -Dpm0644 -t %{buildroot}%{_unitdir} \
  systemd/*.service systemd/*.target
%endif
mkdir -p %{buildroot}%{dracutmodulesdir}
cp -a dracut/* %{buildroot}%{dracutmodulesdir}

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

%changelog
* Tue Mar 11 2025 Benjamin A. Beasley <code@musicinmybrain.net> - 5.7.0-4
- Allow mailparse 0.16

* Thu Feb 06 2025 Fabio Valentini <decathorpe@gmail.com> - 5.7.0-3
- Rebuild for openssl crate >= v0.10.70 (RUSTSEC-2025-0004)

* Sun Jan 19 2025 Fedora Release Engineering <releng@fedoraproject.org> - 5.7.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild

* Wed Sep 18 2024 Yasmin Valim <ydesouza@redhat.com> 5.6.0-1
- Update to 5.7.0

* Thu Sep 5 2024 Aashish Radhakrishnan <aaradhak@redhat.com> - 5.6.0-3
- Exclude ix86

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 5.6.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Tue Jun 18 2024 Steven Presti <spresti@redhat.com> 5.6.0-1
- Update to 5.6.0

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

* Fri Feb 02 2024 Yaakov Selkowitz <yselkowi@redhat.com> - 5.5.1-3
- Update Rust macro usage

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 5.5.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Tue Jan 16 2024 Michael Nguyen <mnguyen@redhat.com> 5.5.1-1
- Update to 5.5.1

* Tue Jan 09 2024 Michael Nguyen <mnguyen@redhat.com> 5.5.0-1
- Update to 5.5.0

* Fri Dec 01 2023 Fabio Valentini <decathorpe@gmail.com> - 5.4.3-2
- Rebuild for openssl crate >= v0.10.60 (RUSTSEC-2023-0044, RUSTSEC-2023-0072)

* Wed Oct 04 2023 Yaakov Selkowitz <yselkowi@redhat.com> - 5.4.3-1
- Update to 5.4.3

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Mon May 22 2023 Steven Presti <spresti@redhat.com> - 5.4.2-1
- Update to 5.4.2

* Fri May 19 2023 Fabio Valentini <decathorpe@gmail.com> - 5.4.0-4
- Refresh for latest Rust package template; update license tag for SPDX

* Wed May 03 2023 Fabio Valentini <decathorpe@gmail.com> - 5.4.0-3
- Rebuild for tokio, h2, and openssl crate security updates

* Mon Mar 20 2023 Benjamin Gilbert <bgilbert@redhat.com> - 5.4.0-2
- Update for Mockito 1.0 API

* Fri Feb 03 2023 Benjamin Gilbert <bgilbert@redhat.com> - 5.4.0-1
- Update to 5.4.0

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon Jun 13 2022 Sohan Kunkerkar <skunkerk@redhat.com> - 5.3.0-2
- Backport patch to expose instance availability-zone-id
  https://github.com/coreos/afterburn/pull/748
  
* Fri Apr 29 2022 Sohan Kunkerkar <skunkerk@redhat.com> - 5.3.0-1
- Update to 5.3.0

* Tue Feb 15 2022 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 5.2.0-5
- Rebuild with package notes

* Mon Jan 31 2022 Benjamin Gilbert <bgilbert@redhat.com> - 5.2.0-4
- Rebuild to fix out-of-order push

* Tue Jan 25 2022 Fabio Valentini <decathorpe@gmail.com> - 5.2.0-3
- Rebuild with thread_local 1.1.4 for RUSTSEC-2022-0006.

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.2.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Jan 14 2022 Benjamin Gilbert <bgilbert@redhat.com> - 5.2.0-1
- Update to 5.2.0

* Fri Sep 24 2021 Sohan Kunkerkar <skunkerk@redhat.com> - 5.1.0-3
- Vendor rust dependencies on el9

* Tue Sep 14 2021 Sahana Prasad <sahana@redhat.com> - 5.1.0-2
- Rebuilt with OpenSSL 3.0.0

* Tue Aug 10 2021 Sohan Kunkerkar <skunkerk@redhat.com> - 5.1.0-1
- Update to 5.1.0

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Apr 09 2021 Sohan Kunkerkar <skunkerk@redhat.com> - 5.0.0-1
- Update to 5.0.0

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.6.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Mon Dec 28 13:26:51 CET 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 4.6.0-3
- Rebuild

* Mon Dec 14 2020 Sohan Kunkerkar <skunkerk@redhat.com> - 4.6.0-2
- Rebuild because of Fedora infra issues last week to see if a new build fixes some 
  problems we are seeing.

* Wed Dec 09 2020 Sohan Kunkerkar <skunkerk@redhat.com> - 4.6.0-1
- Update to 4.6.0 

* Thu Oct 22 2020 Dusty Mabe <dusty@dustymabe.com> - 4.5.3-1
- Update to 4.5.3

* Wed Oct 14 2020 Dusty Mabe <dusty@dustymabe.com> - 4.5.1-3
- Backport patch to get afterburn sshkeys working on openstack.
    - https://github.com/coreos/afterburn/pull/493

* Wed Sep 30 2020 Fabio Valentini <decathorpe@gmail.com> - 4.5.1-2
- Un-downgrade mockito to 0.27.

* Thu Sep 03 2020 Dusty Mabe <dusty@dustymabe.com> - 4.5.1-1
- Update to 4.5.1

* Sun Aug 16 15:01:11 GMT 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 4.5.0-2
- Rebuild

* Thu Aug 13 2020 Dusty Mabe <dusty@dustymabe.com> - 4.5.0-1
- Update to 4.5.0

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Fri Jul 24 2020 Dusty Mabe <dusty@dustymabe.com> - 4.4.2-1
- Update to 4.4.2

* Sat May 23 11:27:14 CEST 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 4.4.0-1
- Update to 4.4.0

* Fri May 22 11:30:58 CEST 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 4.3.3-4
- Update users to 0.10

* Mon May 18 12:54:25 CEST 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 4.3.3-3
- Update mockito to 0.25

* Sun May 17 13:37:32 CEST 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 4.3.3-2
- Update few dependencies

* Fri May 01 2020 Robert Fairley <rfairley@redhat.com> - 4.3.3-1
- Update to 4.3.3

* Fri Feb 28 21:23:17 CET 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 4.3.2-1
- Update to 4.3.2

* Fri Feb 21 2020 Josh Stone <jistone@redhat.com> - 4.3.1-3
- Bump nix to 0.17 and mockito 0.23

* Tue Feb 11 15:24:47 CET 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 4.3.1-2
- Update deps

* Fri Feb 07 2020 Robert Fairley <rfairley@redhat.com> - 4.3.1-1
- Update to 4.3.1

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Thu Jan 09 2020 Josh Stone <jistone@redhat.com> - 4.2.0-2
- Bump to nix 0.16, mockito 0.22

* Tue Oct 15 2019 Robert Fairley <rfairley@redhat.com> - 4.2.0-1
- Update to 4.2.0

* Sat Sep 21 13:11:54 CEST 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 4.1.3-1
- Update to 4.1.3

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.1.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Tue Jul 23 2019 Robert Fairley <rfairley@redhat.com> - 4.1.2-1
- Update to 4.1.2

* Sat Jun 22 11:59:02 CEST 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 4.1.1-3
- Rename dracut subpackage

* Sat Jun 22 11:06:19 CEST 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 4.1.1-2
- Add dracut modules

* Fri Jun 21 2019 Robert Fairley <rfairley@redhat.com> - 4.1.1-1
- Update to 4.1.1
- Regenerate specfile using rust2rpm 10 with DynamicBuildRequires

* Wed Jun 05 2019 Josh Stone <jistone@redhat.com> - 4.1.0-3
- Bump nix to 0.14

* Wed May 22 17:17:00 CEST 2019 Robert Fairley <rfairley@redhat.com> - 4.1.0-2
- Add afterburn-sshkeys@.service patches to enable the unit on supported platfoms only

* Sat Apr 27 09:55:54 CEST 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 4.1.0-1
- Initial package