Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Expand-Archive to 7zip on Windows image generation #861

Merged
merged 12 commits into from
May 13, 2020
1 change: 1 addition & 0 deletions images/win/scripts/ImageHelpers/ImageHelpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Export-ModuleMember -Function @(
'Test-IsWin19'
'Test-IsWin16'
'Choco-Install'
'Extract-7Zip'
)
19 changes: 19 additions & 0 deletions images/win/scripts/ImageHelpers/InstallHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,22 @@ function Test-IsWin16
{
(Get-WinVersion) -match "2016"
}

function Extract-7Zip {
param
(
[Parameter(Mandatory=$true)]
[string]$Path,
[Parameter(Mandatory=$true)]
[string]$DestinationPath
)

Write-Host "Expand archive '$PATH' to '$DestinationPath' directory"
7z.exe x "$Path" -o"$DestinationPath" -y | Out-Null
dibir-magomedsaygitov marked this conversation as resolved.
Show resolved Hide resolved

if ($LASTEXITCODE -ne 0)
{
Write-Host "There is an error during expanding '$Path' to '$DestinationPath' directory"
exit 1
}
}
2 changes: 1 addition & 1 deletion images/win/scripts/Installers/Install-Chrome.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $ChromeDriverZipDownloadUrl = "https://chromedriver.storage.googleapis.com/${Chr
$ChromeDriverArchPath = Start-DownloadWithRetry -Url $ChromeDriverZipDownloadUrl -Name $ChromeDriverArchName

Write-Host "Expand Chrome WebDriver archive..."
dibir-magomedsaygitov marked this conversation as resolved.
Show resolved Hide resolved
Expand-Archive -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath -Force
Extract-7Zip -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath

Write-Host "Setting the environment variables..."
setx ChromeWebDriver "$ChromeDriverPath" /M
Expand Down
2 changes: 1 addition & 1 deletion images/win/scripts/Installers/Install-CloudFoundryCli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ New-Item -Path $CloudFoundryCliPath -ItemType Directory -Force

# Extract the zip archive
Write-Host "Extracting cf cli..."
Expand-Archive -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath -Force
Extract-7Zip -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath

# Add cf to path
Add-MachinePathItem $CloudFoundryCliPath
2 changes: 1 addition & 1 deletion images/win/scripts/Installers/Install-Edge.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $EdgeDriverDownloadUrl="https://msedgedriver.azureedge.net/${EdgeDriverLatestVer
$EdgeDriverArchPath = Start-DownloadWithRetry -Url $EdgeDriverDownloadUrl -Name $EdgeDriverArchName

Write-Host "Expand Microsoft Edge WebDriver archive..."
Expand-Archive -Path $EdgeDriverArchPath -DestinationPath $EdgeDriverPath -Force
Extract-7Zip -Path $EdgeDriverArchPath -DestinationPath $EdgeDriverPath

Write-Host "Setting the environment variables..."
setx EdgeWebDriver "$EdgeDriverPath" /M
Expand Down
2 changes: 1 addition & 1 deletion images/win/scripts/Installers/Install-Firefox.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $GeckoDriverDownloadUrl = $GeckoDriverWindowsAsset.browser_download_url
$GeckoDriverArchPath = Start-DownloadWithRetry -Url $GeckoDriverDownloadUrl -Name $GeckoDriverArchName

Write-Host "Expand Gecko WebDriver archive..."
Expand-Archive -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath -Force
Extract-7Zip -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath

Write-Host "Setting the environment variables..."
Add-MachinePathItem -PathItem $GeckoDriverPath
Expand Down
4 changes: 2 additions & 2 deletions images/win/scripts/Installers/Install-Go.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function Install-GoVersion
[Switch] $addToDefaultPath
)

$latestVersionObject = $refsJson | Where-Object { $_.ref -Match "refs/tags/go$goVersion[./d]*" } | Select-Object -Last 1
$latestVersionObject = $refsJson | Where-Object { $_.ref -Match "refs/tags/go$goVersion[./d]*" } | Select-Object -Last 1
$latestVersion = $latestVersionObject.ref.replace('refs/tags/go','')

# Download the Go zip archive.
Expand All @@ -30,7 +30,7 @@ function Install-GoVersion
# Extract the zip archive. It contains a single directory named "go".
Write-Host "Extracting Go $latestVersion..."
$toolDirectory = Join-Path $env:AGENT_TOOLSDIRECTORY "go\$latestVersion"
7z.exe x $goArchPath -o"$toolDirectory" -y | Out-Null
Extract-7Zip -Path $goArchPath -DestinationPath $toolDirectory

# Rename the extracted "go" directory to "x64" for full path "C:\hostedtoolcache\windows\Go\1.14.2\x64\..."
Rename-Item -path "$toolDirectory\go" -newName "x64"
Expand Down
18 changes: 9 additions & 9 deletions images/win/scripts/Installers/Install-IEWebDriver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
## File: Install-SeleniumWebDrivers.ps1
## Desc: Install Selenium Web Drivers
################################################################################
$DestinationPath = "$($env:SystemDrive)\";
$DestinationPath = "$($env:SystemDrive)\"
$DriversZipFile = "SeleniumWebDrivers.zip"
Write-Host "Destination path: [$DestinationPath]";
Write-Host "Selenium drivers download and install...";
Write-Host "Destination path: [$DestinationPath]"
Write-Host "Selenium drivers download and install..."
try {
Invoke-WebRequest -UseBasicParsing -Uri "https://seleniumwebdrivers.blob.core.windows.net/seleniumwebdrivers/${DriversZipFile}" -OutFile $DriversZipFile;
Invoke-WebRequest -UseBasicParsing -Uri "https://seleniumwebdrivers.blob.core.windows.net/seleniumwebdrivers/${DriversZipFile}" -OutFile $DriversZipFile
}
catch {
Write-Error "[!] Failed to download $DriversZipFile";
exit 1;
Write-Error "[!] Failed to download $DriversZipFile"
exit 1
}

$TempSeleniumDir = Join-Path $Env:TEMP "SeleniumWebDrivers"
Expand-Archive -Path $DriversZipFile -DestinationPath $Env:TEMP -Force;
Remove-Item $DriversZipFile;
Extract-7Zip -Path $DriversZipFile -DestinationPath $Env:TEMP
Remove-Item $DriversZipFile

$SeleniumWebDriverPath = Join-Path $DestinationPath "SeleniumWebDrivers"
$IEDriverPathTemp = Join-Path $TempSeleniumDir 'IEDriver'
Expand All @@ -29,4 +29,4 @@ Move-Item -Path "$IEDriverPathTemp" -Destination $SeleniumWebDriverPath

Write-Host "Setting the environment variables"

setx IEWebDriver "C:\SeleniumWebDrivers\IEDriver" /M;
setx IEWebDriver "C:\SeleniumWebDrivers\IEDriver" /M
2 changes: 1 addition & 1 deletion images/win/scripts/Installers/Install-JavaTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ $uri = 'https://ayera.dl.sourceforge.net/project/cobertura/cobertura/2.1.1/cober
$coberturaPath = "C:\cobertura-2.1.1"

$archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip"
Expand-Archive -Path $archivePath -DestinationPath "C:\"
Extract-7Zip -Path $archivePath -DestinationPath "C:\"

setx COBERTURA_HOME $coberturaPath /M
2 changes: 1 addition & 1 deletion images/win/scripts/Installers/Install-MysqlCli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Install-Binary -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentLi
$mysqlArchPath = Start-DownloadWithRetry -Url $MysqlVersionUrl -Name "mysql.zip"

# Expand the zip
Expand-Archive -Path $mysqlArchPath -DestinationPath "C:\" -Force
Extract-7Zip -Path $mysqlArchPath -DestinationPath "C:\"

# Adding mysql in system environment path
Add-MachinePathItem $mysqlPath