diff --git a/.github/workflows/build-cross-action.yml b/.github/workflows/build-cross-action.yml index d718ec52..bf957b4d 100644 --- a/.github/workflows/build-cross-action.yml +++ b/.github/workflows/build-cross-action.yml @@ -187,7 +187,7 @@ jobs: - name: Install VS Build Tools run: | - relenv/_scripts/install_vc_build.ps1 + relenv/_scripts/install_vc_build.ps1 -CICD - name: Install nox run: | diff --git a/.github/workflows/build-native-action.yml b/.github/workflows/build-native-action.yml index e07d2825..4a96ad4a 100644 --- a/.github/workflows/build-native-action.yml +++ b/.github/workflows/build-native-action.yml @@ -223,7 +223,7 @@ jobs: - name: Install VS Build Tools run: | - relenv/_scripts/install_vc_build.ps1 + relenv/_scripts/install_vc_build.ps1 -CICD - name: Install nox run: | diff --git a/.github/workflows/verify-build-action.yml b/.github/workflows/verify-build-action.yml index 1a9aca97..a7f2c9ee 100644 --- a/.github/workflows/verify-build-action.yml +++ b/.github/workflows/verify-build-action.yml @@ -215,7 +215,7 @@ jobs: - name: Install VS Build Tools run: | - relenv/_scripts/install_vc_build.ps1 + relenv/_scripts/install_vc_build.ps1 -CICD - name: Install nox run: | diff --git a/relenv/_scripts/install_vc_build.ps1 b/relenv/_scripts/install_vc_build.ps1 index 341178f3..19fe28b9 100644 --- a/relenv/_scripts/install_vc_build.ps1 +++ b/relenv/_scripts/install_vc_build.ps1 @@ -1,22 +1,82 @@ -# Copyright 2022 VMware, Inc. -# SPDX-License-Identifier: Apache-2 - <# -Taken from: https://github.com/saltstack/salt-windows-nsis/blob/main/scripts/install_vs_buildtools.bat - .SYNOPSIS Script that installs Visual Studio Build Tools + .DESCRIPTION This script installs the Visual Studio Build Tools if they are not already present on the system. Visual Studio Build Tools are the binaries and libraries needed to build Python from source. + .EXAMPLE install_vc_buildtools.ps1 + #> +param( + [Parameter(Mandatory=$false)] + [Alias("c")] +# Don't prettify the output of the Write-Result + [Switch] $CICD +) +#------------------------------------------------------------------------------- # Script Preferences +#------------------------------------------------------------------------------- + +[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 $ProgressPreference = "SilentlyContinue" $ErrorActionPreference = "Stop" +# https://stackoverflow.com/a/67201331/4581998 +$env:PSModulePath = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') + +#------------------------------------------------------------------------------- +# Script Functions +#------------------------------------------------------------------------------- + +function Write-Result($result, $ForegroundColor="Green") { + if ( $CICD ) { + Write-Host $result -ForegroundColor $ForegroundColor + } else { + $position = 80 - $result.Length - [System.Console]::CursorLeft + Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "") + } +} + +function Add-Certificate { + [CmdletBinding()] + param( + + [Parameter(Mandatory=$true)] + # The path in the certstore (CERT:/LocalMachine/Root/) + [String] $Path, + + [Parameter(Mandatory=$true)] + # The path to the cert file for importing + [String] $File, + + [Parameter(Mandatory=$true)] + # The name of the cert file for importing + [String] $Name + + ) + + # Validation + if ( ! (Test-Path -Path $File)) { + Write-Host "Invalid path to certificate file" + exit 1 + } + + if (! (Test-Path -Path $Path) ) { + + Write-Host "Installing Certificate $Name`: " -NoNewLine + $output = Import-Certificate -FilePath $File -CertStoreLocation "Cert:\LocalMachine\Root" + if ( Test-Path -Path $Path ) { + Write-Result "Success" + } else { + Write-Result "Failed" -ForegroundColor Yellow + Write-Host $output + } + } +} #------------------------------------------------------------------------------- # Start the Script @@ -32,31 +92,38 @@ Write-Host $("-" * 80) # Dependency Variables $VS_BLD_TOOLS = "https://aka.ms/vs/15/release/vs_buildtools.exe" -$VS_CL_BIN = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\VC\bin\cl.exe" -$MSBUILD_BIN = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" -$WIN10_SDK_RC = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\10.0.17763.0\x64\rc.exe" +try { + # If VS is installed, you will be able to get the WMI Object MSFT_VSInstance + $VS_INST_LOC = $(Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs).InstallLocation + $MSBUILD_BIN = $(Get-ChildItem "$VS_INST_LOC\MSBuild\*\Bin\msbuild.exe").FullName +} catch { + # If VS is not installed, this is the fallback for this installation + $MSBUILD_BIN = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" +} #------------------------------------------------------------------------------- # Visual Studio #------------------------------------------------------------------------------- -$install_build_tools = $false Write-Host "Confirming Presence of Visual Studio Build Tools: " -NoNewline -@($VS_CL_BIN, $MSBUILD_BIN, $WIN10_SDK_RC) | ForEach-Object { - if ( ! (Test-Path -Path $_) ) { - $install_build_tools = $true - } -} +# We're only gonna look for msbuild.exe +if ( Test-Path -Path $MSBUILD_BIN ) { + Write-Result "Success" -ForegroundColor Green +} else { + Write-Result "Missing" -ForegroundColor Yellow -if ( $install_build_tools ) { - Write-Host "Missing" -ForegroundColor Yellow + try { + # If VS is installed, you will be able to get the WMI Object MSFT_VSInstance + Write-Host "Get VS Instance Information" + Get-CimInstance MSFT_VSInstance -Namespace root/cimv2/vs + } catch {} Write-Host "Checking available disk space: " -NoNewLine $available = (Get-PSDrive $env:SystemDrive.Trim(":")).Free if ( $available -gt (1024 * 1024 * 1024 * 9.1) ) { - Write-Host "Success" -ForegroundColor Green + Write-Result "Success" -ForegroundColor Green } else { - Write-Host "Failed" -ForegroundColor Red + Write-Result "Failed" -ForegroundColor Red Write-Host "Not enough disk space" exit 1 } @@ -64,9 +131,9 @@ if ( $install_build_tools ) { Write-Host "Downloading Visual Studio 2017 build tools: " -NoNewline Invoke-WebRequest -Uri "$VS_BLD_TOOLS" -OutFile "$env:TEMP\vs_buildtools.exe" if ( Test-Path -Path "$env:TEMP\vs_buildtools.exe" ) { - Write-Host "Success" -ForegroundColor Green + Write-Result "Success" -ForegroundColor Green } else { - Write-Host "Failed" -ForegroundColor Red + Write-Result "Failed" -ForegroundColor Red exit 1 } @@ -80,71 +147,54 @@ if ( $install_build_tools ) { "--add Microsoft.VisualStudio.Workload.MSBuildTools", ` "--add Microsoft.VisualStudio.Workload.VCTools", ` "--add Microsoft.VisualStudio.Component.Windows81SDK", ` - "--add Microsoft.VisualStudio.Component.Windows10SDK.17763", ` "--add Microsoft.VisualStudio.Component.VC.140", ` - "--add Microsoft.Component.VC.Runtime.UCRTSDK", ` "--lang en-US", ` "--includeRecommended", ` "--quiet", ` "--wait" ` -Wait -WindowStyle Hidden if ( Test-Path -Path "$env:TEMP\build_tools\vs_buildtools.exe" ) { - Write-Host "Success" -ForegroundColor Green + Write-Result "Success" -ForegroundColor Green } else { - Write-Host "Failed" -ForegroundColor Red + Write-Result "Failed" -ForegroundColor Red exit 1 } - # Serial: 28cc3a25bfba44ac449a9b586b4339a + # Serial: 28cc3a25bfba44ac449a9b586b4339aa # Hash: 3b1efd3a66ea28b16697394703a72ca340a05bd5 - if (! (Test-Path -Path Cert:\LocalMachine\Root\3b1efd3a66ea28b16697394703a72ca340a05bd5) ) { - Write-Host "Installing Certificate Sign Root Certificate: " -NoNewLine - Start-Process -FilePath "certutil" ` - -ArgumentList "-addstore", ` - "Root", ` - "$($env:TEMP)\build_tools\certificates\manifestCounterSignRootCertificate.cer" ` - -Wait -WindowStyle Hidden - if ( Test-Path -Path Cert:\LocalMachine\Root\3b1efd3a66ea28b16697394703a72ca340a05bd5 ) { - Write-Host "Success" -ForegroundColor Green - } else { - Write-Host "Failed" -ForegroundColor Yellow - } - } + $cert_name = "Sign Root Certificate" + $cert_path = "Cert:\LocalMachine\Root\3b1efd3a66ea28b16697394703a72ca340a05bd5" + $cert_file = "$env:TEMP\build_tools\certificates\manifestCounterSignRootCertificate.cer" + Add-Certificate -Name $cert_name -Path $cert_path -File $cert_file # Serial: 3f8bc8b5fc9fb29643b569d66c42e144 # Hash: 8f43288ad272f3103b6fb1428485ea3014c0bcfe - if (! (Test-Path -Path Cert:\LocalMachine\Root\8f43288ad272f3103b6fb1428485ea3014c0bcfe) ) { - Write-Host "Installing Certificate Root Certificate: " -NoNewLine - Start-Process -FilePath "certutil" ` - -ArgumentList "-addstore", ` - "Root", ` - "$($env:TEMP)\build_tools\certificates\manifestRootCertificate.cer" ` - -Wait -WindowStyle Hidden - if ( Test-Path -Path Cert:\LocalMachine\Root\8f43288ad272f3103b6fb1428485ea3014c0bcfe ) { - Write-Host "Success" -ForegroundColor Green - } else { - Write-Host "Failed" -ForegroundColor Yellow - } - } + $cert_name = "Root Certificate" + $cert_path = "Cert:\LocalMachine\Root\8f43288ad272f3103b6fb1428485ea3014c0bcfe" + $cert_file = "$env:TEMP\build_tools\certificates\manifestRootCertificate.cer" + Add-Certificate -Name $cert_name -Path $cert_path -File $cert_file Write-Host "Installing Visual Studio 2017 build tools: " -NoNewline - Start-Process -FilePath "$env:TEMP\build_tools\vs_setup.exe" ` - -ArgumentList "--wait", "--noweb", "--quiet" ` - -Wait - @($VS_CL_BIN, $MSBUILD_BIN, $WIN10_SDK_RC) | ForEach-Object { - if ( ! (Test-Path -Path $_) ) { - Write-Host "Failed" -ForegroundColor Red - exit 1 - } + $proc = Start-Process ` + -FilePath "$env:TEMP\build_tools\vs_setup.exe" ` + -ArgumentList "--wait", "--noweb", "--quiet" ` + -PassThru -Wait ` + -RedirectStandardOutput "$env:TEMP\stdout.txt" + if ( Test-Path -Path $MSBUILD_BIN ) { + Write-Result "Failed" -ForegroundColor Red + Write-Host "Missing: $_" + Write-Host "ExitCode: $($proc.ExitCode)" + Write-Host "STDOUT:" + Get-Content "$env:TEMP\stdout.txt" + exit 1 } - Write-Host "Success" -ForegroundColor Green -} else { - Write-Host "Success" -ForegroundColor Green + Write-Result "Success" -ForegroundColor Green } #------------------------------------------------------------------------------- # Finished #------------------------------------------------------------------------------- + Write-Host $("-" * 80) Write-Host "Install Visual Studio Build Tools Completed" -ForegroundColor Cyan Write-Host $("=" * 80) diff --git a/relenv/build/linux.py b/relenv/build/linux.py index 8ac59f2a..8b8d2afa 100644 --- a/relenv/build/linux.py +++ b/relenv/build/linux.py @@ -582,8 +582,8 @@ def build_python(env, dirs, logfp): wait_on=["openssl"], download={ "url": "https://kerberos.org/dist/krb5/{version}/krb5-{version}.tar.gz", - "version": "1.21", - "checksum": "e2ee531443122376ac8b62b3848d94376f646089", + "version": "1.22", + "checksum": "3ad930ab036a8dc3678356fbb9de9246567e7984", "checkfunc": krb_version, "checkurl": "https://kerberos.org/dist/krb5/", },