Packaging
While having a build system is great, our app still isn't ready for regular users. We want to make sure our app can be built and installed without having to use Terminal. What we need to do is package our app. To do this, we use Flatpak on elementary OS. This section will teach you how to package your app as a Flatpak, which is required to publish apps in AppCenter. This will allow people to install your app and even get updates for it when you publish them.
Practice Makes Perfect
If you want to get really good really fast, you're going to want to practice. Repetition is the best way to commit something to memory. So let's recreate our entire Hello World app again from scratch:
Create a new branch folder "hello-packaging"
Set up our directory structure including the "src" and "data" folders.
Add your Copying, .desktop, .metainfo.xml, icons, and source code.
Now set up the Meson build system and translations.
Test everything!
Did you commit and push to GitHub for each step? Keep up these good habits and let's get to packaging this app!
Flatpak Manifest
The Flatpak manifest file describes your app's build dependencies and required permissions. Create a io.github.yourusername.yourrepositoryname.yml
file in your project root with the following contents:
To run a test build and install your app, we can use flatpak-builder
with a few arguments:
This tells Flatpak Builder to build the manifest we just wrote into a clean build
folder the same as we did for Meson. Plus, we install the built Flatpak package locally for our user. If all goes well, congrats! You've just built and installed your app as a Flatpak.
That wasn't too bad, right? We'll set up more complicated packaging in the future, but this is all that is required to submit your app to AppCenter Dashboard for it to be built, packaged, and distributed. If you'd like you can always read more about Flatpak.
Uninstalling the application
Ninja and Flatpak both provide commands to uninstalling the application. It is recommended to use the provided method in both cases.
To remove our application with Flatpak, we will use Flatpak's remove
command:
Flatpak will prompt you to remove your application.
Note: You can append
-y
to the command to bypass the dialog confirmation prompt
If you'd like you can always read more about Flatpak remove.
Last updated