### Development Setup with Poetry Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/README.md Instructions for setting up the development environment using Poetry. This includes installing Poetry, project dependencies, and running formatting and type-checking tools. ```bash 1. Install Poetry v2 https://python-poetry.org/docs/#installation 2. poetry install --with dev 3. Format and lint: poetry run ruff format && poetry run ruff check --fix --exit-non-zero-on-fix 4. Type check: poetry run mypy . ``` -------------------------------- ### Example Flatpak Manifest (Simple Buildsystem) Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/README.md This is a complete example of a Flatpak manifest for a Rust project using the simple buildsystem. It includes build commands for fetching dependencies, building the project, and installing the application and its assets. The `cargo-sources.json` is expected to be generated by `flatpak-cargo-generator`. ```yaml app-id: com.example.my_rust_app # Replace with target runtime runtime: org.freedesktop.Platform # Replace with latest runtime version runtime-version: "24.08" sdk: org.freedesktop.Sdk sdk-extensions: - org.freedesktop.Sdk.Extension.rust-stable command: my_app finish-args: - --device=dri - --share=ipc - --socket=wayland - --socket=fallback-x11 modules: # Example using simple buildsystem - name: my_app buildsystem: simple build-options: append-path: /usr/lib/sdk/rust-stable/bin env: CARGO_HOME: /run/build/my_app/cargo CARGO_NET_OFFLINE: 'true' build-commands: - cargo --offline fetch --manifest-path Cargo.toml --verbose - cargo build --offline --release --all-features - install -Dm0755 target/release/my_app ${FLATPAK_DEST}/bin/my_app - install -Dm0644 logo.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/${FLATPAK_ID}.svg - install -Dm0644 ${FLATPAK_ID}.desktop ${FLATPAK_DEST}/share/applications/${FLATPAK_ID}.desktop - install -Dm0644 ${FLATPAK_ID}.metainfo.xml ${FLATPAK_DEST}/share/metainfo/${FLATPAK_ID}.metainfo.xml sources: - type: archive url: https://github.com/my_app/my_app.git tag: "v0.1.1" commit "0284b00219cee734e3f6ee2cd6be2bd8004c3cf2" - cargo-sources.json # Example using meson buildsystem # Here it is assumed that all cargo commands are handled inside # 'meson.build' and 'CARGO_HOME' is set inside 'meson.build' - name: my_app buildsystem: meson build-options: append-path: /usr/lib/sdk/rust-stable/bin env: CARGO_NET_OFFLINE: 'true' sources: - type: archive url: https://github.com/my_app/my_app.git tag: "v0.1.1" commit "0284b00219cee734e3f6ee2cd6be2bd8004c3cf2" - cargo-sources.json ``` -------------------------------- ### Install uv Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Install the uv package manager following the official documentation. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Flatpak Manifest Example for Perl Installation Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cpan/README.md An example Flatpak manifest snippet for installing Perl, including configuration options, build flags, and source archives. It also shows how to restore write permissions to Perl libraries after installation. ```yaml - name: perl no-autogen: true config-opts: - '-des' # Build a shared library. - '-Duseshrplib' build-options: cflags: '-fPIC' ldflags: '-fpic' sources: - type: archive url: https://www.cpan.org/src/5.0/perl-5.30.0.tar.gz sha256: 851213c754d98ccff042caa40ba7a796b2cee88c5325f121be5cbb61bbf975f2 - type: shell commands: # Have Flatpak run the GNU-compatible configure script. - 'ln -s configure{.gnu,}' # Restore write permission to the Perl libraries. post-install: - 'chmod -R u+w /app/lib/perl5' # Clean up a bunch of stuff we don't need. Depending on your application, # you may have to drop some of these (e.g. *.pod). cleanup: - '/bin/corelist' - '/bin/cpan' - '/bin/enc2xs' - '/bin/encguess' - '/bin/h2ph' - '/bin/h2xs' - '/bin/instmodsh' - '/bin/json_pp' - '/bin/libnetcfg' - '/bin/perlbug' - '/bin/perldoc' - '/bin/perlivp' - '/bin/perlthanks' - '/bin/piconv' - '/bin/pl2pm' - '/bin/pod*' - '/bin/prove' - '/bin/ptar*' - '/bin/shasum' - '/bin/splain' - '/bin/xsubpp' - '/bin/zipdetails' - '/include' - '/man' - '*.pod' ``` -------------------------------- ### Install Poetry v2 Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/poetry/readme.md Instructions for installing Poetry version 2, a prerequisite for development. ```bash poetry install --with dev ``` -------------------------------- ### Installing Project Dependencies with Poetry Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md This command is used to set up the local virtual environment for development using Poetry. It installs all necessary project dependencies. ```bash $ poetry install ``` -------------------------------- ### Flatpak Manifest Example for Perl Libraries Installation Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cpan/README.md An example Flatpak manifest snippet for installing CPAN modules generated by flatpak-cpan-generator. It specifies the build system, execution of the install script, and restoration of write permissions to site-perl directories. ```yaml - name: perl-libs buildsystem: simple build-commands: - 'perl-libs/install.sh' # Same as with the Perl module, we need to restore write permission. # However, -f is now passed to avoid errors from trying to touch files from the # above module that are now marked as read-only. post-install: - 'chmod -Rf u+w /app/lib/perl5/site_perl' sources: - generated-sources.json # This step should be customized based on the CPAN packages you're using. cleanup: - '/bin' - '/man' ``` -------------------------------- ### Example Manifest (YAML) Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/go-get/README.md This YAML snippet demonstrates the configuration for a Go module in a Flatpak manifest, specifying runtime, SDK, and build options including environment variables and build commands. ```yaml app-id: writeas-cli runtime: org.freedesktop.Platform runtime-version: '21.08' sdk: org.freedesktop.Sdk sdk-extensions: - org.freedesktop.Sdk.Extension.golang command: echo "Done" modules: - name: writeas buildsystem: simple build-options: append-path: /usr/lib/sdk/golang/bin env: GOBIN: /app/bin GO111MODULE: off GOPATH: /run/build/writeas build-args: - --share=network build-commands: - go get github.com/writeas/writeas-cli/cmd/writeas ``` -------------------------------- ### Example Manifest Module (JSON) Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/go-get/README.md This JSON snippet shows how to configure a Go module in a Flatpak manifest using the `simple` buildsystem, including environment variables and build arguments for network access. ```json { "name": "writeas-cli", "buildsystem": "simple", "build-options": { "env": { "GOBIN": "/app/bin/" }, "build-args": [ "--share=network" ] }, "build-commands": [ ". /usr/lib/sdk/golang/enable.sh; export GOPATH=$PWD; go get github.com/writeas/writeas-cli/cmd/writeas" ] } ``` -------------------------------- ### Example main manifest with Ruby and Bundler modules Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/rubygems/README.md This example shows how to integrate the generated 'rubygems.json' into your main flatpak-builder manifest. It includes definitions for the 'ruby' and 'bundler' modules, specifying their sources and build commands. ```json ... "modules": [ { "name": "ruby", "config-opts": [ "--disable-install-doc" ], "sources": [ { "type": "archive", "url": "https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.6.tar.gz", "sha256": "8322513279f9edfa612d445bc111a87894fac1128eaa539301cebfc0dd51571e" } ] }, { "name": "bundler", "buildsystem": "simple", "build-commands": [ "gem install --local bundler-1.16.2.gem" ], "sources": [ { "type": "file", "url": "https://rubygems.org/downloads/bundler-1.16.2.gem", "sha256": "3bb53e03db0a8008161eb4c816ccd317120d3c415ba6fee6f90bbc7f7eec8690" } ] }, "rubygems.json", ... ], ... ``` -------------------------------- ### Example Flatpak manifest code Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/opam/README.md This YAML snippet shows how to integrate the generated sources file into a Flatpak manifest, including build commands for installing dependencies. ```yaml # Manifest code generated by flatpak-opam-generator - name: lablgtk buildsystem: simple #build-options: # append-path: # env: # OPAMROOT: # OPAMSWITCH: sources: - sources/lablgtk.json - type: git branch: master url: https://github.com/ocaml/opam-repository build-commands: - ls -A --color=never | grep -Ev "cache|packages|repo" | xargs rm -rf - opam admin filter -y lablgtk.2.18.13 camlp-streams.5.0.1 dune.3.11.1 ocamlfind.1.9.6 - opam admin cache - opam repo add lablgtk . - opam install -y lablgtk.2.18.13 camlp-streams.5.0.1 dune.3.11.1 ocamlfind.1.9.6 - opam repo remove --all lablgtk post-install: - opam info --field name,all-installed-versions lablgtk ``` -------------------------------- ### Example Final Module Configuration Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/go-get/README.md This JSON snippet illustrates the structure of a Go module's source list after being processed by the generator, showing git repository URLs and commit hashes. ```json { "name": "writeas-cli", "buildsystem": "simple", "build-options": { "env": { "GOBIN": "/app/bin/" } }, "build-commands": [ ". /usr/lib/sdk/golang/enable.sh; export GOPATH=$PWD; go install github.com/writeas/writeas-cli/cmd/writeas" ], "sources": [ { "type": "git", "url": "https://github.com/atotto/clipboard", "commit": "aa9549103943c05f3e8951009cdb6a0bec2c8949", "dest": "src/github.com/atotto/clipboard" }, ... ] } ``` -------------------------------- ### Example Go Module Manifest Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/go-modules/README.md This YAML snippet shows a basic Flatpak manifest structure for a Go application, including build system configuration and source definition for a Git repository. ```yaml app-id: io.github.golang.tools.gorename runtime: org.freedesktop.Platform runtime-version: '23.08' sdk: org.freedesktop.Sdk sdk-extensions: - org.freedesktop.Sdk.Extension.golang command: gorename modules: - name: gorename buildsystem: simple build-options: append-path: /usr/lib/sdk/golang/bin build-commands: - go install -mod=vendor ./cmd/gorename sources: - type: git url: https://github.com/golang/tools commit: e81af27852c63b9432c0b5bb49707a7f207ef21b ``` -------------------------------- ### Manifest Inclusion Example Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Shows how to include a generated manifest file within a flatpak-builder manifest's 'modules' section. ```json "modules": [ "python3-foo.json", { "name": "other-modules" } ] ``` -------------------------------- ### Install flatpak-node-generator with pipx Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Install the tool using pipx, the recommended method for Python package management. If a JSONDecodeError occurs, try deleting the local pipx virtual environment. ```bash pipx install git+https://github.com/flatpak/flatpak-builder-tools.git#subdirectory=node ``` -------------------------------- ### Example rubygems.json structure Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/rubygems/README.md This is a partial example of the generated rubygems.json file. It defines a 'rubygems' module with a 'simple' build system and includes sources for gems and the Gemfile. ```json { "name": "rubygems", "buildsystem": "simple", "build-commands": [ "bundle install --local" ], "sources": [ "source.json", { "type": "file", "url": "https://rubygems.org/gems/memoist-0.16.0.gem", "sha256": "70bd755b48477c9ef9601daa44d298e04a13c1727f8f9d38c34570043174085f", "dest": "vendor/cache" }, ... ] } ``` -------------------------------- ### Example sources.json content Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/opam/README.md This JSON structure defines files to be downloaded and cached by Flatpak, including URLs, names, and checksums. ```json [ { "type": "file", "url": "https://github.com/garrigue/lablgtk/archive/2.18.13.tar.gz", "name": "lablgtk.2.18.13", "md5": "d0a326b99475216cc22232e72c89415f", "dest": "cache/md5/d0", "dest-filename": "d0a326b99475216cc22232e72c89415f" }, { "type": "file", "url": "https://github.com/ocaml/camlp-streams/archive/v5.0.1.tar.gz", "name": "camlp-streams.5.0.1", "md5": "afc874b25f7a1f13e8f5cfc1182b51a7", "dest": "cache/md5/af", "dest-filename": "afc874b25f7a1f13e8f5cfc1182b51a7" }, { "type": "file", "url": "https://github.com/ocaml/dune/releases/download/3.11.1/dune-3.11.1.tbz", "name": "dune.3.11.1", "sha256": "866f2307adadaf7604f3bf9d98bb4098792baa046953a6726c96c40fc5ed3f71", "dest": "cache/sha256/86", "dest-filename": "866f2307adadaf7604f3bf9d98bb4098792baa046953a6726c96c40fc5ed3f71" }, { "type": "file", "url": "http://download.camlcity.org/download/findlib-1.9.6.tar.gz", "name": "ocamlfind.1.9.6", "md5": "96c6ee50a32cca9ca277321262dbec57", "dest": "cache/md5/96", "dest-filename": "96c6ee50a32cca9ca277321262dbec57" } ] ``` -------------------------------- ### Complete Flatpak Manifest with Go Modules Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/go-modules/README.md This YAML example demonstrates a comprehensive Flatpak manifest that includes Go module sources generated by `flatpak-go-mod`, along with necessary archive sources and checksums. ```yaml app-id: io.github.golang.tools.gorename runtime: org.freedesktop.Platform runtime-version: '23.08' sdk: org.freedesktop.Sdk sdk-extensions: - org.freedesktop.Sdk.Extension.golang command: gorename modules: - name: gorename buildsystem: simple build-options: append-path: /usr/lib/sdk/golang/bin build-commands: - go install -mod=vendor ./cmd/gorename sources: - type: git url: https://github.com/golang/tools commit: e81af27852c63b9432c0b5bb49707a7f207ef21b # Workaround for Go modules generated by github.com/dennwc/flatpak-go-mod - type: file path: modules.txt dest: vendor - type: archive url: https://proxy.golang.org/github.com/yuin/goldmark/@v/v1.4.13.zip strip-components: 3 dest: vendor/github.com/yuin/goldmark sha256: bb41a602b174345fda392c8ad83fcc93217c285c763699677630be90feb7a5e3 - type: archive url: https://proxy.golang.org/golang.org/x/mod/@v/v0.7.0.zip strip-components: 3 dest: vendor/golang.org/x/mod sha256: 24abd1db13329873d72034dc27efad09cbc37d39cf28b8ff7bb3c2adc8eedef7 - type: archive url: https://proxy.golang.org/golang.org/x/net/@v/v0.5.0.zip strip-components: 3 dest: vendor/golang.org/x/net sha256: 0e606881eeb2f572b3d61ad2a639e79cad002064090c75c838aa2f4feca61c8e - type: archive url: https://proxy.golang.org/golang.org/x/sys/@v/v0.4.0.zip strip-components: 3 dest: vendor/golang.org/x/sys sha256: efa9354fcaa709825bbb1c86b83e2347cebb5349f4326cc4c8ccb972ad32032c - type: archive url: https://proxy.golang.org/golang.org/x/sync/@v/v0.1.0.zip strip-components: 3 dest: vendor/golang.org/x/sync sha256: f510bec6009e19882d19953e7273137d34df86c65949345d72f123a255c2ecd2 ``` -------------------------------- ### Install Rust Stable Extension Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/README.md This command installs the necessary Rust stable extension for Flatpak. Ensure the branch matches your runtime version. ```sh flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable//$branch ``` -------------------------------- ### Example Flatpak Module Configuration Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/dotnet/README.md This YAML snippet shows how to integrate the generated sources file into a flatpak-builder module. Ensure the `--source nuget-sources` argument is used with `dotnet build` or `dotnet publish`. ```yaml modules: - name: my-module buildsystem: simple build-commands: - '. /usr/lib/sdk/dotnet/enable.sh; dotnet build -f netcoreapp2.1 -c Release --source nuget-sources my.input.Desktop.csproj' sources: - my-output-sources.json ``` -------------------------------- ### Generate Sources with Custom Arguments Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/dotnet/README.md Example of passing additional arguments to the `dotnet` command using the `--dotnet-args` option. This allows for fine-grained control over the build process, such as disabling cache or setting verbosity. ```bash python3 flatpak-dotnet-generator.py my-output-sources.json my.input.Desktop.csproj --runtime linux-x64 --dotnet-args --no-cache --verbosity detailed ``` -------------------------------- ### Run Deno Generator from JSR Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/deno/README.md Execute the Deno generator using a package from JSR. Ensure you have Deno installed and the necessary lock file. ```bash deno -RN -W=. jsr:@flatpak-contrib/flatpak-deno-generator deno.lock ``` -------------------------------- ### Install Perl Dependencies on Fedora Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cpan/README.md Installs the necessary Perl modules required by flatpak-cpan-generator on a Fedora system using dnf. ```bash sudo dnf install 'perl(App::cpanminus)' 'perl(Getopt::Long::Descriptive)' 'perl(JSON::MaybeXS)' 'perl(LWP::UserAgent)' 'perl(MetaCPAN::Client)' 'perl(Capture::Tiny)' ``` -------------------------------- ### Example source.json for project repository Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/rubygems/README.md Edit source.json to specify your project's repository as a source. This is typically a git repository with a specific tag. ```json { "type": "git", "url": "git://example.com/repo.git", "tag": "X.Y.Z" } ``` -------------------------------- ### Configuring Cargo for Offline Builds in Flatpak Manifest (Simple Buildsystem) Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/README.md This example shows how to configure a Flatpak manifest for applications using a simple build system. It details setting `CARGO_NET_OFFLINE` and executing commands to fetch dependencies and build the project in offline mode. ```yaml # Example using simple buildsystem - name: my_app buildsystem: simple build-options: append-path: /usr/lib/sdk/rust-stable/bin env: CARGO_NET_OFFLINE: 'true' build-commands: - install -Dm0644 cargo/config .cargo/config.toml - cargo --offline fetch --manifest-path Cargo.toml --verbose - cargo build --offline --release --all-features - [...] ``` -------------------------------- ### Configuring Cargo for Offline Builds in Flatpak Manifest (Meson/CMake) Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/README.md This example demonstrates how to configure a Flatpak manifest for applications using Meson or CMake build systems. It includes setting `CARGO_NET_OFFLINE` to true and copying a local Cargo configuration file to ensure offline builds function correctly. ```yaml modules: # Example using meson, cmake, cmake-ninja buildsystems - name: my_app buildsystem: meson build-options: append-path: /usr/lib/sdk/rust-stable/bin env: CARGO_NET_OFFLINE: 'true' sources: - type: archive url: https://github.com/my_app/my_app.git tag: "v0.1.1" commit "0284b00219cee734e3f6ee2cd6be2bd8004c3cf2" - cargo-sources.json - type: shell commands: - mkdir -p .cargo - cp -vf cargo/config .cargo/config.toml ``` -------------------------------- ### Generate rubygems.json from vendor/cache Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/rubygems/README.md Use this command after running 'bundle install && bundle package' to generate the rubygems.json manifest file. This manifest is then used in the main flatpak-builder manifest. ```bash ruby flatpak_rubygems_generator.rb -s source.json -o rubygems.json ``` -------------------------------- ### Find Correct Rust Extension Branch Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/README.md This command helps determine the correct branch of the Rust extension to install for a given GNOME or KDE runtime version. ```sh flatpak info -m org.kde.Sdk | grep -A 5 "org.freedesktop.Sdk.Extension" | grep -E "^version" ``` -------------------------------- ### Convert JSON Manifest to YAML Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/readme.md Converts a JSON manifest file to YAML format. Ensure PyYAML is installed. Usage: ./flatpak-json2yaml.py --output= ```bash ./flatpak-json2yaml.py /path/to/example.json --output=example.yml ``` -------------------------------- ### Generate SPM Manifest JSON Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/spm/README.md Use this command to convert Swift package dependencies into a format flatpak-builder can understand and generate offline dependency setup scripts. The first path is the Swift package directory, and the second is the Flatpak manifest directory. ```bash swift flatpak-spm-generator.swift ./quickstart ./quickstart ``` -------------------------------- ### Generate Flatpak Sources from package-lock.json Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/npm/README.md Use the flatpak-npm-generator script to create a JSON file containing extra sources for offline npm installation. This is typically run outside the sandbox. ```bash ./flatpak-npm-generator.py electron-quick-start-package-lock.json -o generated-sources.json ``` -------------------------------- ### Overwriting Electron's Default ffmpeg Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md This snippet demonstrates how to install a patent-clean ffmpeg binary to replace the default one shipped with Electron. This is useful when the default ffmpeg's proprietary codecs are not required. ```yaml - 'install -Dm 755 flatpak-node/libffmpeg.so -t /app/electron-webpack-quick-start' ``` -------------------------------- ### Enter Flatpak Sandbox and Compile Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Enter the Flatpak sandbox with necessary permissions and prepare the environment for compiling the application. This includes enabling OpenJDK and cleaning the Gradle cache. ```bash flatpak run --command=bash --share=network --filesystem=`pwd` -d org.freedesktop.Sdk//21.08 source /usr/lib/sdk/openjdk11/enable.sh rm -rf gradle-cache mkdir -p dependencies/flatRepo/ ``` -------------------------------- ### Run Gradle Build with Info Logging Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Execute the Gradle build with the --info and --console plain flags to generate a detailed log file containing URLs of dependency artifacts. ```bash gradle -g gradle-cache/ --info --console plain buildGhidra > gradle-log.txt ``` -------------------------------- ### Download and Prepare Dependencies Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Manually download and place specific dependency JAR files into the offline repository directory. This step is specific to certain projects like Ghidra. ```bash wget https://github.com/pxb1988/dex2jar/releases/download/2.0/dex-tools-2.0.zip unzip -j dex-tools-2.0.zip "*.jar" -d dependencies/flatRepo/ wget -P dependencies/flatRepo/ https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/android4me/AXMLPrinter2.jar ``` -------------------------------- ### Basic Usage of flatpak-cpan-generator Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cpan/README.md Demonstrates the basic command-line usage for running flatpak-cpan-generator to process CPAN modules and generate a sources file. ```bash $ flatpak-cpan-generator LWP::UserAgent Some::Other::Package ... ``` -------------------------------- ### Sync Dependencies Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Synchronize and freeze project dependencies using uv. ```bash uv sync -v --all-groups --frozen ``` -------------------------------- ### Build Flatpak Application with Generated Sources Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/npm/README.md Build the Flatpak application using flatpak-builder, referencing the generated sources JSON file and a base application definition. Requires io.atom.electron.BaseApp. ```bash flatpak-builder --force-clean --repo=repo app io.atom.electron.ElectronQuickStart.json ``` -------------------------------- ### Using NW.js Version from File Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md This bash command shows how to use the NW.js version stored in the flatpak-node/nwjs-version file with the nw-builder tool. This is useful when the script manages the NW.js version. ```bash nwbuild -v $(<$FLATPAK_BUILDER_BUILDDIR/flatpak-node/nwjs-version) ``` -------------------------------- ### Generating Manifest from requirements.txt Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Generates a manifest file for all dependencies listed in a specified requirements.txt file. The output can be customized with an output name. ```bash flatpak-pip-generator --runtime='org.freedesktop.Sdk//22.08' --requirements-file='/the/path/to/requirements.txt' --output pypi-dependencies ``` -------------------------------- ### Manifest Inclusion for requirements.txt Output Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Demonstrates how to include a manifest generated from a requirements.txt file into a flatpak-builder manifest. ```json "modules": [ "pypi-dependencies.json", { "name": "other-modules" } ] ``` -------------------------------- ### View generated sources file Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/opam/README.md Use 'cat' to inspect the contents of the generated sources.json file. ```bash $ cat lablgtk_sources.json ``` -------------------------------- ### Flatpak Manifest with Generated Sources Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/spm/README.md This JSON snippet shows how to integrate the generated `generated-sources.json` and `setup-offline.sh` files into a `flatpak-builder` manifest. It specifies the build system, sources, and build commands. ```json { "name": "quickstart", "buildsystem": "simple", "sources": [ { "type": "dir", "path": "." }, "generated-sources.json" ], "build-commands": [ "./setup-offline.sh", "swift build -c release --static-swift-stdlib --skip-update", "install -Dm755 .build/release/quickstart /app/bin/quickstart" ] } ``` -------------------------------- ### Generate Flatpak sources file Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/opam/README.md Run the flatpak-opam-generator.py script with the opam dependency JSON file to create a sources.json file for Flatpak. ```bash $ opam --version 2.2.0~alpha2 $ opam tree --json=lablgtk_deps.json lablgtk $ ./flatpak-opam-generator.py lablgtk_deps.json > lablgtk_sources.json ``` -------------------------------- ### Generate Sources Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/fiddle-yarn-berry/README.md Run this script to generate the required 'generated-sources.json' file for the build process. ```sh ./gen.sh ``` -------------------------------- ### Generate for x86_64 and ppc64le with Preferred Wheels Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Generates manifests preferring platform wheels for specified packages on x86_64 and ppc64le architectures. Requires a Flatpak runtime. ```sh ./flatpak-pip-generator --runtime org.freedesktop.Sdk//25.08 --prefer-wheels=cryptography,cffi --wheel-arches x86_64,ppc64le cryptography ``` -------------------------------- ### Flatpak Node Generator CLI Usage Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Displays the command-line interface usage and all available options for the flatpak-node-generator tool. Use this to understand the full range of configurations. ```bash usage: flatpak-node-generator [-h] [-o OUTPUT] [-r] [-R RECURSIVE_PATTERN] [--registry REGISTRY] [--no-trim-index] [--no-devel] [--no-requests-cache] [--max-parallel MAX_PARALLEL] [--retries RETRIES] [-P] [-s] [-S SPLIT_SIZE] [--node-chromedriver-from-electron NODE_CHROMEDRIVER_FROM_ELECTRON] [--electron-ffmpeg {archive,lib}] [--electron-node-headers] [--nwjs-version NWJS_VERSION] [--nwjs-node-headers] [--nwjs-ffmpeg] [--no-xdg-layout] [--node-sdk-extension NODE_SDK_EXTENSION] {npm,yarn,pnpm} lockfile Flatpak Node generator positional arguments: {npm,yarn,pnpm} lockfile The lockfile path (package-lock.json, yarn.lock, or pnpm-lock.yaml) options: -h, --help show this help message and exit -o, --output OUTPUT The output sources file -r, --recursive Recursively process all files under the lockfile directory with the lockfile basename -R, --recursive-pattern RECURSIVE_PATTERN Given -r, restrict files to those matching the given pattern. --registry REGISTRY The registry to use (npm/pnpm) --no-trim-index Don't trim npm package metadata (npm only) --no-devel Don't include devel dependencies (npm/pnpm) --no-requests-cache Disable the requests cache --max-parallel MAX_PARALLEL Maximium number of packages to process in parallel --retries RETRIES Number of retries of failed requests -P, --no-autopatch Don't automatically patch Git sources from package*.json -s, --split Split the sources file to fit onto GitHub. -S, --split-size SPLIT_SIZE If splitting the sources file, split at this size in KB. Default is 49000 KB. --node-chromedriver-from-electron NODE_CHROMEDRIVER_FROM_ELECTRON Use the ChromeDriver version associated with the given Electron version for node-chromedriver --electron-ffmpeg {archive,lib} Download prebuilt ffmpeg for matching electron version --electron-node-headers Download the electron node headers --nwjs-version NWJS_VERSION Specify NW.js version (will use latest otherwise) --nwjs-node-headers Download the NW.js node headers --nwjs-ffmpeg Download prebuilt ffmpeg for current NW.js version --pnpm-store-version Specify the store version for pnpm v9 lockfile. Default is v10. --no-xdg-layout Don't use the XDG layout for caches --node-sdk-extension NODE_SDK_EXTENSION Flatpak node SDK extension (e.g. org.freedesktop.Sdk.Extension.node24//25.08) ``` -------------------------------- ### Format and Lint Code with Ruff Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/poetry/readme.md Commands to format and lint the project using Ruff, a Python linter and formatter. ```bash poetry run ruff format && poetry run ruff check --fix --exit-non-zero-on-fix ``` -------------------------------- ### Basic Manifest Generation Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Generates a flatpak-builder manifest JSON for a given Python package. The output can be included in a larger manifest. ```bash ./flatpak-pip-generator --runtime='org.freedesktop.Sdk//22.08' foo ``` -------------------------------- ### Generate Flatpak Sources File Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/dotnet/README.md Basic command to generate the Flatpak sources file from a .NET Core .csproj file. The output is saved to `my-output-sources.json` by default. ```bash python3 flatpak-dotnet-generator.py my-output-sources.json my.input.Desktop.csproj ``` -------------------------------- ### Display Help Message Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Shows the full help message for the flatpak-pip-generator command, detailing all available options and arguments. ```sh ./flatpak-pip-generator --help ``` -------------------------------- ### Generate Flatpak Sources File Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Use the flatpak-gradle-generator.py script to parse the Gradle log file and create the flatpak-sources.json file. ```bash flatpak-gradle-generator.py gradle-log.txt gradle-dependencies.json ``` -------------------------------- ### Run Deno Generator Locally Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/deno/README.md Execute the Deno generator locally from the repository. Specify the output file name using the --output flag. ```bash deno -RN -W=. src/main.ts deno.lock --output sources.json ``` -------------------------------- ### Flatpak Manifest Source Integration Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/deno/README.md Include the generated Deno sources file in your Flatpak manifest's sources list. ```yaml sources: - deno-sources.json ``` -------------------------------- ### Generate Flatpak manifest code Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/opam/README.md Use the --generate flag with the script to produce Flatpak manifest code, specifying the package name and dependency JSON file. ```bash $ ./flatpak-opam-generator.py --generate lablgtk lablgtk_deps.json ``` -------------------------------- ### Generate for x86_64 and aarch64 with Preferred Wheels Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Generates manifests preferring platform wheels for specified packages on both x86_64 and aarch64 architectures. Requires a Flatpak runtime. ```sh ./flatpak-pip-generator --runtime org.freedesktop.Sdk//25.08 --prefer-wheels=cryptography,cffi cryptography ``` -------------------------------- ### Generating Manifests for Multiple Packages Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Allows specifying multiple Python packages with version constraints in a single command to generate their combined manifest. ```bash flatpak-pip-generator --runtime='org.freedesktop.Sdk//22.08' foo\>=1.0.0,\<2.0.0 bar ``` -------------------------------- ### Integrate Vendor Directory for JSR/HTTP Dependencies Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/deno/README.md Move the generated vendor directory next to your deno.json file and compile or run with the --vendor flag to use JSR and HTTP dependencies. ```yaml - # sources provides vendor directory - # src is where my deno project at as in deno.json is under src directory, so I'm moving vendor next to it - mv ./vendor src/ - DENORT_BIN=$PWD/denort ./deno compile --vendor --no-check --output virtaudio-bin --cached-only --allow-all --include ./src/gui.slint --include ./src/client.html ./src/gui.ts ``` -------------------------------- ### Execute Script within Flatpak Sandbox Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Run a script containing manual commands within the Flatpak sandbox to reproduce the build environment and generate the sources file. ```bash flatpak run --command=bash --share=network --filesystem=`pwd` -d org.freedesktop.Sdk//21.08 ./script.sh flatpak-gradle-generator.py gradle-log.txt gradle-dependencies.json ``` -------------------------------- ### Setting CARGO_HOME in Meson Build Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/cargo/README.md This snippet shows how to set the `CARGO_HOME` environment variable in a Meson build file. This is often done to direct Cargo to a specific directory for its configuration and cached dependencies. ```meson cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] ``` -------------------------------- ### Symlinking Node-gyp Cache Directory Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Use this workaround when tools like electron-rebuild do not properly respect XDG cache directory specifications. Ensure the symlink and build command are executed in the same command. ```yaml build-commands: - | ln -s $XDG_CACHE_HOME/node-gyp $HOME/.electron-gyp npm run build ``` -------------------------------- ### Generate for x86_64 Only with Preferred Wheels Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Generates manifests preferring platform wheels for specified packages, targeting only the x86_64 architecture. Requires a Flatpak runtime. ```sh ./flatpak-pip-generator --runtime org.freedesktop.Sdk//25.08 --prefer-wheels=cryptography,cffi --wheel-arches x86_64 cryptography ``` -------------------------------- ### Generate Sources with Pattern Matching for Lockfiles (Yarn) Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Use the -R pattern flag in addition to -r to filter which lockfiles are used for source generation. This allows for more specific selection of lockfiles based on patterns. ```bash flatpak-node-generator yarn -r ~/my-project/yarn.lock -R 'something*/yarn.lock' -R 'another*/yarn.lock' ``` -------------------------------- ### Generate SPM Manifest JSON with Suffix Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/spm/README.md Optionally, provide a third argument as a suffix for the generated file names. This is useful when dealing with multiple Swift packages. ```bash swift flatpak-spm-generator.swift ./quickstart ./quickstart quickstart ``` -------------------------------- ### Running Checks and Tests with Poetry Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Execute all project checks and unit tests using Poetry. This command ensures the project adheres to defined standards and passes all tests. ```bash $ poetry run poe check ``` -------------------------------- ### Include Generated Sources in Flatpak Manifest Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/poetry/readme.md Shows how to include the generated poetry sources JSON file in a flatpak-builder manifest. ```json "modules": [ "generated-poetry-sources.json", { "name": "other-modules" } ] ``` -------------------------------- ### Apply Gradle Plugin Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Apply the flatpak-gradle-generator plugin to your Gradle build script. ```groovy plugins { id "io.github.jwharm.flatpak-gradle-generator" version "1.5.0" } ``` -------------------------------- ### Generate Sources for Recursive Lockfiles (Yarn) Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Use the -r flag with flatpak-node-generator to find and generate sources for all lockfiles with a specified name within a directory. This is useful for projects with multiple lockfiles. ```bash flatpak-node-generator yarn -r ~/my-project/yarn.lock ``` -------------------------------- ### Configure Node.js Chromedriver Download Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Set environment variables and append paths to use a pre-downloaded chromedriver for your Flatpak build. This is useful when your application depends on node-chromedriver. ```yaml build-options: append-path: '/usr/lib/sdk/node10/bin:/run/build/MY-MODULE/flatpak-node/chromedriver' env: CHROMEDRIVER_SKIP_DOWNLOAD: 'true' # ... ``` -------------------------------- ### Generate opam dependency JSON Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/opam/README.md Use 'opam tree' to generate a JSON file detailing project dependencies. This command requires opam version 2.2.0 or later. ```bash $ opam tree --json=deps.json [PACKAGE] ``` -------------------------------- ### Generate generated-sources.json Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/vanilla-quick-start/README.md Use `flatpak-node-generator` to create the `generated-sources.json` file required for building a Flatpak. Ensure the local clone of the target project is at the correct commit. ```sh flatpak-node-generator npm /path/to/electron-quick-start/package-lock.json ``` -------------------------------- ### Format and Lint Code Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Format code with ruff format and fix linting issues with ruff check. ```bash uv run ruff format && uv run ruff check --fix --exit-non-zero-on-fix ``` -------------------------------- ### Configure Plugin Management Repository Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Add the offline repository to the pluginManagement section in settings.gradle. This is required for plugins not included in the Gradle distribution. ```groovy pluginManagement { repositories { maven { url "./offline-repository" } } } ``` -------------------------------- ### Configure Flatpak Gradle Generator Task Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Configure the flatpakGradleGenerator task to specify the output file and download directory for dependency artifacts. ```groovy tasks.flatpakGradleGenerator { outputFile = file("flatpak-sources.json") downloadDirectory = "./offline-repository" excludeConfigurations = ["testCompileClasspath", "testRuntimeClasspath"] } ``` -------------------------------- ### Generate Flatpak Node Generator JSON Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/webpack-quick-start/README.md Run this command to generate the 'generated-sources.json' file required for building a Flatpak with Flatpak Node Generator. Ensure the path points to the 'yarn.lock' file of your electron-webpack project. ```sh flatpak-node-generator yarn /path/to/electron-webpack-quick-start/yarn.lock ``` -------------------------------- ### Configure DENO_DIR for NPM Dependencies Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/deno/README.md Set the DENO_DIR environment variable in your Flatpak build to point to the deno_dir generated by the tool, enabling the use of NPM dependencies. ```yaml - name: someModule buildsystem: simple build-options: env: # sources provides deno_dir directory DENO_DIR: deno_dir ``` -------------------------------- ### Advanced Artifact Policy Specification Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/pip/readme.md Specifies artifact policies (e.g., sdist, platform) on a per-module basis for fine-grained control over artifact selection. This is generally not recommended for most use cases. ```sh ./flatpak-pip-generator --runtime org.freedesktop.Sdk//25.08 --artifact-policy cryptography=sdist --artifact-policy cffi=platform cryptography ``` -------------------------------- ### Running Pytest Manually with Poetry Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Invoke pytest manually to run tests, utilizing multiple processes for potentially faster execution. This is an alternative to the 'poe check' command. ```bash $ poetry run pytest -n auto ``` -------------------------------- ### Type Check Code with Mypy Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/poetry/readme.md Command to perform static type checking on the project using Mypy. ```bash poetry run mypy . ``` -------------------------------- ### Add Offline Repository to Gradle Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Configure your Gradle project to use an offline repository for dependency artifacts. This ensures Flatpak-builder can access necessary files. ```groovy repositories { mavenCentral() maven { url "./offline-repository" } } ``` -------------------------------- ### Set Log Level for Generator Script Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/gradle/README.md Control the verbosity of the flatpak-gradle-generator.py script by setting the LOGLEVEL environment variable. ```bash LOGLEVEL=debug flatpak-gradle-generator.py gradle-log.txt gradle-dependencies.json ``` -------------------------------- ### Convert Base64 to Hex Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Converts a base64 hash value, typically from npm, into its hexadecimal representation. Useful for comparing or processing hash values. ```shell $ echo x+sXyT4RLLEIb6bY5R+wZnt5pfk= | tools/b64-to-hex.sh c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9 ``` -------------------------------- ### Convert Hex to Base64 Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Converts a hexadecimal hash value into its base64 representation. This script handles optional slashes within the hex input, making it convenient for copy-pasting paths. ```shell $ echo 867ac74e3864187b1d3d47d996a78ec5c8830777 | tools/hex-to-b64.sh hnRHTjhkGHsdPUfZlqeOxciDB3c= $ echo c7/eb/17c93e112cb1086fa6d8e51fb0667b79a5f9 | tools/hex-to-b64.sh x+sXyT4RLLEIb6bY5R+wZnt5pfk= ``` -------------------------------- ### Generate Base64 Integrity Hash Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Calculates an integrity hash for given input using a specified algorithm (e.g., sha512) and then converts the resulting hex digest into a base64 encoded string. This is useful for generating integrity checks compatible with base64 formats. ```shell $ echo 123 | tools/b64-integrity.sh sha512 6i/la7jB+1rahJY7Qu1xt2SnSwktdXVRc63gby9KranADWwwLhhQNcvoX9/zFpi8qT6GYfDLzvUs8v9lhk/XQg== ``` -------------------------------- ### Disable Autopatching for Git Sources in Nested Projects Source: https://github.com/flatpak/flatpak-builder-tools/blob/master/node/README.md Pass the -P or --no-autopatch flag to flatpak-node-generator to disable automatic patching of Git sources. This is necessary for recursive package.jsons where nested project directories may not exist during the initial patch phase. ```bash flatpak-node/patch.sh npm install ... flatpak-node/patch/node_modules/my-nested-project.sh npm install ... npm run build ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.