diff --git a/WASP/Private/Install-ChocolateyInstallPackage.ps1 b/WASP/Private/Install-ChocolateyInstallPackage.ps1 index 0e56e12..7ee7074 100644 --- a/WASP/Private/Install-ChocolateyInstallPackage.ps1 +++ b/WASP/Private/Install-ChocolateyInstallPackage.ps1 @@ -1,14 +1,13 @@ function Install-ChocolateyInstallPackage() { <# .SYNOPSIS - This function overrides the Install-ChocolateyInstallPackage function and receives an optional filepath. It checks if the binary already exists or if it has to be downloaded first. + This function checks if the binary already exists or if it has to be downloaded first and overrides the Install-ChocolateyInstallPackage function. .DESCRIPTION This function receives and saves the parameters which are given in the package script. If there is file parameter given the function checks if the binary exists or not. If it does not exist the VERIFICATION.txt will be checked to retrieve an url and checksums. - With this parameters the Chocolatey Web downloader can be started and the binary can be downloaded into the tools folder of the package. - In the end the script gets modified by calling the Edit-ChocolateyInstaller script. + Prior to this step the script gets modified by calling the Edit-ChocolateyInstaller script. .PARAMETER all For further information to the parameters: @@ -149,13 +148,22 @@ function Install-ChocolateyInstallPackage() { } } - # Check the url found above ($url or $url64bit) and download the file - if ($null -ne $url) { - $urlFound = $url - } elseif ($null -ne $url64bit) { + # Check the url found above ($url or $url64bit) and download the file. url64bit is preferred over url32 bit! + $urlFound = '' + + if ($url64bit -ne '' -and $null -ne $url64bit) { $urlFound = $url64bit - } + } elseif ($url -ne '' -and $null -ne $url) { + $urlFound = $url + } + if ($urlFound -eq ''){ + Write-Log "No url in Package found - Stop! url64bit: $url64bit, url: $url" -Severity 3 + exit 1 + } + + Write-Log "Found the following URL: $urlFound" -Severity 1 + Write-Log "Start editing chocolateyInstall..." -Severity 1 $defaultFileName = $urlFound.Split("/")[-1] @@ -166,7 +174,8 @@ function Install-ChocolateyInstallPackage() { $downloadFilePath = Join-Path (Join-Path (Get-Item -Path ".\").FullName "tools") "$($packageName)Install.$fileType" $checksumType = Get-ChecksumTypeFromVerificationFile -Checksums $checksum, $checksum64 $checksumType64 = $checksumType - + + # Get-ChocolateyWebFile works like this: url64bit is preferred over url32 bit! $null = Get-ChocolateyWebFile -PackageName $packageName ` -FileFullPath $downloadFilePath ` -Url $url ` diff --git a/WASP/Private/Install-ChocolateyPackage.ps1 b/WASP/Private/Install-ChocolateyPackage.ps1 index 2a45437..229e477 100644 --- a/WASP/Private/Install-ChocolateyPackage.ps1 +++ b/WASP/Private/Install-ChocolateyPackage.ps1 @@ -1,12 +1,12 @@ function Install-ChocolateyPackage() { <# .SYNOPSIS - This function overrides the Install-ChocolateyPackage function and receives an url and checksums to download the package binary. + This function receives an url and checksums to download the package binary and overrides the Install-ChocolateyPackage. .DESCRIPTION This function receives and saves the parameters which are given in the package script. - With this parameters the Chocolatey Web downloader can be started and the binary can be downloaded into the tools folder of the package. - In the end the script gets modified by calling the Edit-ChocolateyInstaller script. + With this parameters the Chocolatey Web downloader can be started and the binary can be downloaded into the tools folder of the package. + Prior to this step the script gets modified by calling the Edit-ChocolateyInstaller script. .PARAMETER all For further information to the parameters: @@ -37,12 +37,21 @@ function Install-ChocolateyPackage() { [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) - # Check the url found above ($url or $url64bit) and download the file - if ($null -ne $url) { - $urlFound = $url - } elseif ($null -ne $url64bit) { + # Check the url found above ($url or $url64bit) and download the file. url64bit is preferred over url32 bit! + $urlFound = '' + + if ($url64bit -ne '' -and $null -ne $url64bit) { $urlFound = $url64bit - } + } elseif ($url -ne '' -and $null -ne $url) { + $urlFound = $url + } + + if ($urlFound -eq ''){ + Write-Log "No url in Package found - Stop! url64bit: $url64bit, url: $url" -Severity 3 + exit 1 + } + + Write-Log "Found the following URL: $urlFound" -Severity 1 Write-Log "Start editing chocolateyInstall..." -Severity 1 @@ -58,6 +67,7 @@ function Install-ChocolateyPackage() { if ($url -or $url64bit) { $downloadFilePath = Join-Path (Join-Path (Get-Item -Path ".\").FullName "tools") "$($packageName)Install.$fileType" + # Get-ChocolateyWebFile works like this: url64bit is preferred over url32 bit! $null = Get-ChocolateyWebFile -PackageName $packageName ` -FileFullPath $downloadFilePath ` -Url $url ` diff --git a/WASP/Private/Install-ChocolateyPowershellCommand.ps1 b/WASP/Private/Install-ChocolateyPowershellCommand.ps1 index ae626c8..c6b7e72 100644 --- a/WASP/Private/Install-ChocolateyPowershellCommand.ps1 +++ b/WASP/Private/Install-ChocolateyPowershellCommand.ps1 @@ -1,12 +1,12 @@ function Install-ChocolateyPowershellCommand() { <# .SYNOPSIS - This function overrides the Install-ChocolateyPowershellCommand function and receives an url and checksums to download the package binary. + This function receives an url and checksums to download the package binary and overrides the Install-ChocolateyPowershellCommand function. .DESCRIPTION This function receives and saves the parameters which are given in the package script. With this parameters the Chocolatey Web downloader can be started and the binary can be downloaded into the tools folder of the package. - In the end the script gets modified by calling the Edit-ChocolateyInstaller script. + Prior to this step the script gets modified by calling the Edit-ChocolateyInstaller script. .PARAMETER all For further information to the parameters: @@ -31,12 +31,21 @@ function Install-ChocolateyPowershellCommand() { $downloadFilePath = Join-Path (Join-Path (Get-Item -Path ".\").FullName "tools") "$($packageName)Install.ps1" - # Check the url found above ($url or $url64bit) and download the file - if ($null -ne $url) { - $urlFound = $url - } elseif ($null -ne $url64bit) { + # Check the url found above ($url or $url64bit) and download the file. url64bit is preferred over url32 bit! + $urlFound = '' + + if ($url64bit -ne '' -and $null -ne $url64bit) { $urlFound = $url64bit - } + } elseif ($url -ne '' -and $null -ne $url) { + $urlFound = $url + } + + if ($urlFound -eq ''){ + Write-Log "No url in Package found - Stop! url64bit: $url64bit, url: $url" -Severity 3 + exit 1 + } + + Write-Log "Found the following URL: $urlFound" -Severity 1 Write-Log "Start editing chocolateyInstall..." -Severity 1 @@ -52,6 +61,7 @@ function Install-ChocolateyPowershellCommand() { New-Item -Path (Join-Path (Join-Path (Get-Item -Path ".\").FullName "tools") "overridden.info") -Force if ($url -or $url64bit) { + # Get-ChocolateyWebFile works like this: url64bit is preferred over url32 bit! $null = Get-ChocolateyWebFile -PackageName $packageName ` -FileFullPath $downloadFilePath ` -Url $url ` diff --git a/WASP/Private/Install-ChocolateyZipPackage.ps1 b/WASP/Private/Install-ChocolateyZipPackage.ps1 index 4a0465e..95fc773 100644 --- a/WASP/Private/Install-ChocolateyZipPackage.ps1 +++ b/WASP/Private/Install-ChocolateyZipPackage.ps1 @@ -1,15 +1,14 @@ function Install-ChocolateyZipPackage() { <# .SYNOPSIS - This function overrides the Install-ChocolateyZipPackage function and receives a optional filepath or an url to a zip file. Depending on the input the functions downloads and/or unzips the binaries. + This function downloads and/or unzips the binaries and overrides the Install-ChocolateyZipPackage function and receives a optional filepath or an url to a zip file. .DESCRIPTION This function receives and saves the parameters which are given in the package script. If there is file parameter given the function checks if the binary exists or not. If it does not exist and there is also no url given the VERIFICATION.txt will be checked to retrieve an url and checksums. If there is a url given or a url found in the VERIFICATION.txt file it will be downloaded. Afterwards the zip will be unpacked into the tools folder. - - In the end the script gets modified by calling the Edit-ChocolateyInstaller script. + Prior the script gets modified by calling the Edit-ChocolateyInstaller script. .PARAMETER all For further information to the parameters: @@ -116,12 +115,21 @@ function Install-ChocolateyZipPackage() { $checksumType64 = $checksumType } - # Check the url found above ($url or $url64bit) and download the file - if ($null -ne $url) { - $urlFound = $url - } elseif ($null -ne $url64bit) { + # Check the url found above ($url or $url64bit) and download the file. url64bit is preferred over url32 bit! + $urlFound = '' + + if ($url64bit -ne '' -and $null -ne $url64bit) { $urlFound = $url64bit - } + } elseif ($url -ne '' -and $null -ne $url) { + $urlFound = $url + } + + if ($urlFound -eq ''){ + Write-Log "No url in Package found - Stop! url64bit: $url64bit, url: $url" -Severity 3 + exit 1 + } + + Write-Log "Found the following URL: $urlFound" -Severity 1 Write-Log "Start editing chocolateyInstall..." -Severity 1 @@ -133,6 +141,7 @@ function Install-ChocolateyZipPackage() { try { if (-Not $remoteFile) { + # Get-ChocolateyWebFile works like this: url64bit is preferred over url32 bit! $null = Get-ChocolateyWebFile -PackageName $packageName ` -FileFullPath $downloadFilePath ` -Url $url `