Merge pull request #76420 from babariviere/flutter-init

flutter: init 1.12.13+hotfix.8
This commit is contained in:
Jörg Thalheim 2020-03-29 14:21:40 +01:00 committed by GitHub
commit 62aa36720c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 414 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 @@
../beta/disable-auto-update.patch

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

@ -8082,6 +8082,10 @@ in
flyctl = callPackage ../development/web/flyctl { };
flutterPackages =
recurseIntoAttrs (callPackage ../development/compilers/flutter { });
flutter = flutterPackages.stable;
fpc = callPackage ../development/compilers/fpc { };
gambit = callPackage ../development/compilers/gambit { stdenv = gccStdenv; };