From cfbb3c69fcd9732096c5fc471d6b095d354d20ea Mon Sep 17 00:00:00 2001 From: Alexander Miroshnichenko Date: Tue, 16 Sep 2025 15:48:26 +0300 Subject: [PATCH] sys-fs/bcachefs-tools: add support out-of-tree module compile Signed-off-by: Alexander Miroshnichenko --- metadata/layout.conf | 2 +- .../bcachefs-tools-1.31.0.ebuild | 72 ++++--------------- 2 files changed, 14 insertions(+), 60 deletions(-) diff --git a/metadata/layout.conf b/metadata/layout.conf index 4731277..c2bf121 100644 --- a/metadata/layout.conf +++ b/metadata/layout.conf @@ -1,4 +1,4 @@ -masters = gentoo +masters = guru gentoo thin-manifests = true sign-manifests = false # Needed for profiles parent with repo syntax diff --git a/sys-fs/bcachefs-tools/bcachefs-tools-1.31.0.ebuild b/sys-fs/bcachefs-tools/bcachefs-tools-1.31.0.ebuild index 2053555..b3df3a3 100644 --- a/sys-fs/bcachefs-tools/bcachefs-tools-1.31.0.ebuild +++ b/sys-fs/bcachefs-tools/bcachefs-tools-1.31.0.ebuild @@ -86,15 +86,14 @@ CRATES=" zeroize@1.8.1 zeroize_derive@1.4.2 " - +MODULES_OPTIONAL_IUSE="modules" +MODULE_S="module/src/${PN%-*}-${PV}" LLVM_COMPAT=( {17..20} ) PYTHON_COMPAT=( python3_{11..14} ) RUST_MIN_VER="1.77.0" VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/kentoverstreet.asc -MODULES_OPTIONAL_IUSE="modules" - -inherit cargo flag-o-matic llvm-r1 python-any-r1 shell-completion toolchain-funcs unpacker verify-sig linux-mod-r1 +inherit cargo flag-o-matic linux-mod-r1 llvm-r1 python-any-r1 shell-completion toolchain-funcs unpacker verify-sig DESCRIPTION="Tools for bcachefs" HOMEPAGE="https://bcachefs.org/" @@ -114,7 +113,7 @@ LICENSE="GPL-2" # Dependent crate licenses LICENSE+=" Apache-2.0 BSD ISC MIT Unicode-DFS-2016" SLOT="0" -IUSE="fuse verify-sig module-src" +IUSE="fuse verify-sig" RESTRICT="test" DEPEND=" @@ -157,10 +156,7 @@ pkg_setup() { rust_pkg_setup llvm-r1_pkg_setup python-any-r1_pkg_setup - - if use modules; then - linux-mod-r1_pkg_setup - fi + use modules && linux-mod-r1_pkg_setup } src_unpack() { @@ -192,6 +188,9 @@ src_prepare() { -e '/^CFLAGS/s:-g::' \ -i Makefile || die append-lfs-flags + + use modules && emake DESTDIR="${WORKDIR}" PREFIX="/module" install_dkms && \ + sed -i 's/^ /\t/g' "${WORKDIR}/${MODULE_S}/Makefile" || die } src_compile() { @@ -211,20 +210,11 @@ src_compile() { ./bcachefs completions ${shell} > ${shell}.completion || die done - local modlist=( "bcachefs=:libbcachefs::bcachefs.ko" ) - linux-mod-r1_src_compile - - local modlist=( bcachefs=kernel/drivers/fs:libbcachefs::module ) - local modargs=( - KERNELDIR=${KV_OUT_DIR} - ) - use modules && linux-mod-r1_src_compile + local modlist=( "bcachefs=:../${MODULE_S}::default" ) + use modules && linux-mod-r1_src_compile } src_install() { - use modules && linux-mod-r1_src_install - use module-src && emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" install_dkms - into / dosbin bcachefs @@ -238,6 +228,8 @@ src_install() { dosym bcachefs /sbin/mount.fuse.bcachefs fi + use modules && linux-mod-r1_src_install + newbashcomp bash.completion bcachefs newfishcomp fish.completion bcachefs.fish newzshcomp zsh.completion _bcachefs @@ -252,43 +244,5 @@ pkg_postinst() { ewarn "You have been warned." fi - if use module-src && ! use module; then - einfo - einfo "You have enabled the module-src USE flag without the module USE" - einfo "flag. This means that sources are installed to" - einfo "${ROOT}/usr/src/bcachefs-${PV} instead of having the" - einfo "kernel module compiled. You will need to compile the module" - einfo "yourself or use dkms. Most likely, you don't want this USE flag, and should" - einfo "rather use USE=module" - einfo - fi - - if use modules; then - linux-mod-r1_pkg_postinst - local old new - if [[ $(uname -r) != "${KV_FULL}" ]]; then - ewarn - ewarn "You have just built bcachefs for kernel ${KV_FULL}, yet the currently running" - ewarn "kernel is $(uname -r). If you intend to use this bcachefs module on the currently" - ewarn "running machine, you will first need to reboot it into the kernel ${KV_FULL}, for" - ewarn "which this module was built." - ewarn - elif [[ -f /sys/module/bcachefs/version ]] && \ - old="$(< /sys/module/bcachefs/version)" && \ - new="$(modinfo -F version "${ROOT}/lib/modules/${KV_FULL}/net/bcachefs.ko" 2>/dev/null)" && \ - [[ $old != "$new" ]]; then - ewarn - ewarn "You appear to have just upgraded bcachefs from version v$old to v$new." - ewarn "However, the old version is still running on your system. In order to use the" - ewarn "new version, you will need to remove the old module and load the new one. As" - ewarn "root, you can accomplish this with the following commands:" - ewarn - ewarn " # rmmod bcachefs" - ewarn " # modprobe bcachefs" - ewarn - ewarn "Do note that doing this will remove currently mounted bcachefs filesystems, so you may want" - ewarn "to gracefully remove them yourself prior." - ewarn - fi - fi + use modules && linux-mod-r1_pkg_postinst }