From ee4bbb43ffd289228ed7c05aa37b29c1551c99fd Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Thu, 3 Mar 2016 18:38:58 +0000 Subject: [PATCH] Add support for building dotnet CLI on Debian. --- .../BuildTestStandaloneProject/project.json | 3 ++- .../CurrentPlatform.cs | 15 +++++++++++++- .../Enumerations/BuildPlatform.cs | 3 ++- scripts/dotnet-cli-build/CompileTargets.cs | 6 +++++- scripts/obtain/install.sh | 20 ++++++++++++++----- test/EndToEnd/EndToEndTest.cs | 14 ++++++++----- 6 files changed, 47 insertions(+), 14 deletions(-) diff --git a/TestAssets/TestProjects/BuildTestStandaloneProject/project.json b/TestAssets/TestProjects/BuildTestStandaloneProject/project.json index 440d05828..8d366cf72 100644 --- a/TestAssets/TestProjects/BuildTestStandaloneProject/project.json +++ b/TestAssets/TestProjects/BuildTestStandaloneProject/project.json @@ -17,6 +17,7 @@ "osx.10.10-x64": {}, "ubuntu.14.04-x64": {}, "centos.7-x64": {}, - "rhel.7.2-x64": {} + "rhel.7.2-x64": {}, + "debian.8.2-x64": {} } } diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs index c860436e7..d1e0a515f 100644 --- a/scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/CurrentPlatform.cs @@ -65,11 +65,20 @@ namespace Microsoft.DotNet.Cli.Build.Framework } } + public static bool IsDebian + { + get + { + var osname = PlatformServices.Default.Runtime.OperatingSystem; + return string.Equals(osname, "debian", StringComparison.OrdinalIgnoreCase); + } + } + public static bool IsLinux { get { - return IsUbuntu || IsCentOS || IsRHEL; + return IsUbuntu || IsCentOS || IsRHEL || IsDebian; } } @@ -118,6 +127,10 @@ namespace Microsoft.DotNet.Cli.Build.Framework { return BuildPlatform.RHEL; } + else if (IsDebian) + { + return BuildPlatform.Debian; + } else { return default(BuildPlatform); diff --git a/scripts/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs b/scripts/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs index adb2c83d6..46578d3ca 100644 --- a/scripts/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs +++ b/scripts/Microsoft.DotNet.Cli.Build.Framework/Enumerations/BuildPlatform.cs @@ -8,6 +8,7 @@ namespace Microsoft.DotNet.Cli.Build.Framework OSX = 4, Ubuntu = 5, CentOS = 6, - RHEL = 7 + RHEL = 7, + Debian = 8 } } diff --git a/scripts/dotnet-cli-build/CompileTargets.cs b/scripts/dotnet-cli-build/CompileTargets.cs index bbf03cf4f..1fc300ce0 100644 --- a/scripts/dotnet-cli-build/CompileTargets.cs +++ b/scripts/dotnet-cli-build/CompileTargets.cs @@ -260,7 +260,7 @@ namespace Microsoft.DotNet.Cli.Build { packageId = "toolchain.ubuntu.14.04-x64.Microsoft.DotNet.AppDep"; } - else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL) + else if (CurrentPlatform.IsCentOS || CurrentPlatform.IsRHEL || CurrentPlatform.IsDebian) { c.Warn($"Native compilation is not yet working on {CurrentPlatform.Current}"); return c.Success(); @@ -308,6 +308,10 @@ namespace Microsoft.DotNet.Cli.Build // CentOS runtime is in the runtime.rhel.7-x64... package. packageId = "runtime.rhel.7-x64.Microsoft.NETCore.Runtime.CoreCLR"; } + else if (CurrentPlatform.IsDebian) + { + packageId = "runtime.debian.8.2-x64.Microsoft.NETCore.Runtime.CoreCLR"; + } else if (CurrentPlatform.IsOSX) { packageId = "runtime.osx.10.10-x64.Microsoft.NETCore.Runtime.CoreCLR"; diff --git a/scripts/obtain/install.sh b/scripts/obtain/install.sh index 362e7a57c..c212eae44 100755 --- a/scripts/obtain/install.sh +++ b/scripts/obtain/install.sh @@ -85,6 +85,8 @@ current_os() echo "centos" elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then echo "rhel.7" + elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then + echo "debian" fi fi } @@ -106,11 +108,19 @@ check_pre_reqs() { fi if [ "$(uname)" = "Linux" ]; then - [ -z "$(ldconfig -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && _failing=true - [ -z "$(ldconfig -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && _failing=true - [ -z "$(ldconfig -p | grep libcurl)" ] && say_err "Unable to locate libcurl. Install libcurl to continue" && _failing=true - [ -z "$(ldconfig -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && _failing=true - [ -z "$(ldconfig -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && _failing=true + + if ! [ -x "$(command -v ldconfig)" ]; then + echo "ldconfig is not in PATH, trying /sbin/ldconfig." + LDCONFIG_COMMAND="/sbin/ldconfig" + else + LDCONFIG_COMMAND="ldconfig" + fi + + [ -z "$($LDCONFIG_COMMAND -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && _failing=true + [ -z "$($LDCONFIG_COMMAND -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && _failing=true + [ -z "$($LDCONFIG_COMMAND -p | grep libcurl)" ] && say_err "Unable to locate libcurl. Install libcurl to continue" && _failing=true + [ -z "$($LDCONFIG_COMMAND -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && _failing=true + [ -z "$($LDCONFIG_COMMAND -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && _failing=true fi if [ "$_failing" = true ]; then diff --git a/test/EndToEnd/EndToEndTest.cs b/test/EndToEnd/EndToEndTest.cs index 5fb8edccc..be21d46ca 100644 --- a/test/EndToEnd/EndToEndTest.cs +++ b/test/EndToEnd/EndToEndTest.cs @@ -83,7 +83,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd [Fact] public void TestDotnetBuildNativeRyuJit() { - if(!IsNativeCompilationSupported()) + if (!IsNativeCompilationSupported()) { return; } @@ -98,8 +98,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd [Fact] public void TestDotnetBuildNativeCpp() { - if(!IsNativeCompilationSupported()) - { + if (!IsNativeCompilationSupported()) + { return; } @@ -113,8 +113,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd [Fact] public void TestDotnetCompileNativeCppIncremental() { - if(!IsNativeCompilationSupported()) - { + if (!IsNativeCompilationSupported()) + { return; } @@ -226,6 +226,10 @@ namespace Microsoft.DotNet.Tests.EndToEnd Console.WriteLine("Skipping native compilation tests on CentOS/RHEL - https://github.com/dotnet/cli/issues/453"); isSupported = false; break; + case "debian": + Console.WriteLine("Skipping native compilation tests on Debian - https://github.com/dotnet/cli/issues/1666"); + isSupported = false; + break; case "windows": Console.WriteLine("Skipping native compilation tests on Windows x86 - https://github.com/dotnet/cli/issues/1550"); isSupported = RuntimeInformation.ProcessArchitecture != Architecture.X86;