#needsrootforbuild
%global __cargo_skip_build 0
%global _debugsource_packages 1
%global _debuginfo_subpackages 1
%define _unpackaged_files_terminate_build 0
%global sysmaster_install_source target/release
%global sysmaster_install_target %{buildroot}/usr/lib/sysmaster
%global unit_install_source units
%global conf_install_source config/conf
%global __cargo_common_opts %{?__cargo_common_opts} --all

Name:           sysmaster 
Version:        0.2.4
Release:        1
Summary:        redesign and reimplement process1.

License:        Mulan PSL v2
URL:            https://gitee.com/openeuler/sysmaster
Source0:        %{name}-%{version}.tar.gz

ExclusiveArch:  x86_64 aarch64

BuildRequires:  rust
BuildRequires:  cargo
BuildRequires:  rust-packaging
BuildRequires:  gcc clang util-linux-devel

%description
redesign and reimplement process1.

Summary:        %{summary}


%prep
%autosetup -p1

%cargo_prep

%cargo_generate_buildrequires

%build
sed -i '/\[source.crates-io\]/{n;d}' ./.cargo/config
sed -i '/\[source.local-registry\]/{n;d}' ./.cargo/config
sed -i '/\[source.local-registry\]/a directory = "vendor"' ./.cargo/config

%cargo_build

%install
install -Dm0550 -t %{buildroot}/usr/bin %{sysmaster_install_source}/sctl
install -Dm0550 -t %{sysmaster_install_target} %{sysmaster_install_source}/init
install -Dm0550 -t %{sysmaster_install_target} %{sysmaster_install_source}/sysmaster

install -Dm0640 -t %{sysmaster_install_target} %{unit_install_source}/*

install -Dm0550 -t %{sysmaster_install_target}/plugin %{sysmaster_install_source}/libservice.so
install -Dm0550 -t %{sysmaster_install_target}/plugin %{sysmaster_install_source}/libtarget.so
install -Dm0640 -t %{sysmaster_install_target}/plugin %{conf_install_source}/plugin.conf

%files
/usr/bin/sctl
/usr/lib/sysmaster/*

%changelog
* Tue Jun 20 2023 licunlong<shenyangyang4@huawei.com> - 0.2.4-1
- update version to 0.2.4 for docker use

* Fri Jun 16 2023 licunlong<licunlong1@huawei.com> - 0.2.3-3
- sync patches from upstream

* Tue May 30 2023 shenyangyang<shenyangyang4@huawei.com> - 0.2.3-2
- Support compatible compile with rust 1.60

* Sat May 6 2023 shenyangyang<shenyangyang4@huawei.com> - 0.2.3-1
- update version to 0.2.3

* Tue Sep 20 2022 licunlong<licunlong1@huawei.com> - 0.2.1-2
- rename process1 to sysmaster, and remove pctrl to /usr/bin

* Tue Sep 13 2022 licunlong<licunlong1@huawei.com> - 0.2.1-1
- sync patches from upstream

* Mon Aug 22 2022 He Xiaowen <hexiaowen@huawei.com> - 0.2.0-2
- strip the libraries

* Mon Aug 22 2022 He Xiaowen <hexiaowen@huawei.com> - 0.2.0-1
- initial package

