Difference between revisions of "Flatpak"
From Free Pascal wiki
Jump to navigationJump to search(2 intermediate revisions by the same user not shown) | |||
Line 28: | Line 28: | ||
<screenshots> | <screenshots> | ||
<screenshot type="default"> | <screenshot type="default"> | ||
− | <caption> | + | <caption>Main screenshot</caption> |
− | + | <image>https://domain.com/Screenshot.jpg</image> | |
− | |||
− | |||
− | |||
− | <image>https:// | ||
</screenshot> | </screenshot> | ||
</screenshots> | </screenshots> | ||
Line 49: | Line 45: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Create a file named com.domain.App.yml: | + | * Create a file named com.domain.App.yml: |
<syntaxhighlight lang="yaml"> | <syntaxhighlight lang="yaml"> | ||
app-id: com.domain.App | app-id: com.domain.App | ||
Line 57: | Line 53: | ||
sdk-extensions: | sdk-extensions: | ||
- org.freedesktop.Sdk.Extension.freepascal | - org.freedesktop.Sdk.Extension.freepascal | ||
− | command: | + | command: App |
finish-args: | finish-args: | ||
- --share=ipc | - --share=ipc | ||
Line 87: | Line 83: | ||
- ln -s $FLATPAK_DEST/share/App/App $FLATPAK_DEST/bin/App | - ln -s $FLATPAK_DEST/share/App/App $FLATPAK_DEST/bin/App | ||
- install -d -m 755 $FLATPAK_DEST/share/applications | - install -d -m 755 $FLATPAK_DEST/share/applications | ||
− | - install -m 755 | + | - install -m 755 ${FLATPAK_ID}.desktop $FLATPAK_DEST/share/applications |
− | - install -d -m 755 $FLATPAK_DEST/share/icons/hicolor/ | + | - install -d -m 755 $FLATPAK_DEST/share/icons/hicolor/256x256/apps |
− | - install -m 644 App.png $FLATPAK_DEST/share/icons/hicolor/ | + | - install -m 644 App.png $FLATPAK_DEST/share/icons/hicolor/256x256/apps/${FLATPAK_ID}.png |
− | - install - | + | - install -d -m 755 $FLATPAK_DEST/share/metainfo |
+ | - install -D com.domain.App.appdata.xml -t $FLATPAK_DEST/share/metainfo/com.domain.App.metainfo.xml | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | * Create file com.domain.App.desktop: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | [Desktop Entry] | ||
+ | Encoding=UTF-8 | ||
+ | Name=App | ||
+ | Comment=Example application | ||
+ | Exec=App | ||
+ | Icon=com.domain.App.png | ||
+ | Terminal=false | ||
+ | Type=Application | ||
+ | Categories=GNOME;Application;Game; | ||
+ | StartupNotify=true | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 97: | Line 108: | ||
#!/bin/bash | #!/bin/bash | ||
+ | BUILD_DIR=build | ||
+ | REPO_DIR=repo | ||
FLATPAK_ID=com.domain.App | FLATPAK_ID=com.domain.App | ||
− | |||
− | |||
# Install dependencies | # Install dependencies | ||
Line 105: | Line 116: | ||
flatpak install flathub org.kde.Platform//5.15-23.08 | flatpak install flathub org.kde.Platform//5.15-23.08 | ||
flatpak install flathub org.freedesktop.Sdk.Extension.freepascal//23.08 | flatpak install flathub org.freedesktop.Sdk.Extension.freepascal//23.08 | ||
+ | flatpak install flathub org.flatpak.Builder | ||
# Build | # Build | ||
− | flatpak | + | flatpak run org.flatpak.Builder --force-clean --sandbox --user --install --ccache --mirror-screenshots-url=https://dl.flathub.org/media/ --repo=$REPO_DIR $BUILD_DIR $FLATPAK_ID.yml |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
# Run | # Run | ||
flatpak run $FLATPAK_ID | flatpak run $FLATPAK_ID | ||
+ | |||
+ | # Linter | ||
+ | flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest $FLATPAK_ID.yml | ||
+ | flatpak run --command=flatpak-builder-lint org.flatpak.Builder repo $REPO_DIR | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | * Run the build.sh script and test the application | ||
+ | * Follow the [https://docs.flathub.org/docs/for-app-authors/submission/ submission process] to submit your app to Flathub. | ||
==Notes== | ==Notes== | ||
Line 130: | Line 142: | ||
* [[Deploying Your Application]] | * [[Deploying Your Application]] | ||
− | + | =External links= | |
− | * [https://github.com/search?q=org%3Aflathub+lazbuild&type=code Existing flatpack projects built with Lazarus] | + | * [https://github.com/search?q=org%3Aflathub+lazbuild&type=code Existing flatpack projects on GitHub built with Lazarus] |
* [https://flathub.org/ flathub.org] | * [https://flathub.org/ flathub.org] | ||
− | * [https://discourse.flathub.org/t/questions-on-building/1975 A forum Post] | + | * [https://discourse.flathub.org/t/questions-on-building/1975 A Flathub forum Post] |
* [https://develop.kde.org/docs/packaging/flatpak/packaging/ KDE Your first Flatpak] | * [https://develop.kde.org/docs/packaging/flatpak/packaging/ KDE Your first Flatpak] | ||
[[Category:Linux]] | [[Category:Linux]] | ||
[[Category:Deployment]] | [[Category:Deployment]] |
Latest revision as of 11:28, 21 May 2024
Instructions
- Assume an application called App with Flatpak ID: com.domain.App
- Create a file named com.domain.App.appdata.xml:
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>com.domain.App</id>
<name>App</name>
<summary>Example application</summary>
<developer_name>Developer</developer_name>
<url type="homepage">https://domain.com/App/</url>
<metadata_license>CC0-1.0</metadata_license>
<project_license>CC0-1.0</project_license>
<description>
<p>
A description of the App.
</p>
</description>
<launchable type="desktop-id">com.domain.App.desktop</launchable>
<screenshots>
<screenshot type="default">
<caption>Main screenshot</caption>
<image>https://domain.com/Screenshot.jpg</image>
</screenshot>
</screenshots>
<releases>
<release version="1.0.0" date="2024-01-01"/>
</releases>
<categories>
<category>Games</category>
</categories>
<content_rating type="oars-1.1"/>
</component>
- Create a file named com.domain.App.yml:
app-id: com.domain.App
runtime: org.kde.Platform
runtime-version: '5.15-23.08'
sdk: org.kde.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.freepascal
command: App
finish-args:
- --share=ipc
- --socket=fallback-x11
- --socket=wayland
- --filesystem=home
- --device=dri
modules:
- name: qt5pas
buildsystem: qmake
config-opts:
- -after
- target.path=/app/lib
sources:
- type: shell
commands:
- cp -r /usr/lib/sdk/freepascal/share/lazarus/lcl/interfaces/qt5/cbindings/. .
- name: App
sources:
- type: svn
url: https://domain.com/App/trunk
revision: r1
buildsystem: simple
build-commands:
- (. /usr/lib/sdk/freepascal/enable.sh && lazbuild --build-mode=Release --ws=qt5 App.lpi)
- install -d -m 755 $FLATPAK_DEST/share/App
- install -s -m 755 App $FLATPAK_DEST/share/App
- install -d -m 755 $FLATPAK_DEST/bin
- ln -s $FLATPAK_DEST/share/App/App $FLATPAK_DEST/bin/App
- install -d -m 755 $FLATPAK_DEST/share/applications
- install -m 755 ${FLATPAK_ID}.desktop $FLATPAK_DEST/share/applications
- install -d -m 755 $FLATPAK_DEST/share/icons/hicolor/256x256/apps
- install -m 644 App.png $FLATPAK_DEST/share/icons/hicolor/256x256/apps/${FLATPAK_ID}.png
- install -d -m 755 $FLATPAK_DEST/share/metainfo
- install -D com.domain.App.appdata.xml -t $FLATPAK_DEST/share/metainfo/com.domain.App.metainfo.xml
- Create file com.domain.App.desktop:
[Desktop Entry]
Encoding=UTF-8
Name=App
Comment=Example application
Exec=App
Icon=com.domain.App.png
Terminal=false
Type=Application
Categories=GNOME;Application;Game;
StartupNotify=true
- Create a build script named build.sh
#!/bin/bash
BUILD_DIR=build
REPO_DIR=repo
FLATPAK_ID=com.domain.App
# Install dependencies
flatpak install flathub org.kde.Sdk//5.15-23.08
flatpak install flathub org.kde.Platform//5.15-23.08
flatpak install flathub org.freedesktop.Sdk.Extension.freepascal//23.08
flatpak install flathub org.flatpak.Builder
# Build
flatpak run org.flatpak.Builder --force-clean --sandbox --user --install --ccache --mirror-screenshots-url=https://dl.flathub.org/media/ --repo=$REPO_DIR $BUILD_DIR $FLATPAK_ID.yml
# Run
flatpak run $FLATPAK_ID
# Linter
flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest $FLATPAK_ID.yml
flatpak run --command=flatpak-builder-lint org.flatpak.Builder repo $REPO_DIR
- Run the build.sh script and test the application
- Follow the submission process to submit your app to Flathub.
Notes
Flathub offers a very limited number of "platforms" that your application needs to fit into. It does not offer a GTK2 one but does have a QT5 one. However that platform does not contain all the libraries normally found on a Qt5 system so expect to have to bundle libraries into your Flatpack if your application makes use of other libraries.
Does not sound like a very FPC/Lazarus (as it stands now) friendly environment but there are some of "our" applications there.