Add bcachefs-tools package
cover Add bcachefs-tools package
This patch series adds a new bcachefs-tools package: the userspace tools for the bcachefs filesystem [1].
The tarballs are only provided with zstd compression, so we first add support for decompressing these in the package infrastructure.
Note that this does *not* teach buildroot how to format bcachefs filesystems, as bcachefs-tools currently lacks the ability to do this without root privileges (see [2]). I have local patches ready for when this feature is implemented.
This package depends on host-clang to provide libclang, which is used to generate C <-> Rust bindings. libudev is also required, which means systemd is needed. Unfortunately these large dependencies seem to result in utils/test-pkg -p bcachefs-tools -a reporting all toolchains SKIPPED.
(Apologies to Thomas -- re-sending because I wasn't subscribed to the mailing list and my mail was rejected :)
[1]: https://bcachefs.org/
[2]: https://github.com/koverstreet/bcachefs-tools/issues/164
Matt Staveley-Taylor (2):
package: add support for extracting zstd archives package/bcachefs-tools: new package
Config.in | 7 ++++++ DEVELOPERS | 3 +++ Makefile | 1 + package/Config.in | 1 + package/bcachefs-tools/Config.in | 26 ++++++++++++++++++++++ package/bcachefs-tools/bcachefs-tools.hash | 2 ++ package/bcachefs-tools/bcachefs-tools.mk | 23 +++++++++++++++++++ package/pkg-utils.mk | 2 ++ support/dependencies/check-host-zstd.mk | 4 ++++ support/dependencies/check-host-zstd.sh | 14 ++++++++++++ 10 files changed, 83 insertions(+) create mode 100644 package/bcachefs-tools/Config.in create mode 100644 package/bcachefs-tools/bcachefs-tools.hash create mode 100644 package/bcachefs-tools/bcachefs-tools.mk create mode 100644 support/dependencies/check-host-zstd.mk create mode 100755 support/dependencies/check-host-zstd.sh
Signature · 6 lines
2.44.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 1/2 package: add support for extracting zstd archives
Teach the generic package handling code how to extract zstd (.tar.zst) archives. When zstd is not installed on the host, host-zstd gets built automatically.
--- Config.in | 7 +++++++ Makefile | 1 + package/pkg-utils.mk | 2 ++ support/dependencies/check-host-zstd.mk | 4 ++++ support/dependencies/check-host-zstd.sh | 14 ++++++++++++++ 5 files changed, 28 insertions(+) create mode 100644 support/dependencies/check-host-zstd.mk create mode 100755 support/dependencies/check-host-zstd.sh
Config.in +7 -0
@@ -173,6 +173,13 @@ config BR2_LZCAT Command to be used to extract a lzip'ed file to stdout. Default is "lzip -d -c" +config BR2_ZSTDCAT + string "zstdcat command" + default "zstdcat" + help + Command to be used to extract a zstd'ed file to stdout. + Default is "zstdcat" + config BR2_TAR_OPTIONS string "Tar options" default ""
Makefile +1 -0
@@ -444,6 +444,7 @@ ZCAT := $(call qstrip,$(BR2_ZCAT)) BZCAT := $(call qstrip,$(BR2_BZCAT)) XZCAT := $(call qstrip,$(BR2_XZCAT)) LZCAT := $(call qstrip,$(BR2_LZCAT)) +ZSTDCAT := $(call qstrip,$(BR2_ZSTDCAT)) TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
package/pkg-utils.mk +2 -0
@@ -59,6 +59,7 @@ INFLATE.tbz = $(BZCAT) INFLATE.tbz2 = $(BZCAT) INFLATE.tgz = $(ZCAT) INFLATE.xz = $(XZCAT) +INFLATE.zst = $(ZSTDCAT) INFLATE.tar = cat # suitable-extractor(filename): returns extractor based on suffix suitable-extractor = $(INFLATE$(suffix $(1)))
@@ -66,6 +67,7 @@ suitable-extractor = $(INFLATE$(suffix $(1))) EXTRACTOR_PKG_DEPENDENCY.lzma = $(BR2_XZCAT_HOST_DEPENDENCY) EXTRACTOR_PKG_DEPENDENCY.xz = $(BR2_XZCAT_HOST_DEPENDENCY) EXTRACTOR_PKG_DEPENDENCY.lz = $(BR2_LZIP_HOST_DEPENDENCY) +EXTRACTOR_PKG_DEPENDENCY.zst = $(BR2_ZSTD_HOST_DEPENDENCY) # extractor-pkg-dependency(filename): returns a Buildroot package # dependency needed to extract file based on suffix
support/dependencies/check-host-zstd.mk new file +4 -0
@@ -0,0 +1,4 @@ +ifeq (,$(call suitable-host-package,zstd,$(ZSTDCAT))) +BR2_ZSTD_HOST_DEPENDENCY = host-zstd +ZSTDCAT = $(HOST_DIR)/bin/zstdcat +endif
support/dependencies/check-host-zstd.sh new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/sh + +candidate="$1" + +zstdcat=`which $candidate 2>/dev/null` +if [ ! -x "$zstdcat" ]; then + zstdcat=`which zstdcat 2>/dev/null` + if [ ! -x "$zstdcat" ]; then + # echo nothing: no suitable zstdcat found + exit 1 + fi +fi + +echo $zstdcat
Signature · 6 lines
2.44.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 1/2] package: add support for extracting zstd archives
Quoted 5 lines · On Mon, 8 Apr 2024 02:38:44 +0100 Matt Staveley-Taylor…
Teach the generic package handling code how to extract zstd (.tar.zst) archives. When zstd is not installed on the host, host-zstd gets built automatically.
Signed-off-by Matt Staveley-Taylor <[email protected]>
Quoted 9 lines
--- Config.in | 7 +++++++ Makefile | 1 + package/pkg-utils.mk | 2 ++ support/dependencies/check-host-zstd.mk | 4 ++++ support/dependencies/check-host-zstd.sh | 14 ++++++++++++++ 5 files changed, 28 insertions(+) create mode 100644 support/dependencies/check-host-zstd.mk create mode 100755 support/dependencies/check-host-zstd.sh
Sorry for the long delay in getting back to you. I have now applied this patch, after fixing the "shellcheck" issues reported on the shell script. Thanks!
Thomas
Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 package/bcachefs-tools: new package
In reply to Matt Staveley-TaylorAdd the bcachefs-tools package. Note that this does not teach buildroot how to create bcachefs filesystems.
--- DEVELOPERS | 3 +++ package/Config.in | 1 + package/bcachefs-tools/Config.in | 26 ++++++++++++++++++++++ package/bcachefs-tools/bcachefs-tools.hash | 2 ++ package/bcachefs-tools/bcachefs-tools.mk | 23 +++++++++++++++++++ 5 files changed, 55 insertions(+) create mode 100644 package/bcachefs-tools/Config.in create mode 100644 package/bcachefs-tools/bcachefs-tools.hash create mode 100644 package/bcachefs-tools/bcachefs-tools.mk
DEVELOPERS +3 -0
@@ -2172,6 +2172,9 @@ F: package/ts4900-fpga/ N: Matt Silva <[email protected]> F: package/rlwrap/ +N: Matt Staveley-Taylor <[email protected]> +F: package/bcachefs-tools/ + N: Mauro Condarelli <[email protected]> F: package/mc/ F: package/python-autobahn/
package/Config.in +1 -0
@@ -213,6 +213,7 @@ menu "Filesystem and flash utilities" source "package/aufs/Config.in" source "package/aufs-util/Config.in" source "package/autofs/Config.in" + source "package/bcachefs-tools/Config.in" source "package/bmap-tools/Config.in" source "package/btrfs-progs/Config.in" source "package/cifs-utils/Config.in"
package/bcachefs-tools/Config.in new file +26 -0
@@ -0,0 +1,26 @@ +config BR2_PACKAGE_BCACHEFS_TOOLS + bool "bcachefs-tools" + depends on BR2_USE_MMU # util-linux + depends on BR2_TOOLCHAIN_HAS_THREADS + depends on BR2_PACKAGE_HAS_UDEV + select BR2_PACKAGE_KEYUTILS + select BR2_PACKAGE_LIBAIO + select BR2_PACKAGE_LIBSODIUM + select BR2_PACKAGE_LIBURCU + select BR2_PACKAGE_LZ4 + select BR2_PACKAGE_UTIL_LINUX + select BR2_PACKAGE_UTIL_LINUX_LIBBLKID + select BR2_PACKAGE_UTIL_LINUX_LIBUUID + select BR2_PACKAGE_ZLIB + select BR2_PACKAGE_ZSTD + help + Bcachefs filesystem utilities + + https://bcachefs.org/ + +comment "bcachefs-tools needs udev" + depends on !BR2_PACKAGE_HAS_UDEV + +comment "bcachefs-tools needs a toolchain w/ threads" + depends on BR2_USE_MMU + depends on !BR2_TOOLCHAIN_HAS_THREADS
package/bcachefs-tools/bcachefs-tools.hash new file +2 -0
@@ -0,0 +1,2 @@ +# Locally computed +sha256 f2125c10494e484611e77a32c301e1cbd5cf6f247808cf1c2c7987c68c7ebd8c bcachefs-tools-vendored-1.6.4.tar.zst
package/bcachefs-tools/bcachefs-tools.mk new file +23 -0
@@ -0,0 +1,23 @@ +################################################################################ +# +# bcachefs-tools +# +################################################################################ + +BCACHEFS_TOOLS_VERSION = 1.6.4 +BCACHEFS_TOOLS_SOURCE = bcachefs-tools-vendored-$(BCACHEFS_TOOLS_VERSION).tar.zst +BCACHEFS_TOOLS_SITE = https://evilpiepirate.org/bcachefs-tools +BCACHEFS_TOOLS_LICENSE = GPL-2.0 +BCACHEFS_TOOLS_LICENSE_FILES = COPYING +BCACHEFS_TOOLS_DEPENDENCIES = host-rustc host-clang keyutils libaio libsodium liburcu lz4 udev util-linux zlib zstd + +define BCACHEFS_TOOLS_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) +endef + +define BCACHEFS_TOOLS_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR="$(TARGET_DIR)" PREFIX=/usr install +endef + +$(eval $(generic-package)) +$(eval $(host-generic-package))
Signature · 6 lines
2.44.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/2] package/bcachefs-tools: new package
Hello,
Quoted 4 lines · On Mon, 8 Apr 2024 02:38:45 +0100 Matt Staveley-Taylor…
Add the bcachefs-tools package. Note that this does not teach buildroot how to create bcachefs filesystems.
Signed-off-by Matt Staveley-Taylor <[email protected]>
I wanted to apply this, but unfortunately, there is a major issue in your package: it doesn't actually cross-compile. Indeed, when you do:
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
nothing tells the build system that it should use the cross-compiler. And indeed it doesn't: it compiles everything with "cc". On my system, it fails because I don't have liburcu installed system-wide, so it couldn't include urcu/list.h.
The canonical way to cross-compile Makefile-based packages is to do:
$(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D)
where TARGET_CONFIGURE_OPTS is provided by Buildroot, and contains CC, LD, CFLAGS, etc. which are correct for cross-compilation.
Unfortunately, passing this makes the build of this package to fail horribly.
I have made many more changes in your package, you will find my latest version at:
https://github.com/tpetazzoni/buildroot/commit/1d1a29b7fedcb9287afd98c2d8a6618af2b6e2df
I will comment below on the things that I have fixed.
package/bcachefs-tools/Config.in line 5
Quoted 11 lines
package/bcachefs-tools/Config.in new file +5
-0@@ -0,0 +1,26 @@ +config BR2_PACKAGE_BCACHEFS_TOOLS + bool "bcachefs-tools" + depends on BR2_USE_MMU # util-linux + depends on BR2_TOOLCHAIN_HAS_THREADS + depends on BR2_PACKAGE_HAS_UDEV
You missed several dependencies of the packages you select. Basically for every package you select, you need to check if it has "depends on" and replicate them. The final code I had looks like this:
depends on BR2_USE_MMU # util-linux, keyutils depends on BR2_TOOLCHAIN_HAS_THREADS # liburcu depends on !BR2_STATIC_LIBS # keyutils depends on BR2_PACKAGE_HAS_UDEV depends on BR2_PACKAGE_LIBURCU_ARCH_SUPPORTS depends on BR2_INSTALL_LIBSTDCPP # liburcu
Quoted 11 lines
package/bcachefs-tools/Config.in new file +11
-0+ select BR2_PACKAGE_KEYUTILS + select BR2_PACKAGE_LIBAIO + select BR2_PACKAGE_LIBSODIUM + select BR2_PACKAGE_LIBURCU + select BR2_PACKAGE_LZ4 + select BR2_PACKAGE_UTIL_LINUX + select BR2_PACKAGE_UTIL_LINUX_LIBBLKID + select BR2_PACKAGE_UTIL_LINUX_LIBUUID + select BR2_PACKAGE_ZLIB + select BR2_PACKAGE_ZSTD + help
package/bcachefs-tools/Config.in line 26
Quoted 10 lines
package/bcachefs-tools/Config.in new file +10
-0+ Bcachefs filesystem utilities + + https://bcachefs.org/ + +comment "bcachefs-tools needs udev" + depends on !BR2_PACKAGE_HAS_UDEV + +comment "bcachefs-tools needs a toolchain w/ threads" + depends on BR2_USE_MMU + depends on !BR2_TOOLCHAIN_HAS_THREADS
So these need to be updated as well:
comment "bcachefs-tools needs udev"
depends on BR2_USE_MMU
depends on BR2_PACKAGE_LIBURCU_ARCH_SUPPORTS depends on !BR2_PACKAGE_HAS_UDEV
comment "bcachefs-tools needs a toolchain w/ threads, C++, dynamic library"
depends on BR2_USE_MMU depends on BR2_PACKAGE_LIBURCU_ARCH_SUPPORTS depends on !BR2_TOOLCHAIN_HAS_THREADS || \ BR2_STATIC_LIBS || \ !BR2_INSTALL_LIBSTDCPP
package/bcachefs-tools/bcachefs-tools.hash line 2
Quoted 8 lines
package/bcachefs-tools/bcachefs-tools.hash new file +2
-0@@ -0,0 +1,2 @@ +# Locally computed +sha256 f2125c10494e484611e77a32c301e1cbd5cf6f247808cf1c2c7987c68c7ebd8c bcachefs-tools-vendored-1.6.4.tar.zst
You have forgotten the hash of the license file. But I had forgotten as well.
Quoted 8 lines
package/bcachefs-tools/bcachefs-tools.mk new file +2
-0@@ -0,0 +1,23 @@ +################################################################################ +#
package/bcachefs-tools/bcachefs-tools.mk line 12
Quoted 10 lines
package/bcachefs-tools/bcachefs-tools.mk new file +10
-0+# bcachefs-tools +# +################################################################################ + +BCACHEFS_TOOLS_VERSION = 1.6.4 +BCACHEFS_TOOLS_SOURCE = bcachefs-tools-vendored-$(BCACHEFS_TOOLS_VERSION).tar.zst +BCACHEFS_TOOLS_SITE = https://evilpiepirate.org/bcachefs-tools +BCACHEFS_TOOLS_LICENSE = GPL-2.0 +BCACHEFS_TOOLS_LICENSE_FILES = COPYING +BCACHEFS_TOOLS_DEPENDENCIES = host-rustc host-clang keyutils libaio libsodium liburcu lz4 udev util-linux zlib zstd
That line was a bit too long, so I split it with one package per line.
package/bcachefs-tools/bcachefs-tools.mk line 15
Quoted 3 lines
package/bcachefs-tools/bcachefs-tools.mk new file +3
-0+ +define BCACHEFS_TOOLS_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
This probably needs $(TARGET_CONFIGURE_OPTS) as discussed above.
package/bcachefs-tools/bcachefs-tools.mk line 19
Quoted 4 lines
package/bcachefs-tools/bcachefs-tools.mk new file +4
-0+endef + +define BCACHEFS_TOOLS_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR="$(TARGET_DIR)" PREFIX=/usr install
Likewise.
package/bcachefs-tools/bcachefs-tools.mk line 23
Quoted 4 lines
package/bcachefs-tools/bcachefs-tools.mk new file +4
-0+endef + +$(eval $(generic-package)) +$(eval $(host-generic-package))
The host-generic-package is to create host packages (compiled natively), and it isn't used anywhere here, so I dropped this line. Only generic-package is needed to create a target package (cross-compiled for the target).
Here is a Buildroot configuration that couldn't build your package:
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_INIT_NONE=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_BCACHEFS_TOOLS=y
# BR2_TARGET_ROOTFS_TAR is not set
In order to validate your package, make sure it builds with the following sequence:
$ make clean $ cat > .config <<EOF BR2_arm=y BR2_cortex_a9=y BR2_ARM_ENABLE_VFP=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y BR2_INIT_NONE=y BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y BR2_SYSTEM_BIN_SH_NONE=y # BR2_PACKAGE_BUSYBOX is not set BR2_PACKAGE_BCACHEFS_TOOLS=y # BR2_TARGET_ROOTFS_TAR is not set EOF $ ./utils/docker-run make olddefconfig $ ./utils/docker-run make
Could you have a look and submit a v2 which fixes this problem? No need to resent your PATCH 1/2 as I applied it to master. Thanks!
Best regards,
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Matt,
Quoted 2 lines · On Mon, 8 Apr 2024 02:38:43 +0100 Matt Staveley-Taylor…
This patch series adds a new bcachefs-tools package: the userspace tools for the bcachefs filesystem [1].
Thanks a lot for working on this!
Quoted 2 lines
This package depends on host-clang to provide libclang, which is used to generate C <-> Rust bindings.
But do we need to unconditionally compile the C <-> Rust bindings?
Best regards,
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 6 lines · Thomas Petazzoni
Quoted 2 lines · On Mon, 8 Apr 2024 02:38:43 +0100 Matt Staveley-Taylor…
This package depends on host-clang to provide libclang, which is used to generate C <-> Rust bindings.
But do we need to unconditionally compile the C <-> Rust bindings?
The main binary and some of the subcommands are written in Rust, but most of them are written in C. The Rust main calls into the C subcommands using a tool called bindgen which generates Rust glue to interface with the C code.
So unfortunately I don't see a good way to avoid building host-clang here.
Matt
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Matt,
Quoted 7 lines · On Tue, 09 Apr 2024 23:43:29 +0100 "Matt Staveley-Taylor"…
The main binary and some of the subcommands are written in Rust, but most of them are written in C. The Rust main calls into the C subcommands using a tool called bindgen which generates Rust glue to interface with the C code.
So unfortunately I don't see a good way to avoid building host-clang here.
Indeed, not much we can do then. Thing is that host-clang is extremely long to build, obviously...
Best regards,
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 2 lines · Thomas Petazzoni
Indeed, not much we can do then. Thing is that host-clang is extremely long to build, obviously...
I noticed that host-rust downloads a pre-built binary from somewhere. Is there a possibility to do the same for host-clang? Or how do you want to proceed here?
Matt
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Matt,
Quoted 3 lines · On Thu, 11 Apr 2024 02:32:24 +0100 "Matt Staveley-Taylor"…
I noticed that host-rust downloads a pre-built binary from somewhere. Is there a possibility to do the same for host-clang? Or how do you want to proceed here?
It seems that
https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.1 has pre-built binaries, but not for the very common x86-64 linux host platform, which seems odd? Apparently, those binaries are made by volunteers. Not sure how much we want to use those binaries.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 5 lines · Thomas Petazzoni
It seems that
https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.1 has pre-built binaries, but not for the very common x86-64 linux host platform, which seems odd? Apparently, those binaries are made by volunteers. Not sure how much we want to use those binaries.
Yeah, agreed. Perhaps there is some Buildroot infrastructure we can leverage for building these ourselves?
Failing that -- is there actually a problem with merging the patch as-is? I can see a couple of other packages that already depend on host-clang.
Matt
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot