Fix package preparation on Windows (#15720)
This commit is contained in:
parent
cc1cf9e12a
commit
d9e3715620
@ -165,10 +165,11 @@ class ProcessRunner {
|
|||||||
|
|
||||||
final int exitCode = await allComplete();
|
final int exitCode = await allComplete();
|
||||||
if (exitCode != 0 && !failOk) {
|
if (exitCode != 0 && !failOk) {
|
||||||
final String message =
|
final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} failed';
|
||||||
'Running "${commandLine.join(' ')}" in ${workingDirectory.path} failed';
|
|
||||||
throw new ProcessRunnerException(
|
throw new ProcessRunnerException(
|
||||||
message, new ProcessResult(0, exitCode, null, 'returned $exitCode'));
|
message,
|
||||||
|
new ProcessResult(0, exitCode, null, 'returned $exitCode'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return utf8.decoder.convert(output).trim();
|
return utf8.decoder.convert(output).trim();
|
||||||
}
|
}
|
||||||
@ -350,13 +351,17 @@ class ArchiveCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _runFlutter(List<String> args, {Directory workingDirectory}) {
|
Future<String> _runFlutter(List<String> args, {Directory workingDirectory}) {
|
||||||
return _processRunner.runProcess(<String>[_flutter]..addAll(args),
|
return _processRunner.runProcess(
|
||||||
workingDirectory: workingDirectory ?? flutterRoot);
|
<String>[_flutter]..addAll(args),
|
||||||
|
workingDirectory: workingDirectory ?? flutterRoot,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _runGit(List<String> args, {Directory workingDirectory}) {
|
Future<String> _runGit(List<String> args, {Directory workingDirectory}) {
|
||||||
return _processRunner.runProcess(<String>['git']..addAll(args),
|
return _processRunner.runProcess(
|
||||||
workingDirectory: workingDirectory ?? flutterRoot);
|
<String>['git']..addAll(args),
|
||||||
|
workingDirectory: workingDirectory ?? flutterRoot,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unpacks the given zip file into the currentDirectory (if set), or the
|
/// Unpacks the given zip file into the currentDirectory (if set), or the
|
||||||
@ -400,8 +405,10 @@ class ArchiveCreator {
|
|||||||
path.basename(source.path),
|
path.basename(source.path),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return _processRunner.runProcess(commandLine,
|
return _processRunner.runProcess(
|
||||||
workingDirectory: new Directory(path.dirname(source.absolute.path)));
|
commandLine,
|
||||||
|
workingDirectory: new Directory(path.dirname(source.absolute.path)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a tar archive from the directory source.
|
/// Create a tar archive from the directory source.
|
||||||
@ -427,7 +434,7 @@ class ArchivePublisher {
|
|||||||
this.platform: const LocalPlatform(),
|
this.platform: const LocalPlatform(),
|
||||||
}) : assert(revision.length == 40),
|
}) : assert(revision.length == 40),
|
||||||
platformName = platform.operatingSystem.toLowerCase(),
|
platformName = platform.operatingSystem.toLowerCase(),
|
||||||
metadataGsPath = '$gsReleaseFolder/releases_${platform.operatingSystem.toLowerCase()}.json',
|
metadataGsPath = '$gsReleaseFolder/${getMetadataFilename(platform)}',
|
||||||
_processRunner = new ProcessRunner(
|
_processRunner = new ProcessRunner(
|
||||||
processManager: processManager,
|
processManager: processManager,
|
||||||
subprocessOutput: subprocessOutput,
|
subprocessOutput: subprocessOutput,
|
||||||
@ -443,8 +450,8 @@ class ArchivePublisher {
|
|||||||
final File outputFile;
|
final File outputFile;
|
||||||
final ProcessRunner _processRunner;
|
final ProcessRunner _processRunner;
|
||||||
String get branchName => getBranchName(branch);
|
String get branchName => getBranchName(branch);
|
||||||
String get destinationArchivePath =>
|
String get destinationArchivePath => '$branchName/$platformName/${path.basename(outputFile.path)}';
|
||||||
'$branchName/$platformName/${path.basename(outputFile.path)}';
|
static String getMetadataFilename(Platform platform) => 'releases_${platform.operatingSystem.toLowerCase()}.json';
|
||||||
|
|
||||||
/// Publish the archive to Google Storage.
|
/// Publish the archive to Google Storage.
|
||||||
Future<Null> publishArchive() async {
|
Future<Null> publishArchive() async {
|
||||||
@ -455,7 +462,15 @@ class ArchivePublisher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> _updateMetadata() async {
|
Future<Null> _updateMetadata() async {
|
||||||
final String currentMetadata = await _runGsUtil(<String>['cat', metadataGsPath]);
|
// We can't just cat the metadata from the server with 'gsutil cat', because
|
||||||
|
// Windows wants to echo the commands that execute in gsutil.bat to the
|
||||||
|
// stdout when we do that. So, we copy the file locally and then read it
|
||||||
|
// back in.
|
||||||
|
final File metadataFile = new File(
|
||||||
|
path.join(tempDir.absolute.path, getMetadataFilename(platform)),
|
||||||
|
);
|
||||||
|
await _runGsUtil(<String>['cp', metadataGsPath, metadataFile.absolute.path]);
|
||||||
|
final String currentMetadata = metadataFile.readAsStringSync();
|
||||||
if (currentMetadata.isEmpty) {
|
if (currentMetadata.isEmpty) {
|
||||||
throw new ProcessRunnerException('Empty metadata received from server');
|
throw new ProcessRunnerException('Empty metadata received from server');
|
||||||
}
|
}
|
||||||
@ -485,14 +500,16 @@ class ArchivePublisher {
|
|||||||
metadata['version'] = version;
|
metadata['version'] = version;
|
||||||
jsonData['releases'][revision][branchName] = metadata;
|
jsonData['releases'][revision][branchName] = metadata;
|
||||||
|
|
||||||
final File tempFile = new File(path.join(tempDir.absolute.path, 'releases_$platformName.json'));
|
|
||||||
const JsonEncoder encoder = const JsonEncoder.withIndent(' ');
|
const JsonEncoder encoder = const JsonEncoder.withIndent(' ');
|
||||||
tempFile.writeAsStringSync(encoder.convert(jsonData));
|
metadataFile.writeAsStringSync(encoder.convert(jsonData));
|
||||||
await _cloudCopy(tempFile.absolute.path, metadataGsPath);
|
await _cloudCopy(metadataFile.absolute.path, metadataGsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _runGsUtil(List<String> args,
|
Future<String> _runGsUtil(
|
||||||
{Directory workingDirectory, bool failOk: false}) async {
|
List<String> args, {
|
||||||
|
Directory workingDirectory,
|
||||||
|
bool failOk: false,
|
||||||
|
}) async {
|
||||||
return _processRunner.runProcess(
|
return _processRunner.runProcess(
|
||||||
<String>['gsutil']..addAll(args),
|
<String>['gsutil']..addAll(args),
|
||||||
workingDirectory: workingDirectory,
|
workingDirectory: workingDirectory,
|
||||||
|
@ -143,10 +143,10 @@ void main() {
|
|||||||
await creator.createArchive();
|
await creator.createArchive();
|
||||||
expect(
|
expect(
|
||||||
verify(processManager.start(
|
verify(processManager.start(
|
||||||
captureAny,
|
typed(captureAny),
|
||||||
workingDirectory: captureAny,
|
workingDirectory: typed(captureAny, named: 'workingDirectory'),
|
||||||
environment: captureAny,
|
environment: typed(captureAny, named: 'environment'),
|
||||||
)).captured[1]['PUB_CACHE'],
|
)).captured[2]['PUB_CACHE'],
|
||||||
endsWith(path.join('flutter', '.pub-cache')),
|
endsWith(path.join('flutter', '.pub-cache')),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -257,10 +257,11 @@ void main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
|
new File(jsonPath).writeAsStringSync(releasesJson);
|
||||||
final Map<String, List<ProcessResult>> calls = <String, List<ProcessResult>>{
|
final Map<String, List<ProcessResult>> calls = <String, List<ProcessResult>>{
|
||||||
'gsutil rm $gsArchivePath': null,
|
'gsutil rm $gsArchivePath': null,
|
||||||
'gsutil -h Content-Type:$archiveMime cp $archivePath $gsArchivePath': null,
|
'gsutil -h Content-Type:$archiveMime cp $archivePath $gsArchivePath': null,
|
||||||
'gsutil cat $gsJsonPath': <ProcessResult>[new ProcessResult(0, 0, releasesJson, '')],
|
'gsutil cp $gsJsonPath $jsonPath': null,
|
||||||
'gsutil rm $gsJsonPath': null,
|
'gsutil rm $gsJsonPath': null,
|
||||||
'gsutil -h Content-Type:application/json cp $jsonPath $gsJsonPath': null,
|
'gsutil -h Content-Type:application/json cp $jsonPath $gsJsonPath': null,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user