From 29d59e3cb7dcd74a8e6ecb57c5c2b11fa106cba0 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Tue, 27 Feb 2018 13:15:32 -0800 Subject: [PATCH] Switch Mac packaging to use .zip files. (#14894) We can't use .tar.xz on Mac because although it can unpack them on the command line (with tar), the "Archive Utility" that runs when you double-click on them just does some crazy behavior (it converts it to a compressed cpio archive, and when you double-click on that, it converts it back to .tar.xz, without ever unpacking it!) So, this changes the script to use .zip for Mac, and the files are about 220MB larger than they need to be. --- dev/bots/prepare_package.dart | 37 ++++++++++++++++++------- dev/bots/test/prepare_package_test.dart | 20 +++++++------ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart index 6cd6ec73ed..5f12782e42 100644 --- a/dev/bots/prepare_package.dart +++ b/dev/bots/prepare_package.dart @@ -248,7 +248,14 @@ class ArchiveCreator { /// Used when an output filename is not given. String get _archiveName { final String os = platform.operatingSystem.toLowerCase(); - final String suffix = platform.isWindows ? 'zip' : 'tar.xz'; + // We don't use .tar.xz on Mac because although it can unpack them + // on the command line (with tar), the "Archive Utility" that runs + // when you double-click on them just does some crazy behavior (it + // converts it to a compressed cpio archive, and when you double + // click on that, it converts it back to .tar.xz, without ever + // unpacking it!) So, we use .zip for Mac, and the files are about + // 220MB larger than they need to be. :-( + final String suffix = platform.isLinux ? 'tar.xz' : 'zip'; return 'flutter_${os}_$_version-$branchName.$suffix'; } @@ -364,15 +371,25 @@ class ArchiveCreator { /// /// May only be run on Windows (since 7Zip is not available on other platforms). Future _createZipArchive(File output, Directory source) { - assert(platform.isWindows); // 7Zip is only available on Windows. - final List commandLine = [ - '7za', - 'a', - '-tzip', - '-mx=9', - output.absolute.path, - path.basename(source.path), - ]; + List commandLine; + if (platform.isWindows) { + commandLine = [ + '7za', + 'a', + '-tzip', + '-mx=9', + output.absolute.path, + path.basename(source.path), + ]; + } else { + commandLine = [ + 'zip', + '-r', + '-9', + output.absolute.path, + path.basename(source.path), + ]; + } return _processRunner.runProcess(commandLine, workingDirectory: new Directory(path.dirname(source.absolute.path))); } diff --git a/dev/bots/test/prepare_package_test.dart b/dev/bots/test/prepare_package_test.dart index e1ba9d1088..f9c18fe97d 100644 --- a/dev/bots/test/prepare_package_test.dart +++ b/dev/bots/test/prepare_package_test.dart @@ -113,10 +113,12 @@ void main() { 'git clean -f -X **/.packages': null, }); final String archiveName = path.join(tmpDir.absolute.path, - 'flutter_${platformName}_v1.2.3-dev${platform.isWindows ? '.zip' : '.tar.xz'}'); + 'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}'); if (platform.isWindows) { calls['7za a -tzip -mx=9 $archiveName flutter'] = null; - } else { + } else if (platform.isMacOS) { + calls['zip -r -9 $archiveName flutter'] = null; + } else if (platform.isLinux) { calls['tar cJf $archiveName flutter'] = null; } processManager.fakeResults = calls; @@ -156,10 +158,12 @@ void main() { 'git clean -f -X **/.packages': null, }); final String archiveName = path.join(tmpDir.absolute.path, - 'flutter_${platformName}_v1.2.3-dev${platform.isWindows ? '.zip' : '.tar.xz'}'); + 'flutter_${platformName}_v1.2.3-dev${platform.isLinux ? '.tar.xz' : '.zip'}'); if (platform.isWindows) { calls['7za a -tzip -mx=9 $archiveName flutter'] = null; - } else { + } else if (platform.isMacOS) { + calls['zip -r -9 $archiveName flutter'] = null; + } else if (platform.isLinux) { calls['tar cJf $archiveName flutter'] = null; } processManager.fakeResults = calls; @@ -211,8 +215,8 @@ void main() { test('calls the right processes', () async { final String releasesName = 'releases_$platformName.json'; - final String archiveName = platform.isWindows ? 'archive.zip' : 'archive.tar.xz'; - final String archiveMime = platform.isWindows ? 'application/zip' : 'application/x-gtar'; + final String archiveName = platform.isLinux ? 'archive.tar.xz' : 'archive.zip'; + final String archiveMime = platform.isLinux ? 'application/x-gtar' : 'application/zip'; final String archivePath = path.join(tempDir.absolute.path, archiveName); final String gsArchivePath = 'gs://flutter_infra/releases/dev/$platformName/$archiveName'; final String jsonPath = path.join(tempDir.absolute.path, releasesName); @@ -225,12 +229,12 @@ void main() { }, "releases": { "6da8ec6bd0c4801b80d666869e4069698561c043": { - "${platformName}_archive": "dev/linux/flutter_${platformName}_0.21.0-beta.tar.xz", + "${platformName}_archive": "dev/linux/flutter_${platformName}_0.21.0-beta.zip", "release_date": "2017-12-19T10:30:00,847287019-08:00", "version": "0.21.0-beta" }, "f88c60b38c3a5ef92115d24e3da4175b4890daba": { - "${platformName}_archive": "dev/linux/flutter_${platformName}_0.22.0-dev.tar.xz", + "${platformName}_archive": "dev/linux/flutter_${platformName}_0.22.0-dev.zip", "release_date": "2018-01-19T13:30:09,728487019-08:00", "version": "0.22.0-dev" }