# https://github.com/sgan81/apfs-fuse/issues/164
%global _lto_cflags %nil

# Force out of source build
%undefine __cmake_in_source_build

%global date			20230104
%global gittag			1f041d7af5df5423832e54e9f358fd9234773fcc
%global short_gittag	1f041d7

Name:			apfs-fuse
Summary:		A read-only FUSE driver for Apple's APFS
Version:		1
Release:		%mkrel 1
License:		GPLv2+
URL:			https://github.com/sgan81/apfs-fuse
Source0:		https://github.com/sgan81/%{name}/archive/%{short_gittag}/%{name}-%{short_gittag}.tar.gz
Source1:		https://github.com/lzfse/lzfse/archive/lzfse-1.0.tar.gz
Provides:		bundled(lzfse) = 1.0
Requires:		fuse3
BuildRequires:	gcc
BuildRequires:	gcc-c++
BuildRequires:	fuse3-devel
BuildRequires:	libicu-devel
BuildRequires:	zlib-devel
BuildRequires:	bzip2-devel
BuildRequires:	cmake
BuildRequires:	git

%description
apfs-fuse is a read-only driver for the new Apple File System, APFS. Since
Apple didn't document the disk format, this driver should be considered
experimental. Not all compression methods are supported yet, thus the driver
may return compressed files instead of uncompressed ones.

%prep
%autosetup -n %{name}-%{short_gittag} -S git
cd 3rdparty
rmdir lzfse
tar zxf %{SOURCE1}
mv lzfse-* lzfse

%build
%cmake -DBUILD_SHARED_LIBS:BOOL=OFF
%cmake_build

%install
mkdir -p %{buildroot}/%{_bindir}
cp -a %{_vpath_builddir}/apfs* %{buildroot}/%{_bindir}/

mkdir -p %{buildroot}/%{_sbindir}
ln -sr %{buildroot}/%{_bindir}/apfs-fuse %{buildroot}/%{_sbindir}/mount.apfs

%files
%{_bindir}/apfs*
%{_sbindir}/mount.apfs
%doc README.md
%license LICENSE