[Buildroot] [PATCH v4 1/1] package/uutils-coreutils: new package
Alexander Shirokov
shirokovalexs at gmail.com
Wed Apr 2 16:59:11 UTC 2025
This package is an implementation of coreutils written entirely in Rust.
uutils-coreutils is under active development and has known behavioral
differences from GNU coreutils. Please use it with caution in
production.
Currently defined functions:
[, b2sum, b3sum, base32, base64, basename, basenc, cat, cksum, comm,
cp, csplit, cut, date, dd, df, dir, dircolors, dirname, du, echo,
env, expand, expr, factor, false, fmt, fold, hashsum, head, join,
link, ln, ls, md5sum, mkdir, mktemp, more, mv, nl, numfmt, od,
paste, pr, printenv, printf, ptx, pwd, readlink, realpath, rm,
rmdir, seq, sha1sum, sha224sum, sha256sum, sha3-224sum, sha3-256sum,
sha3-384sum, sha3-512sum, sha384sum, sha3sum, sha512sum,
shake128sum, shake256sum, shred, shuf, sleep, sort, split, sum, tac,
tail, tee, test, touch, tr, true, truncate, tsort, unexpand, uniq,
unlink, vdir, wc, yes
Signed-off-by: Alexander Shirokov <shirokovalexs at gmail.com>
---
DEVELOPERS | 3 +
package/Config.in | 1 +
package/busybox/busybox.mk | 1 +
package/coreutils/Config.in | 1 +
package/uutils-coreutils/Config.in | 28 +++++
.../uutils-coreutils/uutils-coreutils.hash | 3 +
package/uutils-coreutils/uutils-coreutils.mk | 111 ++++++++++++++++++
support/testing/tests/package/test_rust.py | 9 ++
8 files changed, 157 insertions(+)
create mode 100644 package/uutils-coreutils/Config.in
create mode 100644 package/uutils-coreutils/uutils-coreutils.hash
create mode 100644 package/uutils-coreutils/uutils-coreutils.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index a26a4cbe68..b31159d666 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2967,6 +2967,9 @@ F: package/lrzip/
N: Sam Voss <sam.voss at gmail.com>
F: package/ripgrep/
+N: Alexander Shirokov <shirokovalexs at gmail.com>
+F: package/uutils-coreutils
+
N: Sébastien Szymanski <sebastien.szymanski at armadeus.com>
F: board/armadeus/
F: configs/armadeus*
diff --git a/package/Config.in b/package/Config.in
index eb22c81d1d..db478deba6 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2926,6 +2926,7 @@ menu "System tools"
source "package/tpm2-totp/Config.in"
source "package/unscd/Config.in"
source "package/util-linux/Config.in"
+ source "package/uutils-coreutils/Config.in"
source "package/watchdog/Config.in"
source "package/watchdogd/Config.in"
source "package/xdg-dbus-proxy/Config.in"
diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
index d3074d2218..07e2aab45c 100644
--- a/package/busybox/busybox.mk
+++ b/package/busybox/busybox.mk
@@ -78,6 +78,7 @@ BUSYBOX_DEPENDENCIES = \
$(if $(BR2_PACKAGE_UNZIP),unzip) \
$(if $(BR2_PACKAGE_USBUTILS),usbutils) \
$(if $(BR2_PACKAGE_UTIL_LINUX),util-linux) \
+ $(if $(BR2_PACKAGE_UUTILS_COREUTILS),uutils-coreutils) \
$(if $(BR2_PACKAGE_TINYINIT),tinyinit) \
$(if $(BR2_PACKAGE_VIM),vim) \
$(if $(BR2_PACKAGE_WATCHDOG),watchdog) \
diff --git a/package/coreutils/Config.in b/package/coreutils/Config.in
index 705013bae0..9c1af1dc25 100644
--- a/package/coreutils/Config.in
+++ b/package/coreutils/Config.in
@@ -3,6 +3,7 @@ config BR2_PACKAGE_COREUTILS
depends on BR2_USE_WCHAR
depends on BR2_USE_MMU # fork()
depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+ depends on !BR2_PACKAGE_UUTILS_COREUTILS
help
All of the basic file/text/shell utilities. These are the
core utilities which are expected to exist on every system.
diff --git a/package/uutils-coreutils/Config.in b/package/uutils-coreutils/Config.in
new file mode 100644
index 0000000000..4251d1f4ab
--- /dev/null
+++ b/package/uutils-coreutils/Config.in
@@ -0,0 +1,28 @@
+config BR2_PACKAGE_UUTILS_COREUTILS
+ bool "uutils-coreutils"
+ depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS
+ depends on BR2_PACKAGE_HOST_RUSTC
+ depends on BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
+ help
+ uutils is an attempt at writing universal (as in
+ cross-platform) CLI utilities in Rust. While all programs have
+ been implemented, some options might be missing or different
+ behavior might be experienced.
+
+ https://github.com/uutils/coreutils
+
+if BR2_PACKAGE_UUTILS_COREUTILS
+
+config BR2_PACKAGE_UUTILS_COREUTILS_MULTICALL
+ bool "multicall"
+ default y
+ help
+ Build coreutils as a multi-call binary.
+
+ Selecting 'y' will build and install a single
+ 'coreutils' binary that supports all commands.
+
+ Selecting 'n' will build and install the utilities
+ as separate files.
+
+endif
diff --git a/package/uutils-coreutils/uutils-coreutils.hash b/package/uutils-coreutils/uutils-coreutils.hash
new file mode 100644
index 0000000000..e872e4a75c
--- /dev/null
+++ b/package/uutils-coreutils/uutils-coreutils.hash
@@ -0,0 +1,3 @@
+# Locally generated
+sha256 1260677e4f09364b7f3ddda7affdae23e2232a18b55c1d42b8bb5ee083d5c7c7 uutils-coreutils-0.0.30-cargo2.tar.gz
+sha256 29953405eaa3dcc41c37d1621d55b6a47eee93e05613e439e73295029740b10c LICENSE
diff --git a/package/uutils-coreutils/uutils-coreutils.mk b/package/uutils-coreutils/uutils-coreutils.mk
new file mode 100644
index 0000000000..e17d010fc5
--- /dev/null
+++ b/package/uutils-coreutils/uutils-coreutils.mk
@@ -0,0 +1,111 @@
+################################################################################
+#
+# uutils-coreutils
+#
+################################################################################
+
+UUTILS_COREUTILS_VERSION = 0.0.30
+UUTILS_COREUTILS_SITE = $(call github,uutils,coreutils,$(UUTILS_COREUTILS_VERSION))
+UUTILS_COREUTILS_LICENSE = MIT
+UUTILS_COREUTILS_LICENSE_FILES = LICENSE
+
+# The list of supported utilities is used to instruct Cargo on which package(s)
+# to build when coreutils is built as a set of separate files. It is also
+# required to install the files into a target directory.
+#
+# There is some duplication with the native 'GNUMakefile' from the project.
+# Unfortunately, it seems that the 'GNUMakefile' is not designed to support
+# cross-compilation and cannot be used to build and install utilities in this
+# case. Some manual handling is required here.
+PROGS = \
+ base32 \
+ base64 \
+ basenc \
+ basename \
+ cat \
+ cksum \
+ comm \
+ cp \
+ csplit \
+ cut \
+ date \
+ dd \
+ df \
+ dir \
+ dircolors \
+ dirname \
+ echo \
+ env \
+ expand \
+ expr \
+ factor \
+ false \
+ fmt \
+ fold \
+ hashsum \
+ head \
+ join \
+ link \
+ ln \
+ ls \
+ mkdir \
+ mktemp \
+ more \
+ mv \
+ nl \
+ numfmt \
+ nproc \
+ od \
+ paste \
+ pr \
+ printenv \
+ printf \
+ ptx \
+ pwd \
+ readlink \
+ realpath \
+ rm \
+ rmdir \
+ seq \
+ shred \
+ shuf \
+ sleep \
+ sort \
+ split \
+ sum \
+ sync \
+ tac \
+ tail \
+ tee \
+ test \
+ tr \
+ true \
+ truncate \
+ tsort \
+ unexpand \
+ uniq \
+ vdir \
+ wc \
+ whoami \
+ yes
+
+ifeq ($(BR2_ENABLE_DEBUG),y)
+UUTILS_COREUTILS_PROFILE=debug
+else
+UUTILS_COREUTILS_PROFILE=release
+endif
+
+ifeq ($(BR2_PACKAGE_UUTILS_COREUTILS_MULTICALL),y)
+define UUTILS_COREUTILS_INSTALL_TARGET_CMDS
+ $(INSTALL) -D -m 0755 $(@D)/target/$(RUSTC_TARGET_NAME)/$(UUTILS_COREUTILS_PROFILE)/coreutils $(TARGET_DIR)/bin/
+endef
+else
+UUTILS_COREUTILS_CARGO_BUILD_OPTS += $(foreach prog,$(PROGS),-p uu_$(prog))
+define UUTILS_COREUTILS_INSTALL_TARGET_CMDS
+ $(foreach prog,$(PROGS), \
+ $(INSTALL) -D -m 0755 $(@D)/target/$(RUSTC_TARGET_NAME)/$(UUTILS_COREUTILS_PROFILE)/$(prog) $(TARGET_DIR)/bin/
+ )
+endef
+endif
+
+$(eval $(cargo-package))
diff --git a/support/testing/tests/package/test_rust.py b/support/testing/tests/package/test_rust.py
index 8160cb6053..c0fe56f1be 100644
--- a/support/testing/tests/package/test_rust.py
+++ b/support/testing/tests/package/test_rust.py
@@ -28,11 +28,14 @@ class TestRustBin(TestRustBase):
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_RUSTC=y
BR2_PACKAGE_RIPGREP=y
+ BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+ BR2_PACKAGE_UUTILS_COREUTILS=y
"""
def test_run(self):
self.login()
self.assertRunOk("rg Buildroot /etc/issue")
+ self.assertRunOk("coreutils --help")
class TestRust(TestRustBase):
@@ -50,11 +53,14 @@ class TestRust(TestRustBase):
BR2_PACKAGE_HOST_RUSTC=y
BR2_PACKAGE_HOST_RUST=y
BR2_PACKAGE_RIPGREP=y
+ BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+ BR2_PACKAGE_UUTILS_COREUTILS=y
"""
def test_run(self):
self.login()
self.assertRunOk("rg Buildroot /etc/issue")
+ self.assertRunOk("coreutils --help")
class TestRustVendoring(infra.basetest.BRConfigTest):
@@ -70,6 +76,8 @@ class TestRustVendoring(infra.basetest.BRConfigTest):
BR2_PACKAGE_RIPGREP=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
+ BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
+ BR2_PACKAGE_UUTILS_COREUTILS=y
"""
def setUp(self):
@@ -95,3 +103,4 @@ class TestRustVendoring(infra.basetest.BRConfigTest):
def test_run(self):
self.check_download("ripgrep")
self.check_download("python-cryptography")
+ self.check_download("uutils-coreutils")
--
2.49.0
More information about the buildroot
mailing list