Signed-off-by: Mitja Horvat <pinkfluid@gmail.com>
Binary-Only Flatpak Package Example
This demonstrates how to create a Flatpak package that distributes only a compiled binary without source code.
Project Structure
- hello.c - Source code (kept only for development, not distributed)
- hello - Compiled binary (this is what gets distributed)
- com.example.HelloWorld.yml - Flatpak manifest
Key Points
The Flatpak manifest uses a pre-compiled binary instead of building from source:
modules:
- name: hello
buildsystem: simple
build-commands:
- install -D hello /app/bin/hello
sources:
- type: file
path: hello # Pre-compiled binary
This approach:
- Distributes only the compiled binary
- Does not include source code in the package
- Source file (hello.c) is excluded from distribution
Build Instructions
Option 1: Pre-compiled Binary (com.example.HelloWorld.yml)
-
Compile the binary locally:
gcc -o hello hello.c -
Build and install the Flatpak:
flatpak-builder --user --install --force-clean build-dir com.example.HelloWorld.yml
Option 2: Build Inside Flatpak (com.example.HelloWorld-build-inside.yml)
Build the binary inside the Flatpak sandbox using the SDK:
flatpak-builder --user --install --force-clean build-dir com.example.HelloWorld-build-inside.yml
This compiles hello.c using gcc inside the Flatpak environment, then installs only the resulting binary.
Run the Application
flatpak run com.example.HelloWorld
Package for Distribution
After building, create a single-file bundle for distribution:
# Create bundle from user installation
flatpak build-bundle ~/.local/share/flatpak/repo com.example.HelloWorld.flatpak com.example.HelloWorld
# Or create a custom repo and bundle
flatpak-builder --repo=repo build-dir com.example.HelloWorld.yml
flatpak build-bundle repo com.example.HelloWorld.flatpak com.example.HelloWorld
The resulting .flatpak file contains only the compiled binary and can be distributed to users.
Install from Bundle
Users can install your package:
flatpak install com.example.HelloWorld.flatpak
Notes
- The source file (hello.c) is never included in the Flatpak package
- Only the compiled binary is distributed
- You can delete hello.c after building if desired
Description
Languages
C
100%