Skip to content
This repository was archived by the owner on Jul 21, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions Formula/findutils.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
require (Tap.fetch("automattic", "kandelo-homebrew").path/"Kandelo/formula_support/kandelo_formula_support").to_s

class Findutils < Formula
include KandeloFormulaSupport

desc "GNU find and xargs utilities for Kandelo"
homepage "https://www.gnu.org/software/findutils/"
url "https://ftpmirror.gnu.org/gnu/findutils/findutils-4.10.0.tar.xz"
mirror "https://ftp.gnu.org/gnu/findutils/findutils-4.10.0.tar.xz"
sha256 "1387e0b67ff247d2abde998f90dfbf70c1491391a59ddfecb8ae698789f0a4f5"
license "GPL-3.0-or-later"

depends_on "binaryen" => :build
depends_on "wabt" => :build
depends_on "automattic/kandelo-homebrew/dash" => :test

skip_clean "bin/find", "bin/xargs"

def install
kandelo_require_arch!("wasm32")

kandelo_wasm_build do |root|
system kandelo_configure, *kandelo_std_configure_args,
"--disable-nls",
"--without-selinux",
"--localstatedir=/var",
"--disable-dependency-tracking"
system "make", "-j#{ENV.make_jobs}"

{
buildpath/"find/find" => buildpath/"find/find.instrumented",
buildpath/"xargs/xargs" => buildpath/"xargs/xargs.instrumented",
}.each do |source, instrumented|
system "#{root}/scripts/run-wasm-fork-instrument.sh", source, "-o", instrumented
kandelo_validate_wasm_artifact(instrumented, fork: :required)
mv instrumented, source
end

system "make", "-C", "find", "install"
system "make", "-C", "xargs", "install"
system "make", "-C", "doc", "install"
end
end

test do
[man1/"find.1", man1/"xargs.1", info/"find.info", info/"find-maint.info"].each do |document|
assert_path_exists document
end
assert_match(/find \(GNU findutils\) 4\.10\.0$/,
kandelo_run_wasm(bin/"find", ["--version"]))
assert_match(/xargs \(GNU findutils\) 4\.10\.0$/,
kandelo_run_wasm(bin/"xargs", ["--version"]))

workspace = testpath/"workspace"
(workspace/"nested").mkpath
(workspace/"alpha.txt").write("alpha\n")
(workspace/"nested/beta.txt").write("beta\n")
(workspace/"nested/skip.log").write("skip\n")
env = { "KERNEL_CWD" => "/work" }
mount = { "/work" => workspace }
dash = formula_opt_bin("automattic/kandelo-homebrew/dash")/"dash"
exec_programs = { "/bin/sh" => dash }

listing = kandelo_run_wasm(
bin/"find", [".", "-type", "f", "-name", "*.txt", "-printf", "%P:%s\\n"],
env: env, writable_host_directories: mount
)
assert_equal ["alpha.txt:6", "nested/beta.txt:5"], listing.lines.map(&:chomp).sort

exec_output = kandelo_run_wasm(
bin/"find",
[".", "-type", "f", "-name", "*.txt", "-exec", "/bin/sh", "-c", 'printf "found %s\\n" "$1"',
"sh", "{}", ";"],
env: env,
exec_programs: exec_programs,
writable_host_directories: mount,
expected_fork_descendants: 2,
)
assert_equal ["found ./alpha.txt", "found ./nested/beta.txt"],
exec_output.lines.map(&:chomp).sort

assert_equal "item alpha beta\nitem gamma\n",
kandelo_run_wasm(
bin/"xargs",
["-n", "2", "/bin/sh", "-c", 'printf "item"; printf " %s" "$@"; printf "\\n"', "sh"],
stdin: "alpha beta gamma\n",
exec_programs: exec_programs,
expected_fork_descendants: 2,
)

missing = kandelo_run_wasm(
bin/"find", ["missing"], env: env, merge_stderr: true,
writable_host_directories: mount, expected_status: 1
)
assert_match(/missing.*No such file or directory/, missing)
end
end
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Current migration controls and pilots include:
- `wget`, GNU HTTP and HTTPS retrieval linked against the tap TLS and compression roots.
- `coreutils`, the GNU filesystem, text, checksum, and shell utility suite.
- `diffutils`, GNU `diff`, `cmp`, `diff3`, and `sdiff` file-comparison tools.
- `findutils`, GNU filesystem traversal and argument-driven process execution.

The SDK is not yet a Homebrew dependency. Trusted builds supply an
`HOMEBREW_KANDELO_ROOT` checkout containing the SDK, sysroot, kernel, and Node
Expand Down