blob: bb7ecdfdc21aa6189b16e21570b32f292f23fd1f [file] [log] [blame]
// Copyright 2024, 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 'package:file/file.dart';
import '../build.dart';
import '../cipd.dart';
import '../fetch.dart';
import '../useful_directory.dart';
class FirefoxPackage extends CipdPackage with HttpDownloader, UnzipBuild {
FirefoxPackage._(String name, Uri source, String version)
: super(name, source, version);
factory FirefoxPackage(String platform, String os, String versionAndBuild) {
final parts = versionAndBuild.split('+');
if (parts.length != 2) {
ArgumentError.value(versionAndBuild, 'versionAndBuild',
'Firefox versions must contain exactly one "+" character.');
}
final version = parts.first;
final build = parts.last;
final extension = os == 'linux-x86_64' ? 'tar.bz2' : 'zip';
final archiveName = 'firefox-$version.$extension';
// Using 'candidates' because 'releases' only has installers on Windows.
final path = 'pub/firefox/candidates'
'/$version-candidates/build$build/$os/en-US/$archiveName';
final source = Uri.https('archive.mozilla.org', path);
return FirefoxPackage._('dart/browsers/firefox/$platform', source, version);
}
@override
Future<bool> check(Directory artifacts) async =>
await artifacts.resolveFile('firefox/firefox').exists() ||
await artifacts
.resolveFile('Firefox.app/Contents/MacOS/firefox')
.exists() ||
await artifacts.resolveFile('firefox/firefox.exe').exists();
}