User:Gromit/Flutter package guidelines
32-bit – CLR – CMake – Cross – DKMS – Eclipse – Electron – Font – Free Pascal – GNOME – Go – Haskell – Java – KDE – Kernel modules – Lisp – Meson – MinGW – Node.js – Nonfree – OCaml – Perl – PHP – Python – R – Ruby – Rust - Security – Shell – VCS – Web – Wine
This document covers standards and guidelines on writing PKGBUILDs for Flutter.
Building
Desktop dependencies
Flutter requires several dependencies to build desktop apps, these dependencies include:
These should be set in makedepends array of the package.
Sample PKGBUILD
pkgname=flutter-default-linux-app pkgver=3.10.2 pkgrel=1 pkgdesc='Example PKGBUILD for a flutter linux app' arch=('x86_64') url="https://docs.flutter.dev/" depends=('gtk3') makedepends=('flutter' 'clang' 'cmake' 'ninja' 'pkgconf' 'xz') source=("https://github.com/christian-heusel/flutter-default-linux-app/archive/refs/tags/v$pkgver.tar.gz") sha256sums=('c07ab021cb11ce79076ab805b8507d3782d714d70b3bd5f26b2e927cdddf5f0c') prepare(){ cd "$pkgname-$pkgver" flutter --no-version-check config --no-analytics flutter --no-version-check config --enable-linux-desktop flutter --no-version-check pub get } build() { cd "$pkgname-$pkgver" flutter --no-version-check build linux --release } package() { cd "$pkgname-$pkgver/build/linux/x64/release/bundle/" # create the target folders install -dm 755 "$pkgdir/opt/$pkgname" "$pkgdir/usr/bin/" # copy the bundled output to /opt cp -rdp --no-preserve=ownership . "$pkgdir/opt/$pkgname/" # symlink to /usr/bin so the app can be found in PATH ln -s "/opt/$pkgname/flutterapp" "$pkgdir/usr/bin/$pkgname" }
Example packages
Saber
Saber is a cross platform note taking app, the package contains a few complications which makes it a good example:
- Uses native libraries written in Rust, Flutter explicitly checks for the rustup binary, therefore rustup must be used instead of rust.
- Written in Flutter
Links
- AURWeb - details on the package.
- AUR cgit - to view the saber PKGBUILD.
- Github issue - to view the development process of the package, with help from upstream, and other Arch Users which tested the package before it was pushed to the AUR.
- External git repository - used for development and maintenance of the saber package, and issues should also be reported here.
Known issues
Ownership problems, or permission denial
If you get an error where you do not have permission to build flutter packages, run the following command:
$ flutter doctor
This will check if flutter is encountering any issues, most likely you will see the following error:
detected dubious ownership in repository at '/opt/flutter'
To fix this problem, run the following command:
$ git config --global --add safe.directory /opt/flutter
This is a known issue with flutterAUR which has not yet been fixed.
Troubleshooting
If you attempt to run a flutter application, and the loader states that some_library.so
can not be found, please follow the steps below.
Example error:
saber: error while loading shared libraries: libsuper_native_extensions.so: cannot open shared object file: No such file or directory
This error occurs due to the loader attempting to find the libraries within the usual (/usr/lib
) or other wrong paths, however the libraries are stored within the flutter bundle next to the executable.
To fix this, execute the package by setting the LD_LIBRARY_PATH
to the path of the lib directory within the flutter bundle, see an example launcher script below:
#!/bin/bash LD_LIBRARY=/opt/pkgname/lib /opt/pkgname/pkgname "$@"