Enable building dotnet-CLI for centos.

I had to patch up a redhat dnx package which supports NETStandard.Library package. It is currently uploaded to dotnet-cli blob storage. This hack will no longer be required when we move to xplat nuget to do 'dotnet restore'. Apart from this there are three issues that are tracked for centos.
- compile-native not yet supported - https://github.com/dotnet/cli/issues/453
- dnu restore crashes intermittently on centos. I need to investigate this a little bit more and file issues on dnx or coreclr. This will make our CI builds very flaky.
- Dotnet restore does not restore native shims when using “centos.7-x64” - https://github.com/dotnet/corefx/issues/5066
This commit is contained in:
Sridhar Periyasamy 2015-12-18 11:32:20 -08:00
parent 3b9828404e
commit 1db27b7ae3
5 changed files with 93 additions and 25 deletions

View file

@ -7,11 +7,12 @@ import jobs.generation.Utilities;
def project = GithubProject def project = GithubProject
def osList = ['Ubuntu', 'OSX', 'Windows_NT'] def osList = ['Ubuntu', 'OSX', 'Windows_NT', 'CentOS7.1']
def machineLabelMap = ['Ubuntu':'ubuntu-doc', def machineLabelMap = ['Ubuntu':'ubuntu-doc',
'OSX':'mac', 'OSX':'mac',
'Windows_NT':'windows'] 'Windows_NT':'windows',
'CentOS7.1' : 'centos-71']
def static getBuildJobName(def configuration, def os) { def static getBuildJobName(def configuration, def os) {
return configuration.toLowerCase() + '_' + os.toLowerCase() return configuration.toLowerCase() + '_' + os.toLowerCase()

View file

@ -77,16 +77,14 @@ if [ -z "$RID" ]; then
if [ "$UNAME" == "Darwin" ]; then if [ "$UNAME" == "Darwin" ]; then
export OSNAME=osx export OSNAME=osx
export RID=osx.10.10-x64 export RID=osx.10.10-x64
export DNX_FLAVOR="dnx-coreclr-darwin-x64"
elif [ "$UNAME" == "Linux" ]; then elif [ "$UNAME" == "Linux" ]; then
# Detect Distro # Detect Distro
if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then
export OSNAME=ubuntu export OSNAME=ubuntu
export RID=ubuntu.14.04-x64 export RID=ubuntu.14.04-x64
export DNX_FLAVOR="dnx-coreclr-linux-x64"
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
export OSNAME=centos export OSNAME=centos
export RID=centos.7-x64 export RID=centos.7.1-x64
else else
error "unknown Linux Distro" 1>&2 error "unknown Linux Distro" 1>&2
fi fi
@ -96,11 +94,8 @@ if [ -z "$RID" ]; then
fi fi
fi fi
export DNX_VERSION="1.0.0-rc1-update1"
export REPOROOT=$(cd $COMMONDIR/.. && pwd) export REPOROOT=$(cd $COMMONDIR/.. && pwd)
export OUTPUT_ROOT=$REPOROOT/artifacts/$RID export OUTPUT_ROOT=$REPOROOT/artifacts/$RID
export DNX_DIR=$OUTPUT_ROOT/dnx
export STAGE1_DIR=$OUTPUT_ROOT/stage1 export STAGE1_DIR=$OUTPUT_ROOT/stage1
export STAGE2_DIR=$OUTPUT_ROOT/stage2 export STAGE2_DIR=$OUTPUT_ROOT/stage2
export HOST_DIR=$OUTPUT_ROOT/corehost export HOST_DIR=$OUTPUT_ROOT/corehost

View file

@ -16,6 +16,37 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
source "$DIR/_common.sh" source "$DIR/_common.sh"
getDnx()
{
DNX_FEED="https://api.nuget.org/packages"
DNX_VERSION="1.0.0-rc1-update1"
DNX_DIR=$OUTPUT_ROOT/dnx
if [ "$OSNAME" == "osx" ]; then
DNX_FLAVOR="dnx-coreclr-darwin-x64"
elif [ "$OSNAME" == "ubuntu" ]; then
DNX_FLAVOR="dnx-coreclr-linux-x64"
elif [ "$OSNAME" == "centos" ]; then
# No support dnx on redhat yet.
# using patched dnx
DNX_FEED="https://dotnetcli.blob.core.windows.net/dotnet/redhat_dnx"
DNX_VERSION="1.0.0-rc2-15000"
DNX_FLAVOR="dnx-coreclr-redhat-x64"
else
error "unknown OS: $OSNAME" 1>&2
exit 1
fi
header "Downloading DNX $DNX_VERSION"
DNX_URL="$DNX_FEED/$DNX_FLAVOR.$DNX_VERSION.nupkg"
DNX_ROOT="$DNX_DIR/bin"
rm -rf $DNX_DIR
mkdir -p $DNX_DIR
curl -o $DNX_DIR/dnx.zip $DNX_URL --silent
unzip -qq $DNX_DIR/dnx.zip -d $DNX_DIR
chmod a+x $DNX_ROOT/dnu $DNX_ROOT/dnx
}
if ! type -p cmake >/dev/null; then if ! type -p cmake >/dev/null; then
error "cmake is required to build the native host 'corehost'" error "cmake is required to build the native host 'corehost'"
error "OS X w/Homebrew: 'brew install cmake'" error "OS X w/Homebrew: 'brew install cmake'"
@ -26,14 +57,8 @@ fi
[ -z "$CONFIGURATION" ] && export CONFIGURATION=Debug [ -z "$CONFIGURATION" ] && export CONFIGURATION=Debug
# Download DNX to copy into stage2 # Download DNX to copy into stage2
header "Downloading DNX $DNX_VERSION" getDnx
DNX_URL="https://api.nuget.org/packages/$DNX_FLAVOR.$DNX_VERSION.nupkg"
DNX_ROOT="$DNX_DIR/bin"
rm -rf $DNX_DIR
mkdir -p $DNX_DIR
curl -o $DNX_DIR/dnx.zip $DNX_URL --silent
unzip -qq $DNX_DIR/dnx.zip -d $DNX_DIR
chmod a+x $DNX_ROOT/dnu $DNX_ROOT/dnx
# Ensure the latest stage0 is installed # Ensure the latest stage0 is installed
$DIR/install.sh $DIR/install.sh
@ -103,9 +128,13 @@ cp -R $DNX_ROOT $STAGE2_DIR/bin/dnx
cp $DIR/dotnet-restore.sh $STAGE2_DIR/bin/dotnet-restore cp $DIR/dotnet-restore.sh $STAGE2_DIR/bin/dotnet-restore
chmod a+x $STAGE2_DIR/bin/dotnet-restore chmod a+x $STAGE2_DIR/bin/dotnet-restore
# No compile native support in centos yet
# https://github.com/dotnet/cli/issues/453
if [ "$OSNAME" != "centos" ]; then
# Copy in AppDeps # Copy in AppDeps
header "Acquiring Native App Dependencies" header "Acquiring Native App Dependencies"
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $REPOROOT/scripts/build/build_appdeps.sh "$STAGE2_DIR/bin" DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $REPOROOT/scripts/build/build_appdeps.sh "$STAGE2_DIR/bin"
fi
# Stamp the output with the commit metadata # Stamp the output with the commit metadata
COMMIT_ID=$(git rev-parse HEAD) COMMIT_ID=$(git rev-parse HEAD)
@ -115,9 +144,13 @@ echo $COMMIT_ID > $STAGE2_DIR/.commit
header "Testing stage2 ..." header "Testing stage2 ..."
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/smoke-test.sh DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/smoke-test.sh
# Skipping E2E tests for centos
# tracked by issue - https://github.com/dotnet/corefx/issues/5066
if [ "$OSNAME" != "centos" ]; then
# E2E test on the output # E2E test on the output
header "Testing stage2 End to End ..." header "Testing stage2 End to End ..."
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/e2e-test.sh DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/e2e-test.sh
fi
# Run Validation for Project.json dependencies # Run Validation for Project.json dependencies
dotnet publish "$REPOROOT/tools/MultiProjectValidator" -o "$STAGE2_DIR/../tools" dotnet publish "$REPOROOT/tools/MultiProjectValidator" -o "$STAGE2_DIR/../tools"

View file

@ -18,7 +18,7 @@ REPOROOT="$( cd -P "$DIR/../.." && pwd )"
source "$DIR/../_common.sh" source "$DIR/../_common.sh"
rm "$REPOROOT/test/TestApp/project.lock.json" rm "$REPOROOT/test/TestApp/project.lock.json"
dotnet restore "$REPOROOT/test/TestApp" --runtime "osx.10.10-x64" --runtime "ubuntu.14.04-x64" --runtime "win7-x64" dotnet restore "$REPOROOT/test/TestApp" --runtime "$RID"
dotnet compile "$REPOROOT/test/TestApp" --output "$REPOROOT/artifacts/$RID/smoketest" dotnet compile "$REPOROOT/test/TestApp" --output "$REPOROOT/artifacts/$RID/smoketest"
# set -e will abort if the exit code of this is non-zero # set -e will abort if the exit code of this is non-zero

View file

@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved. // Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Microsoft.DotNet.ProjectModel namespace Microsoft.DotNet.ProjectModel
@ -17,14 +19,51 @@ namespace Microsoft.DotNet.ProjectModel
return "win7-x64"; return "win7-x64";
} }
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
if(IsCentOS())
{
return "centos.7.1-x64";
}
else if(IsUbuntu())
{ {
return "ubuntu.14.04-x64"; return "ubuntu.14.04-x64";
} }
else
{
// unknown distro. Lets fail fast
throw new InvalidOperationException("Current linux distro is not supported.");
}
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{ {
return "osx.10.10-x64"; return "osx.10.10-x64";
} }
return "unknown";
throw new InvalidOperationException("Current operating system is not supported.");
}
private static bool IsCentOS()
{
return IsLinuxDistro("centos");
}
private static bool IsUbuntu()
{
return IsLinuxDistro("ubuntu");
}
private static bool IsLinuxDistro(string distro)
{
// HACK - A file which can be found in most linux distros
// Did not test in non-en distros
const string OSIDFILE = "/etc/os-release";
if(!File.Exists(OSIDFILE))
{
return false;
}
return File.ReadAllText(OSIDFILE).ToLower().Contains(distro);
} }
} }
} }