Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add x64 emulation support to pkg installers #11813

Merged
merged 6 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/redist/targets/GeneratePKG.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<SdkProductArchiveId>com.microsoft.dotnet.dev.$(Version).osx.$(Architecture)</SdkProductArchiveId>

<PkgInstallDirectory>/usr/local/share/dotnet</PkgInstallDirectory>
<x64EmulationPkgInstallDirectory>/usr/local/share/dotnet/x64</x64EmulationPkgInstallDirectory>

<SdkPkgSourcesRootDirectory>$(MSBuildThisFileDirectory)packaging/osx/clisdk</SdkPkgSourcesRootDirectory>
<SdkPkgScriptsDirectory>$(SdkPkgSourcesRootDirectory)/scripts</SdkPkgScriptsDirectory>
Expand All @@ -22,7 +23,8 @@
<SdkPkgScriptFile>$(SdkPkgDestinationScriptsDirectory)/postinstall</SdkPkgScriptFile>
<SdkProductArchiveResourcesDirectory>$(PkgIntermediateDirectory)/resources</SdkProductArchiveResourcesDirectory>

<SdkProductArchiveDistributionTemplateFile>$(SdkPkgSourcesRootDirectory)/Distribution-Template</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionTemplateFile Condition="'$(Architecture)' != 'x64'">$(SdkPkgSourcesRootDirectory)/Distribution-Template</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionTemplateFile Condition="'$(Architecture)' == 'x64'">$(SdkPkgSourcesRootDirectory)/Distribution-Template-x64</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionFile>$(PkgIntermediateDirectory)/CLI-SDK-Formatted-Distribution-Template.xml</SdkProductArchiveDistributionFile>

<SdkPkgIntermediatePath>$(PkgIntermediateDirectory)/$(SdkComponentId).pkg</SdkPkgIntermediatePath>
Expand Down Expand Up @@ -96,6 +98,9 @@
<ReplacementString>10.13</ReplacementString>
<ReplacementString Condition="'$(Architecture)' == 'arm64'" >11.0</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{x64EmulationPkgInstallDirectory}">
<ReplacementString>$(x64EmulationPkgInstallDirectory)</ReplacementString>
</DistributionTemplateReplacement>

<PostInstallScriptReplacement Include="%SDK_VERSION%">
<ReplacementString>$(Version)</ReplacementString>
Expand Down
101 changes: 101 additions & 0 deletions src/redist/targets/packaging/osx/clisdk/Distribution-Template-x64
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
<title>{CLISdkBrandName} ({arch})</title>
<background file="dotnetbackground.png" mime-type="image/png"/>
<options customize="never" require-scripts="false" hostArchitectures="{hostArchitectures}" />
<welcome file="welcome.html" mime-type="text/html" />
<conclusion file="conclusion.html" mime-type="text/html" />
<volume-check>
<allowed-os-versions>
<os-version min="{minOsVersion}" />
</allowed-os-versions>
</volume-check>
<choices-outline>
<line choice="{NetCoreAppTargetingPackComponentId}.pkg.x64" />
<line choice="{NetStandardTargetingPackComponentId}.pkg.x64" />
<line choice="{NetCoreAppHostPackComponentId}.pkg.x64" />
<line choice="{SharedFxComponentId}.pkg.x64" />
<line choice="{HostFxrComponentId}.pkg.x64" />
<line choice="{SharedHostComponentId}.pkg.x64" />
<line choice="{CLISdkComponentId}.pkg.x64"/>
<line choice="{NetCoreAppTargetingPackComponentId}.pkg.arm64" />
<line choice="{NetStandardTargetingPackComponentId}.pkg.arm64" />
<line choice="{NetCoreAppHostPackComponentId}.pkg.arm64" />
<line choice="{SharedFxComponentId}.pkg.arm64" />
<line choice="{HostFxrComponentId}.pkg.arm64" />
<line choice="{SharedHostComponentId}.pkg.arm64" />
<line choice="{CLISdkComponentId}.pkg.arm64"/>
</choices-outline>
<choice id="{NetCoreAppTargetingPackComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{NetCoreAppTargetingPackBrandName} ({arch})" description="The .NET Targeting Pack">
<pkg-ref id="{NetCoreAppTargetingPackComponentId}.pkg" />
</choice>
<choice id="{NetStandardTargetingPackComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{NetStandardTargetingPackBrandName} ({arch})" description="The .NET Standard 2.1 Targeting Pack">
<pkg-ref id="{NetStandardTargetingPackComponentId}.pkg" />
</choice>
<choice id="{NetCoreAppHostPackComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{NetCoreAppHostPackBrandName} ({arch})" description="The .NET App Host Pack">
<pkg-ref id="{NetCoreAppHostPackComponentId}.pkg" />
</choice>
<choice id="{SharedFxComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{SharedFxBrandName} ({arch})" description="The .NET Shared Framework">
<pkg-ref id="{SharedFxComponentId}.pkg" />
</choice>
<choice id="{HostFxrComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{HostFxrBrandName} ({arch})" description="The .NET Host FX Resolver">
<pkg-ref id="{HostFxrComponentId}.pkg" />
</choice>
<choice id="{SharedHostComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{SharedHostBrandName} ({arch})" description="The .NET Shared Host.">
<pkg-ref id="{SharedHostComponentId}.pkg" />
</choice>
<choice id="{CLISdkComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{CLISdkBrandName} ({arch})" description="The .NET SDK">
<pkg-ref id="{CLISdkComponentId}.pkg"/>
</choice>
<choice id="{NetCoreAppTargetingPackComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{NetCoreAppTargetingPackBrandName} ({arch})" description="The .NET Targeting Pack">
<pkg-ref id="{NetCoreAppTargetingPackComponentId}.pkg" />
</choice>
<choice id="{NetStandardTargetingPackComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{NetStandardTargetingPackBrandName} ({arch})" description="The .NET Standard 2.1 Targeting Pack">
<pkg-ref id="{NetStandardTargetingPackComponentId}.pkg" />
</choice>
<choice id="{NetCoreAppHostPackComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{NetCoreAppHostPackBrandName} ({arch})" description="The .NET App Host Pack">
<pkg-ref id="{NetCoreAppHostPackComponentId}.pkg" />
</choice>
<choice id="{SharedFxComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{SharedFxBrandName} ({arch})" description="The .NET Shared Framework">
<pkg-ref id="{SharedFxComponentId}.pkg" />
</choice>
<choice id="{HostFxrComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{HostFxrBrandName} ({arch})" description="The .NET Host FX Resolver">
<pkg-ref id="{HostFxrComponentId}.pkg" />
</choice>
<choice id="{SharedHostComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{SharedHostBrandName} ({arch})" description="The .NET Shared Host.">
<pkg-ref id="{SharedHostComponentId}.pkg" />
</choice>
<choice id="{CLISdkComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{CLISdkBrandName} ({arch})" description="The .NET SDK">
<pkg-ref id="{CLISdkComponentId}.pkg"/>
</choice>
<pkg-ref id="{NetCoreAppTargetingPackComponentId}.pkg">{NetCoreAppTargetingPackComponentId}.pkg</pkg-ref>
<pkg-ref id="{NetStandardTargetingPackComponentId}.pkg">{NetStandardTargetingPackComponentId}.pkg</pkg-ref>
<pkg-ref id="{NetCoreAppHostPackComponentId}.pkg">{NetCoreAppHostPackComponentId}.pkg</pkg-ref>
<pkg-ref id="{SharedFxComponentId}.pkg">{SharedFxComponentId}.pkg</pkg-ref>
<pkg-ref id="{HostFxrComponentId}.pkg">{HostFxrComponentId}.pkg</pkg-ref>
<pkg-ref id="{SharedHostComponentId}.pkg">{SharedHostComponentId}.pkg</pkg-ref>
<pkg-ref id="{CLISdkComponentId}.pkg">{CLISdkComponentId}.pkg</pkg-ref>
<script>
<![CDATA[
function IsX64Machine() {
var machine = system.sysctl("hw.machine");
var cputype = system.sysctl("hw.cputype");
var cpu64 = system.sysctl("hw.cpu64bit_capable");
var translated = system.sysctl("sysctl.proc_translated");
system.log("Machine type: " + machine);
system.log("Cpu type: " + cputype);
system.log("64-bit: " + cpu64);
system.log("Translated: " + translated);

// From machine.h
// CPU_TYPE_X86_64 = CPU_TYPE_X86 | CPU_ARCH_ABI64 = 0x010000007 = 16777223
// CPU_TYPE_X86 = 7
var result = machine == "amd64" || machine == "x86_64" || cputype == "16777223" || (cputype == "7" && cpu64 == "1");
// We may be running under translation (Rosetta) that makes it seem like system is x64, if so assume machine is not actually x64
result = result && (translated != "1");
system.log("IsX64Machine: " + result);
return result;
}
]]>
</script>
</installer-gui-script>