🏡 index : quine-global/app-build.git

#!/usr/bin/env bash
# Builds a Flutter app's Linux release bundle for this machine's
# architecture (Flutter can't cross-compile: arm64 builds under emulation),
# then packages it; the spec also gets `bundle`, the bundle's directory.
# The version is pubspec.yaml's.
source /scripts/common.sh

# Flutter's stable release, pinned (storage.googleapis.com/flutter_infra_release/releases/releases_linux.json).
FLUTTER_VERSION=3.47.9
FLUTTER_SHA256=25ed8c3c29d51a7353f2a944310b478af8214920639524b19c50a19e6c044c5a

# shellcheck disable=SC2086 # DNF_PACKAGES is a list
dnf install -y --setopt=install_weak_deps=False \
  clang cmake ninja-build pkgconf-pkg-config gtk3-devel xz-devel libstdc++-devel \
  git xz which unzip rpm-build desktop-file-utils $DNF_PACKAGES

case $(uname -m) in x86_64) arch=x64 ;; aarch64) arch=arm64 ;; *) echo "unsupported: $(uname -m)" >&2; exit 1 ;; esac
sdk=/cache/flutter-$FLUTTER_VERSION-$arch
if [ ! -x "$sdk/bin/flutter" ]; then
  curl -fL --retry 3 -o "/cache/flutter-$arch.tar.xz" \
    "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_$FLUTTER_VERSION-stable.tar.xz"
  echo "$FLUTTER_SHA256  /cache/flutter-$arch.tar.xz" | sha256sum -c
  rm -rf "$sdk.tmp" && mkdir -p "$sdk.tmp"
  tar -xJf "/cache/flutter-$arch.tar.xz" -C "$sdk.tmp" --strip-components=1
  # The release tarball carries an x64 Dart SDK; without it, the first run
  # fetches the one for this machine.
  [ "$arch" = x64 ] || rm -rf "$sdk.tmp/bin/cache"
  mv "$sdk.tmp" "$sdk" && rm "/cache/flutter-$arch.tar.xz"
fi
git_safe
export PUB_CACHE=/cache/pub PATH="$sdk/bin:$PATH"
flutter --disable-analytics >/dev/null 2>&1 || true

cd /src
flutter build linux --release

version=$(sed -n 's/^version: *\([0-9][0-9.]*\).*/\1/p' pubspec.yaml)
package_rpm "$version" --define "bundle /src/build/linux/$arch/release/bundle"