bcachefs-tools-1.38.5xarblu-overlay
download
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# shellcheck shell=bash
# shellcheck disable=SC2034
EAPI=8
CRATES="
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]+spec-1.1.0
[email protected]+spec-1.0.0
[email protected]+spec-1.1.0
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]+wasi-snapshot-preview1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
"
LLVM_COMPAT=( {19..22} )
MODULES_INITRAMFS_IUSE=+initramfs
MODULES_KERNEL_MIN=6.16
PYTHON_COMPAT=( python3_{12..14} )
RUST_MIN_VER="1.85.0"
RUST_NEEDS_LLVM=1
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/kentoverstreet.asc
# for _pre* snapshots
# git -c safe.directory=$PWD -c core.abbrev=12 describe
# ("v${PV}" if unset)
#BCH_VERSION=
# matching commit for S
#COMMIT=
inherit cargo flag-o-matic linux-mod-r1 llvm-r1 multiprocessing python-any-r1
inherit shell-completion toolchain-funcs unpacker verify-sig udev systemd
DESCRIPTION="Tools for bcachefs"
HOMEPAGE="https://bcachefs.org/"
if [[ ${PV} == "9999" ]]; then
inherit git-r3
EGIT_REPO_URI="https://evilpiepirate.org/git/bcachefs-tools.git"
else
if [[ ${PV} == *_pre* ]]; then
# fetch via BCH_VERSION as a rough QA check (should always match COMMIT)
SRC_URI="
https://github.com/koverstreet/bcachefs-tools/archive/${BCH_VERSION}.tar.gz
-> ${PN}-${BCH_VERSION}.tar.gz
${CARGO_CRATE_URIS}
"
S="${WORKDIR}/${PN}-${COMMIT}"
else
SRC_URI="
https://evilpiepirate.org/bcachefs-tools/${P}.tar.zst
${CARGO_CRATE_URIS}
"
SRC_URI+=" verify-sig? ( https://evilpiepirate.org/bcachefs-tools/bcachefs-tools-${PV}.tar.sign )"
S="${WORKDIR}/${P}"
KEYWORDS="~amd64 ~arm64"
fi
fi
LICENSE="GPL-2"
# Dependent crate licenses
LICENSE+=" Apache-2.0 BSD-2 BSD ISC MIT Unicode-DFS-2016"
SLOT="0"
IUSE="debug llvm-libunwind +modules verify-sig"
# manual testing for now:
# fallocate -l 10G /tmp/bcfs.img
# loopdev=$(losetup --find --show /tmp/bcfs.img)
# bcachefs format $loopdev
# mkdir -p /tmp/bcfs-mount
# mount -t bcachefs $loopdev /tmp/bcfs-mount
# touch /tmp/bcfs-mount/foo
RESTRICT="test"
DEPEND="
app-arch/lz4:=
app-arch/zstd:=
dev-libs/libaio
dev-libs/libsodium:=
dev-libs/userspace-rcu:=
sys-apps/keyutils:=
sys-apps/util-linux
virtual/zlib:=
virtual/udev
llvm-libunwind? ( llvm-runtimes/libunwind )
!llvm-libunwind? ( sys-libs/libunwind )
"
# bcachefs-kmod in ::guru provided USE=modules for previous tools versions.
RDEPEND="
${DEPEND}
modules? ( !sys-fs/bcachefs-kmod )
"
# Clang is required for bindgen
# shellcheck disable=SC2016 # don't want expansion
BDEPEND="
${PYTHON_DEPS}
$(python_gen_any_dep '
dev-python/docutils[${PYTHON_USEDEP}]
')
$(unpacker_src_uri_depends)
$(llvm_gen_dep '
llvm-core/clang:${LLVM_SLOT}
')
elibc_musl? ( >=sys-libs/musl-1.2.5 )
virtual/pkgconfig
modules? ( >=sys-kernel/linux-headers-${MODULES_KERNEL_MIN}.0 )
verify-sig? ( >=sec-keys/openpgp-keys-kentoverstreet-20241012 )
${RUST_DEPEND}
"
QA_FLAGS_IGNORED="sbin/bcachefs"
python_check_deps() {
python_has_version "dev-python/docutils[${PYTHON_USEDEP}]"
}
pkg_setup() {
# early llvm_prepend_path
# to keep C and Rust synced
if [[ ${MERGE_TYPE} != binary ]]; then
llvm_prepend_path "${LLVM_SLOT}"
fi
llvm-r1_pkg_setup
python-any-r1_pkg_setup
rust_pkg_setup
if use modules; then
# grep -r 'depends on\|select ' ${S}/fs/Kconfig | grep -v '^#'
local CONFIG_CHECK="
!BCACHEFS_FS
BLOCK
EXPORTFS
CRC32
CRC64
FS_POSIX_ACL
LZ4_COMPRESS
LZ4_DECOMPRESS
LZ4HC_COMPRESS
ZLIB_DEFLATE
ZLIB_INFLATE
ZSTD_COMPRESS
ZSTD_DECOMPRESS
CRYPTO_LIB_SHA256
CRYPTO_LIB_CHACHA
CRYPTO_LIB_POLY1305
KEYS
RAID6_PQ
XOR_BLOCKS
XXHASH
SYMBOLIC_ERRNAME
"
use debug && CONFIG_CHECK+="
DEBUG_INFO
FRAME_POINTER
!DEBUG_INFO_REDUCED
"
linux-mod-r1_pkg_setup
fi
}
src_unpack() {
if [[ ${PV} == "9999" ]]; then
git-r3_src_unpack
S="${S}/rust-src" cargo_live_src_unpack
else
# Upstream signs the uncompressed tarball
# Snapshots come from GitHub and thus aren't signed
if [[ ${PV} != *_pre* ]] && use verify-sig; then
einfo "Unpacking ${P}.tar.zst ..."
verify-sig_verify_detached - "${DISTDIR}/${P}.tar.sign" \
< <(zstd -fdc "${DISTDIR}/${P}.tar.zst" | tee >(tar -xf -))
assert "Unpack failed"
fi
if [[ ${PV} == *_pre* ]]; then
unpacker "${PN}-${BCH_VERSION}.tar.gz"
else
unpacker "${P}.tar.zst"
fi
cargo_src_unpack
fi
}
src_prepare() {
default
tc-export CC
sed \
-e '/^CFLAGS/s:-O2::' \
-e '/^CFLAGS/s:-g::' \
-i Makefile || die
append-lfs-flags
# llvm-runtimes/libunwind doesn't provide pkgconfig files
# so we need to handle it ourself...
if use llvm-libunwind; then
sed -E \
-e '/^PKGCONFIG_LIBS/s/(".*) libunwind(.*")/\1\2/' \
-i Makefile || die
export EXTRA_LDLIBS="-lunwind"
fi
# generate version.h
echo "${BCH_VERSION:-"v${PV}"}" > .version || die
emake generate_version
}
src_configure() {
cargo_src_configure
use modules && emake DESTDIR="${WORKDIR}" DKMSDIR="/module" install_dkms
}
src_compile() {
export BUILD_VERBOSE=1
local modlist=( "bcachefs=:../module:../module/src/fs/bcachefs" )
local modargs=( KDIR="${KV_OUT_DIR}" )
# Makefile calls `cargo` directly, so make sure we set our rustflags (etc)
cargo_env emake "-j$(get_makeopts_jobs)" bcachefs || die
use modules && linux-mod-r1_src_compile
(
# shellcheck disable=SC2155
export PATH="$(cargo_target_dir):${PATH}"
for shell in bash fish zsh; do
bcachefs completions "${shell}" > "${shell}.completion" || die
done
)
local [email protected]
sed -e 's|@sbindir@|/sbin|g' "${unit}".in > "${unit}" || die
}
src_install() {
into /
dosbin "$(cargo_target_dir)/bcachefs"
dosym bcachefs /sbin/fsck.bcachefs
dosym bcachefs /sbin/mkfs.bcachefs
dosym bcachefs /sbin/mount.bcachefs
# Uses a crate-based implementation of FUSE, no dependency on sys-fs/fuse and unconditionally included.
dosym bcachefs /sbin/fsck.fuse.bcachefs
dosym bcachefs /sbin/mkfs.fuse.bcachefs
dosym bcachefs /sbin/mount.fuse.bcachefs
newbashcomp bash.completion bcachefs
newfishcomp fish.completion bcachefs.fish
newzshcomp zsh.completion _bcachefs
doman bcachefs.8
use modules && linux-mod-r1_src_install
udev_dorules udev/64-bcachefs.rules
systemd_dounit [email protected]
}
pkg_postinst() {
udev_reload
}
pkg_postrm() {
udev_reload
}