From ddcfc61a2dff9cdf2ea03ffa4dc3707aafb28b0e Mon Sep 17 00:00:00 2001 From: Peter Mounce Date: Mon, 6 Mar 2017 18:30:13 +0000 Subject: Fix powershellv2 Powershell v2 (win7 vintage) doesn't have json cmdlets. Got a report via chocolatey.org message that this doesn't work on win7. Cried. Replaced with simpler text file based approach for separating data from code. Also fix package version fix notation bit of the automation to produce version numbers valid with chocolatey/nuspec. I've already published a fixed 0.4.5-rc2 and 0.4.4 with this * https://chocolatey.org/packages/bazel/0.4.4.20170306 * https://chocolatey.org/packages/bazel/0.4.5-rc2-20170306-124051 Closes #2633. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/2633 PiperOrigin-RevId: 149314972 MOS_MIGRATED_REVID=149314972 --- scripts/packages/chocolatey/build.ps1 | 21 +++++++++++---------- scripts/packages/chocolatey/test.ps1 | 7 ++++--- .../packages/chocolatey/tools/chocolateyinstall.ps1 | 18 +++++++----------- 3 files changed, 22 insertions(+), 24 deletions(-) (limited to 'scripts/packages') diff --git a/scripts/packages/chocolatey/build.ps1 b/scripts/packages/chocolatey/build.ps1 index ae1d594163..2b196d9415 100644 --- a/scripts/packages/chocolatey/build.ps1 +++ b/scripts/packages/chocolatey/build.ps1 @@ -27,13 +27,17 @@ if ($mode -eq "release") { } if ($fixPackage -eq $true) { - $tvPackageFixVersion = "-$((get-date).tostring("yyyyMMdd-hhmmss"))" + $prefix = "-" + if ($mode -eq "release") { + $prefix = "." + } + $tvPackageFixVersion = "$($prefix)$((get-date).tostring("yyyyMMdd"))" } rm -force -ErrorAction SilentlyContinue ./*.nupkg rm -force -ErrorAction SilentlyContinue ./bazel.nuspec rm -force -ErrorAction SilentlyContinue ./tools/LICENSE -rm -force -ErrorAction SilentlyContinue ./tools/params.json rm -force -ErrorAction SilentlyContinue ./tools/*.orig +rm -force -ErrorAction SilentlyContinue "./tools/params.*" if ($checksum -eq "") { rm -force -ErrorAction SilentlyContinue ./*.zip } @@ -63,13 +67,10 @@ From: https://github.com/bazelbuild/bazel/blob/master/LICENSE add-content -value $licenseHeader -path "./tools/LICENSE" add-content -value (get-content "../../../LICENSE") -path "./tools/LICENSE" -$params = @{ - package = @{ - uri = $tvUri; - checksum = $tvChecksum; - checksumType = "sha256"; - } -} -add-content -value (ConvertTo-Json $params) -path "./tools/params.json" +$params = @" +$tvUri +$tvChecksum +"@ +add-content -value $params -path "./tools/params.txt" choco pack ./bazel.nuspec diff --git a/scripts/packages/chocolatey/test.ps1 b/scripts/packages/chocolatey/test.ps1 index febbc2f417..b561ba2a98 100644 --- a/scripts/packages/chocolatey/test.ps1 +++ b/scripts/packages/chocolatey/test.ps1 @@ -1,12 +1,13 @@ param( - [switch] $prerelease + [switch] $prerelease, + [string] $sources = "." ) choco uninstall bazel --force -y if ($prerelease) { - choco install bazel --verbose --debug --prerelease --force -y -s ".;https://chocolatey.org/api/v2/" + choco install bazel --verbose --debug --prerelease --force -y -s $sources } else { - choco install bazel --verbose --debug --force -y -s ".;https://chocolatey.org/api/v2/" + choco install bazel --verbose --debug --force -y -s $sources } if ($LASTEXITCODE -ne 0) diff --git a/scripts/packages/chocolatey/tools/chocolateyinstall.ps1 b/scripts/packages/chocolatey/tools/chocolateyinstall.ps1 index fbd3cc32b0..2690150391 100644 --- a/scripts/packages/chocolatey/tools/chocolateyinstall.ps1 +++ b/scripts/packages/chocolatey/tools/chocolateyinstall.ps1 @@ -2,22 +2,18 @@ $ErrorActionPreference = 'Stop'; # stop on all errors $packageName = 'bazel' $toolsDir = Split-Path -parent $MyInvocation.MyCommand.Definition -$json = gc "$toolsDir\params.json" -$p = (($json) -join "`n") | convertfrom-json +$paramsText = get-content "$($toolsDir)\params.txt" +$p = $paramsText.Split("`n") $packageDir = Split-Path -parent $toolsDir -$binRoot = (Get-ToolsLocation) -replace "\\", "/" -write-host "Read params from json" -write-host (convertto-json $p) +write-host "Read params from text file" +write-host $p Install-ChocolateyZipPackage -PackageName "$packageName" ` - -Url "$($p.package.uri)" ` - -Checksum "$($p.package.checksum)" ` - -ChecksumType "$($p.package.checksumType)" ` - -Url64bit "$($p.package.uri)" ` - -Checksum64 "$($p.package.checksum)" ` - -Checksum64Type "$($p.package.checksumType)" ` + -Url64bit "$($p[0])" ` + -Checksum64 "$($p[1])" ` + -Checksum64Type "sha256" ` -UnzipLocation "$packageDir" write-host "Ensure that msys2 dll is present in PATH to allow bazel to be run from non-msys2 shells" -- cgit v1.2.3