Edit: recommend to ignore this post, old .deb aren't archived and the situation + options usage changed so it's unlikely this ebuild will stay usable/right, should probably let bcachefs upstream sort things out for a while before anyone tries to write a proper ebuild
I don't intend to push this nor maintain it nor offer real support, but if anyone interested I randomly made an ebuild for the out-of-tree version. Haven't actually tried the module though, only checked that it builds against gentoo-kernel-bin-6.16.8, so no idea if it works. Use at your own risks esp. if for a rootfs+initramfs mount.
Intended for version 1.31.2, ebuild may need updates for any other version but I won't be looking at that.
bcachefs-1.31.2.ebuild:
Code: Select all
# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
MODULES_INITRAMFS_IUSE=+initramfs
inherit linux-mod-r1 unpacker
DESCRIPTION="The COW filesystem for Linux that won't eat your data"
HOMEPAGE="https://bcachefs.org/"
# no proper source tarball yet(?), grab from the .deb (arch does not matter)
SRC_URI="https://apt.bcachefs.org/unstable/pool/main/b/bcachefs-tools/bcachefs-kernel-dkms_${PV}_amd64.deb"
S=${WORKDIR}/usr/src/${P}
LICENSE="GPL-2 BSD LGPL-2.1+"
SLOT="0"
KEYWORDS="~amd64"
CONFIG_CHECK="BCACHEFS_FS"
ERROR_BCACHEFS_FS="CONFIG_BCACHEFS_FS: is not set but is (still) needed to build the
out-of-tree version of ${PN} as it re-uses kernel config options
and is not currently fully independent (this module will be
prioritized over the kernel's if both exists as long as not builtin)"
DOCS=( ../../share/doc/bcachefs-kernel-dkms/changelog )
src_prepare() {
default
sed -i "s:/usr/src/.*:${S}/src/fs/bcachefs:" src/fs/bcachefs/trace.h || die
gzip -d ../../share/doc/bcachefs-kernel-dkms/changelog.gz || die
}
src_compile() {
local modlist=( bcachefs=::src/fs/bcachefs )
local modargs=(
KDIR="${KV_OUT_DIR}"
CONFIG_MEAN_AND_VARIANCE_UNIT_TEST=
)
linux-mod-r1_src_compile
}
wrt the ERROR_ message, afaik the module isn't actually leaving the kernel yet but it's going to become outdated most likely and an ebuild lets you get a more recent version.
Edit/Update: well, it did leave after all -- bchafefs upstream did update their Makefile but it doesn't handle other options right now, and the things it need to be enabled in the kernel are a pain to select for a non-generic kernel given lot of options do not have directly select'able menu entries -- e.g. need to enable btrfs to enable them among other things
Could probably still use some improvements, like error out if BCACHEFS_FS is set as builtin rather than module, may or may not need more things in CONFIG_CHECK too, albeit the in-kernel Kconfig BCACHEFS_FS likely selects most things needed. With gentoo-kernel-bin did not have to worry too much given it enables about everything.
To avoid collisions, the module will be installed to /lib/modules/*/extra/ rather than kernel/fs/bcachefs/ -- the "extra" dir is special and should take priority for which of the two bcachefs.ko to load. If using a initramfs needed for a rootfs, may want to double-check that it did get included or else it will load the other one (it should with dracut because of the generated config file the eclass installs, but I haven't actually tried USE=initramfs).