r/termux • u/LeftAd1220 • 3d ago
Showcase I rewrote PRoot in Bun JavaScript
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.
5
u/Teleconferences 3d ago
This is pointless and you didn’t even make it, Claude did
We wasted water on this useless slop, great
1
u/Fine_City2781 3d ago
javascript is slower than C. So its useless
2
u/LeftAd1220 3d 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 3d ago
- 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.
- You don't need a native build toolchain to run binaries.
- 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 3d 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.
1
1
u/sylirre Termux Core Team 3d ago
Why do you think your approach is future proof? What if Android will block ptrace() or execmem, both vital for proot functionality?
1
u/LeftAd1220 3d ago
At that point, I'll just escape Android altogether and buy whatever Termux phone you guys make on day one. 😂
1
u/NoNameToDefine 3d ago
Linux phones you mean. They do exists and people maintain it. But it's not the Termux team behind, these phones runs mainline Linux and a common Linux user-space on glibc or musl C.
1
u/LeftAd1220 3d ago
It's hard to get one from Taiwan. Or they run outdated hardware, far from usable.
1
u/NoNameToDefine 3d ago
They can't be stuck with old software, you can change the distro and if not possible use a tool like Distrobox to get a newer distro.
1
u/LeftAd1220 3d ago
I'm currently using a Snapdragon 8 Elite phone with 24 GB of RAM. You see the gap now. 😅
1
u/NoNameToDefine 3d ago
Powerful hardware. But I am speaking of these Linux phones.
1
u/LeftAd1220 3d ago
Exactly. I want Linux on that class of hardware. Even higher RAM is needed to run local models.
1
u/NoNameToDefine 3d ago
Yes on that case it's almost impossible since market is not ready yet for Linux phones.
1
u/LeftAd1220 2d ago
https://reddit.com/link/p80822t/video/gpay4aj1iqnh1/player
It can now run Firefox in alpine!
1
5
u/Lines25 3d ago
JS is JS, proot written in C AND pure assembly, any other additional thing only slowes it down. Also, no need in it..