%bcond_without rust
%global __requires_exclude ^libdnf[.]so[.].*$
%global __provides_exclude_from ^%{_libdir}/%{name}/.*$

Name:		rpm-ostree
Version:	2022.16
Release:	5
Summary:	Hybrid image/package system
License:	Apache-2.0 or MIT and GPL-2.0-or-later and LGPL-2.0-or-later
URL:		https://github.com/coreos/rpm-ostree
Source0:	https://github.com/coreos/rpm-ostree/releases/download/v%{version}/%{name}-%{version}.tar.xz
Patch0:         fix-compose-err.patch
Patch1:         fix-2022.16-build-error.patch
Patch2:         add-for-support-NestOS-kernel.patch
Patch3:         fix-compose-error-for-selinux.patch
# https://github.com/bytecodealliance/cap-std/commit/cd966ac70595391b2382c1ef75c179847a845878
Patch4:         fix-compilation-on-Rust-beta.patch
%if %{with rust}

%if !%{defined rust_arches}
%define rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x riscv64 loongarch64 sw_64
%endif 

ExclusiveArch: %{rust_arches}

%ifarch loongarch64
Patch1000:  1000-add-loongarch64-support-not-upstream-modified-files.patch
%endif

%ifarch sw_64
Patch1001:  1001-add-sw_64-support-not-upstream-modified-files.patch
%endif

%if %{defined rusttoolset_version}
BuildRequires: %{rusttoolset_version}-cargo
%else
BuildRequires:	 cargo 
%endif

%endif

BuildRequires:   /usr/bin/python3 autoconf automake libtool git chrpath libattr-devel 
BuildRequires:   gtk-doc gperf gnome-common /usr/bin/g-ir-scanner ostree-devel cmake
BuildRequires:   polkit-devel json-glib-devel rpm-devel libarchive-devel systemd-devel 
BuildRequires:   libcap-devel libcurl-devel librepo-devel expat-devel check-devel 
BuildRequires:   pkgconfig(libsolv) gcc gcc-c++
BuildRequires:   chrpath jq glib2-devel sqlite-devel json-c-devel cppunit-devel
BuildRequires:   libmodulemd-devel libsmartcols-devel gettext gpgme-devel make

Requires:	 ostree bubblewrap fuse 

Provides:        rpm-ostree-libs = %{version}-%{release}
Obsoletes:       rpm-ostree-libs < %{version}-%{release}

%description
rpm-ostree is a hybrid image/package system.  It supports
"composing" packages on a build server into an OSTree repository,
which can then be replicated by client systems with atomic upgrades.
Additionally, unlike many "pure" image systems, with rpm-ostree
each client system can layer on additional packages, providing
a "best of both worlds" approach.

%package         devel
Summary:         Header files for rpm-ostree
Requires:        %{name} = %{version}-%{release}

%description     devel
Header files for rpm-ostree.

%package_help

%prep
%autosetup -n %{name}-%{version} -p1
# for patch4
sed -i "s/3f6633fa050c0751542d023624f627955436d78cf8eba355370b886683a9d471/f2340d99ce67f1bb842ae2ba6dd57a253b3427d0f7185c59e74fd5f5c3ceec12/" vendor/cap-primitives/.cargo-checksum.json

%build
%{?rusttoolset} env NOCONFIGURE=1 ./autogen.sh
%configure --disable-silent-rules --enable-gtk-doc \
           %{?with_rust:--enable-rust}

%{?rusttoolset} %make_build

%install
%{?rusttoolset}  %make_install INSTALL="install -p -c"
%delete_la 

chrpath -d %{buildroot}%{_libdir}/librpmostree-1.so.1.0.0
chrpath -d %{buildroot}%{_bindir}/rpm-ostree

mkdir -p %{buildroot}/etc/ld.so.conf.d
echo "%{_libdir}/%{name}" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf

%ldconfig_scriptlets

install -d -m 0755 %{buildroot}/etc/dbus-1/system.d/
install -pm 0644 src/daemon/org.projectatomic.rpmostree1.conf %{buildroot}/etc/dbus-1/system.d/

%files
%defattr(-,root,root)
%doc README.md
%license COPYING.*
%{_bindir}/*
%{_sysconfdir}/dbus-1/system.d/*
%{_sysconfdir}/rpm-ostreed.conf
%{_libdir}/*.so.*
%{_libdir}/rpm-ostree/*
%{_libdir}/girepository-1.0/*
%{_libexecdir}/rpm-ostree*
%{_libexecdir}/libostree/*
%{_prefix}/lib/systemd/system/*
%{_datadir}/dbus-1/system-services
%{_datadir}/polkit-1/actions/*.policy
%{_datadir}/dbus-1/system.d/org.projectatomic.rpmostree1.conf
%{_datadir}/bash-completion/completions/rpm-ostree
%config(noreplace) /etc/ld.so.conf.d/*

%files       devel
%defattr(-,root,root)
%{_libdir}/*.so
%{_includedir}/*
%{_libdir}/pkgconfig/*
%{_datadir}/gtk-doc/html/*
%{_datadir}/gir-1.0/*-1.0.gir
%{_datadir}/dbus-1/interfaces/org.projectatomic.rpmostree1.xml

%files       help
%defattr(-,root,root)
%{_mandir}/man*/*

%changelog
* Tue Oct 15 2024 wangkai <13474090681@163.com> - 2022.16-5
- Fix compilation on Rust-1.76

* Fri Oct 13 2023 wangyueliang <wangyueliang@kylinos.cn> - 2022.16-4
- merge feature from branch openEuler-22.03-LTS-SP1：
- DESC: add loongarch64 and sw_64 support
- AUTHOR: panchenbo <panchenbo@kylinsec.com.cn>

* Mon Sep 18 2023 wangyueliang <wangyueliang@kylinos.cn> - 2022.16-3
- fix compose error for selinux.
- add-for-support-NestOS-kernel.

* Fri Aug 04 2023 Jingwiw  <wangjingwei@iscas.ac.cn> - 2022.16-2
- enable riscv64 architecture

* Mon May 22 2023 duyiwei <duyiwei@kylinos.cn> - 2022.16-1
- Update rpm-ostree to 2022.16.

* Thu Dec 29 2022 chenmaodong <chenmaodong@xfusion.com> - 2022.8-4
- Fix has_modules_enable() check

* Mon Oct 10 2022 fushanqing <fushanqing@kylinos.cn> - 2022.8-3
- add fix-compose-err.patch

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

* Tue Jun 07 2022 fushanqing <fushanqing@kylinos.cn> - 2022.8-1
- Update rpm-ostree to 2022.8

* Wed May 11 2022 duyiwei <duyiwei@kylinos.cn> - 2022.7-2
- update URL (projectatomic->coreos)

* Thu Apr 14 2022 yaoxin <yaoxin30@h-partners.com> - 2022.7-1
- Update rpm-ostree to 2022.7

* Fri Sep 10 2021 gaihuiying <gaihuiying1@huawei.com> - 2018.8-4
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:remove rpath of rpm-ostree's binary files

* Mon May 31 2021 huanghaitao <huanghaitao8@huawei.com> - 2018.8-3
- Completing build dependencies to fix gcc/gcc-c++ compiler missing error

* Sat Oct 19 2019 openEuler Buildteam <buildteam@openeuler.org> - 2018.8-2
- Package init
