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

Fixes for #45 , #12 and #52 #53

Merged
merged 2 commits into from
Sep 6, 2016
Merged
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
4 changes: 4 additions & 0 deletions AppVeyor/AppVeyorBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Write-Host "ModuleName : $env:ModuleName"
Write-Host "Build version : $env:APPVEYOR_BUILD_VERSION"
Write-Host "Author : $env:APPVEYOR_REPO_COMMIT_AUTHOR"
Write-Host "Branch : $env:APPVEYOR_REPO_BRANCH"
Write-Host "Repo : $env:APPVEYOR_REPO_NAME"
Write-Host "PSModulePath :"

$env:PSModulePath -split ';'

#---------------------------------#
# BuildScript #
Expand Down
3 changes: 2 additions & 1 deletion AppVeyor/AppVeyorDeploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Write-Host "Updating module manifest to version: $env:APPVEYOR_BUILD_VERSION"
#---------------------------------#
# Publish to PS Gallery #
#---------------------------------#
if ($env:APPVEYOR_REPO_BRANCH -notmatch 'master')

if ( ($env:APPVEYOR_REPO_NAME -notmatch 'PowerShellOrg') -or ($env:APPVEYOR_REPO_BRANCH -notmatch 'master') )
{
Write-Host "Finished testing of branch: $env:APPVEYOR_REPO_BRANCH - Exiting"
exit;
Expand Down
81 changes: 39 additions & 42 deletions DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ function Set-TargetResource
[ValidateNotNullOrEmpty()]
[System.String]
$Version,
[parameter(Mandatory = $false)]
[parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[System.String]
$Source
$Source,
[parameter(Mandatory = $false)]
[String]
$chocoParams

)
Write-Verbose "Start Set-TargetResource"
Expand All @@ -89,7 +92,7 @@ function Set-TargetResource
($Version) -and -not ($isInstalledVersion) `
)
{
InstallPackage -pName $Name -pParams $Params -pVersion $Version
InstallPackage -pName $Name -pParams $Params -pVersion $Version -cParams $chocoParams
}
}
elseif ($isInstalled) {
Expand Down Expand Up @@ -118,10 +121,13 @@ function Test-TargetResource
[ValidateNotNullOrEmpty()]
[System.String]
$Version,
[parameter(Mandatory = $false)]
[parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[System.String]
$Source
$Source,
[parameter(Mandatory = $false)]
[String]
$chocoParams
)

Write-Verbose "Start Test-TargetResource"
Expand Down Expand Up @@ -156,43 +162,34 @@ function CheckChocoInstalled
return DoesCommandExist choco
}

function InstallPackage
{
param(
[Parameter(Position=0,Mandatory=1)][string]$pName,
[Parameter(Position=1,Mandatory=0)][string]$pParams,
[Parameter(Position=2,Mandatory=0)][string]$pVersion
)

$env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine')

#Todo: Refactor
if ((-not ($pParams)) -and (-not $pVersion))
{
Write-Verbose "Installing Package Standard"
$packageInstallOuput = choco install $pName -y
}
elseif ($pParams -and $pVersion)
{
Write-Verbose "Installing Package with Params $pParams and Version $pVersion"
$packageInstallOuput = choco install $pName --params="$pParams" --version=$pVersion -y
}
elseif ($pParams)
{
Write-Verbose "Installing Package with params $pParams"
$packageInstallOuput = choco install $pName --params="$pParams" -y
}
elseif ($pVersion)
{
Write-Verbose "Installing Package with version $pVersion"
$packageInstallOuput = choco install $pName --version=$pVersion -y
}


Write-Verbose "Package output $packageInstallOuput "

#refresh path varaible in powershell, as choco doesn"t, to pull in git
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
function InstallPackage
{
param(
[Parameter(Position=0,Mandatory=1)][string]$pName,
[Parameter(Position=1,Mandatory=0)][string]$pParams,
[Parameter(Position=2,Mandatory=0)][string]$pVersion,
[Parameter(Position=3,Mandatory=0)][string]$cParams
)

$env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine')

[string]$chocoinstallparams = '-y'
if ($pParams) {
$chocoinstallparams += " --params=`"$pParams`""
}
if ($pVersion) {
$chocoinstallparams += " --version=`"$pVersion`""
}
if ($cParams) {
$chocoinstallparams += " $cParams"
}
Write-Verbose "Install command: 'choco install $pName $chocoinstallparams'"

$packageInstallOuput = Invoke-Expression "choco install $pName $chocoinstallparams"
Write-Verbose "Package output $packageInstallOuput "

#refresh path varaible in powershell, as choco doesn"t, to pull in git
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
}

function UninstallPackage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class cChocoPackageInstall : OMI_BaseResource
[write] string Params;
[write] string Version;
[write] string Source;
[Write] String chocoParams;
};
15 changes: 11 additions & 4 deletions ExampleConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
DependsOn = "[cChocoInstaller]installChoco"

}
cChocoPackageInstaller installSkypeWithChocoParams
{
Name = 'skype'
chocoParams = '--allowdowngrade --allowemptychecksum --allowemptychecksumsecure'
Ensure = 'Present'
Version = '7.25.0.106'
DependsOn = '[cChocoInstaller]installChoco'
}
cChocoPackageInstaller installAtomSpecificVersion
{
Name = "atom"
Expand All @@ -40,8 +48,7 @@
{
Ensure = 'Present'
Name = @(
"git"
"skype"
"git",
"7zip"
)
DependsOn = "[cChocoInstaller]installChoco"
Expand All @@ -50,8 +57,8 @@
{
Ensure = 'Absent'
Name = @(
"vlc"
"ruby"
"vlc",
"ruby",
"adobeair"
)
DependsOn = "[cChocoInstaller]installChoco"
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#---------------------------------#
version: 2.2.0.{build}
os: WMF 5
clone_folder: c:\projects\cChoco

install:
- ps: . .\AppVeyor\AppVeyorInstall.ps1

Expand Down