Skip to content

Commit

Permalink
(GH-296) Enhance installer template
Browse files Browse the repository at this point in the history
- Add recommended settings for installer
- Add checksum values to installer
- Add future registry key
- Add msi silent args
  • Loading branch information
ferventcoder committed Jun 5, 2015
1 parent 79b60fb commit 7b468c8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,63 @@ public class ChocolateyInstallTemplate
{
public static string Template =
@"#NOTE: Please remove any commented lines to tidy up prior to releasing the package, including this one
# REMOVE ANYTHING BELOW THAT IS NOT NEEDED
# stop on all errors
$ErrorActionPreference = 'Stop';
$ErrorActionPreference = 'Stop'; # stop on all errors
[[AutomaticPackageNotesInstaller]]
$packageName = '[[PackageName]]' # arbitrary name for the package, used in messages
$registryUninstallerKeyName = '[[PackageName]]' #ensure this is the value in the registry
$installerType = '[[InstallerType]]' #only one of these: exe, msi, msu
$url = '[[Url]]' # download url
$url64 = '[[Url64]]' # 64bit URL here or remove - if installer decides, then use $url
$silentArgs = '[[SilentArgs]]' # ""/s /S /q /Q /quiet /silent /SILENT /VERYSILENT"" # try any of these to get the silent installer #msi is always /quiet
$validExitCodes = @(0) #please insert other valid exit codes here, exit codes for ms http://msdn.microsoft.com/en-us/library/aa368542(VS.85).aspx
$toolsDir = ""$(Split-Path -parent $MyInvocation.MyCommand.Definition)""
$url = '[[Url]]' # download url
$url64 = '[[Url64]]' # 64bit URL here or remove - if installer is both, use $url
$packageArgs = @{
packageName = $packageName
unzipLocation = $toolsDir
fileType = '[[InstallerType]]' #only one of these: exe, msi, msu
url = $url
url64bit = $url64
#MSI
silentArgs = ""/qn /norestart /l*v '$env:TEMP\chocolatey\$packageName\install.log'"" # ALLUSERS=1 DISABLEDESKTOPSHORTCUT=1 ADDDESKTOPICON=0 ADDSTARTMENU=0
validExitCodes= @(0, 3010, 1641)
#OTHERS
#silentArgs ='[[SilentArgs]]' # ""/s /S /q /Q /quiet /silent /SILENT /VERYSILENT -s"" # try any of these to get the silent installer
#validExitCodes= @(0) #please insert other valid exit codes here
# optional
registryUninstallerKey = '[[PackageName]]' #ensure this is the value in the registry
checksum = '[[Checksum]]'
checksumType = '[[ChecksumType]]' #default is md5, can also be sha1
checksum64 = '[[Checksum64]]'
checksumType64= '[[ChecksumType64]]' #default is checksumType
}
Install-ChocolateyPackage @packageArgs
#Install-ChocolateyZipPackage @packageArgs
# main helper functions - these have error handling tucked into them already
# see https://github.com/chocolatey/choco/wiki/HelpersReference
# Install an application, will assert administrative rights
# add additional optional arguments as necessary
#Install-ChocolateyPackage ""$packageName"" ""$installerType"" ""$silentArgs"" ""$url"" [""$url64"" -validExitCodes $validExitCodes -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64]
Install-ChocolateyPackage ""$packageName"" ""$installerType"" ""$silentArgs"" ""$url""
# Download and unpack a zip file
#Install-ChocolateyZipPackage ""$packageName"" ""$url"" ""$toolsDir"" [""$url64"" -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64]
Install-ChocolateyZipPackage ""$packageName"" ""$url"" ""$toolsDir""
# Install Visual Studio Package
#Install-ChocolateyVsixPackage ""$packageName"" ""$url"" [$vsVersion] [-checksum $checksum -checksumType $checksumType]
Install-ChocolateyVsixPackage ""$packageName"" ""$url""
## Main helper functions - these have error handling tucked into them already
## see https://github.com/chocolatey/choco/wiki/HelpersReference
## Install an application, will assert administrative rights
## add additional optional arguments as necessary
##Install-ChocolateyPackage $packageName $fileType $silentArgs $url [$url64 -validExitCodes $validExitCodes -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64]
## Download and unpack a zip file
##Install-ChocolateyZipPackage $packageName $url $toolsDir [$url64 -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64]
## Install Visual Studio Package
#Install-ChocolateyVsixPackage $packageName $url [$vsVersion] [-checksum $checksum -checksumType $checksumType]
#Install-ChocolateyVsixPackage @packageArgs
# see the full list at https://github.com/chocolatey/choco/wiki/HelpersReference
# downloader that the main helpers use to download items
# if removing $url64, please remove from here
#Get-ChocolateyWebFile ""$packageName"" 'DOWNLOAD_TO_FILE_FULL_PATH' ""$url"" ""$url64""
#Get-ChocolateyWebFile $packageName 'DOWNLOAD_TO_FILE_FULL_PATH' $url $url64
# installer, will assert administrative rights - used by Install-ChocolateyPackage
#Install-ChocolateyInstallPackage ""$packageName"" ""$installerType"" ""$silentArgs"" '_FULLFILEPATH_' -validExitCodes $validExitCodes
#Install-ChocolateyInstallPackage $packageName $fileType $silentArgs '_FULLFILEPATH_' -validExitCodes $validExitCodes
# unzips a file to the specified location - auto overwrites existing content
#Get-ChocolateyUnzip ""FULL_LOCATION_TO_ZIP.zip"" ""$toolsDir""
#Get-ChocolateyUnzip ""FULL_LOCATION_TO_ZIP.zip"" $toolsDir
# Runs processes asserting UAC, will assert administrative rights - used by Install-ChocolateyInstallPackage
#Start-ChocolateyProcessAsAdmin 'STATEMENTS_TO_RUN' 'Optional_Application_If_Not_PowerShell' -validExitCodes $validExitCodes
# add specific folders to the path - any executables found in the chocolatey package folder will already be on the path. This is used in addition to that or for cases when a native installer doesn't add things to the path.
Expand All @@ -69,7 +91,13 @@ public class ChocolateyInstallTemplate
#Install-BinFile ## only use this for non-exe files - chocolatey will automatically pick up the exe files and shim them automatically
## https://github.com/chocolatey/choco/wiki/CreatePackages#how-do-i-exclude-executables-from-getting-batch-redirects
# PORTABLE EXAMPLE
##PORTABLE EXAMPLE
#$toolsDir = ""$(Split-Path -parent $MyInvocation.MyCommand.Definition)""
# despite the name ""Install-ChocolateyZipPackage"" this also works with 7z archives
#Install-ChocolateyZipPackage $packageName $url $toolsDir $url64
## END PORTABLE EXAMPLE
## [DEPRECATING] PORTABLE EXAMPLE
#$binRoot = Get-BinRoot
#$installDir = Join-Path $binRoot ""$packageName""
#Write-Host ""Adding `'$installDir`' to the path and the current shell path""
Expand All @@ -78,8 +106,8 @@ public class ChocolateyInstallTemplate
# if removing $url64, please remove from here
# despite the name ""Install-ChocolateyZipPackage"" this also works with 7z archives
Install-ChocolateyZipPackage ""$packageName"" ""$url"" ""$installDir"" ""$url64""
# END PORTABLE EXAMPLE
#Install-ChocolateyZipPackage ""$packageName"" ""$url"" ""$installDir"" ""$url64""
## END PORTABLE EXAMPLE
";

public static string AutomaticPackageNotes =
Expand All @@ -89,8 +117,9 @@ public class ChocolateyInstallTemplate
#{{DownloadUrl}} - The url for the native file | /u
#{{PackageFilePath}} - Downloaded file if including it in package | /pp
#{{PackageGuid}} - This will be used later | /pg
#{{DownloadUrlx64}} - The 64bit url for the native file | /u64
#{{DownloadUrlx64}} - The 64-bit url for the native file | /u64
#{{Checksum}} - The checksum for the url | /c
#{{Checksumx64}} - The checksum for the 64-bit url | /c64
";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ public class ChocolateyUninstallTemplate
{
public static string Template =
@"#NOTE: Please remove any commented lines to tidy up prior to releasing the package, including this one
# stop on all errors
$ErrorActionPreference = 'Stop';
# REMOVE ANYTHING BELOW THAT IS NOT NEEDED
# Auto Uninstaller should be able to detect and handle registry uninstalls (if it is turned on, it is in preview for 0.9.9).
$ErrorActionPreference = 'Stop'; # stop on all errors
$packageName = '[[PackageName]]'
# registry uninstaller key name is the key that is found at HKLM:\Software\Windows\CurrentVersion\Uninstall\ THE NAME
$registryUninstallerKeyName = '[[PackageName]]' #ensure this is the value in the registry
Expand Down
10 changes: 10 additions & 0 deletions src/chocolatey/infrastructure.app/templates/TemplateValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public void set_normal()
Url64 = "";
SilentArgs = "";
AutomaticPackageNotesNuspec = "";
Checksum = "";
ChecksumType = "md5";
Checksum64 = "";
ChecksumType64 = "md5";
}

public void set_auto()
Expand All @@ -44,6 +48,8 @@ public void set_auto()
AutomaticPackageNotesNuspec = NuspecTemplate.AutomaticPackageNotes;
Url = "{{DownloadUrl}}";
Url64 = "{{DownloadUrlx64}}";
Checksum = "{{Checksum}}";
Checksum64 = "{{Checksumx64}}";
}


Expand All @@ -63,6 +69,10 @@ public string PackageNameLower
public string Url { get; set; }
public string Url64 { get; set; }
public string SilentArgs { get; set; }
public string Checksum { get; set; }
public string ChecksumType { get; set; }
public string Checksum64 { get; set; }
public string ChecksumType64 { get; set; }

public static readonly string NamePropertyName = "PackageName";
public static readonly string VersionPropertyName = "PackageVersion";
Expand Down

0 comments on commit 7b468c8

Please sign in to comment.