%global crate bootupd

Name:           rust-%{crate}
Version:        0.2.9
Release:        1
Summary:        Bootloader updater

License:        Apache-2.0
URL:            https://crates.io/crates/bootupd
Source0:        https://github.com/coreos/bootupd/releases/download/v%{version}/bootupd-%{version}.crate
Source1:        https://github.com/coreos/%{crate}/releases/download/v%{version}/%{crate}-%{version}-vendor.tar.gz

BuildRequires:  make
BuildRequires:  openssl-devel
BuildRequires:  rust-packaging
BuildRequires:  systemd

%global _description %{expand:
Bootloader updater}
%description %{_description}

%package     -n %{crate}
Summary:        %{summary}
License:        ASL 2.0
%{?systemd_requires}

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

%files -n %{crate}
%license LICENSE
%doc README.md
%{_bindir}/bootupctl
%{_libexecdir}/bootupd
%{_unitdir}/*

%prep
%autosetup -n %{crate}-%{version} -p1
tar -xv -f %{SOURCE1}
mkdir -p .cargo
cat >.cargo/config << EOF
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
EOF

%build
%cargo_build

%install
%make_install INSTALL="install -p -c"

%post        -n %{crate}
%systemd_post bootupd.service bootupd.socket

%preun       -n %{crate}
%systemd_preun bootupd.service bootupd.socket

%postun      -n %{crate}
%systemd_postun bootupd.service bootupd.socket

%changelog
* Fri Jun 09 2023 duyiwei <duyiwei@kylinos.cn> - 0.2.9-1
- upgrade version to 0.2.9

* Tue Nov 08 2022 fushanqing <fushanqing@kylinos.cn> - 0.2.8-1
- update to 0.2.8

* Wed Aug 03 2022 liukuo <liukuo@kylinos.cn> - 0.2.6-2
- License compliance rectification

* Thu Jun 09 2022 duyiwei <duyiwei@kylinos.cn> - 0.2.6-1
- upgrade to 0.2.6

* Mon Jan 17 2022 fushanqing <fushanqing@kylinos.cn> - 0.2.5-1
- Initial package
