Merge pull request #613 from Sridhar-MS/centos-builds

Enable building dotnet-CLI for centos.
This commit is contained in:
Sridhar Periyasamy 2015-12-23 17:52:31 -08:00
commit 5eb617676a
4 changed files with 91 additions and 24 deletions

View file

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

View file

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

View file

@ -16,6 +16,37 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
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
error "cmake is required to build the native host 'corehost'"
error "OS X w/Homebrew: 'brew install cmake'"
@ -29,14 +60,7 @@ if [[ ! -z "$OFFLINE" ]]; then
header "Skipping Stage 0, Dnx, and Packages download: Offline Build"
else
# Download DNX to copy into stage2
header "Downloading DNX $DNX_VERSION"
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
getDnx
# Ensure the latest stage0 is installed
$DIR/install.sh
@ -107,17 +131,25 @@ cp -R $DNX_ROOT $STAGE2_DIR/bin/dnx
cp $DIR/dotnet-restore.sh $STAGE2_DIR/bin/dotnet-restore
chmod a+x $STAGE2_DIR/bin/dotnet-restore
# Copy in AppDeps
header "Acquiring Native App Dependencies"
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $REPOROOT/scripts/build/build_appdeps.sh "$STAGE2_DIR/bin"
# No compile native support in centos yet
# https://github.com/dotnet/cli/issues/453
if [ "$OSNAME" != "centos" ]; then
# Copy in AppDeps
header "Acquiring Native App Dependencies"
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
COMMIT_ID=$(git rev-parse HEAD)
echo $COMMIT_ID > $STAGE2_DIR/.commit
# Run tests on the stage2 output
header "Testing stage2..."
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/runtests.sh
# Skipping tests for centos
# tracked by issue - https://github.com/dotnet/corefx/issues/5066
if [ "$OSNAME" != "centos" ]; then
# Run tests on the stage2 output
header "Testing stage2..."
DOTNET_HOME=$STAGE2_DIR DOTNET_TOOLS=$STAGE2_DIR $DIR/test/runtests.sh
fi
# Run Validation for Project.json dependencies
dotnet publish "$REPOROOT/tools/MultiProjectValidator" -o "$STAGE2_DIR/../tools"

View file

@ -1,6 +1,8 @@
// 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.
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Microsoft.DotNet.ProjectModel
@ -18,13 +20,50 @@ namespace Microsoft.DotNet.ProjectModel
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return "ubuntu.14.04-x64";
if(IsCentOS())
{
return "centos.7.1-x64";
}
else if(IsUbuntu())
{
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))
{
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);
}
}
}