flutter: init 1.12.13+hotfix.8

flutter: add beta and dev channels

flutter: artifacts are now downloaded in $HOME/.cache/flutter

flutter: remove all artifacts from flutter

flutter: fix lockfile path

flutter: fix pub_cache

flutter: fix flutter_tools/.packages pointing to /build

flutter: clean patches

flutter: fix write error on .cache/flutter/lockfile

flutter: add zlib as a dependency

flutter: add missing dependencies

flutter: fix flutter version

flutter: update versions + dependencies
This commit is contained in:
Bastien Rivière 2019-12-24 18:01:45 +01:00
parent ea5c800175
commit d037e64ef6
No known key found for this signature in database
GPG key ID: EECF965F5AAA4E1A
9 changed files with 444 additions and 0 deletions

View file

@ -0,0 +1,30 @@
{ callPackage }:
let
mkFlutter = opts: callPackage (import ./flutter.nix opts) { };
getPatches = dir:
let files = builtins.attrNames (builtins.readDir dir);
in map (f: dir + ("/" + f)) files;
in {
stable = mkFlutter {
pname = "flutter";
channel = "stable";
version = "1.12.13+hotfix.8";
sha256Hash = "01ik4xckr3fp65sq4g0g6wy5b9i0r49l643xmbxa6z9k21sby46d";
patches = getPatches ./patches/stable;
};
beta = mkFlutter {
pname = "flutter-beta";
channel = "beta";
version = "1.14.6";
sha256Hash = "1a79pr741zkr39p5gc3p9x59d70vm60hpz2crgc53ysglj4ycigy";
patches = getPatches ./patches/beta;
};
dev = mkFlutter {
pname = "flutter-dev";
channel = "dev";
version = "1.15.3";
sha256Hash = "06mawwqf7q7wdmzlyxlrlblhnnk4ckf3vp92lplippdh3d52r93i";
patches = getPatches ./patches/dev;
};
}

View file

@ -0,0 +1,128 @@
{ channel, pname, version, sha256Hash, patches }:
{ bash, buildFHSUserEnv, cacert, coreutils, git, makeWrapper, runCommand, stdenv
, fetchurl, alsaLib, dbus, expat, libpulseaudio, libuuid, libX11, libxcb
, libXcomposite, libXcursor, libXdamage, libXfixes, libGL, nspr, nss, systemd }:
let
drvName = "flutter-${channel}-${version}";
flutter = stdenv.mkDerivation {
name = "${drvName}-unwrapped";
src = fetchurl {
url =
"https://storage.googleapis.com/flutter_infra/releases/${channel}/linux/flutter_linux_v${version}-${channel}.tar.xz";
sha256 = sha256Hash;
};
buildInputs = [ makeWrapper git ];
inherit patches;
postPatch = ''
patchShebangs --build ./bin/
find ./bin/ -executable -type f -exec patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) {} \;
'';
buildPhase = ''
FLUTTER_ROOT=$(pwd)
FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools"
SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot"
STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp"
SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart"
DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
DART="$DART_SDK_PATH/bin/dart"
PUB="$DART_SDK_PATH/bin/pub"
HOME=../.. # required for pub upgrade --offline, ~/.pub-cache
# path is relative otherwise it's replaced by /build/flutter
(cd "$FLUTTER_TOOLS_DIR" && "$PUB" upgrade --offline)
local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)"
"$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
echo "$revision" > "$STAMP_PATH"
echo -n "${version}" > version
rm -rf bin/cache/{artifacts,downloads}
rm -f bin/cache/*.stamp
'';
installPhase = ''
mkdir -p $out
cp -r . $out
'';
};
# Wrap flutter inside an fhs user env to allow execution of binary,
# like adb from $ANDROID_HOME or java from android-studio.
fhsEnv = buildFHSUserEnv {
name = "${drvName}-fhs-env";
multiPkgs = pkgs: [
# Flutter only use these certificates
(runCommand "fedoracert" { } ''
mkdir -p $out/etc/pki/tls/
ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs
'')
pkgs.zlib
];
targetPkgs = pkgs:
with pkgs; [
bash
curl
git
unzip
which
xz
# flutter test requires this lib
libGLU
# for android emulator
alsaLib
dbus
expat
libpulseaudio
libuuid
libX11
libxcb
libXcomposite
libXcursor
libXdamage
libXfixes
libGL
nspr
nss
systemd
];
};
in runCommand drvName {
startScript = ''
#!${bash}/bin/bash
export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"}
export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
${fhsEnv}/bin/${drvName}-fhs-env ${flutter}/bin/flutter --no-version-check "$@"
'';
preferLocalBuild = true;
allowSubstitutes = false;
passthru = { unwrapped = flutter; };
meta = with stdenv.lib; {
description =
"Flutter is Google's SDK for building mobile, web and desktop with Dart.";
longDescription = ''
Flutter is Googles UI toolkit for building beautiful,
natively compiled applications for mobile, web, and desktop from a single codebase.
'';
homepage = "https://flutter.dev";
license = licenses.bsd3;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ babariviere ];
};
} ''
mkdir -p $out/bin
echo -n "$startScript" > $out/bin/${pname}
chmod +x $out/bin/${pname}
''

View file

@ -0,0 +1,31 @@
diff --git a/bin/flutter b/bin/flutter
index e0c18e235..2c3fb7ddd 100755
--- a/bin/flutter
+++ b/bin/flutter
@@ -185,8 +185,6 @@ fi
# FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS"
# FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432"
-(upgrade_flutter) 3< "$PROG_NAME"
-
# FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as
# separate space-separated args.
"$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@"
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
index 99455ae64..f5b0cb59c 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
@@ -301,13 +301,6 @@ class FlutterCommandRunner extends CommandRunner<void> {
}
_checkFlutterCopy();
- try {
- await globals.flutterVersion.ensureVersionFile();
- } on FileSystemException catch (e) {
- globals.printError('Failed to write the version file to the artifact cache: "$e".');
- globals.printError('Please ensure you have permissions in the artifact cache directory.');
- throwToolExit('Failed to write the version file');
- }
final bool machineFlag = topLevelResults['machine'] as bool;
if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool && !machineFlag) {
await globals.flutterVersion.checkFlutterVersionFreshness();

View file

@ -0,0 +1,63 @@
diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart
index 8e511eefd..fbc7d6ac3 100644
--- a/dev/devicelab/lib/framework/runner.dart
+++ b/dev/devicelab/lib/framework/runner.dart
@@ -126,7 +126,7 @@ Future<void> cleanupSystem() async {
print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)');
final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.');
- recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir);
+ recursiveCopy(Directory(path.join(homeDirPath, '.cache', 'flutter', 'artifacts', 'gradle_wrapper')), tempDir);
copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'app', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper')));
if (!Platform.isWindows) {
await exec(
diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart
index 79b06949f..9040ba0a8 100644
--- a/packages/flutter_tools/lib/src/asset.dart
+++ b/packages/flutter_tools/lib/src/asset.dart
@@ -6,6 +6,7 @@ import 'dart:async';
import 'package:yaml/yaml.dart';
+import 'base/common.dart';
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/utils.dart';
@@ -325,7 +326,7 @@ List<_Asset> _getMaterialAssets(String fontSet) {
for (final Map<dynamic, dynamic> font in family['fonts']) {
final Uri entryUri = globals.fs.path.toUri(font['asset'] as String);
result.add(_Asset(
- baseDir: globals.fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'),
+ baseDir: globals.fs.path.join(homeDirPath, '.cache', 'flutter', 'artifacts', 'material_fonts'),
relativeUri: Uri(path: entryUri.pathSegments.last),
entryUri: entryUri,
));
diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart
index 715189938..5afb2a0db 100644
--- a/packages/flutter_tools/lib/src/cache.dart
+++ b/packages/flutter_tools/lib/src/cache.dart
@@ -189,8 +189,14 @@ class Cache {
return;
}
assert(_lock == null);
+
+ final Directory dir = globals.fs.directory(globals.fs.path.join(homeDirPath, '.cache', 'flutter'));
+ if (!dir.existsSync()) {
+ dir.createSync(recursive: true);
+ os.chmod(dir, '755');
+ }
final File lockFile =
- globals.fs.file(globals.fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile'));
+ globals.fs.file(globals.fs.path.join(homeDirPath, '.cache', 'flutter', 'lockfile'));
try {
_lock = lockFile.openSync(mode: FileMode.write);
} on FileSystemException catch (e) {
@@ -290,7 +296,7 @@ class Cache {
if (_rootOverride != null) {
return _fileSystem.directory(_fileSystem.path.join(_rootOverride.path, 'bin', 'cache'));
} else {
- return _fileSystem.directory(_fileSystem.path.join(flutterRoot, 'bin', 'cache'));
+ return _fileSystem.directory(_fileSystem.path.join(homeDirPath, '.cache', 'flutter'));
}
}

View file

@ -0,0 +1,31 @@
diff --git a/bin/flutter b/bin/flutter
index e0c18e235..2c3fb7ddd 100755
--- a/bin/flutter
+++ b/bin/flutter
@@ -185,8 +185,6 @@ fi
# FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS"
# FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432"
-(upgrade_flutter) 3< "$PROG_NAME"
-
# FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as
# separate space-separated args.
"$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@"
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
index 99455ae64..f5b0cb59c 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
@@ -301,13 +301,6 @@ class FlutterCommandRunner extends CommandRunner<void> {
}
_checkFlutterCopy();
- try {
- await globals.flutterVersion.ensureVersionFile();
- } on FileSystemException catch (e) {
- globals.printError('Failed to write the version file to the artifact cache: "$e".');
- globals.printError('Please ensure you have permissions in the artifact cache directory.');
- throwToolExit('Failed to write the version file');
- }
final bool machineFlag = topLevelResults['machine'] as bool;
if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool && !machineFlag) {
await globals.flutterVersion.checkFlutterVersionFreshness();

View file

@ -0,0 +1,63 @@
diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart
index 8e511eefd..fbc7d6ac3 100644
--- a/dev/devicelab/lib/framework/runner.dart
+++ b/dev/devicelab/lib/framework/runner.dart
@@ -126,7 +126,7 @@ Future<void> cleanupSystem() async {
print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)');
final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.');
- recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir);
+ recursiveCopy(Directory(path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter', 'artifacts', 'gradle_wrapper')), tempDir);
copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'app', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper')));
if (!Platform.isWindows) {
await exec(
diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart
index 79b06949f..9040ba0a8 100644
--- a/packages/flutter_tools/lib/src/asset.dart
+++ b/packages/flutter_tools/lib/src/asset.dart
@@ -6,6 +6,7 @@ import 'dart:async';
import 'package:yaml/yaml.dart';
+import 'base/common.dart';
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/utils.dart';
@@ -325,7 +326,7 @@ List<_Asset> _getMaterialAssets(String fontSet) {
for (final Map<dynamic, dynamic> font in family['fonts']) {
final Uri entryUri = globals.fs.path.toUri(font['asset'] as String);
result.add(_Asset(
- baseDir: globals.fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'),
+ baseDir: globals.fs.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter', 'artifacts', 'material_fonts'),
relativeUri: Uri(path: entryUri.pathSegments.last),
entryUri: entryUri,
));
diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart
index 715189938..5afb2a0db 100644
--- a/packages/flutter_tools/lib/src/cache.dart
+++ b/packages/flutter_tools/lib/src/cache.dart
@@ -189,8 +189,14 @@ class Cache {
return;
}
assert(_lock == null);
+
+ final Directory dir = globals.fs.directory(globals.fs.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter'));
+ if (!dir.existsSync()) {
+ dir.createSync(recursive: true);
+ globals.os.chmod(dir, '755');
+ }
final File lockFile =
- globals.fs.file(globals.fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile'));
+ globals.fs.file(globals.fs.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter', 'lockfile'));
try {
_lock = lockFile.openSync(mode: FileMode.write);
} on FileSystemException catch (e) {
@@ -290,7 +296,7 @@ class Cache {
if (_rootOverride != null) {
return _fileSystem.directory(_fileSystem.path.join(_rootOverride.path, 'bin', 'cache'));
} else {
- return _fileSystem.directory(_fileSystem.path.join(flutterRoot, 'bin', 'cache'));
+ return _fileSystem.directory(_fileSystem.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter'));
}
}

View file

@ -0,0 +1,31 @@
diff --git a/bin/flutter b/bin/flutter
index 3955f8f39..1e7573d30 100755
--- a/bin/flutter
+++ b/bin/flutter
@@ -185,8 +185,6 @@ fi
# FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS"
# FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432"
-(upgrade_flutter) 3< "$PROG_NAME"
-
# FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as
# separate space-separated args.
"$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@"
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
index 5e45819d9..ab748b059 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
@@ -377,13 +377,6 @@ class FlutterCommandRunner extends CommandRunner<void> {
}
_checkFlutterCopy();
- try {
- await FlutterVersion.instance.ensureVersionFile();
- } on FileSystemException catch (e) {
- printError('Failed to write the version file to the artifact cache: "$e".');
- printError('Please ensure you have permissions in the artifact cache directory.');
- throwToolExit('Failed to write the version file');
- }
if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool) {
await FlutterVersion.instance.checkFlutterVersionFreshness();
}

View file

@ -0,0 +1,63 @@
diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart
index 9fae74726..d88d6ecbb 100644
--- a/dev/devicelab/lib/framework/runner.dart
+++ b/dev/devicelab/lib/framework/runner.dart
@@ -126,7 +126,7 @@ Future<void> cleanupSystem() async {
print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)');
final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew';
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.');
- recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir);
+ recursiveCopy(Directory(path.join(homeDirPath, '.cache', 'flutter', 'artifacts', 'gradle_wrapper')), tempDir);
copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'app', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper')));
if (!Platform.isWindows) {
await exec(
diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart
index e6216c737..5ab497092 100644
--- a/packages/flutter_tools/lib/src/asset.dart
+++ b/packages/flutter_tools/lib/src/asset.dart
@@ -6,6 +6,7 @@ import 'dart:async';
import 'package:yaml/yaml.dart';
+import 'base/common.dart';
import 'base/context.dart';
import 'base/file_system.dart';
import 'base/platform.dart';
@@ -326,7 +327,7 @@ List<_Asset> _getMaterialAssets(String fontSet) {
for (Map<dynamic, dynamic> font in family['fonts']) {
final Uri entryUri = fs.path.toUri(font['asset'] as String);
result.add(_Asset(
- baseDir: fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'),
+ baseDir: fs.path.join(homeDirPath, '.cache', 'flutter', 'artifacts', 'material_fonts'),
relativeUri: Uri(path: entryUri.pathSegments.last),
entryUri: entryUri,
));
diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart
index 5e1950b56..45585f9c0 100644
--- a/packages/flutter_tools/lib/src/cache.dart
+++ b/packages/flutter_tools/lib/src/cache.dart
@@ -164,8 +164,14 @@ class Cache {
return;
}
assert(_lock == null);
+
+ final Directory dir = fs.directory(fs.path.join(homeDirPath, '.cache', 'flutter'));
+ if (!dir.existsSync()) {
+ dir.createSync(recursive: true);
+ os.chmod(dir, '755');
+ }
final File lockFile =
- fs.file(fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile'));
+ fs.file(fs.path.join(homeDirPath, '.cache', 'flutter', 'lockfile'));
try {
_lock = lockFile.openSync(mode: FileMode.write);
} on FileSystemException catch (e) {
@@ -239,7 +245,7 @@ class Cache {
if (_rootOverride != null) {
return fs.directory(fs.path.join(_rootOverride.path, 'bin', 'cache'));
} else {
- return fs.directory(fs.path.join(flutterRoot, 'bin', 'cache'));
+ return fs.directory(fs.path.join(homeDirPath, '.cache', 'flutter'));
}
}

View file

@ -8181,6 +8181,10 @@ in
inherit (darwin.apple_sdk.frameworks) Security;
};
flutterPackages =
recurseIntoAttrs (callPackage ../development/compilers/flutter { });
flutter = flutterPackages.stable;
fpc = callPackage ../development/compilers/fpc { };
gambit = callPackage ../development/compilers/gambit { stdenv = gccStdenv; };