termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
31.28k stars 3.32k forks source link

Allow access #3923

Closed appt2 closed 3 weeks ago

appt2 commented 3 weeks ago

Feature description

Hello dear Termux developer, I want to use the entire Termux resource in my program, the name of my program is Ghost web ide, I need to implement the entire Termux in my program so that my user can install the required packages, and I have another question, if Should I add the entire Termux source in my program, do I not need a special api to install all kinds of packages?

Additional information

.

agnostic-apollo commented 3 weeks ago

https://github.com/termux/termux-app#forking

agnostic-apollo commented 3 weeks ago

Direct integration will also require releasing your app as open source under GPLv3. Allowing users to install packages at runtime will require hosting your own packages repo as well.

https://github.com/termux/termux-app/blob/master/LICENSE.md

appt2 commented 3 weeks ago

Direct integration will also require releasing your app as open source under GPLv3. Allowing users to install packages at runtime will require hosting your own packages repo as well.

https://github.com/termux/termux-app/blob/master/LICENSE.md

bro im trying to compile and run app

exec("/data/data/com.termux/files/usr/bin/login"): Permission denied

[Process completed (code 1) - press Enter]

agnostic-apollo commented 3 weeks ago

exec("/data/data/com.termux/files/usr/bin/login"): Permission denied

As expected. You need to compile all packages including the bootstrap for you app package name and make appropriate changes in java code as well. Read the forking docs linked above, especially TermuxConstants class javadocs. Not easy to do it.

appt2 commented 3 weeks ago

exec("/data/data/com.termux/files/usr/bin/login"): Permission denied

As expected. You need to compile all packages including the bootstrap for you app package name and make appropriate changes in java code as well. Read the forking docs linked above, especially TermuxConstants class javadocs. Not easy to do it.

Well, I don't want to create my own package, I want to use Thermox directly. I tried several times to use Thermox intents, but it didn't work. For example, I need an intent to run Python code.

agnostic-apollo commented 3 weeks ago

https://github.com/termux/termux-app/wiki/RUN_COMMAND-Intent

appt2 commented 3 weeks ago

https://github.com/termux/termux-app/wiki/RUN_COMMAND-Intent

I read and wrote its codes, but it doesn't work

agnostic-apollo commented 3 weeks ago

That code is tested and does work, tonne of people use it.

If you are facing issues, read its setup instructions again and check both system and app package logcat output.

appt2 commented 3 weeks ago

That code is tested and does work, tonne of people use it.

If you are facing issues, read its setup instructions again and check both system and app package logcat output.

Intent intent = new Intent(); intent.setClassName("com.termux", "com.termux.app.RunCommandService"); intent.setAction("com.termux.RUN_COMMAND"); intent.putExtra( "com.termux.RUN_COMMAND_PATH", "/data/data/com.termux/files/usr/bin/pkg"); intent.putExtra("com.termux.RUN_COMMAND_BACKGROUND", true); intent.putExtra( "com.termux.RUN_COMMAND_ARGUMENTS", new String[]{"-c", "pkg install python3 -y jq gettext curl openssh; curl -s url; command 3;"}); startService(intent);

This is my code, I am expected to run the Python code from the path that I set, even Thermox does not open

twaik commented 3 weeks ago

Github has special syntax for code blocks. https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks Consider using it please.

agnostic-apollo commented 3 weeks ago

intent.putExtra("com.termux.RUN_COMMAND_BACKGROUND", true);

If you run it in background, of course Termux is not gonna open in foreground. Also check https://github.com/termux/termux-app?tab=readme-ov-file#debugging for how to see what commands are received and run.

intent.putExtra("com.termux.RUN_COMMAND_PATH", "/data/data/com.termux/files/usr/bin/pkg"); intent.putExtra("com.termux.RUN_COMMAND_ARGUMENTS", new String[]{"-c", "pkg install python3 -y jq gettext curl openssh; curl -s url; command 3;"});

You are passing pkg as RUN_COMMAND_PATH and passing it the -c argument and additional pkg arguments. You need to use bash.

twaik commented 3 weeks ago

You are executing pkg with arguments -c and some command in bash format. pkg is not a shell to parse it.

appt2 commented 3 weeks ago

You are executing pkg with arguments -c and some command in bash format. pkg is not a shell to parse it.

Can you provide a sample code?

twaik commented 3 weeks ago

@agnostic-apollo already told you what exactly you should do.