Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Initial support for .run packages. #651

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ $nugetPath = (Split-Path -Parent $nugetChocolateyPath)
$nugetExePath = Join-Path $nuGetPath 'bin'
$nugetLibPath = Join-Path $nuGetPath 'lib'
$badLibPath = Join-Path $nuGetPath 'lib-bad'
$runLibPath = Join-Path $nuGetPath 'lib-run'
$extensionsPath = Join-Path $nugetPath 'extensions'
$chocInstallVariableName = "ChocolateyInstall"
$nugetExe = Join-Path $nugetChocolateyPath 'nuget.exe'
Expand Down
47 changes: 34 additions & 13 deletions src/functions/Chocolatey-NuGet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ param(
$srcArgs = "(from $source)"
}

$isRunPackage = $packageName.ToLower().EndsWith('.run');
Write-Host "Chocolatey (v$chocVer) is installing `'$packageName`' and dependencies. By installing you accept the license for `'$packageName`' and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black

if($isRunPackage) {
$nugetInstallPath = Join-Path $nuGetPath 'lib-run'
Write-Host ".run Package detected. Will run package install script, and remove package afterwards." -ForegroundColor $Note -BackgroundColor Black
}
else {
$nugetInstallPath=$nugetLibPath;
}

Write-Debug "Installing packages to `"$nugetLibPath`"."

$nugetOutput = (Run-NuGet $packageName $source $version).Split("`n")
Expand Down Expand Up @@ -77,20 +87,31 @@ Write-Debug "Installing packages to `"$nugetLibPath`"."
Write-Host "$installedPackageName v$installedPackageVersion" -ForegroundColor $Note -BackgroundColor Black

if ([System.IO.Directory]::Exists($packageFolder)) {
try {
Delete-ExistingErrorLog $installedPackageName
Run-ChocolateyPS1 $packageFolder $installedPackageName "install" $installerArguments
Get-ChocolateyBins $packageFolder
if ($installedPackageName.ToLower().EndsWith('.extension')) {
Chocolatey-InstallExtension $packageFolder $installedPackageName
if($installedPackageName.ToLower().EndsWith('.run')) {
try {
Delete-ExistingErrorLog $installedPackageName
Run-ChocolateyPS1 $packageFolder $installedPackageName "install" $installerArguments
} catch {
Write-Error "Package `'$installedPackageName v$installedPackageVersion`' did not run successfully: $($_.Exception.Message)"
$chocolateyErrored = $true
}
Remove-Item $packageFolder -force -recurse
}
else {
try {
Delete-ExistingErrorLog $installedPackageName
Run-ChocolateyPS1 $packageFolder $installedPackageName "install" $installerArguments
Get-ChocolateyBins $packageFolder
if ($installedPackageName.ToLower().EndsWith('.extension')) {
Chocolatey-InstallExtension $packageFolder $installedPackageName
}
} catch {
Move-BadInstall $installedPackageName $installedPackageVersion $packageFolder
Write-Error "Package `'$installedPackageName v$installedPackageVersion`' did not install successfully: $($_.Exception.Message)"
if ($badPackages -ne '') { $badPackages += ', '}
$badPackages += "$packageName"
$chocolateyErrored = $true
}

} catch {
Move-BadInstall $installedPackageName $installedPackageVersion $packageFolder
Write-Error "Package `'$installedPackageName v$installedPackageVersion`' did not install successfully: $($_.Exception.Message)"
if ($badPackages -ne '') { $badPackages += ', '}
$badPackages += "$packageName"
$chocolateyErrored = $true
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/functions/Run-NuGet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
param(
[string] $packageName,
[string] $source = '',
[string] $version = ''
)
[string] $version = '',
[string] $nugetInstallPath=$nugetLibPath)

Write-Debug "Running 'Run-NuGet' for $packageName with source: `'$source`', version:`'$version`'";
Write-Debug "___ NuGet ____"

$srcArgs = Get-SourceArguments $source

$packageArgs = "install $packageName -OutputDirectory `"$nugetLibPath`" $srcArgs -NonInteractive -NoCache"
$packageArgs = "install $packageName -OutputDirectory `"$nugetInstallPath`" $srcArgs -NonInteractive -NoCache"
if ($version -notlike '') {
$packageArgs = $packageArgs + " -Version $version";
}
Expand Down