File flutter.spec of Package flutter
#
# spec file for package flutter
#
# Copyright (c) 2026 Fitzmachine
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: flutter
Version: 3.27.4+0
Release: 0
%define _unpackaged_files_terminate_build 0
%define _binaries_in_noarch_packages_terminate_build 0
%global __os_install_post %{nil}
Summary: Google's UI toolkit for building natively compiled applications
License: BSD-3-Clause
Group: Development/Tools/Other
URL: https://github.com/flutter/flutter
Source0: %{name}-%{version}.tar.xz
Source1: %{name}-rpmlintrc
BuildRequires: bash
BuildRequires: curl
BuildRequires: git-core
BuildRequires: unzip
BuildRequires: xz
BuildRequires: python3
BuildRequires: clang
BuildRequires: libstdc++-devel
BuildRequires: fdupes
Requires: bash
Requires: curl
Requires: git-core
Requires: unzip
Requires: xz
Requires: python3
Requires: clang
%description
Flutter is Google's UI toolkit for building natively compiled applications from a single codebase.
This package installs the Flutter SDK into /opt/flutter.
%prep
%setup -q
# Flutter requires a .git directory with proper branch tracking to function
# Since tar_scm excludes .git, we create a minimal git repo here
echo "=== Setting up git repository for Flutter ==="
if [ ! -d .git ]; then
echo "Creating minimal git repository..."
git init
git config user.email "build@opensuse.org"
git config user.name "OBS Build"
# Set the remote to Flutter's official repo
git remote add origin https://github.com/flutter/flutter.git
# Create initial commit with all files
git add -A
# Force-add engine.version which is in .gitignore but needed for version detection
# This file must be tracked for update_engine_version.sh to use it instead of
# falling back to content-aware hashing
git add -f bin/internal/engine.version
git commit -m "Flutter SDK %{version}" --no-verify
# Create and checkout the stable branch
# This ensures Flutter correctly identifies itself as being on the stable channel
git checkout -b stable
# Create a local reference to origin/stable so upstream tracking can be configured
# This simulates the remote tracking branch without requiring a fetch
git update-ref refs/remotes/origin/stable HEAD
# Configure upstream tracking for the stable branch
# This allows Flutter to determine the repository URL and channel
git branch --set-upstream-to=origin/stable stable
echo "✓ Git repository created on stable branch with upstream tracking"
git log --oneline -n 1
else
echo "✓ .git directory already exists"
fi
# Verify git repository is functional
git rev-parse HEAD || (echo "✗ ERROR: git repository not functional" && exit 1)
echo "✓ Git repository is functional"
# Verify branch and upstream configuration
echo "=== Verifying git configuration for Flutter ==="
CURRENT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || echo "detached")
UPSTREAM_REF=$(git rev-parse --abbrev-ref --symbolic @{upstream} 2>/dev/null || echo "none")
REMOTE_URL=$(git ls-remote --get-url origin 2>/dev/null || echo "none")
echo "Current branch: $CURRENT_BRANCH"
echo "Upstream tracking: $UPSTREAM_REF"
echo "Remote URL: $REMOTE_URL"
# Validate configuration matches Flutter's requirements
if [ "$CURRENT_BRANCH" = "stable" ] && [ "$UPSTREAM_REF" = "origin/stable" ]; then
echo "✓ Git configuration correct for stable channel"
else
echo "✗ WARNING: Git configuration may not match Flutter's expectations"
echo " Expected branch: stable, Got: $CURRENT_BRANCH"
echo " Expected upstream: origin/stable, Got: $UPSTREAM_REF"
fi
%build
# The Flutter SDK is distributed as source and precompiled binaries for the engine.
# This prepares the SDK for the first run.
%install
mkdir -p %{buildroot}/opt/flutter
# Use . to include hidden files like .git
cp -aT . %{buildroot}/opt/flutter/
# Create symlinks
mkdir -p %{buildroot}%{_bindir}
ln -s /opt/flutter/bin/flutter %{buildroot}%{_bindir}/flutter
ln -s /opt/flutter/bin/dart %{buildroot}%{_bindir}/dart
# Pre-create cache directory for user access
mkdir -p %{buildroot}/opt/flutter/bin/cache
touch %{buildroot}/opt/flutter/bin/cache/.keep
# Fix permissions
find %{buildroot}/opt/flutter/bin -type f -exec chmod +x {} +
# Verify .git was copied
echo "=== Verifying .git in buildroot ==="
if [ -d %{buildroot}/opt/flutter/.git ]; then
echo "✓ .git directory present in buildroot"
du -sh %{buildroot}/opt/flutter/.git
else
echo "✗ ERROR: .git directory NOT in buildroot"
exit 1
fi
%fdupes %{buildroot}/opt/flutter
%post
# Ensure the users group can write to the flutter directory
# This allows 'flutter doctor' and 'flutter upgrade' to work as intended
# We use root:users as most interactive users on openSUSE are in the users group
chown -R root:users /opt/flutter
chmod -R g+w /opt/flutter
# Mark /opt/flutter as a safe directory for git globally on the system
# This prevents "fatal: detected dubious ownership" errors when users run flutter
git config --system --add safe.directory /opt/flutter
%postun
# Clean up the safe directory configuration if the package is removed
if [ $1 -eq 0 ]; then
git config --system --unset-all safe.directory /opt/flutter || true
fi
%files
%license LICENSE
%{_bindir}/flutter
%{_bindir}/dart
/opt/flutter
/opt/flutter/.git
%dir /opt/flutter/bin/cache
/opt/flutter/bin/cache/.keep
%changelog