install static method
Future<AndroidSigningSession>
install(
- AndroidSigningCredentials credentials, {
- ProcessRunner processRunner = const SystemProcessRunner(),
Installs upload-key material without changing the consumer repository.
Implementation
static Future<AndroidSigningSession> install(
AndroidSigningCredentials credentials, {
ProcessRunner processRunner = const SystemProcessRunner(),
}) async {
final directory = await Directory.systemTemp.createTemp(
'smf-android-sign-',
);
final keystorePath = p.join(directory.path, 'upload-keystore');
try {
List<int> keystore;
try {
keystore = base64Decode(credentials.keystoreBase64);
} on FormatException catch (error) {
throw SmfError(
'Android upload keystore is not valid Base64.',
SmfErrorCode.invalidCredential,
cause: error,
);
}
SmfError.check(
keystore.isNotEmpty,
'Android upload keystore decoded to an empty file.',
SmfErrorCode.invalidCredential,
);
await File(keystorePath).writeAsBytes(keystore, flush: true);
await processRunner.run('/bin/chmod', <String>[
'700',
directory.path,
]);
await processRunner.run('/bin/chmod', <String>[
'600',
keystorePath,
]);
return AndroidSigningSession._(
directory: directory,
keystorePath: keystorePath,
);
} on Object {
await directory.delete(recursive: true);
rethrow;
}
}