Lazarus development for Ubuntu Phone

This post will cover:
  • Why Lazarus
  • Installing Lazarus IDE on the phone
  • Using phone-installed Lazarus over SSH
  • Device-specific aspects of developing software with Lazarus
  • Native execution on the Ubuntu phone
  • Software publishing and distribution
  • Appendix: tools and scripts
but just before all this, here is a 30 min video I recorded especially to go with this post:



And these are earlier attempts, where I actually ran lazarus inside a headless X server in a container with an openbox window manager and accessed via VNC. Yes, it was a bit of an overkill, but you gotta start somewhere, and at least I made a progress by now already:



Why Lazarus

Most of people when they hear "Lazarus" they have no idea what that is. Then they hear "Free Pascal" and they think/say: "Pascal?? Someone is still using this? I learnt it at junior high..."
Well, they probably have vague memory of Borland Turbo Pascal, an rather ancient compiler crafted for DOS (Disk Operating System), of which the latest version released was 7.0, and which preceded even an era of WinAPI and Windows, and we are talking windows 95 or 3.11 here. 

So yeah, no wonder their reaction. However, some people also have a vague memory of something called "Delphi". Well, the truth is, Borland's Delphi was the next step after Turbo Pascal, and had the most advanced and user-friendly IDE (Integrated Development Environment) for visual programming to day, which would lead for YEARS to follow. Visual Studio had to catch up years after and as I have tried it personally I think it never got the user friendliness and slickness of even those early Delphi IDEs. In fact, for Linux which is my primary Operating System privately and at work, there is no better IDE available, and that's a fact.
Later Borland has also crafted C++ Builder, which was basically developed in Delphi, and completely used Delphi's IDE, but allowed using C++ language for programming. In fact, all the class structure was just the same one as in Delphi, and users could even mix libraries both in C++ and Delphi (Object Pascal) in the same project. By the way, Pascal became objective (Object Pascal) even before C did (C++), and the makers didn't even consider it a big thing, as the version only changed from Turbo Pascal 5 to 5.5 - LOL! 

Anyways, so what is Delphi now? Well, it is still an IDE that you run on Windows, however now it compiles for: Windows, MacOS, iOS and Android, both 32 and 64 bit. Also, you can totally publish your Delphi-compiled apps on the App Store and on the Google Play Store. Wait, what? You can use Pascal for mobile??? Yes, precisely, YES. And, by the way, you gain world leading IDE for your software development. I think probably the best, really, but well, what you like is what you like. But I have written apps for Android in Eclipse, I did Xcode, I did Android Studio, and let me tell you - that Delphi IDE... damn it's GOOD!

And wait, you said you can also do apps with Dlphi for iOS? but how.. aren't you suppose to need Xcode?? Well, yes, precisely. But do you even realize that Xcode itself has been supporting Object Pascal as its official language of choice since like... ever? In fact Apple has long history with Pascal as the Classical Mac OS was written in Pascal. So was early Photoshop, but hey, I don't blame you there are things you didn't know. We learn the whole life ;)

So wait, what has Lazarus to do with Delphi? Glad you asked! Well, in the beginning there was Free Pascal, an Objective Pascal compiler written originally by Florian Klämpfl, see: www.freepascal.org. Free Pascal is a completely free compiler, that additionally comes available for many many many platforms. And I mean MANY, a whole lot of them! Do you even know Amiga OS?

So Free Pascal was great, but then even more greatness happened - Lazarus Project happened: www.lazarus-ide.org. And Lazarus, to oversimplify it, is a Delphi rewritten in Free Pascal. In fact, it is almost completely compatible with early Delphi, up to Probably everything before Delphi XE when Firemonkey appeared. In fact, you can turn a Delphi dialect on in Free Pascal and write code that will also compile with Delphi. 

So Lazarus is like Delphi but completely free, or even Free with a capital letter, as in FOSS! But this is only the top of the iceberg, really. It also had full support for Unicode way before Delphi did. In fact, I personally believe the Unicode lacking support was one of main reasons why Delphi kind of started loosing the market. Also, it had support for 64 bit very soon after it became mainstream, almost at the same time actually. Again, Delphi was years late with this. Also, it was a cross-plaform IDE for cross-platform software development. But please, read the previous sentence again. Did you notice "cross-platform IDE" part? Well, tell me, have you wrote software for Android, iOS, MacOS, Windows, Linux? I have, for all of these. You know what is probably the main difference between me and you? I did ALL of that, and more, with just one IDE and just one programming language: Lazarus (Free Pascal) and Objective Pascal! Do you get this??? Both Free Pascal and thus Lazarus (compiled by Free Pascal Compiler), target many hardware platforms: x86, x64, ARM, PowerPC, and even more! Lazarus is big on Raspberry Pi, just google it!

Now coming back to the context of this very post. We are now going to talk software development for Ubuntu Phone. Guess what language we will program in? what IDE? That's right: Lazarus, Pascal, you got that right! 

Now the absolute mind-blowing part: what is the default, standard, encouraged and promoted way to make apps for Ubuntu Phone? well, it is the Ubuntu SDK off course. Have you seen it maybe? Perhaps tried? well, I have. And let me tell you this about it:

  1. IDE is nowhere as good as Lazarus IDE
  2. You can't run it (the IDE) ON your Ubuntu Phone
  3. Once you've written an app, you can't also compile it for Windows, MacOS and bunch of other operating systems just like that
  4. PERIOD.
So that is why Free Pascal and that is why Lazarus. Write once, compile everywhere. Enjoy!


Installing Lazarus IDE on the phone

Although Free Pascal can even be installed directly into the Ubuntu Phone from standard repositories (see Free Pascal development for Ubuntu Phone), but Lazarus will not, because Ubuntu Phone won't satisfy its dependencies. The main problem with Lazarus and Ubuntu Phone is that the former depends on GTK widgetset, while the later uses QT over Mir display server. True, Lazarus IDE can be compiled against QT widgetset as well, but currently the stable port of qt for Lazarus is qt4 whereas Ubuntu  Phone uses much newer version.  
The good news is, however, that we can still install Lazarus in the Ubuntu Phone with a customized method. The one I chose for myself is to install it inside a container. I am using debootstrap chroot jail with Ubuntu 14.04 filesystem. It is also perfectly possible to install it inside a Libertine container, however, there are some issues when using either Free Pascal or Lazarus directly on phone's display. I still do not understand the exact reasons, but apparently it has something to do with using them as 'phablet' user and under AppArmor. Anyways, everything works perfectly once used as root and without AppArmor's firewalling. So since I won't be able to launch use (launching actually works) Lazarus directly on the phone's screen, I might as well let go the entire Libertine and work with a custom chroot jail tailored to my absolute liking - which is exactly what I chose to do. 
Now, if you'd like sort of step-by-step instructions, check my other post soon (coming up): Easy containers on Ubuntu Touch with qemu-debootstrap
And once you have your container up and running installing Lazarus is in fact the most standard way that a seasoned Ubuntu user would expect:
  $ sudo apt-get install fpc lazarus
Sometimes, like in Libertine, or when your Ubuntu version is very recent (16.04 and above) there might be some errors thrown. If you are lucky it may suffice to run:
  $ sudo apt-get -f install
which would fix all of the dependencies. However I couldn't get this to work on my libertine container (running Ubuntu 15.04 Vivid, same as the phone), and after a lot of trials, I finally found that somehow a dependency on awk could not be automatically solved. I mean, awk! Well, this is strange to me as why awk would even be a dependency problem on a Linux, but I was finally able to get fpc and lazarus packages installed after first running:
 $ sudo apt-get install original-awk
You might not even need to perform this extra step, but just in case, I let you know what worked for me.


Using phone-installed Lazarus over SSH

Essentially the X forwarding was available over SSH for years. You just use X or Y switch when connecting, I personally prefer Y:

 $ ssh -Y username@192.168.0.2 #use your username and IP

And that's it! But is it really? Well, when you want to run x11 app that is sitting directly in the phone's OS then yeah, that's pretty much all there is to it. However, when you want to start x11 app from inside a container on your phone, then it generally doesn't work out-of-the-box. The reason is, that inside a chroot environment there is no valid X Authority. Long story short, you want to initiate things properly and then you get green light to start x11 apps over SSH from inside a container. So what are the needed steps, well, what works for me every time is to mount few standard system directories under the corresponding mountpoints in my container (ie. SYS, DEV, DEV/PTS, PROC) and, most importantly for the X forwarding kepchatpart: copy .Xauthority file into your chroot's home directory. You can do it manually, you can script this, I have written a small utility in Free Pascal and I use it every time, the utility is called enter-the-chroot and you can find it in the Appendix at the end of this post (download and use for free). You should use it as root because it deals with mounting:

 $ sudo enter-the-chroot -list #to list containers
 $ sudo enter-the-chroot -start <containerID> #to initiate and enter one

This utility will check for which initiation aspects are needed to perform, and only run those. So if something needed to be mounted already is mounted, it will not mount again. And it takes care of the .Xauthority as well. I'm sure you get the point. With the precompiled binary I am also including the source, so you can study into it or even compile yourself with Free Pascal.

Device-specific aspects of developing software with Lazarus

When you start producing x11 apps with Lazarus with intention of running them on Ubuntu Phone, you will realize few problematic aspects of it:

  • Dependency on 3rd party libraries
  • UI looks tiny on a High DPI display
  • Using on-screen keyboard as main input interface
  • Traditional scrolling differs from touch scrolling
  • Missing window manager and/or window decorations
  • Supporting phone-specific hardware and API
  • Inter Process Communication with other apps
Dependency on 3rd party libraries


This is not really an issue with Lazarus, because it creates binaries that are self-contained and without any external dependencies by default (which, by the way, is one of main reasons I like Delphi/Lazarus software on Windows: no runtimes, redistributables, dot-net platforms; just an exe file and it works). However, if you want/need to depend on external libraries please mind that the user will not be able to install anything outside of his/her home directory in a straightforward way. It has to do with both the limited space on the system partition and that it is mounted as read-only. Again, I am not saying that it cannot be done, but that it isn't a straightforward process. Whenever possible, you really want to ship all the 3rd party dependencies with bundled with your program and stored along under user's home Directory. When possible, avoid all the /opt, /var, /usr etc. On Ubuntu Phone these will be write-protected and even if you unlock them, your data will most likely be gone after a next OTA firmware update.

UI looks tiny on a High DPI display

Lazarus has some means for supporting High DPI on its official wiki. However, I found out, that the DPI is not reported properly to the x11 application running under XMir. It still reported 96 dpi for me when I know in fact it is larger on the phone (~418 ppi pixel density). For this reason all you develop in Lazarus and run directly on the phone will look just minuscule. Tiny text, tiny buttons, everything so tiny it is hard to aim when using touch screen. What I ended up doing, is resizing every form upon initiation by the rule of proportion. I assume every form to be meant to run full screen on the phone, but I don't use Form.Align := alClient; Instead, I use alNone and manually set its size and position. Then I remember by how much I adjusted the Height, by how much the width, and I go on resizing all of the child controls accordingly. I do the same for fonts. To make the proportion work good, I begin with setting the size of the form in my project to one corresponding to the aspect ratio on the phone. So, if my phone has a screen resolution of 1152 x 1920 pixels then I make a small in the project smaller to fit on my desktop screen (remember, using Lazarus over SSH with X forwarding!) but I keep the exact ratio - or just approximately is also fine.
Now the best part - no I do not do all this manually. I just wrote a routine that I call for every form in the project. It is part of my libPhablet.pas library which you can find in the Appendix at the bottom of this post, and it is called:

  Procedure FullscrinizeForm(const Form: TForm);

You just pass your form as an argument and it will resize it to the extent of your phone's screen along with all the controls on it - proportionally. Including BorderSpacing property. Let me know in the comments if you figure out a better way, but for now this works great for me, just see this sample project I did for demonstration purpose:
 And when running on the phone:


As you can see it's all tiny, so I just add the call in Form's OnCreate method:
And the problem fixed with just one line of code:
You may notice that the Editdoesn't seem proportionally resized. That is because somehow the native widget insists to adjust to the font size. One way I found to fix it, is to place an Edit inside, say, a Panel, and set it to Edit1.Align := alClient, then only resize the container.



Using on-screen keyboard as main input interface

There are two steps to get the system OSK (on-screen keyboard) to work with our x11 app:

  1. install OSK packages for GTK
  2. set environmental variable for your app
to install the packages, you will need to make the system partition writable, then install, then make it read-only again. But the size of required packages is really small, and I think this really should be in the default system image for Ubuntu Phone, so here you go:

 $ sudo mount -o remount,rw /
 $ sudo apt-get -q -y install maliit-inputcontext-gtk3 maliit-inputcontext-gtk2 
 $ sudo mount -o remount,ro /

And the related environmental variables are QT_IM_MOUDULE and GTK_IM_MOUDULE. The QT one is optional, but since Lazarus also allows for compiling programs against qt widgetset, so I include it here. The value you should set those to for ISK to work in the Ubuntu Phone is maliitphablet, and some users on some forums claimed that it might not work with anything set inside another variable called QT_DEVICE_PIXEL_RATIO so you might want to unset this one just to be safe. The way I solve these variables is that inside Exec parameter of my .desktop launcher for my app, I call a bash wrapper xrun.sh like so:

 Exec=xrun.sh my_app

and the wrapper is very simple:

 #!/bin/bash
 export QT_IM_MOUDULE=maliitphablet
 export GTK_IM_MODULE=maliitphablet
 export QT_DEVICE_PIXEL_RATIO=
 exec $@

so feel free to use the same method. I treat it as a standard template, copy to my every x11 app and reuse. Feel free to do the same. I didn't test it, but perhaps it will also suffice to just set these variables programatically from within your Pascal code. If you try and find out it works, let me know.

Traditional scrolling differs from touch scrolling

I do talk about Hig DPI aspect of the UI built with Lazarus in this post, and I hope you can get familiar with that part. Long story short, we can enlarge controls of the app so they look good on the phone's high DPI screen instead of looking super tiny. But even when you resize a control, not all of its internal elements will also get enlarged along. And example are scrollbars inside controls like TMemo, TScrollBox and many other. They will continue to be really small on the phone's screen. This already makes scrolling more difficult, when you need to aim into the scrollbar.

The other aspect is that you pull a scrollbar down when you want to scroll the contend down, while on touch interface you need to swipe up for the same outcome. 

Touch interface and touch user experience are much different between standard Desktop with mouse and keyboard and Touch devices.

In Lazarus, to support touch-like scrolling you would have to program some events like OnMouseDown, OnMouseMove, OnMouseUp to say the least. Unlike Delphi XE, Lazarus does not yet provide easy way for programming gestures. Not that I know of at least, would be great to be wrong about this.

Alternatively, you may still use scrollbar, but then, when possible, use the TScrillBar component, rather than depending on controls own built-in scrollbars, because this one you can resize to your liking easily. Having a traditional scrollbar for touch interface is still ok as long as it is big enough to aim in it and operate it with a finger rather than a mouse cursor.


Missing window manager and/or window decorations

Currenlty (will it ever change? IDK) there is no window manager provided by Xmir, so your GTK app will open but it will have no window decorations, nothing to grab a window by to move/resize it, minimize or close. Multi windowed application will run but becomes uneasy to use because of this. My remedy is quite simple, I make every form of my app that I want to run on the phone a fullscreen one, and with form's BorderStyle property set to bsNone. However, I do not set Align property to alClient to make the form fullscreen. I wrote about this earlier in this post when discussing High DPI. I use libPhablet.pas to handle form for me. Check the Appendix at the end of this post.

Supporting phone-specific hardware and API

The hardware on the phone is made easy to use with Ubuntu API - that is if you are developing with Ubuntu SDK. If you work with Lazarus, however, at least until this API gets ported or a binding gets done, you are left without it. Well you may try to bind to it yourself, by translating library headers from C++ to Pascal, which is totally possible and how WinAPI support was done (off topic). But this is not the way I will write about.
Instead I want you to realize two things:

  1. lot of hardware has uniform way of being used across all Linux systems
  2. Ubuntu Phone actually has Android subsystem up and running
The first point is about the fact that in case of some hardware once you learn how to do it on one Linux you will be able to do it the same (or almost same) way on any other Linux, from Desktop to phone to Raspberry Pi. One such example is using built-in vibrator. If you are interested, check the libPhablet.pas library in the Appendix because I added support for it there in form of simple shell calls. Another example is playing sounds, as long as your sound file is in WAV format you can run it both on Ubuntu Phone and Desktop same way:

 $ aplay file.wav

And there is a long list of things like that. No difference in calling things from shell between desktop and phone.

Another thing is the Android subsystem that runs within Ubuntu Phone. It is this sybsystem that makes things like ADB work, and why your Ubuntu Phone gets mistakenly taken for an Android device sometimes. Well, it's not completely a mistake anyways, a part of Android is actually running there. And that means that at least part of the Android shell tools will also work on your Ubuntu Phone. Although this sub paragraph is about the hardware, but think of turning services on and off on the Ubuntu Phone. How do you turn the ssh deamon? do you:

 $ sudo service ssh start

or do you:

 $ adb shell android-gadget-service enable ssh

So this is what I am talking about. Whatever you learn about adb in term of accessing hardware features on Android, you may find also applicable to Ubuntu Phone.


Inter Process Communication with other apps

Naturally all the standard IPC will work, and even the Lazarus default components for IPC will work also, however since we aren't developing with Ubuntu SDK, we don't have the native API for things like firing intents as it happens in Android. What does this mean? Well, we are good with launching 3rd party programs and interacting with them as long as they are interactive from the terminal. For simple call where we do not care for a callback, we may jsut use fpSystem() routine from Unix.pas unit. The example would be to fire an URL directly in phone's web browser. You can check libPhablet.pas library (in the Appendix) for some ideas.
Another situation is when you need to run another process and then read its output. You can either use TProcess (or TProcessUTF8) class from Process.pas unit, or (from the same unit) a RunCommand() routine. With TProcess class you get a granular control over the process you start, while RunCommand is a simplified wrapper around that class to just run a process, catch it output and return in a string variable. Say, I need the output of:

 $ uname -a

in Pascal I simply add Process unit and call:

 var s: string;
 (...)
 if RunCommand('uname', ['-a'], s)
    then writeln(s)
    else writeln('error.');

and it is good to know Ubuntu Phone's commands for starting things up from terminal:

  • ubuntu-app-launch <app_name>
  • aa-exec
  • aa-exec-click
  • Xmir
Especially I encourage you to go and study into Xmir because as long as you deal with GTK applications you will need it. Read on.

Native execution on the Ubuntu phone

Ubuntu Phone is running Ubuntu Touch system which runs on Mir display server - not the X11. So, to simply put it, it cannot run x11 apps using GTK apps. Mir uses QT.
This only means you cannot run GTK apps on your phone directly by executing them, not that there is no way to run it. Not yet (see GTK for Mir). Mir comes with a compatibility layer for X, called Xmir:

 $ Xmir --help

This provides an execution environment for x11 GTK apps so that they are fooled into believing that they are actually executed inside x11 environment. It works pretty good and is said to improve even further. Well, it better do, because obviously all the currently existing software for Linux is from era before Mir.

I will not write about calling Xmir directly from terminal, because I have not study into it. Instead, the way I know how to use it is by preparing a .desktop launcher for your app that defines 2 extra parameters:

  [Desktop Entry]
  Name=<AppName>
  Comment=<your app description>
  X-Ubuntu-Touch=true
  X-Ubuntu-XMir-Enable=true
  Exec=<path_to_your_app>
  Icon=<path_to_your_icon>
  Terminal=false
  Type=Application

The ones in bold font are the one that do the trick. But Terminal=false also seems to be required, at least from my experience. A launcher created with this setup will show up among your native apps on your phone, and will launch your x11 app directly on the phone inside Xmir environment. Read on, there is more info related to this here.


Software publishing and distribution

This is the part of the story where things aren't fully clear yet. Sure, you can zip your program up, and send over to users, who just extract it. Then, either they need to manually copy/link the .desktop launcher to their ~/.local/share/applications/ directory, or you provide them with some installation script that does that automatically, they just need to run it. But real benefits come from packaging your program with something standard, that Ubuntu users know and use. Ideally, if it is something that can be uploaded to Ubuntu Apps Directory. Anyways, the things to mention in this sections are:

  • compressed archive for manual installation by the user
  • customized installer
  • deb package
  • click package
  • snap package
Compressed archive for manual installation by the user

this is by far the easiest to produce, but also the least sexy to use by the end-user. Should be no problem though if your users are familiar with working in console mode. Basically, you put your program and all needed files in a folder, and also put a script there, with a catchy name, like install.sh:

 #!/bin/sh
 cp ./<my_launcher_name>.desktop ~/.local/share/applications/
 echo "Installation finished successfully." 

alternatively you can create a symbolic link instead of actually copying the launcher. You could also check if the user is or isn't root and act differently in each case. At the end it is really all up to you.


Customized installer

This would be something we know from Windows: a single, bulky setup.exe bundle. You can perfectly do this with your app. You could write, in Free Pascal, a setup program, and then append your compressed archive to the end of it, or as a compiled-in resource. In your program, you extract the content where you need it extracted to, you make your symbolic links, and set everything up. For the purpose of Ubuntu Phone you would want to make a terminal mode installer, because you won't be able to run a GTK installer directly. So a terminal installer that installs a GTK app with GUI onto the phone for you. And it can install the app entirely under your home directory, so that user would not be required to use any special permissions. I will make a template project for such installer and make it available here in the Appendix at the end of this post, for all of you to use. For the good and better of Free Pascal and Lazarus.

Deb package

So happens that deb packages are in the default packaging format for Debian based Linux distributions. It is a format that has been around for years. It means it is super mature, right? It means it is a bit old, not to say archaic. Which is why Ubuntu is shifting away and into a more recent Snap packaging format (read on later in the post).
To build a deb package you can either go a long way with calculating md5 checksum of every single file i your package, or you can go an easy way with:

 $ dpkg -b <app_folder>

that is my preferred method, a single command for building a deb package. You do need to create a standard directory structure inside your <app_folder though>. For one, you need to create a DEBIAN folder inside with a file called control inside it. You can also put some scripts inside that correspond to package management aka Package Mainainer Scripts. Other than that you create folders that mimic the linux root file system, so things like usr, opt, etc. depending on where you want your content to end up extracted to on the actual file system. However, there is no mechanism for targeting user's home directory. Some say it would be considered a rude practice to create things inside another user's home directory. But to me, it would be a perfect win-win situation. Users would be able to install deb package without root privilege and without sudo, and they would only install the package locally for themselves without the risk of messing up the system. Also, it would work great on Ubuntu Phone, where additionally almost everything except for the user space is on a read-only file system. So in other words, after you build a deb package with your x11 Lazarus app, the user needs to go out of his/her way to deal with all of this in the command line:

 $ sudo mount -o remount,rw /
 $ sudo dpkg -i <your_deb_package>.deb
 $ sudo mount -o remount,ro /

And this all could have been just much simpler if deb supported local directory installation:

 $ dpkg -i <your_deb_package>.deb
 #unfortunately it is not the case

Thus even a simple compressed archive with a simple installation script still seems MUCH easier way for users to install your apps then this most widely known packaging system on Debian based Linux flavors. To be fair, it would not be so inconvenient on Ubuntu Desktop, where the root file system is not write-protected. But we are talking Ubuntu Phone here, so please keep this in mind.
In the Appendix, at the end of this post, you find a sample deb package and the source folder I used to build from, where you can study into DEBIAN/control file format.

UPDATE: attached in the Appendix is an updated deb package that installs under /opt/click.ubuntu.com/ folder which is writable on Ubuntu Touch. It also contains a postinst script in which it uses lazinstaller (sources includes in lazinstaller.pas) to copy .desktop launcher of the app to users local folders. Also in the preinst script it attempts to install packages for the system OSK support. 

Click package

This process is very similar conceptually to deb packaging. You also gather all your program data in a folder and then build the package with a single command:

 $ sudo click build <app_dir>

and you then can install it locally for testing like so:

 $ sudo click install --user=phablet --allow-unauthenticated <your_click_name>.click
 #your username may be different from phablet

The --allow-unauthenticated switch installs your click even before it gets digitally signed by the Ubuntu Store, and spits this message to the console:

  WARNING:root:Signature check failed, but installing anyway as requested

The difference is, that there is no special DEBIAN folder in the directory structure. And there are 2 special files: manifest.json and <your_app_name>.json which have to be found there in the app folder in order for the click to be able to build your package. The official manifest.json format is here
A blog post from which I learnt is here: notyetthere.org/on-manually-creating-click-packages/
Example of my setup is available along with the click package in the Appendix. I need to mind you though, you can install the click, you can see the icon, but you cannot launch it. For the time being I do not have a solution, but I will be looking for it. Apparently it has to do with AppArmor confinement and running Xmir. Somehow Canonical doesn't seem to see Xmir as a real viable way for using their Ubuntu devices. Well, I think they are missing the real killer app for their new platform. Hope they catch up, and soon. Just to clarify, the AppArmor becomes a concern, all of sudden you might feel, because once you install a click package, it is being extracted under /opt/click.ubuntu.com/.click/users/<your_username> and then a .desktop launcher is placed in your ~/.local/share/applications that prefixes the Exec flag with:

  (...)
  Exec=aa-exec-click -p <your_click_package_id> -- ./
  (...)

where aa-exec-click is basically the AppArmor. So this is now not working. I need to either find a way to run click app unconfined, or to create a suitable AppArmor profile, with the later being the solution I would favor. Until then, I can't just yet publish Lazarus apps to Ubuntu Store as click packages. 

AppArmor resources:
Although click packages also do not install things into user's home directory, but it still manages to go around the read-only file system on Ubuntu Phone. The reason for this is, that the/opt/click.ubuntu.com/.click/users/<your_username> directory where it extracts packages to is mounted under a user space, so on a writable portion of the file system.
I does however end up creating .desktop launcher file under your home folder, which I am not sure how exactly it is done but probably that is why when installing click package you are supposed to use the --user switch. Some registration takes place in the background. During this registration also the name of the click app is getting stored somewhere. This registration also persists in arguing with Xmir. What I mean is, that even if you manually edited the .desktop file created during click installation to remove the aa-exec-click from Exec parameter, the launcher would still fail to start your app for as long as the name of the app inside Name parameter, and also the name of the .desktop file remain unchanged. Those names also get remembered somewhere during click package installation, some sort of binding between these values and an AppArmor profile. I wish I knew more in this matter, but for now this is all I can tell you. If you know something more, please share.

snap package

This is the newest standard for packaging software for Linux that is very favored by Canonical in Ubuntu. In fact, all the new software for Ubuntu in general, is going to be only allowed as Snap, so no more deb, except for continuing already software already pre-existing in the Launchpad. It is apparently going widespread in Linux world as well. It is the one that I will want to explore now, but haven't done so just yet. I really hope this is how I can finally get Lazarus apps published to Ubuntu Phone. And consecutively also to Ubuntu Desktop. I just hope that this will be more allowing method with regards to xmir apps.
If any of you follows this way and learns things related to this post, please share with me.
Official Snapcraft page: http://snapcraft.io


Appendix: tools and scripts

This part is coming up soon, I am currently collecting all the resources and getting them double-checked and ready. My time is limited to after my daily work, and so this Appendix is expected by me to land ready within next two weeks or so. I felt, that the entire blog post is however ready to publish and shouldn't wait. Thank you for your patience, and hope to see you back here soon to check the updated content!



The lazSnake game is already available in deb format here, and it also containes compressed folder that I used to build the deb package. This is an updated deb package that installs under /opt/click.ubuntu.com/ folder.

Comments

  1. Hello Kris,
    Many thanks for your interesting "How to blogs". I've used your tutorial "Easy containers" to install the Mate-desktop on my BQ Aquarius M10 and launch it with Xephyr. I'am looking forward to the Appendix.
    Greetings Jaap.

    ReplyDelete
  2. Great to hear you try out some things on your own. You also can always drop me any questions in comments. As for the Appendix, I have a bunch of things to publish right after Chinese New Year, so the very beginning of February. Not only for the blog, but also for my new project to be soon found at opensoftwarehub.org
    Cheers!

    ReplyDelete

Post a Comment

Popular posts from this blog

Delphi VCL/FMX for Linux before the official platform support

How I use Linux to write software for multiple target platforms

Easy containers on Ubuntu Touch with qemu-debootstrap