From 8986e95dca62c694921609f1f134f1071b5d6382 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20Rivi=C3=A8re?= <babathriviere@gmail.com>
Date: Sun, 5 Apr 2020 00:41:19 +0200
Subject: [PATCH] flutter: update channels + fix dev channel

---
 .../development/compilers/flutter/default.nix | 17 ++---
 .../development/compilers/flutter/flutter.nix |  5 +-
 .../flutter/patches/beta/move-cache.patch     | 12 ++--
 .../patches/dev/disable-auto-update.patch     |  1 -
 .../flutter/patches/dev/move-cache.patch      | 63 -------------------
 5 files changed, 18 insertions(+), 80 deletions(-)
 delete mode 120000 pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch
 delete mode 100644 pkgs/development/compilers/flutter/patches/dev/move-cache.patch

diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix
index 89e05be1e4e..afc8fbd7f49 100644
--- a/pkgs/development/compilers/flutter/default.nix
+++ b/pkgs/development/compilers/flutter/default.nix
@@ -9,22 +9,23 @@ in {
   stable = mkFlutter {
     pname = "flutter";
     channel = "stable";
-    version = "1.12.13+hotfix.8";
-    sha256Hash = "01ik4xckr3fp65sq4g0g6wy5b9i0r49l643xmbxa6z9k21sby46d";
+    version = "1.12.13+hotfix.9";
+    sha256Hash = "1ql3zvmmk5zk47y30lajxaam04q6vr373dayq15jv4vpc0fzif1y";
     patches = getPatches ./patches/stable;
   };
   beta = mkFlutter {
     pname = "flutter-beta";
     channel = "beta";
-    version = "1.14.6";
-    sha256Hash = "1a79pr741zkr39p5gc3p9x59d70vm60hpz2crgc53ysglj4ycigy";
+    version = "1.15.17";
+    sha256Hash = "0iil6y6y477dhjgzx54ab5m9nj0jg4xl8x4zzd9iwh8m756r7qsd";
     patches = getPatches ./patches/beta;
   };
-  dev = mkFlutter {
+  dev = mkFlutter rec {
     pname = "flutter-dev";
     channel = "dev";
-    version = "1.15.3";
-    sha256Hash = "06mawwqf7q7wdmzlyxlrlblhnnk4ckf3vp92lplippdh3d52r93i";
-    patches = getPatches ./patches/dev;
+    version = "1.17.0-dev.5.0";
+    filename = "flutter_linux_${version}-${channel}.tar.xz";
+    sha256Hash = "0ks2jf2bd42y2jsc91p33r57q7j3m94d8ihkmlxzwi53x1mwp0pk";
+    patches = getPatches ./patches/beta;
   };
 }
diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix
index 1b9c482d6e9..fad2a646a16 100644
--- a/pkgs/development/compilers/flutter/flutter.nix
+++ b/pkgs/development/compilers/flutter/flutter.nix
@@ -1,4 +1,5 @@
-{ channel, pname, version, sha256Hash, patches }:
+{ channel, pname, version, sha256Hash, patches
+, filename ? "flutter_linux_v${version}-${channel}.tar.xz" }:
 
 { bash, buildFHSUserEnv, cacert, coreutils, git, makeWrapper, runCommand, stdenv
 , fetchurl, alsaLib, dbus, expat, libpulseaudio, libuuid, libX11, libxcb
@@ -11,7 +12,7 @@ let
 
     src = fetchurl {
       url =
-        "https://storage.googleapis.com/flutter_infra/releases/${channel}/linux/flutter_linux_v${version}-${channel}.tar.xz";
+        "https://storage.googleapis.com/flutter_infra/releases/${channel}/linux/${filename}";
       sha256 = sha256Hash;
     };
 
diff --git a/pkgs/development/compilers/flutter/patches/beta/move-cache.patch b/pkgs/development/compilers/flutter/patches/beta/move-cache.patch
index 303f8dd3739..4672d4c625d 100644
--- a/pkgs/development/compilers/flutter/patches/beta/move-cache.patch
+++ b/pkgs/development/compilers/flutter/patches/beta/move-cache.patch
@@ -7,7 +7,7 @@ index 8e511eefd..fbc7d6ac3 100644
      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);
++    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(
@@ -28,7 +28,7 @@ index 79b06949f..9040ba0a8 100644
        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'),
++        baseDir: globals.fs.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter', 'artifacts', 'material_fonts'),
          relativeUri: Uri(path: entryUri.pathSegments.last),
          entryUri: entryUri,
        ));
@@ -41,14 +41,14 @@ index 715189938..5afb2a0db 100644
      }
      assert(_lock == null);
 +
-+    final Directory dir = globals.fs.directory(globals.fs.path.join(homeDirPath, '.cache', 'flutter'));
++    final Directory dir = globals.fs.directory(globals.fs.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter'));
 +    if (!dir.existsSync()) {
 +      dir.createSync(recursive: true);
-+      os.chmod(dir, '755');
++      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(homeDirPath, '.cache', 'flutter', '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) {
@@ -57,7 +57,7 @@ index 715189938..5afb2a0db 100644
        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'));
++      return _fileSystem.directory(_fileSystem.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter'));
      }
    }
  
diff --git a/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch
deleted file mode 120000
index 2c92799f3bb..00000000000
--- a/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch
+++ /dev/null
@@ -1 +0,0 @@
-../beta/disable-auto-update.patch
\ No newline at end of file
diff --git a/pkgs/development/compilers/flutter/patches/dev/move-cache.patch b/pkgs/development/compilers/flutter/patches/dev/move-cache.patch
deleted file mode 100644
index 4672d4c625d..00000000000
--- a/pkgs/development/compilers/flutter/patches/dev/move-cache.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-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'));
-     }
-   }
-