Add the self-hosting build script for linux

- build.sh will not install dotnet using apt-get from a feed. The installed dotnet is used to build teh cli repo and to produce teh dotnet deb package
	- Download the dnx dependency for dotnet restore
	- Fix dotnet-restore script file permission issues
This commit is contained in:
Sridhar Periyasamy 2015-10-20 10:46:28 -07:00
parent e95acaa27d
commit 37b78b2918
3 changed files with 72 additions and 7 deletions

View file

@ -11,26 +11,85 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
UNAME=$(uname)
if [ "$UNAME" == "Darwin" ]; then
echo "Building Currently not supported on OSX"
exit 1
fi
REPO_ROOT=$DIR
OUTPUT_DIR="$REPO_ROOT/bin"
PACKAGE_LAYOUT_DIR="$OUTPUT_DIR/package_layout"
PACKAGE_OUTPUT_DIR="$OUTPUT_DIR/package_output"
REPO_BINARIES_DIR="$REPO_ROOT/artifacts/ubuntu.14.04-x64"
REPO_BINARIES_DIR="$REPO_ROOT/bin/$UNAME"
execute(){
install_dotnet
build_repo
create_empty_debian_layout
copy_files_to_debian_layout
create_debian_package
}
acquire_previous_version(){
install_dotnet(){
sudo sh -c 'echo "deb [arch=amd64] http://tux-devrepo.corp.microsoft.com/repos/dotnet-dev/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver tux-devrepo.corp.microsoft.com --recv-keys 008C0E6C
sudo apt-get update
# install/upgrade dotnet debian package
echo "Installing dotnet.."
sudo apt-get install dotnet
if [[ $? > 0 ]]
then
echo "Installing 'dotnet' failed, exiting."
exit 1
else
echo "Installing 'dotnet' succeeded."
fi
}
build_repo(){
if [ -z "$RID" ]; then
if [ "$UNAME" == "Darwin" ]; then
RID=osx.10.10-x64
elif [ "$UNAME" == "Linux" ]; then
# Detect Distro?
RID=ubuntu.14.04-x64
else
echo "Unknown OS: $UNAME" 1>&2
exit 1
fi
fi
dotnet restore "$REPO_ROOT" --runtime osx.10.10-x64 --runtime ubuntu.14.04-x64 --runtime osx.10.11-x64
dirs=(`find ./src -type f -iname 'project.json' | sed -r 's|/[^/]+$||' |sort |uniq`)
for i in ${dirs[@]}; do
echo "Building directory $i";
pushd $i
# HACK for getting dnu. Right now dotnet-restore depends on dnu.
# Restore the dnx package into tmp and copy the binaries into the output folder
if [[ $i == *"Microsoft.DotNet.Tools.Restore"* ]]; then
dotnet restore . --runtime $RID --packages /tmp
mkdir $REPO_BINARIES_DIR/dnx
cp -r /tmp/dnx-coreclr-linux-x64/1.0.0-*/bin/* "$REPO_BINARIES_DIR/dnx/"
cp "$REPO_ROOT/scripts/dotnet-restore" "$REPO_BINARIES_DIR"
elif [[ $i == *"Microsoft.Extensions.ProjectModel"* ]]; then
:
#HACK to prevent publishing of Microsoft.Extensions.ProjectModel
else
dotnet-publish --framework dnxcore50 --runtime $RID --output "$REPO_BINARIES_DIR" .
fi
popd
done
}
create_empty_debian_layout(){
@ -49,12 +108,10 @@ copy_files_to_debian_layout(){
# Copy config file
cp "$REPO_ROOT/debian_config.json" "$PACKAGE_LAYOUT_DIR"
# Copy Wrapper Scripts
# TODO: This is a workaround for https://github.com/dotnet/coreclr/issues/1774
cp "$REPO_ROOT/wrappers/." "PACKAGE_LAYOUT_DIR/package_root"
}
create_debian_package(){
$DIR/package_tool/package_tool $PACKAGE_LAYOUT_DIR $PACKAGE_OUTPUT_DIR
}
}
execute

0
scripts/dotnet-restore Normal file → Executable file
View file

View file

@ -0,0 +1,8 @@
{
"dependencies": {
"dnx-coreclr-linux-x64": "1.0.0-*",
},
"frameworks": {
"dnxcore50": { }
}
}