Would be great to add mosh as a package to termux
A fork of mosh with patches meant for android is available here:
https://github.com/ddrown/mosh/tree/android-unicode
One nicity is that the dependency on perl is dropped in favor of C++.
Scripts to build mosh for android are available here:
https://github.com/kmcallister/mosh/blob/android/android/build
I see that mosh is in the disabled package section, presumably because it wasn't working. By using the fork above together with the previous build instructions (the build part is pretty simple, the only relevant flag is --disable-server to build only the client side) we should be able to get something working.
If I get some time I might try to put something together and put a merge-request, otherwise hopefully the info in this comment will help someone else do the work.
Thanks, I'll look into it!
Cool, tks Fredrik. I'll also try to put some time into this.
Also, I have created a docker image suitable for creating teremux packages. (I've tested it with a few so far, and it works great). I will put up a pull request in case you want to include it.
This means that you could generate reproduce termux packages in any OS (not just linux). Perhaps that would also open up the possibility of using the travis CI service to generate the teremux packages and upload them to the right place whenever this repo gets updated.
The docker image and potential travis integration sounds great - let me know if I can help with that in any way! If you put the docker image up somewhere I can add a link to it in the README file.
About mosh, with https://github.com/termux/termux-packages/blob/master/disabled-packages/mosh/build.sh I'm able to build stock mosh 1.2.5 without any patches - a package built with debug symbols is available at http://termux.com/tmp/mosh-1.2.5_arm.deb.
Unfortunately, the mosh-client seems to segfault (I haven't debugged the issue yet to see where the segfault is yet). Perhaps https://github.com/ddrown/mosh/tree/android-unicode contains a patch for this already?
Dropping the perl dependency would be nice! Do you know if this is getting upstreamed into mosh itself? I remember reading http://blogs.perl.org/users/rurban/2012/07/i-had-to-remove-perl-from-mosh.html which indicated that this was done, but perhaps this has not been merged yet?
(Deleted)
Arhh, typing on cellphone and ruined last comment.
The Docker image is ready, so I will absolutely post that in another pull request. Travis integration should be doable too, but that bit depends on where and how you are hosting the produced Debian packages (if its aws or something the that will work well).
Mosh is known not to work on Android without some heavy patches, which is why I linked to that particular branch which has most of them.
Both the android patches and the C++ frontend are likely to be included on mosh 1.3, but there is no ETA on that.
Good news, I got mosh working on termux!
I want to contribute this back to termux, but I need to resolve some issues first. I have two questions where you might be able to save me some time:
Another piece of good news, is that I did all this using the Docker container, so i'll create a pull-request for that too as soon as I figure out the rest.
I had to create a minor patch on a file, what is the exact command line I should use to generate the patch file in order to hook it up with your buildscripts? (I assume its just diff -p, but on what folder should I be, what should I call the original and new filename, etc.. for this build I just edited the file manually).
Go to your patched source directory, and create the patch with:
diff -p -u -r $PATH_TO_PRISTINE .
where $PATH_TO_PRISTINE is the path to the unpacked unpatched tarball. Then put this patch file in the mosh/ folder (alongside build.sh) with the *.patch file extension, which will cause it to be applied when building.
The debian package generated by the buildscripts had the perl version of mosh (which didn't work) instead of the binary version of mosh, this is despite the fact that the binary mosh got built (and is the one I successfully launched on my phone and tablet). How can I override the build script to replace the file before the debian package gets built? I would need to do something like: cp mosh/src/src/frontend/mosh mosh/package/usr/bin..., but I am unsure about the paths and the moment where I should execute this.
I think you should define termux_step_post_make_install function, where you can copy binaries from the $TERMUX_PKG_BUILDDIR to $TERMUX_PREFIX. Something like this in mosh/build.sh:
termux_step_post_make_install () {
cp $TERMUX_PKG_BUILDDIR/path/to/binary/mosh $TERMUX_PREFIX/bin/mosh
}
Another piece of good news, is that I did all this using the Docker container, so i'll create a pull-request for that too as soon as I figure out the rest.
Nice work!
ok. got the package creation bit working with the buildscripts and created a pull request.
However, things are not ready for merge yet, there is also an unresolved exception in my build, it seems to be related to a C++ string resize operation; I am suspicious of mosh.cc (this is the perl replacement bit), but without being able to generate a stack trace or core dump I will never know.
Ideas? (I tried fiddling with ulimit inside android, and also running with gdb.. neither worked..maybe this is a good time to setup the android emulator instead of trying to debug this on my phone).
Ideas?
Do the binaries link with libgnustl_shared.so?
ldd $(which mosh)
libgnustl_shared.so
libandroid-support.so
libncursesw.so.6
libprotobuf.so.9
libssl.so.1.0.0
libcrypto.so.1.0.0
libutil.so
libz.so
libm.so
libc.so
libdl.so
do you know how to get a core dump inside termux? i tried ulimit but that didnt work.
mosh is available in some other open source apps in android; ill look into how they build and try to figure out the differences. i know at least one uses the same mosh fork i am using, but it also uses a different ncurses and protoc, so maybe the difference is there.
I'm excited to see such progress on this!
How is this going?
Any progress on this?
Unfortunately no progress here - a debug build still crashes at:
#0 0xb6f72b24 in std::locale::operator=(std::locale const&) () from /data/data/com.termux/files/usr/lib/libgnustl_shared.so
#1 0xb6f71e54 in std::ios_base::_M_init() () from /data/data/com.termux/files/usr/lib/libgnustl_shared.so
#2 0xb6f7df64 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*) ()
from /data/data/com.termux/files/usr/lib/libgnustl_shared.so
#3 0x2a012ef8 in std::basic_istream<char, std::char_traits<char> >::basic_istream (__vtt_parm=<optimized out>, this=0xb6167348,
__in_chrg=<optimized out>) at /home/fornwall/lib/android-standalone-toolchain-arm-api21-gcc4.9/include/c++/4.9/istream:608
#4 std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream (__mode=(std::_S_bin | std::_S_in),
__s=0x2a04a560 <rdev> "/dev/urandom", this=0xb6167348, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
at /home/fornwall/lib/android-standalone-toolchain-arm-api21-gcc4.9/include/c++/4.9/fstream:471
#5 PRNG::PRNG (this=0xb6167348) at /home/fornwall/termux/mosh/src/src/frontend/../crypto/prng.h:59
#6 Network::TransportSender<Network::UserStream>::TransportSender (this=0xb6167288, s_connection=<optimized out>, initial_state=...)
at /home/fornwall/termux/mosh/src/src/frontend/../network/transportsender.cc:65
#7 0x2a01322c in Network::Transport<Network::UserStream, Terminal::Complete>::Transport (this=0xb6167100, initial_state=...,
initial_remote=..., key_str=<optimized out>, ip=0xb60408cc "23.229.0.146", port=0xb6037214 "60001")
at /home/fornwall/termux/mosh/src/src/frontend/../network/networktransport.cc:65
#8 0x2a009cb0 in STMClient::main_init (this=this@entry=0xbefff790) at /home/fornwall/termux/mosh/src/src/frontend/stmclient.cc:251
#9 0x2a009ff4 in STMClient::main (this=0xbefff790) at /home/fornwall/termux/mosh/src/src/frontend/stmclient.cc:414
#10 0x2a005f00 in main (argc=<optimized out>, argv=<optimized out>) at /home/fornwall/termux/mosh/src/src/frontend/mosh-client.cc:171
If you use juicessh you can find a mosh-client in its directory that works in termux. You just have to create a .terminfo in your home dir that points to valid terminfo. So a symbolic link to ../usr/share/terminfo will get it to work. The mosh script from a normal installation will work with it. So vrom that the client is working.
thanks @its-pointless for the hint with the juicessh mosh! Where can I find the app? Do I need to download and unpack the juicessh.apk or can I access mosh directly via termux somehow? A hint would be cool :)
It's an entirely different app. https://play.google.com/store/apps/details?id=com.sonelli.juicessh
@grilldos yep, I know. I have installed it. The question is: how can I access the mosh client that comes with it, like @its-pointless mentioned? Maybe I'm missing the point :)
@hirschnase The easiest way would probably be:
cp /data/data/com.sonelli.juicessh/files/bin/arm/pie/mosh-client /sdcardcp /sdcard/mosh-client ~; chmod +x ~/mosh-clientHey, cool, that worked! I also copied over the "mosh" command-line utility (which is a Perl wrapper script) from my OS X machine and modified it:
line 1: #!/data/data/com.termux/files/usr/bin/perl
line 40: my $client = '/data/data/com.termux/files/home/bin/mosh-client';
Works well! Whoho :+1:
@fornwall just a suggestion, but maybe the mosh developers at MIT can give you a hint what the problem is? I know that they're very supportive. A couple years back I asked the developer of an iphone ssh client if he would embed mosh and he was in conversation with the mosh team at MIT and I was in 'cc. Maybe it's worth a try to email them :)
I managed to get mosh working recompiling the package for aarch64 using latest https://github.com/mobile-shell/mosh clone instead of the latest 1.2.5 release.
/me happy
@courville Interesting! Did you cross compile or compiled on an Android device? Could you write down the steps and commands?
Well I did nothing extraordinary, I just cloned latest mosh git repository and then did a simple tar.gz of this archive and pointed the build script to it:
TERMUX_PKG_SRCURL=file:/root/src/termux-packages/packages/mosh/mosh.tar.gz
That did the trick (cross compilation in the docker) and it works reliably at least on aarch64 (nexus 9 armv8l) i.e. plain build-package.sh
It would be nice perhaps to have a "git way'" for TERMUX_PKG_SRCURL
@courville Hm, it still segfaults for me on a Nexus 6p when i build from latest mosh git. Could you share your git package (link to it here) so I can try it?
BTW on a side but related topic, when crosscompiling perl it does override system /usr/bin/perl.
Got around it doing a chattr +i on it following a friend advice from the host.
It's a great pleasure to report that mosh is now available as a proper package and that this issue can be closed;
Run apt update && apt upgrade to ensure updated packages, then apt install mosh.
Thanks for all the help and feedback, enjoy mosh and let me know if there are any problems!
Most helpful comment
It's a great pleasure to report that mosh is now available as a proper package and that this issue can be closed;
Run
apt update && apt upgradeto ensure updated packages, thenapt install mosh.Thanks for all the help and feedback, enjoy mosh and let me know if there are any problems!