File bcachefs-tools.spec of Package bcachefs-tools
# Avoid OOM during compilation due to -flto
%define _lto_cflags %{nil}
%define with_rust 0
# Spec file
Name: bcachefs-tools
Version: 2025.03.28
Release: 0
License: GPL-2.0
Group: System/Filesystems
Summary: Userspace tools to manage bcachefs filesystems
URL: http://bcachefs.org
#Source: https://evilpiepirate.org/git/bcachefs-tools.git/
Source: %{name}-%{version}.tar.xz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: libblkid-devel libuuid-devel libsodium-devel zlib-devel
# libudev-devel gets replaced by systemd-devel if needed
BuildRequires: libzstd-devel libscrypt-devel udev libudev-devel libattr-devel libaio-devel
BuildRequires: libtool-ltdl-devel
BuildRequires: python3-docutils findutils
#BuildRequires: rust cargo llvm clang clang-devel
%if 0%{?rhel_version} >= 500 && 0%{?rhel_version} < 800
BuildRequires: valgrind
%else
%ifnarch riscv64
BuildRequires: valgrind-devel
%endif
%endif
%if 0%{?suse_version} > 0
BuildRequires: keyutils-devel liblz4-devel liburcu8 liburcu-devel
%else
BuildRequires: keyutils-libs-devel lz4-devel userspace-rcu-devel
%if 0%{?fedora_version} > 28 || 0%{?redhat_version} >= 800 || 0%{?centos_version} >= 800
%ifarch %_x86 x86_64
BuildRequires: libvmmalloc-devel
%endif
%endif
%endif
%if %{with_rust}
BuildRequires: rust cargo
%define no_rust
%else
%define no_rust NO_RUST=1
%endif
BuildRequires: gcc make glibc-devel
#BuildRequires: linux-glibc-devel
BuildRequires: pkg-config
BuildRequires: xz
%if 0%{?suse_version} >= 1500 || 0%{?rhel_version} >= 800 || 0%{?centos_version} >= 800 || 0%{?fedora_version} >= 28
BuildRequires: python3-pytest
%define _with_python3 1
%else
%define _with_python3 0
%endif
%if 0%{?rhel_version} >= 600 || 0%{?centos_version} >= 600
BuildRequires: kernel-headers
%endif
%if 0%{?fedora_version} == 32 || 0%{?fedora_version} >= 34
BuildRequires: glibc-langpack-en
%endif
%description
Tools for creation, inspection, manipulation of bcachefs filesystems
The userspace tools for dealing with the bcachefs filesystem.
http://evilpiepirate.org/git/bcachefs-tools.git
Author: Kent Overstreet
%prep
%setup -n %name-%version
%if 0%{?rhel_version} >= 500 && 0%{?rhel_version} < 800
sed -i 's/CFLAGS+=-DCONFIG_VALGRIND/#CFLAGS+=-DCONFIG_VALGRIND/' Makefile
%endif
%ifarch riscv64
sed -i 's/CFLAGS+=-DCONFIG_VALGRIND/#CFLAGS+=-DCONFIG_VALGRIND/' Makefile
%endif
# gcc-7.5 does not like unnamed parameter
sed -i 's@static inline void shrink_dcache_sb(struct super_block \*) {}@static inline void shrink_dcache_sb(struct super_block *sb) {}@' include/linux/dcache.h
sed -i 's@static inline int sync_filesystem(struct super_block \*) { return 0; }@static inline int sync_filesystem(struct super_block *sb) { return 0; }@' include/linux/blkdev.h
%if 0%{?suse_version} > 0 && 0%{?suse_version} < 1600
sed -i 's@\.aio_rw_flags\t= bio\->bi_opf & REQ_FUA ? RWF_SYNC : 0,@//.aio_rw_flags = bio->bi_opf \& REQ_FUA ? RWF_SYNC : 0,@' linux/blkdev.c
%endif
%build
make %{?_smp_mflags} EXTRA_CFLAGS="$RPM_OPT_FLAGS" VERSION="v%{version}" %{no_rust}
%install
make install DESTDIR=%buildroot PREFIX=/usr EXTRA_CFLAGS="$RPM_OPT_FLAGS" VERSION="v%{version}" LIB=%{_lib} %{no_rust}
# No initramfs-tools on SUSE, Fedora, RedHat, CentOS
%if 0%{?suse_version} > 0 || 0%{?fedora_version} > 0 || 0%{?centos_version} > 0 || 0%{?redhat_version} > 0
rm -rf %buildroot/usr/share/initramfs-tools
%endif
%check
%if %_with_python3
make tests/test_helper EXTRA_CFLAGS="$RPM_OPT_FLAGS" %{no_rust}
cd tests
ln -s . tests
python3 ./test_basic.py
python3 ./test_fixture.py
%endif
%files
%defattr(-,root,root)
%doc README.md INSTALL.md COPYING
/sbin/bcachefs
/sbin/fsck.bcachefs
/sbin/mkfs.bcachefs
/sbin/mount.bcachefs
/sbin/fsck.fuse.bcachefs
/sbin/mkfs.fuse.bcachefs
/sbin/mount.fuse.bcachefs
#/sbin/mount.bcachefs.sh
%doc /usr/share/man/man8/bcachefs.8.gz
%if 0%{?suse_version} == 0 && 0%{?fedora_version} == 0 && 0%{?centos_version} == 0 && 0%{?redhat_version} == 0
/etc/initramfs-tools/hooks/bcachefs
/etc/initramfs-tools/scripts/local-premount/bcachefs
%endif
%if 0
%dir /etc/initramfs-tools
%dir /etc/initramfs-tools/hooks
%dir /etc/initramfs-tools/scripts
%dir /etc/initramfs-tools/scripts/local-premount
%endif
#% _libdir/libbcachefs.so