diff --git a/debian_config.json b/debian_config.json new file mode 100644 index 000000000..bd8f0bd1e --- /dev/null +++ b/debian_config.json @@ -0,0 +1,42 @@ +{ + "maintainer_name":"Microsoft", + "maintainer_email": "dotnetcore@microsoft.com", + + "package_name": "dotnet", + + "short_description": "NOT FINAL debian package for dotnet cli", + "long_description": "NOT FINAL This package restores, compiles, and publishes.", + "homepage": "https://dotnet.github.io/core", + + "release":{ + "package_version":"0.3", + "package_revision":"1", + "urgency" : "low", + "changelog_message" : "Bootstrap loop package" + }, + + "control": { + "priority":"standard", + "section":"devel", + "architecture":"any" + }, + + "copyright": "2015 Microsoft", + "license": { + "type": "MIT", + "full_text": "Copyright (c) 2015 Microsoft\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE." + }, + + "debian_dependencies":{ + "libssl-dev" : {} + }, + + "symlinks": { + "dotnet" : "usr/bin/dotnet", + "dotnet-compile" : "usr/bin/dotnet-compile", + "dotnet-compile-csc" : "usr/bin/dotnet-compile-csc", + "dotnet-publish" : "usr/bin/dotnet-publish", + "dotnet-restore" : "usr/bin/dotnet-restore", + "resgen" : "usr/bin/resgen" + } +} diff --git a/package_tool/setup/build_setup.sh b/package_tool/setup/build_setup.sh old mode 100644 new mode 100755 index 6d70859f6..5280f2ad3 --- a/package_tool/setup/build_setup.sh +++ b/package_tool/setup/build_setup.sh @@ -1,10 +1,15 @@ install_dependencies(){ - apt-get update - apt-get install -y debhelper build-essential devscripts git + # Add LLdb 3.6 package source + echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main" | tee /etc/apt/sources.list.d/llvm.list + wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add - + + #Install Deps + apt-get update + apt-get install -y debhelper build-essential devscripts git liblttng-ust-dev lldb-3.6-dev } setup(){ - install_dependencies + install_dependencies } setup \ No newline at end of file diff --git a/package_tool/setup/test_setup.sh b/package_tool/setup/test_setup.sh index cdc3b0f7b..01f0f37d1 100755 --- a/package_tool/setup/test_setup.sh +++ b/package_tool/setup/test_setup.sh @@ -1,17 +1,22 @@ install_dependencies(){ - apt-get update - apt-get install -y debhelper build-essential devscripts git + # Add LLdb 3.6 package source + echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main" | tee /etc/apt/sources.list.d/llvm.list + wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add - + + #Install Deps + apt-get update + apt-get install -y debhelper build-essential devscripts git liblttng-ust-dev lldb-3.6-dev } install_bats(){ - git clone https://github.com/sstephenson/bats.git - cd bats - ./install.sh /usr/local + git clone https://github.com/sstephenson/bats.git + cd bats + ./install.sh /usr/local } setup(){ - install_dependencies - install_bats + install_dependencies + install_bats } setup \ No newline at end of file diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 1a2a9fc38..bf21bc8b2 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -88,6 +88,9 @@ dotnet publish --framework dnxcore50 --runtime $RID --output "$STAGE1_DIR" "$REP # Add stage1 to the path and use it to build stage2 export PATH=$STAGE1_DIR:$PATH +# Make corerun explicitly executable +chmod a+x $STAGE1_DIR/corerun + echo "Building stage2 dotnet using stage1 ..." dotnet publish --framework dnxcore50 --runtime $RID --output "$STAGE2_DIR" "$REPOROOT/src/Microsoft.DotNet.Cli" rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi @@ -99,3 +102,6 @@ dotnet publish --framework dnxcore50 --runtime $RID --output "$STAGE2_DIR" "$REP rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi dotnet publish --framework dnxcore50 --runtime $RID --output "$STAGE2_DIR" "$REPOROOT/src/Microsoft.DotNet.Tools.Resgen" rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi + +# Make Stage 2 Folder Accessible +chmod -R a+r $STAGE2_DIR \ No newline at end of file diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile index 5e0b76d69..ce020e821 100644 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -1,5 +1,14 @@ # Dockerfile that creates a container suitable to build dotnet-cli FROM microsoft/aspnet:1.0.0-beta8-coreclr +RUN apt-get update +RUN apt-get install -y wget + +# Install Package Build Prereqs +RUN echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.6 main" | tee /etc/apt/sources.list.d/llvm.list +RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add - +RUN apt-get update +RUN apt-get install -y debhelper build-essential devscripts git liblttng-ust-dev lldb-3.6-dev + # Set working directory WORKDIR /opt/code diff --git a/scripts/dockerbuild.sh b/scripts/dockerbuild.sh index 8392ffbe9..3342074f3 100755 --- a/scripts/dockerbuild.sh +++ b/scripts/dockerbuild.sh @@ -11,9 +11,19 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" cd $DIR/.. [ -z "$DOTNET_BUILD_CONTAINER_TAG" ] && DOTNET_BUILD_CONTAINER_TAG="dotnetcli-build" +[ -z "$DOTNET_BUILD_CONTAINER_NAME" ] && DOTNET_BUILD_CONTAINER_NAME="dotnetcli-build-container" +[ -z "$DOCKER_HOST_SHARE_DIR" ] && DOCKER_HOST_SHARE_DIR=$(pwd) +[ -z "$BUILD_COMMAND" ] && BUILD_COMMAND="//opt\\code\\build.sh" + +echo $DOCKER_HOST_SHARE_DIR # Build the docker container (will be fast if it is already built) docker build -t $DOTNET_BUILD_CONTAINER_TAG scripts/docker/ # Run the build in the container -docker run -it --rm -v $(pwd):/opt/code -e DOTNET_BUILD_VERSION=$DOTNET_BUILD_VERSION $DOTNET_BUILD_CONTAINER_TAG /opt/code/build.sh +docker rm -f $DOTNET_BUILD_CONTAINER_NAME +docker run \ + -v $DOCKER_HOST_SHARE_DIR:/opt/code \ + --name $DOTNET_BUILD_CONTAINER_NAME \ + -e DOTNET_BUILD_VERSION=$DOTNET_BUILD_VERSION \ + $DOTNET_BUILD_CONTAINER_TAG $BUILD_COMMAND diff --git a/scripts/package-debian.sh b/scripts/package-debian.sh new file mode 100644 index 000000000..b15ef37c6 --- /dev/null +++ b/scripts/package-debian.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +# +# Build Script +# Currently Intended to build on ubuntu14.04 + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +UNAME=$(uname) + + +if [ "$UNAME" != "Linux" ]; then + echo "Error: Build only supported on Linux" + exit 1 +fi + +REPO_ROOT=$(readlink -f $DIR/..) + +OUTPUT_DIR="$REPO_ROOT/artifacts" +PACKAGE_LAYOUT_DIR="$OUTPUT_DIR/deb_intermediate" +PACKAGE_OUTPUT_DIR="$OUTPUT_DIR/packages/debian" +REPO_BINARIES_DIR="$REPO_ROOT/artifacts/ubuntu.14.04-x64/stage2" + +execute(){ + create_empty_debian_layout + copy_files_to_debian_layout + create_debian_package + test_debian_package +} + +create_empty_debian_layout(){ + rm -rf $PACKAGE_LAYOUT_DIR + mkdir -p $PACKAGE_LAYOUT_DIR + + mkdir "$PACKAGE_LAYOUT_DIR/\$" + mkdir "$PACKAGE_LAYOUT_DIR/package_root" + mkdir "$PACKAGE_LAYOUT_DIR/samples" + mkdir "$PACKAGE_LAYOUT_DIR/docs" +} + +copy_files_to_debian_layout(){ + # Copy Built Binaries + cp -a "$REPO_BINARIES_DIR/." "$PACKAGE_LAYOUT_DIR/package_root" + + # Copy config file + cp "$REPO_ROOT/debian_config.json" "$PACKAGE_LAYOUT_DIR" +} + +create_debian_package(){ + mkdir -p $PACKAGE_OUTPUT_DIR + + $REPO_ROOT/package_tool/package_tool $PACKAGE_LAYOUT_DIR $PACKAGE_OUTPUT_DIR +} + +test_debian_package(){ + git clone https://github.com/sstephenson/bats.git /tmp/bats + pushd /tmp/bats + ./install.sh /usr/local + popd + + bats $PACKAGE_OUTPUT_DIR/test_package.bats +} + +execute diff --git a/scripts/package-dnvm.sh b/scripts/package-dnvm.sh new file mode 100644 index 000000000..bc0401976 --- /dev/null +++ b/scripts/package-dnvm.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +REPOROOT="$( cd -P "$DIR/.." && pwd )" + +if [ -z "$RID" ]; then + UNAME=$(uname) + if [ "$UNAME" == "Darwin" ]; then + OSNAME=osx + RID=osx.10.10-x64 + elif [ "$UNAME" == "Linux" ]; then + # Detect Distro? + OSNAME=linux + RID=ubuntu.14.04-x64 + else + echo "Unknown OS: $UNAME" 1>&2 + exit 1 + fi +fi + +if [ -z "$DOTNET_BUILD_VERSION" ]; then + TIMESTAMP=$(date "+%Y%m%d%H%M%S") + DOTNET_BUILD_VERSION=0.0.1-alpha-t$TIMESTAMP +fi + +STAGE2_DIR=$REPOROOT/artifacts/$RID/stage2 + +if [ ! -d "$STAGE2_DIR" ]; then + echo "Missing stage2 output in $STAGE2_DIR" 1>&2 + exit +fi + +PACKAGE_DIR=$REPOROOT/artifacts/packages/dnvm +[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR + +PACKAGE_NAME=$PACKAGE_DIR/dotnet-${OSNAME}-x64.${DOTNET_BUILD_VERSION}.tar.gz + +cd $STAGE2_DIR + +# Correct all the mode flags + +# Managed code doesn't need 'x' +find . -type f -name "*.dll" | xargs chmod 644 +find . -type f -name "*.exe" | xargs chmod 644 + +# Generally, dylibs and sos have 'x' (no idea if it's required ;)) +if [ "$OSNAME" == "osx" ]; then + find . -type f -name "*.dylib" | xargs chmod 744 +else + find . -type f -name "*.so" | xargs chmod 744 +fi + +# Executables (those without dots) are executable :) +find . -type f ! -name "*.*" | xargs chmod 755 + +# Tar up the stage2 artifacts +tar -czf $PACKAGE_NAME * + +echo "Packaged stage2 to $PACKAGE_NAME" \ No newline at end of file diff --git a/scripts/package.sh b/scripts/package.sh old mode 100755 new mode 100644 index a94ea27ae..5c23b11bb --- a/scripts/package.sh +++ b/scripts/package.sh @@ -7,60 +7,11 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" -REPOROOT="$( cd -P "$DIR/.." && pwd )" -if [ -z "$RID" ]; then - UNAME=$(uname) - if [ "$UNAME" == "Darwin" ]; then - OSNAME=osx - RID=osx.10.10-x64 - elif [ "$UNAME" == "Linux" ]; then - # Detect Distro? - OSNAME=linux - RID=ubuntu.14.04-x64 - else - echo "Unknown OS: $UNAME" 1>&2 - exit 1 - fi -fi +# Create Dnvm Package +$DIR/package-dnvm.sh -if [ -z "$DOTNET_BUILD_VERSION" ]; then - TIMESTAMP=$(date "+%Y%m%d%H%M%S") - DOTNET_BUILD_VERSION=0.0.1-alpha-t$TIMESTAMP -fi - -STAGE2_DIR=$REPOROOT/artifacts/$RID/stage2 - -if [ ! -d "$STAGE2_DIR" ]; then - echo "Missing stage2 output in $STAGE2_DIR" 1>&2 - exit -fi - -PACKAGE_DIR=$REPOROOT/artifacts/packages/dnvm -[ -d "$PACKAGE_DIR" ] || mkdir -p $PACKAGE_DIR - -PACKAGE_NAME=$PACKAGE_DIR/dotnet-${OSNAME}-x64.${DOTNET_BUILD_VERSION}.tar.gz - -cd $STAGE2_DIR - -# Correct all the mode flags - -# Managed code doesn't need 'x' -find . -type f -name "*.dll" | xargs chmod 644 -find . -type f -name "*.exe" | xargs chmod 644 - -# Generally, dylibs and sos have 'x' (no idea if it's required ;)) -if [ "$OSNAME" == "osx" ]; then - find . -type f -name "*.dylib" | xargs chmod 744 -else - find . -type f -name "*.so" | xargs chmod 744 -fi - -# Executables (those without dots) are executable :) -find . -type f ! -name "*.*" | xargs chmod 755 - -# Tar up the stage2 artifacts -tar -czf $PACKAGE_NAME * - -echo "Packaged stage2 to $PACKAGE_NAME" +# Create Debian package +$DIR/package-debian.sh +# TODO: Create Pkg \ No newline at end of file diff --git a/scripts/windows_dockerbuild.sh b/scripts/windows_dockerbuild.sh new file mode 100644 index 000000000..a289d16b0 --- /dev/null +++ b/scripts/windows_dockerbuild.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash +# +# Prerequisites: +# Git Bash (http://www.git-scm.com/downloads) +# Docker Toolbox (https://www.docker.com/docker-toolbox) +# Ensure Hyper-V is disabled! + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + +# This function is necessary to bypass POSIX Path Conversion in Git Bash +# http://www.mingw.org/wiki/Posix_path_conversion +_convert_path(){ + local path=$1 + path=$( echo "$path" | sed -r 's/[\/]+/\\/g') + path=${path#\\} + path=//$path + + echo $path +} + +# Bypass Msys path conversion +REPO_ROOT=$(readlink -f $DIR/..) +REPO_ROOT=$(_convert_path $REPO_ROOT) + +VM_NAME="dotnet" +VM_CODE_DIR="/home/docker/code" + +RESULTS_DIR="$REPO_ROOT/artifacts" + +execute(){ + check_prereqs + + echo "Setting up VM..." + create_or_start_vm + + echo "Copying code from Host to VM" + eval $(docker-machine env --shell bash $VM_NAME) + copy_code_to_vm + + echo "Running Build in Docker Container" + run_build + + echo "Copying Results from VM to Hosts..." + copy_results_from_vm +} + +check_prereqs(){ + if ! which docker; then + echo "Error: Install docker toolbox (https://www.docker.com/docker-toolbox)" + exit 1 + fi + + if ! which docker-machine; then + echo "Error: Install docker toolbox (https://www.docker.com/docker-toolbox)" + exit 1 + fi + +} + +create_or_start_vm(){ + + if [[ $(docker-machine ls | grep $VM_NAME) == "" ]]; then + docker-machine create -d virtualbox $VM_NAME + else + docker-machine start $VM_NAME + fi + +} + +copy_code_to_vm(){ + docker-machine ssh $VM_NAME "sudo rm -rf $VM_CODE_DIR" + docker-machine scp -r $REPO_ROOT $VM_NAME:$VM_CODE_DIR >> /dev/null 2>&1 +} + + +run_build(){ + # These are env variables for dockerbuild.sh + export DOCKER_HOST_SHARE_DIR="$(_convert_path $VM_CODE_DIR)" + echo $DOCKER_HOST_SHARE_DIR + + $DIR/dockerbuild.sh +} + +# This will duplicate the entire repo + any side effects from +# the operations in the docker container +copy_results_from_vm(){ + T_RESULTS_DIR=$( echo "$RESULTS_DIR" | sed -r 's/[\\]+/\//g') + T_RESULTS_DIR=${T_RESULTS_DIR#/} + + mkdir $T_RESULTS_DIR + docker-machine ssh $VM_NAME "sudo chmod -R a+rx $VM_CODE_DIR" + docker-machine scp -r $VM_NAME:$VM_CODE_DIR/artifacts $REPO_ROOT >> /dev/null 2>&1 +} + +execute +