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

Termux support for Android Emacs #1

Open
jfmcbrayer opened this issue Feb 20, 2023 · 16 comments
Open

Termux support for Android Emacs #1

jfmcbrayer opened this issue Feb 20, 2023 · 16 comments

Comments

@jfmcbrayer
Copy link

Hi! Have you emailed Po Lu about the shared user ID thing? This is probably something that needs to be upstreamed, unless we all want to maintain our own builds of Termux and Emacs every time there's an update. The shared signature thing will be taken care of by installing both of them from F-Droid.

@marek-g
Copy link
Owner

marek-g commented Feb 20, 2023

Hi! This is a great idea. However, this is not that simple. There is an additional requirement that both APKs are signed with the same key. Currently they are not (they can be if you or me resign them). SHA1 fingerprints on F-Droid are:

Termux: E8:75:4A:2C:61:43:92:07:1D:27:02:1B:BC:DF:B8:DD:A7:E0:71:1C
Emacs: 06:AC:74:B5:CB:46:EE:01:86:97:FB:D4:63:21:20:42:07:B3:44:F6

They are different. To make that happen both party should agree to use the same key. Anyway, I'll try to reach them both. Thanks for the idea!

@jfmcbrayer
Copy link
Author

That's odd. I thought F-Droid signed everything with the same key. Maybe Emacs is in Izzy-On-F-Droid or something?

@marek-g
Copy link
Owner

marek-g commented Feb 20, 2023

I though the same (I believe I have read it in Termux docs somewhere) - that's why I verified it myself. But there is also this documentation: https://f-droid.org/en/docs/Signing_Process/ - and it can be configured in different ways.

@marek-g
Copy link
Owner

marek-g commented Feb 20, 2023

What I have read probably must have been about that Google Play & F-Droid use different keys but not that all F-Droid apps are signed with the same key.

@leiserfg
Copy link

leiserfg commented Mar 9, 2023

Is there any progress on this?

@marek-g
Copy link
Owner

marek-g commented Mar 12, 2023

Po Lu contacted me first and we are talking about possible solutions. But it's not easy to find the best one. There are many questions (problems with building GnuTLS on F-Droid, incompatible change for existing users - cannot upgrade current version without uninstalling it first, the method with userSharedId is already deprecated although Termux is using it itself, what about integration with other similar software like Nix-on-Droid, do we want to maintain multiple versions, because of that maybe each party like Temux and Nix-on-Droid should maintain their own version?).

Thanks to Po I have learned that you can find the latest binary version not on F-Droid but on https://sourceforge.net/projects/android-ports-for-gnu-emacs/files/ which is also better, because it's build with GnuTLS enabled.

In the meantime I have updated Emacs to the latest version in the releases here.

@jdriordan
Copy link

In case it was useful I put a really rough script of the re-signing instructions here:

https://gist.github.com/jdriordan/e652ba692dad52400e01a44c8cc14881

There are likely a few mistakes as well as a couple of places where it prompts for input that could be fixed with expect.

Neither the files created using this script nor the prebuilt ones from the releases can be installed and I just get a modal saying "Package has not been installed". I have permissions for installing external APKs etc, and if I download the equivalent APK from f-droid (but through Firefox) it installs without issue.

Could there be something about the instructions that doesn't work with Android 13.

@jdriordan
Copy link

Po Lu contacted me first and we are talking about possible solutions. But it's not easy to find the best one. There are many questions (problems with building GnuTLS on F-Droid, incompatible change for existing users - cannot upgrade current version without uninstalling it first, the method with userSharedId is already deprecated although Termux is using it itself, what about integration with other similar software like Nix-on-Droid, do we want to maintain multiple versions, because of that maybe each party like Temux and Nix-on-Droid should maintain their own version?).

Thanks to Po I have learned that you can find the latest binary version not on F-Droid but on https://sourceforge.net/projects/android-ports-for-gnu-emacs/files/ which is also better, because it's build with GnuTLS enabled.

In the meantime I have updated Emacs to the latest version in the releases here.

Would it be possible to include some of the termux applications inside the emacs package? It wouldn't be ideal, but it would still add a lot of functionality (via packages that assume a certain environment) if there were a few basic utilities and maybe the package installer available within the emacs sandbox. If I have some time I'll try naively copying some binaries from termux into the emacs package. Even just having the git binary for magit would be good.

@marek-g
Copy link
Owner

marek-g commented Mar 28, 2023

HI @jdriordan ! Thanks for the script. One missing part I can is it that strings.xml file may be missing header and footer line (it needs to be valid XML). But it's a good starting point. Thanks!!

Would it be possible to include some of the termux applications inside the emacs package?

This may be the way to go for the future Android versions as userSharedId is already deprecated by Google.

I'm sure it is possible, but it's more work than just copy some binaries.

First of all the Termux apps have hardcoded paths to Termux data folder. So it requires that the namespace of the final app is the same as the Temux's. Or you have to recompile all the Termux packages with updated paths.

Secondly, the Termux packages should be installed in the data folder, not the app's folder. To put them there you need to ensure that you run the installer that copies initial files (pkg) to data folder. So, Emacs should be modified to at least call this class at the first run: https://github.com/termux/termux-app/blob/master/app/src/main/java/com/termux/app/TermuxInstaller.java.

But theoretically, when that's done you should be able to use Emacs' shell to call pkg install from inside it and have fun.

For me it's not worth the time yet as long as userSharedId method works. But it's good to know there are other options for the future.

@daraul
Copy link

daraul commented May 7, 2023

Do you now use the Android port, instead of running emacs inside of termux? I do the latter, but I use doom emacs, and have been trying in vain for some time to get doom working in the Android port.

@marek-g
Copy link
Owner

marek-g commented May 7, 2023

Yes, I do.

Doom isn't working on Android port. That's because doom command is a bash script that calls emacs executable to evaluate files. Executing lisp that way cannot work from inside native Android app. The same problem have some package managers as elpaca and maybe (I'm not sure) streight. Elpaca also starts emacs as a separate process...

So, what I did is I rewrote my doom's config to vanilla Emacs using package.el. Like you can see in this repo. It does everything I had with doom and works great.

@marek-g
Copy link
Owner

marek-g commented May 7, 2023

And if you are interested I forked orgzly and published modified version today that enables and fixes some bugs in repeated remainders and enables git integration (based on public PRs that are not merged). I'm planning to use it to have Android notifications based on org-mode tasks. I'm not sure yet what will be the best method of sync (git or folder shared with emacs or syncthing - I need to play with settings).

If you are interested you can find it here: https://github.com/marek-g/orgzly-android/releases

@daraul
Copy link

daraul commented May 7, 2023

That's incredible! Thank you, I'll take a look.

@daraul
Copy link

daraul commented May 7, 2023

I decided to just clone your config into my test environment using termux -- does this look about right?

cd /data/data/org.gnu.emacs/files
git clone https://github.com/marek-g/emacs-config .config/emacs

Screenshot_1683478717

@marek-g
Copy link
Owner

marek-g commented May 7, 2023 via email

@marek-g
Copy link
Owner

marek-g commented May 7, 2023 via email

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

5 participants