Add mac ulimit -n 2048 workaround and more debug spew in CLI installation into init...
authorYi Zhang (CLR) <yzha@microsoft.com>
Sat, 2 Apr 2016 02:52:43 +0000 (19:52 -0700)
committerYi Zhang (CLR) <yzha@microsoft.com>
Sat, 2 Apr 2016 02:52:43 +0000 (19:52 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/d7653d909ad252b9e9ffab9c6d2089767cb6981f

src/coreclr/init-tools.sh

index 326e651..759a2ec 100755 (executable)
@@ -73,42 +73,55 @@ if [ "$__DistroName" == "rhel" ]; then
     __DOTNET_PKG=dotnet-dev-centos-x64
 fi
 
+# Work around mac build issue 
+if [ "$OS"=="OSX" ]; then
+  echo Raising file open limit - otherwise Mac build may fail
+  echo ulimit -n 2048
+  ulimit -n 2048
+fi
+
 __CLIDownloadURL=https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/${__DOTNET_TOOLS_VERSION}/${__DOTNET_PKG}.${__DOTNET_TOOLS_VERSION}.tar.gz
 echo ".NET CLI will be downloaded from $__CLIDownloadURL"
+echo "Locating $__PROJECT_JSON_FILE to see if we already downloaded .NET CLI tools..." 
 
 if [ ! -e $__PROJECT_JSON_FILE ]; then
- if [ -e $__TOOLRUNTIME_DIR ]; then rm -rf -- $__TOOLRUNTIME_DIR; fi
-
- if [ ! -e $__DOTNET_PATH ]; then
-    # curl has HTTPS CA trust-issues less often than wget, so lets try that first.
-    which curl > /dev/null 2> /dev/null
-    if [ $? -ne 0 ]; then
-      mkdir -p "$__DOTNET_PATH"
-      wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL
-    else
-      curl -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL
-    fi
-    cd $__DOTNET_PATH
-    tar -xf $__DOTNET_PATH/dotnet.tar
-    if [ -n "$BUILDTOOLS_OVERRIDE_RUNTIME" ]; then
-        find $__DOTNET_PATH -name *.ni.* | xargs rm 2>/dev/null
-        cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/bin
-        cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/bin/dnx
-        cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/runtime/coreclr
-    fi
+    echo "$__PROJECT_JSON_FILE not found. Proceeding to download .NET CLI tools. " 
+    if [ -e $__TOOLRUNTIME_DIR ]; then rm -rf -- $__TOOLRUNTIME_DIR; fi
+
+    if [ ! -e $__DOTNET_PATH ]; then
+        # curl has HTTPS CA trust-issues less often than wget, so lets try that first.
+        which curl > /dev/null 2> /dev/null
+        if [ $? -ne 0 ]; then
+          mkdir -p "$__DOTNET_PATH"
+          wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL
+          echo "wget -q -O $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL"
+        else
+          curl -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL
+          echo "curl -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar $__CLIDownloadURL"
+        fi
+        cd $__DOTNET_PATH
+        tar -xf $__DOTNET_PATH/dotnet.tar
+        if [ -n "$BUILDTOOLS_OVERRIDE_RUNTIME" ]; then
+            find $__DOTNET_PATH -name *.ni.* | xargs rm 2>/dev/null
+            cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/bin
+            cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/bin/dnx
+            cp -R $BUILDTOOLS_OVERRIDE_RUNTIME/* $__DOTNET_PATH/runtime/coreclr
+        fi
 
-    cd $__scriptpath
- fi
+        cd $__scriptpath
   fi
 
- mkdir "$__PROJECT_JSON_PATH"
- echo $__PROJECT_JSON_CONTENTS > "$__PROJECT_JSON_FILE"
   mkdir "$__PROJECT_JSON_PATH"
   echo $__PROJECT_JSON_CONTENTS > "$__PROJECT_JSON_FILE"
 
- if [ ! -e $__BUILD_TOOLS_PATH ]; then
-    $__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE
- fi
   if [ ! -e $__BUILD_TOOLS_PATH ]; then
+        $__DOTNET_CMD restore "$__PROJECT_JSON_FILE" --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE
   fi
 
- # On ubuntu 14.04, /bin/sh (symbolic link) calls /bin/dash by default.
- $__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR
   # On ubuntu 14.04, /bin/sh (symbolic link) calls /bin/dash by default.
   $__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR
 
- chmod a+x $__TOOLRUNTIME_DIR/corerun
+    chmod a+x $__TOOLRUNTIME_DIR/corerun
+else
+    echo "$__PROJECT_JSON_FILE found. Skipping .NET CLI installation."   
 fi