@@ -29,7 +29,10 @@ enum CodesignType {
29
29
withEntitlements (filename: 'entitlements.txt' ),
30
30
31
31
/// Binaries requiring codesigning that DO NOT use APIs requiring entitlements.
32
- withoutEntitlements (filename: 'without_entitlements.txt' );
32
+ withoutEntitlements (filename: 'without_entitlements.txt' ),
33
+
34
+ /// Binaries that do not require codesigning.
35
+ unsigned (filename: 'unsigned_binaries.txt' );
33
36
34
37
const CodesignType ({required this .filename});
35
38
@@ -87,6 +90,9 @@ class FileCodesignVisitor {
87
90
88
91
/// Files that require codesigning that DO NOT use APIs requiring entitlements.
89
92
Set <String > withoutEntitlementsFiles = < String > {};
93
+
94
+ /// Files that do not require codesigning.
95
+ Set <String > unsignedBinaryFiles = < String > {};
90
96
Set <String > fileConsumed = < String > {};
91
97
Set <String > directoriesVisited = < String > {};
92
98
Map <String , String > availablePasswords = {
@@ -124,26 +130,30 @@ class FileCodesignVisitor {
124
130
static final RegExp _notarytoolStatusCheckPattern = RegExp (r'[ ]*status: ([a-zA-z ]+)' );
125
131
static final RegExp _notarytoolRequestPattern = RegExp (r'id: ([a-z0-9-]+)' );
126
132
127
- static const String fixItInstructions = '''
133
+ static final String fixItInstructions = '''
128
134
Codesign test failed.
129
135
130
136
We compared binary files in engine artifacts with those listed in
131
- entitlement.txt and withoutEntitlements.txt, and the binary files do not match.
132
- *entitlements.txt is the configuration file encoded in engine artifact zip,
133
- built by BUILD.gn and Ninja, to detail the list of entitlement files.
134
- Either an expected file was not found in *entitlements.txt, or an unexpected
135
- file was found in entitlements.txt.
137
+ * ${CodesignType .withEntitlements .filename }
138
+ * ${CodesignType .withoutEntitlements .filename }
139
+ * ${CodesignType .unsigned .filename }
140
+ and the binary files do not match.
141
+
142
+ These are the configuration files encoded in engine artifact zip that detail
143
+ the code-signing requirements of each of the binaries in the archive.
144
+ Either an unexpected binary was listed in these files, or one of the expected
145
+ binaries listed in these files was not found in the archive.
136
146
137
147
This usually happens during an engine roll.
138
- If this is a valid change, then BUILD.gn needs to be changed.
139
- Binaries that will run on a macOS host require entitlements, and
140
- binaries that run on an iOS device must NOT have entitlements.
148
+
149
+ If this is a valid change, then the BUILD.gn or the codesigning configuration
150
+ files need to be changed. Binaries that will run on a macOS host require
151
+ entitlements, and binaries that run on an iOS device must NOT have entitlements.
141
152
For example, if this is a new binary that runs on macOS host, add it
142
- to [entitlements.txt] file inside the zip artifact produced by BUILD.gn.
143
- If this is a new binary that needs to be run on iOS device, add it
144
- to [withoutEntitlements.txt].
145
- If there are obsolete binaries in entitlements configuration files, please delete or
146
- update these file paths accordingly.
153
+ to ${CodesignType .withEntitlements .filename } file inside the zip artifact produced by BUILD.gn.
154
+ If this is a new binary that needs to be run on iOS device, add it to
155
+ ${CodesignType .withoutEntitlements .filename }. If there are obsolete binaries in entitlements
156
+ configuration files, please delete or update these file paths accordingly.
147
157
''' ;
148
158
149
159
/// Read a single line of password stored at [passwordFilePath] .
@@ -202,8 +212,10 @@ update these file paths accordingly.
202
212
// Read codesigning configuration files.
203
213
withEntitlementsFiles = await parseCodesignConfig (parentDirectory, CodesignType .withEntitlements);
204
214
withoutEntitlementsFiles = await parseCodesignConfig (parentDirectory, CodesignType .withoutEntitlements);
215
+ unsignedBinaryFiles = await parseCodesignConfig (parentDirectory, CodesignType .unsigned);
205
216
log.info ('parsed binaries with entitlements are $withEntitlementsFiles ' );
206
217
log.info ('parsed binaries without entitlements are $withoutEntitlementsFiles ' );
218
+ log.info ('parsed binaries without codesigning $unsignedBinaryFiles ' );
207
219
208
220
// recursively visit extracted files
209
221
await visitDirectory (directory: parentDirectory, parentVirtualPath: '' );
@@ -319,17 +331,23 @@ update these file paths accordingly.
319
331
final String entitlementCurrentPath = joinEntitlementPaths (parentVirtualPath, currentFileName);
320
332
321
333
if (! withEntitlementsFiles.contains (entitlementCurrentPath) &&
322
- ! withoutEntitlementsFiles.contains (entitlementCurrentPath)) {
323
- log.severe ('the binary file $currentFileName is causing an issue. \n '
334
+ ! withoutEntitlementsFiles.contains (entitlementCurrentPath) &&
335
+ ! unsignedBinaryFiles.contains (entitlementCurrentPath)) {
336
+ log.severe ('The binary file $currentFileName is causing an issue. \n '
324
337
'This file is located at $entitlementCurrentPath in the flutter engine artifact.' );
325
338
log.severe ('The system has detected a binary file at $entitlementCurrentPath . '
326
- 'But it is not in the entitlements configuration files you provided. '
339
+ 'But it is not in the codesigning configuration files you provided. '
327
340
'If this is a new engine artifact, please add it to one of the entitlements.txt files.' );
328
341
throw CodesignException (fixItInstructions);
329
342
}
330
- log.info ('signing file at path ${binaryFile .absolute .path }' );
331
- log.info ('the virtual entitlement path associated with file is $entitlementCurrentPath ' );
332
- log.info ('the decision to sign with entitlement is ${withEntitlementsFiles .contains (entitlementCurrentPath )}' );
343
+ if (unsignedBinaryFiles.contains (entitlementCurrentPath)) {
344
+ // No codesigning necessary.
345
+ log.info ('Not signing file at path ${binaryFile .absolute .path }' );
346
+ return ;
347
+ }
348
+ log.info ('Signing file at path ${binaryFile .absolute .path }' );
349
+ log.info ('The virtual entitlement path associated with file is $entitlementCurrentPath ' );
350
+ log.info ('The decision to sign with entitlement is ${withEntitlementsFiles .contains (entitlementCurrentPath )}' );
333
351
fileConsumed.add (entitlementCurrentPath);
334
352
if (dryrun) {
335
353
return ;
0 commit comments