@@ -38,9 +38,9 @@ class CodesignCommand extends Command<void> {
3838 platform = checkouts.platform,
3939 stdio = checkouts.stdio,
4040 processManager = checkouts.processManager {
41- if (framework != null ) {
42- _framework = framework;
43- }
41+ if (framework != null ) {
42+ _framework = framework;
43+ }
4444 argParser.addFlag (
4545 kVerify,
4646 help:
@@ -89,7 +89,7 @@ class CodesignCommand extends Command<void> {
8989 'For codesigning and verifying the signatures of engine binaries.' ;
9090
9191 @override
92- void run () {
92+ Future < void > run () async {
9393 if (! platform.isMacOS) {
9494 throw ConductorException (
9595 'Error! Expected operating system "macos", actual operating system is: '
@@ -112,29 +112,30 @@ class CodesignCommand extends Command<void> {
112112 'the desired revision and run that version of the conductor.\n ' );
113113 revision = argResults! [kRevision] as String ;
114114 } else {
115- revision = (processManager.runSync (
115+ revision = (( await processManager.run (
116116 < String > ['git' , 'rev-parse' , 'HEAD' ],
117- workingDirectory: framework.checkoutDirectory.path,
118- ).stdout as String ).trim ();
117+ workingDirectory: ( await framework.checkoutDirectory) .path,
118+ )) .stdout as String ).trim ();
119119 assert (revision.isNotEmpty);
120120 }
121121
122- framework.checkout (revision);
122+ await framework.checkout (revision);
123123
124124 // Ensure artifacts present
125- framework.runFlutter (< String > ['precache' , '--android' , '--ios' , '--macos' ]);
125+ await framework.runFlutter (< String > ['precache' , '--android' , '--ios' , '--macos' ]);
126126
127- verifyExist ();
127+ await verifyExist ();
128128 if (argResults! [kSignatures] as bool ) {
129- verifySignatures ();
129+ await verifySignatures ();
130130 }
131131 }
132132
133133 /// Binaries that are expected to be codesigned and have entitlements.
134134 ///
135135 /// This list should be kept in sync with the actual contents of Flutter's
136136 /// cache.
137- List <String > get binariesWithEntitlements {
137+ Future <List <String >> get binariesWithEntitlements async {
138+ final String frameworkCacheDirectory = await framework.cacheDirectory;
138139 return < String > [
139140 'artifacts/engine/android-arm-profile/darwin-x64/gen_snapshot' ,
140141 'artifacts/engine/android-arm-release/darwin-x64/gen_snapshot' ,
@@ -165,15 +166,16 @@ class CodesignCommand extends Command<void> {
165166 'dart-sdk/bin/utils/gen_snapshot' ,
166167 ]
167168 .map ((String relativePath) =>
168- fileSystem.path.join (framework.cacheDirectory , relativePath))
169+ fileSystem.path.join (frameworkCacheDirectory , relativePath))
169170 .toList ();
170171 }
171172
172173 /// Binaries that are only expected to be codesigned.
173174 ///
174175 /// This list should be kept in sync with the actual contents of Flutter's
175176 /// cache.
176- List <String > get binariesWithoutEntitlements {
177+ Future <List <String >> get binariesWithoutEntitlements async {
178+ final String frameworkCacheDirectory = await framework.cacheDirectory;
177179 return < String > [
178180 'artifacts/engine/darwin-x64-profile/FlutterMacOS.framework/Versions/A/FlutterMacOS' ,
179181 'artifacts/engine/darwin-x64-release/FlutterMacOS.framework/Versions/A/FlutterMacOS' ,
@@ -188,7 +190,7 @@ class CodesignCommand extends Command<void> {
188190 'artifacts/ios-deploy/ios-deploy' ,
189191 ]
190192 .map ((String relativePath) =>
191- fileSystem.path.join (framework.cacheDirectory , relativePath))
193+ fileSystem.path.join (frameworkCacheDirectory , relativePath))
192194 .toList ();
193195 }
194196
@@ -200,12 +202,13 @@ class CodesignCommand extends Command<void> {
200202 /// [binariesWithEntitlements] or [binariesWithoutEntitlements] lists should
201203 /// be updated accordingly.
202204 @visibleForTesting
203- void verifyExist () {
205+ Future < void > verifyExist () async {
204206 final Set <String > foundFiles = < String > {};
205- for (final String binaryPath in findBinaryPaths (framework.cacheDirectory)) {
206- if (binariesWithEntitlements.contains (binaryPath)) {
207+ for (final String binaryPath
208+ in await findBinaryPaths (await framework.cacheDirectory)) {
209+ if ((await binariesWithEntitlements).contains (binaryPath)) {
207210 foundFiles.add (binaryPath);
208- } else if (binariesWithoutEntitlements.contains (binaryPath)) {
211+ } else if (( await binariesWithoutEntitlements) .contains (binaryPath)) {
209212 foundFiles.add (binaryPath);
210213 } else {
211214 throw ConductorException (
@@ -214,7 +217,7 @@ class CodesignCommand extends Command<void> {
214217 }
215218
216219 final List <String > allExpectedFiles =
217- binariesWithEntitlements + binariesWithoutEntitlements;
220+ ( await binariesWithEntitlements) + ( await binariesWithoutEntitlements) ;
218221 if (foundFiles.length < allExpectedFiles.length) {
219222 final List <String > unfoundFiles = allExpectedFiles
220223 .where (
@@ -237,19 +240,19 @@ class CodesignCommand extends Command<void> {
237240
238241 /// Verify code signatures and entitlements of all binaries in the cache.
239242 @visibleForTesting
240- void verifySignatures () {
243+ Future < void > verifySignatures () async {
241244 final List <String > unsignedBinaries = < String > [];
242245 final List <String > wrongEntitlementBinaries = < String > [];
243246 final List <String > unexpectedBinaries = < String > [];
244-
245- for ( final String binaryPath in findBinaryPaths (framework.cacheDirectory)) {
247+ for ( final String binaryPath
248+ in await findBinaryPaths (await framework.cacheDirectory)) {
246249 bool verifySignature = false ;
247250 bool verifyEntitlements = false ;
248- if (binariesWithEntitlements.contains (binaryPath)) {
251+ if (( await binariesWithEntitlements) .contains (binaryPath)) {
249252 verifySignature = true ;
250253 verifyEntitlements = true ;
251254 }
252- if (binariesWithoutEntitlements.contains (binaryPath)) {
255+ if (( await binariesWithoutEntitlements) .contains (binaryPath)) {
253256 verifySignature = true ;
254257 }
255258 if (! verifySignature && ! verifyEntitlements) {
@@ -258,7 +261,7 @@ class CodesignCommand extends Command<void> {
258261 continue ;
259262 }
260263 stdio.printTrace ('Verifying the code signature of $binaryPath ' );
261- final io.ProcessResult codeSignResult = processManager.runSync (
264+ final io.ProcessResult codeSignResult = await processManager.run (
262265 < String > [
263266 'codesign' ,
264267 '-vvv' ,
@@ -275,7 +278,7 @@ class CodesignCommand extends Command<void> {
275278 }
276279 if (verifyEntitlements) {
277280 stdio.printTrace ('Verifying entitlements of $binaryPath ' );
278- if (! hasExpectedEntitlements (binaryPath)) {
281+ if (! ( await hasExpectedEntitlements (binaryPath) )) {
279282 wrongEntitlementBinaries.add (binaryPath);
280283 }
281284 }
@@ -330,11 +333,12 @@ class CodesignCommand extends Command<void> {
330333 List <String >? _allBinaryPaths;
331334
332335 /// Find every binary file in the given [rootDirectory] .
333- List <String > findBinaryPaths (String rootDirectory) {
336+ Future < List <String >> findBinaryPaths (String rootDirectory) async {
334337 if (_allBinaryPaths != null ) {
335338 return _allBinaryPaths! ;
336339 }
337- final io.ProcessResult result = processManager.runSync (
340+ final List <String > allBinaryPaths = < String > [];
341+ final io.ProcessResult result = await processManager.run (
338342 < String > [
339343 'find' ,
340344 rootDirectory,
@@ -346,13 +350,19 @@ class CodesignCommand extends Command<void> {
346350 .split ('\n ' )
347351 .where ((String s) => s.isNotEmpty)
348352 .toList ();
349- _allBinaryPaths = allFiles.where (isBinary).toList ();
353+
354+ await Future .forEach (allFiles, (String filePath) async {
355+ if (await isBinary (filePath)) {
356+ allBinaryPaths.add (filePath);
357+ }
358+ });
359+ _allBinaryPaths = allBinaryPaths;
350360 return _allBinaryPaths! ;
351361 }
352362
353363 /// Check mime-type of file at [filePath] to determine if it is binary.
354- bool isBinary (String filePath) {
355- final io.ProcessResult result = processManager.runSync (
364+ Future < bool > isBinary (String filePath) async {
365+ final io.ProcessResult result = await processManager.run (
356366 < String > [
357367 'file' ,
358368 '--mime-type' ,
@@ -364,8 +374,8 @@ class CodesignCommand extends Command<void> {
364374 }
365375
366376 /// Check if the binary has the expected entitlements.
367- bool hasExpectedEntitlements (String binaryPath) {
368- final io.ProcessResult entitlementResult = processManager.runSync (
377+ Future < bool > hasExpectedEntitlements (String binaryPath) async {
378+ final io.ProcessResult entitlementResult = await processManager.run (
369379 < String > [
370380 'codesign' ,
371381 '--display' ,
@@ -386,7 +396,7 @@ class CodesignCommand extends Command<void> {
386396 final String output = entitlementResult.stdout as String ;
387397 for (final String entitlement in expectedEntitlements) {
388398 final bool entitlementExpected =
389- binariesWithEntitlements.contains (binaryPath);
399+ ( await binariesWithEntitlements) .contains (binaryPath);
390400 if (output.contains (entitlement) != entitlementExpected) {
391401 stdio.printError (
392402 'File "$binaryPath " ${entitlementExpected ? 'does not have expected' : 'has unexpected' } '
0 commit comments