The Linux ecosystem for smartphone is still a little bit confusing for me at the minute so I decided to start small before trying to make actual contributions to the core system or useful apps by just making a dummy example app.
I've decided to go with kirigami for building the app as it seems to me to be the best compromise at the moment. Kirigami is the KDE solution to make apps work on both desktop and phones. The apps are using Qt widgets and depending on the platform, alternate versions of the widget and layout are used. As it's developed by KDE it should integrate well with Plama on Postmarketos but it should also works on Ubuntu Touch (and even Android, Windows and Mac).
However, kirigami is still a rather new technology and there is few documentation on it. I also had some difficulties on getting all the kde5 dependencies installed on the pinephone using apk because of some issues with the latest mesa driver. This will probably be fixed soon but in the meantime, i used flatpak to get all the required dependencies on both my computer and the Pinephone and i think it actually proved easier and more versatile than building directly into the pmbootstrap chroot.
Here are the websites i relied on for documentation:
Part I : Compiling the hellokirigami example app
The idea is to code the app on the computer, cross-build it with flatpak for the pinephone, send it on the pinephone and install there. First, we need to install flatpak on the development computer, most likely.
apt install flatpak
Then we need to add those two remotes to flatpak (flathub because it's generally useful for software and kde for the Qt5 libraries)
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo flatpak remote-add --if-not-exists kdeapps --from https://distribute.kde.org/kdeapps.flatpakrepo
We can then install the Qt libraries for the computer in order to compile the app for desktop and be able to try it before sending to the phone.
flatpak install flathub org.kde.Platform//5.12 flatpak install flathub org.kde.Sdk//5.12
We also need to install flatpak those same libraries but for the phone architecture. Now, most tutorials for kirigamiu are installing the arm architecture version for mobile plateform but uname -m returns aarch64 on the pinephone so we need the aarch64 version.
apk add flatpak flatpak install flathub org.kde.Platform/aarch64/5.12 flatpak install flathub org.kde.Sdk/aarch64/5.12
also to be able to cross compile later with flatpak builder, you will need the following packages installed on your system :
sudo apt install qemu binfmt-support qemu-user-static
We can then download the following example project and try to compile it :
git clone https://invent.kde.org/jbbgameich/plasma-mobile-app-template.git
Then, to build :
cd plasma-mobile-app-template flatpak-builder flatpak-build-desktop --force-clean --ccache *.json
To make the app display as as on a smartphone on the computer
export QT_QUICK_CONTROLS_MOBILE=true QT_QUICK_CONTROLS_STYLE=Plasma
To then run the app on the computer
flatpak-builder --run flatpak-build-desktop *.json hellokirigami
The app should launch in a new window.
We can then compile for the phone arcchitecture :
flatpak-builder flatpak-build-phone --repo=arm-phone --arch=arm --force-clean --ccache *.json flatpak build-bundle arm-phone hellokirigami.flatpak org.kde.hellokirigami --arch=arm
Send the app to the phone (with postmarketos, the phone is available on the IP 10.15.19.82 as soon as it's connected to the computer via USB.
scp hellokirigami.flatpak firstname.lastname@example.org:/home/phablet/app.flatpak
To test the app on the phone, we need to install it, as for now we just have the package copied to memory.
To install flatpak on the Pinephone:
sudo apk install flatpak flatpak install flathub org.kde.Platform/aarch64/5.12 flatpak install flathub org.kde.Sdk/aarch64/5.12 flatpak install hellokirigami.flatpak
The application should appear on the launcher. Otherwise, it should be possible to launch it with :
flatpak run org.kde.hellokirigami
Then, to develop, it's just going to be iterations of : Building on the computer for the phone, bundling into a flatpak package, sending to the phone, installing, ... iterate!
On the computer :
flatpak-builder flatpak-build-desktop --repo=aarch64-phone --arch=aarch64 --force-clean --ccache *.json flatpak build-bundle aarch64-phone hellokirigami.flatpak org.kde.hellokirigami --arch=aarch64 scp hellokirigami.flatpak email@example.com:/home/sylvain/
On the phone SSH console:
sudo flatpak install hellokirigami.flatpak