Difference between revisions of "Chocolatey"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
Line 15: Line 15:
  
 
  <package
 
  <package
        id="chocolatey"
+
                id="chocolatey"
        name="Chocolatey"
+
                name="Chocolatey"
        revision="1.%version%"
+
                revision="1.%version%"
        reboot="false"
+
                reboot="false"
        priority="1">
+
                priority="1">
 
 
 
<variable name="version" value="0.10.5.0" />
 
<variable name="version" value="0.10.5.0" />
Line 44: Line 44:
 
 
 
<package
 
<package
        id="vlc"
+
                id="chocobasic"
        name="VideoLAN Client (using Chocolatey)"
+
                name="Basic packages (using Chocolatey)"
        revision="1.%version%"
+
                revision="1"
        reboot="false"
+
                reboot="false"
        priority="1">
+
                priority="1">
  
<depends package-id="chocolatey" />
+
<depends package-id="chocolatey" />
 +
 +
<!-- See https://chocolatey.org/packages . Can use more than one:
 +
<variable name="PKGNAMES" value="vlc firefox nssm notepadplusplus git 7zip" />
 +
-->
 +
<variable name="PKGNAMES" value="classic-shell googlechrome notepadplusplus" />
 
 
<variable name="version" value="2.2.6" />
+
<!-- check for a version of each package -->
<variable name="PKGNAME" value="vlc" />
+
<check path='Classic Shell' value='4.3.0' type='uninstall' condition='versiongreaterorequal' />
 +
<check path='Google Chrome' value='61.0.3163.100' type='uninstall' condition='versiongreaterorequal' />
 +
<check path='Notepad\+\+.*' value='7.5.1' type='uninstall' condition='versiongreaterorequal' />
 +
        <!--
 +
Or could possibly use choco list in a .cmd file like this, though harder to catch versiongreaterorequal:
 +
choco list - -localonly | findstr /ib /c:%1
 +
exit %ERRORLEVEL%
 +
<check type="execute" path='chocotest.cmd "7zip "' condition="exitcodeequalto" value="0"/>
 +
-->
 
 
<check type='uninstall' condition='versiongreaterorequal' path='VLC media player' value='%version%' />
+
<!-- "choco upgrade" command installs or upgrades as appropriate. -->
+
<install cmd='%COMSPEC% /v /c set ChocolateyInstall=%programdata%\chocolatey&amp;&amp; %programdata%\chocolatey\choco upgrade %PKGNAMES% -y &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"'  />  
<install cmd='%COMSPEC% /c choco install %PKGNAME% -y'  />  
+
<upgrade include="install" />
<upgrade cmd='%COMSPEC% /c choco upgrade %PKGNAME% -y' />
+
<remove  cmd='%COMSPEC% /v /c set ChocolateyInstall=%programdata%\chocolatey&amp;&amp; %programdata%\chocolatey\choco uninstall %PKGNAMES% -y &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"'/>
<remove  cmd='%COMSPEC% /c choco uninstall %PKGNAME% -y'/>
+
 
 
<!--
 
<install cmd='%COMSPEC% /c %programdata%\chocolatey\bin\chocolatey.exe install %PKGNAME% -y - -forceX86 - -force' architecture="x64" />
 
-->
 
 
<!--  
 
<!--  
Can be useful to pipe chocolatey output to log file: e.g. &gt;c:\temp\choc.log  
+
Useful to pipe chocolatey output to log file: e.g. &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"
or see C:\ProgramData\chocolatey\logs\chocolatey.log
+
See also C:\ProgramData\chocolatey\logs\chocolatey.log
 
-->
 
-->
 
 
   </package>
 
   </package>
  

Revision as of 15:26, 10 October 2017

A silent installer for Chocolately (https://chocolatey.org), which in turn does silent Windows software installs.

This downloads the install.ps1 script, which will download and install chocolatey to %programdata%\chocolatey.

Once this is installed, you can use commands like "choco install 7zip -y" to install software automatically. This can be useful to save having to update WPKG packages for common tools, as chocolatey has a central repository.

An example of how VLC might be installed using WPKG to trigger chocolatey is given below.

<?xml version="1.0" encoding="UTF-8"?>

<packages:packages xmlns:packages="http://www.wpkg.org/packages"
	xmlns:wpkg="http://www.wpkg.org/wpkg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.wpkg.org/packages ../xsd/packages.xsd">

 	<package
                id="chocolatey"
                name="Chocolatey"
                revision="1.%version%"
                reboot="false"
                priority="1">
		
		<variable name="version" value="0.10.5.0" />

		<check type="file" condition="exists" path='%programdata%\chocolatey\bin\chocolatey.exe' value="%version%" />
		
		<variable name="installerPath" value="chocolatey\install.ps1"/>
		<variable name="installerURL" value="https://chocolatey.org/install.ps1" />

		<!-- standard variables - usually in config.xml -->
		<variable name="SOFTWARE" value="software" 		/>	
		<variable name="DOWNLOADERPATH" value="tools\downloader\downloader.cmd"  />  
		<!-- conditional download -->
		<install cmd='"%DOWNLOADERPATH%" "%installerURL%"	"%software%\%installerPath%"  >NUL'>
			<condition><check type="logical" condition="not"><check type="file" condition="exists" path="%SOFTWARE%\%installerPath%" /></check></condition>
		</install>		
		
		<install cmd='powershell "%SOFTWARE%\%installerPath%"'  /> 
		
		<upgrade include="install" />
		<remove cmd='cmd /c rmdir /s /q "%programdata%\chocolatey\"' /> 

  	</package>
	
	<package
                id="chocobasic"
                name="Basic packages (using Chocolatey)"
                revision="1"
                reboot="false"
                priority="1">

		<depends package-id="chocolatey" /> 
	
		<!-- See https://chocolatey.org/packages . Can use more than one:
			<variable name="PKGNAMES" value="vlc firefox nssm notepadplusplus git 7zip" />
		-->	
		<variable name="PKGNAMES" value="classic-shell googlechrome notepadplusplus" />
		
		<!-- check for a version of each package -->
		<check path='Classic Shell' 	value='4.3.0' 			type='uninstall' condition='versiongreaterorequal' />
		<check path='Google Chrome' 	value='61.0.3163.100' 	type='uninstall' condition='versiongreaterorequal' />
		<check path='Notepad\+\+.*' 	value='7.5.1' 			type='uninstall' condition='versiongreaterorequal' />
	        <!--
		Or could possibly use choco list in a .cmd file like this, though harder to catch versiongreaterorequal:
			choco list - -localonly | findstr /ib /c:%1
			exit %ERRORLEVEL%
		<check type="execute" path='chocotest.cmd "7zip "' condition="exitcodeequalto" value="0"/>		
		-->
		
		<!-- "choco upgrade" command installs or upgrades as appropriate. -->
		<install cmd='%COMSPEC% /v /c set ChocolateyInstall=%programdata%\chocolatey&amp;&amp; %programdata%\chocolatey\choco upgrade %PKGNAMES% -y &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"'  /> 
		<upgrade include="install" />
		<remove  cmd='%COMSPEC% /v /c set ChocolateyInstall=%programdata%\chocolatey&amp;&amp; %programdata%\chocolatey\choco uninstall %PKGNAMES% -y &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"'/>
		
		<!-- 
		Useful to pipe chocolatey output to log file: e.g. &gt;"%programdata%\chocolatey\logs\wpkgchocoinstall.log"
		See also C:\ProgramData\chocolatey\logs\chocolatey.log
		-->
  	</package>		

</packages:packages>