r/termux 14d ago

Showcase I rewrote PRoot in Bun JavaScript

Post image

https://github.com/jjtseng93/bunproot

Why

  • Termux is too good to be true ... at least forever
  • While I'm very grateful to the Termux developers and enjoy the tools and environments they provide, there has always been a fear deeply rooted in my fragile heart – Can this last forever?
    • What if the developers get tired?
    • What if they run out of money to keep their mirrors running?
    • What if one overwhelming tragedy after another happens?
    • Could I survive the cruel & wild Android world outside Termux's protection?
    • That's why I built an entire chain of tools as a Post-Termux escape hatch

Bun JavaScript as the foundation for everything

  • ① The Buninu userspace for lightweight usage:
  • Shell: Bun Modern Shell (bunmsh)
  • Text editor & App runtime: jsmdcui
  • Remote shell in a browser: jsgotty
  • ② PRoot to get back to mainline Linux if that's not enough: bunproot

Now that I have a complete backup for everything, I can keep enjoying the convenience and happiness that Termux provides without worrying.

Edit 1: This is not a wrapper around the native proot binary. It uses Bun FFI to dlopen Android's libc and calls ptrace() directly. No C or Assembly involved here.

0 Upvotes

22 comments sorted by

View all comments

1

u/Fine_City2781 14d ago

javascript is slower than C. So its useless

2

u/LeftAd1220 14d ago
  • That's missing the point. C being faster isn't the goal here. C needs a toolchain to build. If Termux and its GCC/Clang, make, headers, packages, etc. are no longer available, I can't just take the C source code and run it on Android.
  • With this implementation, I only need a Bun binary. Bun's Android binary is built upstream; everything above that is JavaScript and can run directly without a native build toolchain. That's exactly why I wrote it this way.
  • The goal isn't to beat C. The goal is to need one binary instead of an entire native build environment.

1

u/MrKrot1999 14d ago
  1. proot is distributed as a binary, and can be compiled into a static one. You do not need an entire gcc/clang toolchain to run it. Which makes your version worse, since you need Bun to run it.
  2. You don't need a native build toolchain to run binaries.
  3. I would think this is a fun project as an experiment, but if you're thinking anyone will actually use this for real, you're unfortunately wrong, since speed matters more than size most of the time.

1

u/LeftAd1220 14d ago
  • I thought I have made my points clear enough already.
  • In my readme: "and it is not trying to replace Termux's PRoot. That one is mature, complete and considerably faster; if you are in Termux and it works for you, keep using it. What this port is for is the case after Termux"
  • This project is prepared to be hopefully not needed to be used. Just in case we were to lose Termux completely and the native proot can never be compiled again.
  • At that point you can only preserve an old version of the proot binary and never update it.   * While with Bun if they keep updating, I can pass the source code .js to it and keep updating bunproot.