Skip to content

Commit

Permalink
[bundletool] Remove com/sun/jna content (#9162)
Browse files Browse the repository at this point in the history
Context: c89de29

Various symbol and signing checks have been failing after bumping
bundletool.jar to version 1.17.0. We can fix these by stripping out the
offending content from bundletool.jar.
  • Loading branch information
pjcollins authored and jonathanpeppers committed Aug 12, 2024
1 parent a9d10b4 commit 5ff92d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion build-tools/create-packs/SignVerifyIgnore.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
**\*.xml,ignore unsigned xml
**\cab*.cab.cab,ignore unsigned .cab
**\com\sun\jna\win32-*\jnidispatch.dll, ignore external bundletool.jar content
22 changes: 15 additions & 7 deletions src/bundletool/bundletool.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<_Destination>$(MicrosoftAndroidSdkOutDir)</_Destination>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<_BundleToolDownloadLocation>$(AndroidToolchainCacheDirectory)\bundletool-all-$(XABundleToolVersion).jar</_BundleToolDownloadLocation>
<_BundleToolExtractLocation>$(AndroidToolchainCacheDirectory)\bundletool-unzip</_BundleToolExtractLocation>
<_BundleToolCopyLocation>$(AndroidToolchainCacheDirectory)\bundletool-all-$(XABundleToolVersion)-copy.jar</_BundleToolCopyLocation>
<_BundleToolExtractLocation>$(AndroidToolchainCacheDirectory)\bundletool-unzip-$(XABundleToolVersion)</_BundleToolExtractLocation>
<_JarPath Condition=" '$(JavaSdkDirectory)' != '' ">$(JavaSdkDirectory)/bin/jar</_JarPath>
<_JarPath Condition=" '$(_JarPath)' == '' ">jar</_JarPath>
</PropertyGroup>
Expand All @@ -21,16 +22,23 @@
DependsOnTargets="_DownloadBundleTool"
Inputs="$(_BundleToolDownloadLocation)"
Outputs="$(_Destination)bundletool.jar" >
<!-- Strip aapt2 from bundletool.jar, as we pass it our own path to aapt2.
This simplifies macOS signing/hardening and reduces our installation footprint slightly. -->
<!-- Strip unused jna content and aapt2 from bundletool.jar, as we pass it our own path to aapt2.
This simplifies signing/hardening and reduces our installation footprint slightly. -->
<RemoveDir Directories="$(_BundleToolExtractLocation)" />
<MakeDir Directories="$(_BundleToolExtractLocation)" />
<Exec WorkingDirectory="$(_BundleToolExtractLocation)" Command="$(_JarPath) -xf &quot;$(_BundleToolDownloadLocation)&quot;" />
<Delete Files="$(_BundleToolDownloadLocation);$(_BundleToolExtractLocation)\linux\aapt2;$(_BundleToolExtractLocation)\macos\aapt2;$(_BundleToolExtractLocation)\windows\aapt2.exe" />
<Exec WorkingDirectory="$(_BundleToolExtractLocation)" Command="$(_JarPath) -cmf META-INF/MANIFEST.MF &quot;$(_BundleToolDownloadLocation)&quot; ." />
<RemoveDir Directories="$(_BundleToolExtractLocation)" />
<Copy
SourceFiles="$(_BundleToolDownloadLocation)"
DestinationFiles="$(_BundleToolCopyLocation)"
SkipUnchangedFiles="True"
/>
<Exec WorkingDirectory="$(_BundleToolExtractLocation)" Command="$(_JarPath) -xf &quot;$(_BundleToolCopyLocation)&quot;" />
<Delete Files="$(_BundleToolCopyLocation)" />
<Delete Files="$(_BundleToolExtractLocation)\linux\aapt2;$(_BundleToolExtractLocation)\macos\aapt2;$(_BundleToolExtractLocation)\windows\aapt2.exe" />
<RemoveDir Directories="$(_BundleToolExtractLocation)\com\sun\jna" />
<Exec WorkingDirectory="$(_BundleToolExtractLocation)" Command="$(_JarPath) -cmf META-INF/MANIFEST.MF &quot;$(_BundleToolCopyLocation)&quot; ." />
<RemoveDir Directories="$(_BundleToolExtractLocation)" />
<Copy
SourceFiles="$(_BundleToolCopyLocation)"
DestinationFiles="$(_Destination)bundletool.jar"
SkipUnchangedFiles="True"
/>
Expand Down

0 comments on commit 5ff92d6

Please sign in to comment.