Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Lightweight flavor of the app without package management #2201

Open
Fs00 opened this issue Aug 2, 2021 · 9 comments
Open

Feature: Lightweight flavor of the app without package management #2201

Fs00 opened this issue Aug 2, 2021 · 9 comments

Comments

@Fs00
Copy link

Fs00 commented Aug 2, 2021

Feature description

Termux provides a great terminal UX, however it's a very big app (~150MB) for those users that don't take advantage of all of its features.
Actually, I use Termux only to run system commands as root (pm, appops, am, ecc.) from time to time and I'm not interested in installing packages or running Linux binaries. However, I love the extra keys row and just this feature is a strong enough motivation to use Termux simply as a terminal emulator.
Therefore, I think that a "lite"/"core" flavor of the app without package management nor pre-installed packages would better fit those people who want to use Termux just for its UX, without taking too much storage space.

Also, this alternative flavor would (theoretically) not be subject to the W^X restriction (#2155) and could be updated through the Play Store.

Reference implementation

The "failsafe" mode of Termux is a good example of how a trimmed version of Termux could look like.

@finagolfin
Copy link
Member

This is a good point. @fornwall, what do you think about updating the Play Store Termux app to only be a terminal, then linking from there to F-Droid for those who want the package manager version too? That way, we could keep an updated terminal in the Play Store, but direct people who want packages to F-Droid.

@frak0d
Copy link

frak0d commented Nov 7, 2021

I want this too, since I only use termux as terminal app on my rooted device.

Here are some suggestions for the trimmed down version :-

  1. If device is rooted, It should start as root shell by default.
  2. Preserve termux.properties feature.
  3. Add option to set startup command & exit command in termux.properties, these commands will be run after logging in to root shell and before exiting the root shell respectively. (this feature will save people time, for example by mounting and chrooting into their Arch BTW rootfs, and unmounting it on app exit)

@agnostic-apollo
Copy link
Member

  1. If device is rooted, It should start as root shell by default.

Add sudo su in ~/.bashrc. It also supports pre/post commands. I can add an env variable for the first session as well so that specific commands can only be run on that.

There are issues with people messing with root and changing ownership and then complaining that termux says permission denied. Packages will not be upgraded by apt if running as root either. Any scripts created with root for plugins cannot be read by termux. Same applies to .properties and TMPDIR files.

The 3 is already planned but more complex than simple start and exit. Probably something like systemd (or SysVinit) with configuration options, including boot and shutdown events, etc. That will take time. I haven't really much thought of the design yet anyway.

@frak0d
Copy link

frak0d commented Nov 7, 2021

There are issues with people messing with root and changing ownership and then complaining that termux says permission denied.

Since there will be no termux system, so no need to worry about people. As for the .termux folder (that contains termux's customisations), you can keep it in apps private data folder (usually /data/data/com.termux/). Since people have root, they can modify it anyways from the root shell.

Packages will not be upgraded by apt if running as root either. Any scripts created with root for plugins cannot be read by termux. Same applies to .properties and TMPDIR files.

That's the whole point of this feature request, we don't want apt and the termux's linux ecosystem. Just want to use it as a terminal app because it's the best terminal app on Android.

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Nov 7, 2021

Since there will be no termux system, so no need to worry about people.

Lolz, you should check issues, emails and support forums. We do have to deal with them and users don't read the documentation, nor understand linux ACL and selinux contexts. So every change that's made, has to be thought through. I have no issue with making things easier for rooted people, do plan on adding support for it, including in systemd and I'm a rooted user as well, but the way its implemented matters and shouldn't affect the default non-root way of things since that's what termux's design is for. Lot of root solutions are available, although likely not with a good terminal.

Moreover, termux app does not control what shell gets called (other than failsafe), it is decided by $PREFIX/bin/login and you can define a custom one with ~/.termux/shell in which you can run /path/to/su --shell /system/bin/sh or remove $PREFIX entirely except in the login script, just do exec /path/to/su --shell /system/bin/sh and you "should" (untested) have a root based mksh shell. The $PREFIX/bin/su is a wrapper script that searches for su, hence full paths are required if its deleted.

And termux app allegedly being the best terminal app on Android has a lot to do with it having bash shell as default. The mksh shell at /system/bin/bash sucks is fairly limited and doesn't even have persistent history support to file, so every time you start termux, you will have no history and will have to start fresh. The bash shell and its dependencies can be made optional I guess if bootstrap is not being setup for secondary user, since bash requires prefix patches, but for that bootstrap will have to contain info of exactly the files required to get bash running, so support for that will have to be added as well in generate-bootstraps.sh.

Moreover, am command provided by android does not work either on Android 8+. Termux has its own TermuxAm implementation for it, which would also require other stuff like am.apk, etc,. It also doesn't work in secondary user, so that's another case to handle.

Some other termux-* scripts like termux-open, termux-reload-settings, and termux-setup-storage may also be required by some users and will have to be extracted.

Moreover, if bootstrap isn't extracted, then things like tar won't exist either and the one provided by android likely does not have all the features termux one does so backup/restore will be an issue too for $HOME.

So this "minimal" non-termux env is neither as useable or easy to implement or configure as one may think, specially considering not everyone may have the same requirements as you do. This minimal env will still need parts of termux ecosystem, at initial implementation or added at a later time. Only a failsafe env can be added initially, but request or at least the need for other termux parts will still come later.

As for the .termux folder (that contains termux's customisations), you can keep it in apps private data folder (usually /data/data/com.termux/

Minimal env is not just for rooted people, its for non root people and secondary user as well. So such files need to be under $HOME so that they are accessible via SAF and can be backed up.

@frak0d
Copy link

frak0d commented Nov 7, 2021

And termux app allegedly being the best terminal app on Android has a lot to do with it having bash shell as default. The mksh shell at /system/bin/bash sucks is fairly limited and doesn't even have persistent history support.

For me atleast, termux being the best terminal app on Android has mainly to do with theming and custom font support, along with a good support of escape codes, touch support and the customisable extra keys row.

All I use it is for is to enter root shell and then chroot (provided by toybox) into my Arch Linux rootfs.

And I believe that someone without rooted device wouldn't want to use this proposed minimal termux anyways (since androids built-in shell is limited without root). They should go for full termux, shouldn't they ?

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Nov 7, 2021

They should go for full termux, shouldn't they ?

OP didn't say they were rooted. Also required for secondary user #2291

@frak0d
Copy link

frak0d commented Nov 7, 2021

They should go for full termux, shouldn't they ?

OP didn't say they were rooted. Also required for secondary user #2291

Actually he did said he was root here :-

I use Termux only to run system commands as root (pm, appops, am, ecc.) from time to time and I'm not interested in installing packages

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Nov 7, 2021

Ah, sorry! But even I very often use system binaries without root for testing and stuff for different stuff, including when writing shell libraries for posixy shells and writing scripts for tasker or my tasker framework which without root can only access system binaries. The binaries and their options change in every android version, so to maintain compatibility, have to test various versions. I usually do that through tudo though with PATH prioritized/set for system binaries.

https://android.googlesource.com/platform/system/core/+/master/shell_and_utilities/README.md

Moreover, now android-tools package provides adb, so a lot more stuff can be done with it that root can do, including am and monitoring processes of other apps, logcat and dumpsys without granting termux development permissions. So there are likely users who want it. Like I said, everybody may have different requirements, so things need to be designed well.

Termux checking of bootstrap, prefix, profile user, permissions, etc is relatively complex even now. Adding more variants including potential apk packaging and proot variants support, required for android 10 issues requires thought on how to support all of them.

https://github.com/termux/termux-app/blob/master/app/src/main/java/com/termux/app/TermuxInstaller.java

https://www.xda-developers.com/termux-terminal-linux-google-play-updates-stopped/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants