flatpak build definition

This commit is contained in:
Paul Sajna 2024-02-17 18:47:08 -08:00
parent f03f373e82
commit 858a42a63c
7 changed files with 212 additions and 1 deletions

7
.gitignore vendored
View File

@ -51,8 +51,13 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
/android/key.properties
# WASM
/web/wasm/
android/key.properties
# Flatpak
flatpak/build-dir/
flatpak/repo/
flatpak/.flatpak-builder/
*.flatpak

84
flatpak/README.md Normal file
View File

@ -0,0 +1,84 @@
- [Building the Flatpak](#building-the-flatpak)
- [Prerequisites](#prereq)
- [Build](#build)
- [Create Flatpak repo of the app](#create-flatpak-repo-of-the-app)
- [Publish to app store](#publish-to-app-store)
- [Bundle the Flatpak repo into an installable `.flatpak` file](#bundle-the-flatpak-repo-into-an-installable-flatpak-file)
- [We now have a `.flatpak` file that we can install on any machine with](#we-now-have-a-flatpak-file-that-we-can-install-on-any-machine-with)
- [We can see that it is installed:](#we-can-see-that-it-is-installed)
# Prerequisites
`flatpak install -y org.gnome.Platform/x86_64/45`
`flatpak install -y org.gnome.Sdk/x86_64/45`
# Building the Flatpak
We imagine this is a separate git repo containing the information specifically
for building the flatpak, as that is how an app is built for FlatHub.
Important configuration files are as follows:
- `com.veilid.veilidchat.yml` -- Flatpak manifest, contains the Flatpak
configuration and information on where to get the build files
- `build-flatpak.sh` -- Shell script that will be called by the manifest to assemble the flatpak
## Build
**This should be built on an older version on Linux so that it will run on the
widest possible set of Linux installations. Recommend docker or a CI pipeline
like GitHub actions using the oldest supported Ubuntu LTS.**
### Create Flatpak repo of the app
This is esentially what will happen when being built by FlatHub.
```bash
flatpak-builder --force-clean build-dir com.veilid.veilidchat.yml --repo=repo
```
#### Publish to app store
When this succeeds you can proceed to [submit to an app store like Flathub](https://github.com/flathub/flathub/wiki/App-Submission).
<br>
---
<br>
*The remainder is optional if we want to try installing locally, however only
the first step is needed to succeed in order to publish to FlatHub.*
### Bundle the Flatpak repo into an installable `.flatpak` file
This part is not done when building for FlatHub.
```bash
flatpak build-bundle repo com.veilid.veilidchat.flatpak com.veilid.veilidchat
```
### We now have a `.flatpak` file that we can install on any machine with
Flatpak:
```bash
flatpak install --user com.veilid.veilidchat.flatpak
```
### We can see that it is installed:
```bash
flatpak list --app | grep com.veilid.veilidchat
```
> Flutter App com.veilid.veilidchat 1.0.0 master flutterapp-origin user
If we search for "Flutter App" in the system application menu there should be an
entry for the app with the proper name and icon.
We can also uninstall our test flatpak:
```bash
flatpak remove com.veilid.veilidchat
```

41
flatpak/build-flatpak.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Convert the archive of the Flutter app to a Flatpak.
# Exit if any command fails
set -e
# Echo all commands for debug purposes
set -x
# No spaces in project name.
projectName=VeilidChat
projectId=com.veilid.veilidchat
executableName=veilidchat
# ------------------------------- Build Flatpak ----------------------------- #
# Copy the portable app to the Flatpak-based location.
cp -r bundle/ /app/$projectName
chmod +x /app/$projectName/$executableName
mkdir -p /app/bin
ln -s /app/$projectName/$executableName /app/bin/$executableName
# Install the icon.
iconDir=/app/share/icons/hicolor/256x256/apps
mkdir -p $iconDir
cp $projectId.png $iconDir/$projectId.png
# Install the desktop file.
desktopFileDir=/app/share/applications
mkdir -p $desktopFileDir
cp -r $projectId.desktop $desktopFileDir/
# Install the AppStream metadata file.
metadataDir=/app/share/metainfo
mkdir -p $metadataDir
cp -r $projectId.metainfo.xml $metadataDir/

View File

@ -0,0 +1,9 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=VeilidChat
Comment=VeilidChat Private Messaging
Exec=veilidchat
Icon=com.veilid.veilidchat
Terminal=false
Type=Application
Categories=Network;

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Generator for metainfo & .desktop files:
https://www.freedesktop.org/software/appstream/metainfocreator/#/
-->
<component type="desktop-application">
<id>com.veilid.veilidchat</id>
<name>VeilidChat</name>
<summary>VeilidChat Private Messaging</summary>
<icon>
<local>com.veilid.veilidchat.png</local>
</icon>
<developer_name>Veilid Foundation Inc</developer_name>
<url type="homepage">https://veilid.com/chat</url>
<metadata_license>MIT</metadata_license>
<project_license>MPL-2.0</project_license>
<supports>
<control>pointing</control>
<control>keyboard</control>
<control>touch</control>
</supports>
<description>
<p>TODO</p>
</description>
<launchable type="desktop-id">com.veilid.veilidchat.desktop</launchable>
<screenshots>
<screenshot type="default">
<image>TODO</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1" />
<releases>
<release version="0.1.2+4" date="2023-11-19" />
</releases>
</component>

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,37 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/flatpak/flatpak-builder/main/data/flatpak-manifest.schema.json
---
app-id: com.veilid.veilidchat
runtime: org.gnome.Platform
runtime-version: "45"
sdk: org.gnome.Sdk
command: veilidchat
separate-locales: false
finish-args:
- --share=ipc
- --socket=fallback-x11
- --socket=wayland
- --device=dri
- --socket=pulseaudio
- --share=network
- --talk-name=org.freedesktop.secrets
modules:
# FlutterApp
- name: VeilidChat
buildsystem: simple
only-arches:
- x86_64
#- aarch64
build-commands:
- "./build-flatpak.sh"
sources:
- type: dir
path: ../build/linux/x64/release/
- type: file
path: build-flatpak.sh
- type: file
path: com.veilid.veilidchat.png
- type: file
path: com.veilid.veilidchat.desktop
- type: file
path: com.veilid.veilidchat.metainfo.xml