[infra] Remove update homebrew scripts
They have been moved to dart-lang/homebrew-dart.
Change-Id: I9f81e804f07a7e8426b8034a45e5be5b57bebffa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205784
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
diff --git a/tools/apps/update_homebrew/.gitignore b/tools/apps/update_homebrew/.gitignore
deleted file mode 100644
index e4da250a3..0000000
--- a/tools/apps/update_homebrew/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.packages
-.dart_tool
diff --git a/tools/apps/update_homebrew/bin/generate.dart b/tools/apps/update_homebrew/bin/generate.dart
deleted file mode 100644
index ea29e06..0000000
--- a/tools/apps/update_homebrew/bin/generate.dart
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:io';
-
-import 'package:args/args.dart';
-import 'package:path/path.dart' as p;
-import 'package:stack_trace/stack_trace.dart';
-import 'package:update_homebrew/update_homebrew.dart';
-
-void main(List<String> args) async {
- final parser = ArgParser()
- ..addOption('revision', abbr: 'r')
- ..addOption('channel', abbr: 'c', allowed: supportedChannels);
-
- final options = parser.parse(args);
- final revision = options['revision'] as String;
- final channel = options['channel'] as String;
- if ([revision, channel].contains(null)) {
- print(
- "Usage: generate.dart -r revision -c channel <path_to_existing_dart.rb>");
- exitCode = 1;
- return;
- }
-
- if (options.rest.length != 1) {
- print("Pass in the path to an existing '$dartRbFileName' file.");
- exitCode = 1;
- return;
- }
- final existingDartRb = options.rest.single;
-
- var file = File(existingDartRb);
-
- if (!file.existsSync()) {
- print("Expected '$existingDartRb' to exist.");
- exitCode = 1;
- return;
- }
-
- if (p.basename(existingDartRb) != dartRbFileName) {
- print("Expected provided path to end with '$dartRbFileName'.");
- exitCode = 1;
- }
-
- await Chain.capture(() async {
- await writeHomebrewInfo(channel, revision, file.parent.path);
- }, onError: (error, chain) {
- print(error);
- print(chain.terse);
- exitCode = 1;
- });
-}
diff --git a/tools/apps/update_homebrew/bin/ssh_with_key b/tools/apps/update_homebrew/bin/ssh_with_key
deleted file mode 100755
index 6df4a04..0000000
--- a/tools/apps/update_homebrew/bin/ssh_with_key
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env bash
-ssh -i $SSH_KEY_PATH $@
diff --git a/tools/apps/update_homebrew/bin/update_homebrew.dart b/tools/apps/update_homebrew/bin/update_homebrew.dart
deleted file mode 100644
index 68dc9e0..0000000
--- a/tools/apps/update_homebrew/bin/update_homebrew.dart
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:io';
-
-import 'package:args/args.dart';
-import 'package:stack_trace/stack_trace.dart';
-import 'package:update_homebrew/update_homebrew.dart';
-
-void main(List<String> args) async {
- final parser = ArgParser()
- ..addFlag('dry-run', abbr: 'n')
- ..addOption('revision', abbr: 'r')
- ..addOption('channel', abbr: 'c', allowed: supportedChannels)
- ..addOption('key', abbr: 'k');
- final options = parser.parse(args);
- final dryRun = options['dry-run'] as bool;
- final revision = options['revision'] as String;
- final channel = options['channel'] as String;
- if ([revision, channel].contains(null)) {
- print(
- "Usage: update_homebrew.dart -r version -c channel [-k ssh_key] [-n]\n"
- " ssh_key should allow pushes to $githubRepo on github");
- exitCode = 1;
- return;
- }
-
- Map<String, String> gitEnvironment;
-
- final key = options['key'] as String;
- if (key != null) {
- final sshWrapper = Platform.script.resolve('ssh_with_key').toFilePath();
- gitEnvironment = {'GIT_SSH': sshWrapper, 'SSH_KEY_PATH': key};
- }
-
- await Chain.capture(() async {
- var tempDir = await Directory.systemTemp.createTemp('update_homebrew');
-
- try {
- var repository = tempDir.path;
-
- await runGit(['clone', 'git@github.com:$githubRepo.git', '.'], repository,
- gitEnvironment);
- await writeHomebrewInfo(channel, revision, repository);
- await runGit([
- 'commit',
- '-a',
- '-m',
- 'Updated $channel branch to revision $revision'
- ], repository, gitEnvironment);
- if (dryRun) {
- await runGit(['diff', 'origin/master'], repository, gitEnvironment);
- } else {
- await runGit(['push'], repository, gitEnvironment);
- }
- } finally {
- await tempDir.delete(recursive: true);
- }
- }, onError: (error, chain) {
- print(error);
- print(chain.terse);
- exitCode = 1;
- });
-}
diff --git a/tools/apps/update_homebrew/lib/src/impl.dart b/tools/apps/update_homebrew/lib/src/impl.dart
deleted file mode 100644
index 2a07403..0000000
--- a/tools/apps/update_homebrew/lib/src/impl.dart
+++ /dev/null
@@ -1,65 +0,0 @@
-part of '../update_homebrew.dart';
-
-const _files = [
- 'dartsdk-macos-x64-release.zip',
- 'dartsdk-linux-x64-release.zip',
- 'dartsdk-linux-arm64-release.zip',
- 'dartsdk-linux-ia32-release.zip',
- 'dartsdk-linux-arm-release.zip',
-];
-
-const _host = 'https://storage.googleapis.com/dart-archive/channels';
-
-Future<String> _getHash256(
- String channel, String version, String download) async {
- var client = http.Client();
- try {
- var api = storage.StorageApi(client);
- var url = 'channels/$channel/release/$version/sdk/$download.sha256sum';
- var media = await api.objects.get('dart-archive', url,
- downloadOptions: DownloadOptions.FullMedia) as Media;
- var hashLine = await ascii.decodeStream(media.stream);
- return RegExp('[0-9a-fA-F]*').stringMatch(hashLine);
- } finally {
- client.close();
- }
-}
-
-Future<void> _updateFormula(String channel, File file, String version,
- Map<String, String> hashes) async {
- var contents = await file.readAsString();
-
- // Replace the version identifier. Formulas with stable and pre-release
- // versions have multiple identifiers and only the right one should be
- // updated.
- var versionId = channel == 'stable'
- ? RegExp(r'version \"\d+\.\d+.\d+\"')
- : RegExp(r'version \"\d+\.\d+.\d+\-.+\"');
- contents = contents.replaceAll(versionId, 'version "$version"');
-
- // Extract files and hashes that are stored in the formula in this format:
- // url "<url base>/<channel>/release/<version>/sdk/<artifact>.zip"
- // sha256 "<hash>"
- var filesAndHashes = RegExp(
- 'channels/$channel/release'
- r'/(\d[\w\d\-\.]*)/sdk/([\w\d\-\.]+)\"\n(\s+)sha256 \"[\da-f]+\"',
- multiLine: true);
- contents = contents.replaceAllMapped(filesAndHashes, (m) {
- var currentVersion = m.group(1);
- if (currentVersion == version) {
- throw new ArgumentError(
- 'Channel $channel is already at version $version in homebrew.');
- }
- var artifact = m.group(2);
- var indent = m.group(3);
- return 'channels/$channel/release/$version/sdk/$artifact"\n'
- '${indent}sha256 "${hashes[artifact]}"';
- });
- await file.writeAsString(contents, flush: true);
-}
-
-Future<Map<String, String>> _getHashes(String channel, String version) async {
- return <String, String>{
- for (var file in _files) file: await _getHash256(channel, version, file)
- };
-}
diff --git a/tools/apps/update_homebrew/lib/update_homebrew.dart b/tools/apps/update_homebrew/lib/update_homebrew.dart
deleted file mode 100644
index e38e51f..0000000
--- a/tools/apps/update_homebrew/lib/update_homebrew.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-import 'dart:async';
-import 'dart:convert';
-import 'dart:io';
-
-import 'package:_discoveryapis_commons/_discoveryapis_commons.dart';
-import 'package:googleapis/storage/v1.dart' as storage;
-import 'package:http/http.dart' as http;
-import 'package:path/path.dart' as p;
-
-part 'src/impl.dart';
-
-const githubRepo = 'dart-lang/homebrew-dart';
-
-const formulaByChannel = {
- 'beta': 'dart-beta.rb',
- 'dev': 'dart.rb',
- 'stable': 'dart.rb'
-};
-
-Iterable<String> get supportedChannels => formulaByChannel.keys;
-
-Future<void> writeHomebrewInfo(
- String channel, String version, String repository) async {
- var formula = File(p.join(repository, formulaByChannel[channel]));
- var hashes = await _getHashes(channel, version);
- await _updateFormula(channel, formula, version, hashes);
-}
-
-Future<void> runGit(List<String> args, String repository,
- Map<String, String> gitEnvironment) async {
- print("git ${args.join(' ')}");
-
- var result = await Process.run('git', args,
- workingDirectory: repository, environment: gitEnvironment);
-
- print(result.stdout);
- print(result.stderr);
-}
diff --git a/tools/apps/update_homebrew/pubspec.yaml b/tools/apps/update_homebrew/pubspec.yaml
deleted file mode 100644
index 9089614..0000000
--- a/tools/apps/update_homebrew/pubspec.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-name: update_homebrew
-
-publish_to: none
-environment:
- sdk: '>=2.0.0 <3.0.0'
-
-dependencies:
- _discoveryapis_commons: ^0.1.3+1
- args: ^1.5.0
- googleapis: ^0.51.0
- http: ^0.11.1+1
- path: ^1.4.1
- stack_trace: ^1.3.2