# 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: ```yaml 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) 1. Compile the binary locally: ```bash gcc -o hello hello.c ``` 2. Build and install the Flatpak: ```bash 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: ```bash 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 ```bash flatpak run com.example.HelloWorld ``` ## Package for Distribution After building, create a single-file bundle for distribution: ```bash # 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: ```bash 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