1

I have already seen some answers related to this, but they didn't bring me to a definitive answer, so I'm going to try again.

Basically, my question is: how can I run Ubuntu Touch applications from the command line - specifically, so that I could debug them with gdb?


More details:

First, what that means is that I'd like to run them from a remote shell connection to a (phone/tablet) device on a PC, either from adb shell or phablet-shell (see Hacking Ubuntu Touch, Part 5: adb shell vs. phablet-shell). I already got the Terminal app, but - given that one cannot establish a proper (VNC) remote desktop connection to an Ubuntu Touch system, - it is of little use to me, as I cannot really work with it (haven't yet tried a Bluetooth keyboard attached to a device, though).

Second, I'd like, if possible, to run applications in the foreground; then when called from the terminal command line, I'd expect the applications to dump their stdout printouts to the terminal. Thus, the recommendation in Ubuntu Touch: How do I run an ubuntu touch app from the terminal? I cannot use much, since (this is from a BQ E5 (Ubuntu 15.04, OTA-10.1)):

phablet@ubuntu-phablet:~$ ubuntu-app-list
ubuntu-system-settings
com.ubuntu.calculator_calculator_2.0.233
phablet@ubuntu-phablet:~$ ubuntu-app-launch com.ubuntu.calculator_calculator_2.0.233
phablet@ubuntu-phablet:~$ 

... it simply launches the app in the background, and immediately exits. And AFAICS, webapp-container simply opens an URL in the browser, doesn't run arbitrary applications.

Some of the preinstalled applications are apparently run by a program qmlscene, as How do I simply run an ubuntu touch app from the terminal? notes; but even the accepted answer there isn't applicable to Ubuntu 15.04 Touch as-is:

$ /usr/bin/qmlscene \
> --desktop_file_hint=/usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/share/applications/ubuntu-clock-app.desktop \
> /usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/share/qml/ubuntu-clock-app.qml
Loading module: 'libubuntu_application_api_touch_mirclient.so.3.0.0'
file:///usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/share/qml/ubuntu-clock-app.qml:22 module "Alarm" is not installed
file:///usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/share/qml/ubuntu-clock-app.qml:20 module "WorldClock" is not installed

... and the application shuts down on device barely after being started. And below is the only command line I've found to work on a BQ E5 Ubuntu 15.04:

APP_ID=com.ubuntu.clock_clock_3.7.456 \
QML2_IMPORT_PATH=/usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/lib/arm-linux-gnueabihf \
QML_IMPORT_TRACE=1 \
/usr/bin/qmlscene \
--desktop_file_hint=/usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/share/applications/ubuntu-clock-app.desktop \
/usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/share/qml/ubuntu-clock-app.qml

The application then starts on phone, while on shell terminal messages are being dumped, like:

Loading module: 'libubuntu_application_api_touch_mirclient.so.3.0.0'
QQmlImportDatabase::addImportPath: "/usr/lib/arm-linux-gnueabihf/qt5/qml"
QQmlImportDatabase::addImportPath: "/usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/lib/arm-linux-gnueabihf"
QQmlImportDatabase::addImportPath: "/usr/lib/arm-linux-gnueabihf/qt5/bin"
...

... and after you press Ctrl-C in terminal, the application exits.

Why I like this, is for one, I know what is the application printout and how to redirect/save it - and for another, I know how to build a gdb command line in order to debug. I managed to set the device in writable mode, and from the shell install build-essential (see Recommended way to install regular(cli) .deb packages on Ubuntu Phone?), which pulls in gdb, so now it is available in shell also in read-only mode. Then I can do:

APP_ID=com.ubuntu.clock_clock_3.7.456 \
QML2_IMPORT_PATH=/usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/lib/arm-linux-gnueabihf \
QML_IMPORT_TRACE=1 \
gdb --args \
/usr/bin/qmlscene \
--desktop_file_hint=/usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/share/applications/ubuntu-clock-app.desktop \
/usr/share/click/preinstalled/com.ubuntu.clock/3.7.456/share/qml/ubuntu-clock-app.qml

... which will properly open gdb:

GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9
...
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/qmlscene...(no debugging symbols found)...done.

(but won't be of that much use in this example due to missing debugging symbols).

However, besides these apps ran by qmlscene, there are seemingly also "proper" executables on Ubuntu Touch 15.03, such as the Browser app:

phablet@ubuntu-phablet:~$ which webbrowser-app
/usr/bin/webbrowser-app
phablet@ubuntu-phablet:~$ file /usr/bin/webbrowser-app
/usr/bin/webbrowser-app: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=c173774045b98a97e831eda92dd5008d08b9a251, stripped

... but this kind I simply cannot get to run from the command line. Closest I got to (by analogy with above, and copying some environment variables that env ran on the Terminal app on the phone reported) is this:

APP_ID=webbrowser-app \
UNITY_MIR_SOCKET=/run/mir_socket \
MIR_SOCKET=/var/run/mir_socket \
MIR_SERVER_PROMPT_FILE=1 \
MIR_SERVER_NAME=session-0 \
/usr/bin/webbrowser-app \
--desktop_file_hint=/usr/share/applications/webbrowser-app.desktop

... which however fails immediately in terminal with:

Loading module: 'libubuntu_application_api_touch_mirclient.so.3.0.0'
UbuntuClientIntegration: connection to Mir server failed. Check that a Mir server is
running, and the correct socket is being used and is accessible. The shell may have
rejected the incoming connection, so check its log file
Aborted

What's more, all this business with --desktop_file_hint seems something required by Unity8 (i.e. Unity8 might inspect the app command line and look for it, even if the app itself doesn't use it) - but may be (or is) going away:

ubuntu-bugs - [Bug 1578319] [NEW] Some ubuntu-ui-toolkit AP tests failing to launch - rejected by unity8 as is using desktop_file_hint (2016-05)

...is not using upstart-app-launch - which would explain the fail. desktop_file_hint is not a supported means of launching an app (and can go away at any time), so UITK should change to use UAL in its AP tests.

This indeed used to work until recently, but a recent refactoring broke the desktop_file_hint behaviour. Since it's not a supported behaviour, it should be relied on, so it would be better to fix UITK than restore the old behaviour.

Ok, but then, how do I run executable files, possibly from non installed applications, with upstart-app-launch (i.e. ubuntu-app-launch) - and how would I run them in foreground in the terminal? I'm aware that, - just like Android has ndk-gdb, - the Ubuntu SDK has something similar via Qt Creator which apparently uses gdbserver on the device. However, I'd prefer not firing up a GUI for something like that - and in fact, would love to run gdb in the old-fashioned way, as described above, with an executable as argument on the command line.

I guess a lot of this has to do with me not quite understanding init/Upstart, X11/Mir, Gnome/Unity etc differences that are applicable on a device vs. a (classic) desktop - and I cannot really tell what runs what. I'd love to have enough of it explained, so I can understand how running (GUI) Ubuntu Touch apps from a terminal command line would work.

0

Well, I think I found something that explains some of the things I was wondering about - but I'd still love for someone to post a proper erudite answer, so I'm not going to accept this one for now...

Anyways, the resource is:

Bug #1367871 “ubuntu-app-launch doesn't pass arguments to the executable” : Bugs : Ubuntu Application Launcher
https://bugs.launchpad.net/ubuntu-app-launch/+bug/1367871

UAL isn't designed to run custom binaries how ever you'd like, it's designed to launch applications. An application is defined with a bunch of different metadata, but one of the key ones is a desktop file. That file defines how to launch the application and is what UAL decides to use for how to launch it. In this way the application can get launched in a consistent manner and is the same thing from device to device. [...]

The tricky thing about app confinement, is that command line arguments and environment variables aren't really a good mix for it. An "app" is completely separate from the rest of the system, in the click package world. There are some hooks in click to set up symlinks or such, for other parts of the system to be able to easily find those apps, such as ubuntu-app-launch and the apps scope. But they are not command line applications, and you can't simply just run them from the command line with arbitrary configuration.

0

I'm running Lubuntu, and I find that these work fine from a remote shell started with ssh -Y user@linuxbox:

ubuntu-app-launch "qterminal"    
qterminal

The first launches qterminal in Quartz and doesn't need to ask my password The second also launches qterminal but needs password

I think the first is also running bash. Have you tried running lxsession ? Although it's unusable, I get this weird new Trash can and the Unity linux installer appearing strangely.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.