From 3a66c04f23cde0b4a542cabb5d32a4e828a50a21 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 8 Sep 2016 16:21:20 -0700 Subject: [PATCH] Add -NoSudo option to Start-PSBootstrap --- build.psm1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.psm1 b/build.psm1 index 1d2cfc361..977fc6284 100644 --- a/build.psm1 +++ b/build.psm1 @@ -688,6 +688,7 @@ function Start-PSBootstrap { [string]$Channel = "rel-1.0.0", [string]$Version = "latest", [switch]$Package, + [switch]$NoSudo, [switch]$Force ) @@ -695,6 +696,10 @@ function Start-PSBootstrap { Push-Location $PSScriptRoot/tools + # This allows sudo install to be optional; needed when running in containers / as root + # Note that when it is null, Invoke-Expression (but not &) must be used to interpolate properly + $sudo = if (!$NoSudo) { "sudo" } + try { # Update googletest submodule for linux native cmake if ($IsLinux -or $IsOSX) { @@ -723,7 +728,7 @@ function Start-PSBootstrap { if ($Package) { $Deps += "ruby-dev", "groff" } # Install dependencies - sudo apt-get install -y -qq $Deps + Start-NativeExecution { Invoke-Expression "$sudo apt-get install -y -qq $Deps" } } elseif ($IsCentOS) { # Build tools $Deps += "which", "curl", "gcc-c++", "cmake", "make" @@ -735,7 +740,9 @@ function Start-PSBootstrap { if ($Package) { $Deps += "ruby-devel", "rpm-build", "groff" } # Install dependencies - sudo yum install -y -q $Deps + Start-NativeExecution { + Invoke-Expression "$sudo yum install -y -q $Deps" + } } elseif ($IsOSX) { precheck 'brew' "Bootstrap dependency 'brew' not found, must install Homebrew! See http://brew.sh/"