Changes

Packages.xml:French

14,459 bytes added, 13:48, 8 June 2007
no edit summary
'''packages.xml''' is a file which defines how to install and uninstall software packages. In other words, it is a list of all packages and scripts that can be deployed or executed on workstations.

This file has to be placed in the same direstory as [[wpkg.js]].

[http://wpkg.org WPKG] will not work without this file.


==packages.xml structure==

A basic structure of '''packages.xml''' is as follows:

<pre>
<packages>
<package
id="wpkg1"
name="Windows Packager sample 1"
revision="1"
reboot="false"
priority="0">
<check type="registry" condition="exists" path="HKLM\Software\wpkg\full\key\not\part\of\it" />
<check type="file" condition="exists" path="%PROGRAMFILES%\wpkg\wpkg.bat" />
<check type="uninstall" condition="exists" path="WPKG" />

<install cmd='msiexec /i (path to msi)'>
<exit code="0" />
</install>

<remove cmd='%PROGRAMFILES%\uninstall\uninst.exe -quiet' />

<upgrade cmd='msiexec /i (path to msi)' />

</package>

</packages>
</pre>


Each package has the following attributes:

* '''id''' - A unique identifier representing the package. Should be short and to the point.

* '''name''' - Longer textual description of the package. This should be the full product name.

* '''revision''' - User created integer to represent the "version" of the specific package. Should be incremented when creating a new release.

* '''reboot''' - If "true" system reboots when done installing, removing or upgrading the package.

* '''priority''' - Specifies a numeric value that determines in what order a package will be installed. The higher the number, the higher the priority, and so the earlier the package will be installed compared with lower priority packages. For example:
** 2 - installs these packages 1st
** 1 - installs these packages 2nd
** 0 - installs these packages 3rd
Note that a package installer with priority '5' would install before all these.

== Check conditions / check type ==


Of course it would be unwise to launch the installer if the software is already installed. That's why there are "check conditions".

Check conditions are broken down into 3 categories:


<ul>
<li>'''Registry''' - Checks the registry for conditions
<li>'''File''' - Verifies various information about files within the filesystem
<li>'''Uninstall''' - Checks the software installation registry key (as displayed in Windows' Add/Remove Programs section) for the existence of an existing package
</ul>


'''Registry'''

Registry checks allow you to check for the existence of or a specific value in a registry key. There are two possible conditions available for registry checks: ''exists'' and ''equals''.

<div style="margin-left: 30px">
'''exists''' - This checks for the existence of a registry key. If the registry key is found, the condition returns true, otherwise it returns false.

'''equals''' - This checks a specific value of a registry key. If the registry value is found and that value is equal to the supplied value, the condition returns true, otherwise it returns false.
</div>

Examples:

This checks for the existence of Adobe Reader within the registry:

<pre>
<check type="registry" condition="exists" path="HKLM\Software\Adobe\Adobe Reader\7.0" />
</pre>

This checks to see if Firefox, US English, version 1.5.0.6, is installed:

<pre>
<check type="registry" condition="equals" path="HKLM\Software\Mozilla\Mozilla Firefox\CurrentVersion" value="1.5.0.6 (en-US)" />
</pre>


'''File'''

File checks allow you to check for the existence of a file, check for a particular file's size, or examine version information about a file. There are several possible conditions available for file checks:

<div style="margin-left: 30px">
'''exists''' - This checks for the existence of a file. If the file is found, the condition returns true.

'''sizeequals''' - This checks the size of a file. If the file is found and the size equals the value supplied, the condition returns true.

'''versionsmallerthan''' - This checks the version of a particular file. If the file is found and the version is less than the supplied version number, the condition returns true.

'''versionlessorequal''' - This checks the version of a particular file. If the file is found and the version is less than or equal to the supplied version number, the condition returns true.

'''versionequalto''' - This checks the version of a particular file. If the file is found and the version is equal to the supplied version number, the condition returns true.

'''versiongreaterorequal''' - This checks the version of a particular file. If the file is found and the version is greater than or equal to the supplied version number, the condition returns true.

'''versiongreaterthan''' - This checks the version of a particular file. If the file is found and the version is greater than the supplied version number, the condition returns true.
</div>

Examples:

This checks for the existence of Adobe Reader within the filesystem:

<pre>
<check type="file" condition="exists" path="%PROGRAMFILES%\Adobe\Acrobat 7.0\Reader\AcroRd32.exe" />
</pre>

This checks to see if Firefox US English version 1.5.0.6 is installed based on the file size of the executable:

<pre>
<check type="file" condition="sizeequals" path="%PROGRAMFILES%\Mozilla Firefox\firefox.exe" value="7183469" />
</pre>

This checks whether the version of Firefox .exe that's currently installed is less than 1.5.0.6:

<pre>
<check type="file" condition="versionsmallerthan" path="%PROGRAMFILES%\Mozilla Firefox\firefox.exe" value="1.5.0.6" />
</pre>


'''Uninstall'''

Uninstall checks allow you to check the Microsoft software installation registry keys (as displayed in Windows' Add/Remove Programs section) for the existence of a particular package. Microsoft maintains the list
of applications installed and available for uninstallation in the ''HKLM\Software\Microsoft\Windows\Current Version\Uninstall'' registry key. The value in the DisplayName key of a
particular package is what's matched by this check. The only condition available for this option is ''exists''.

<div style="margin-left: 30px">
'''exists''' - This checks for the existence of the particular software package in the installation database. If the package is found, the condition returns true.
</div>

Examples:

This checks for the existence of Adobe Reader through the installation list:

<pre>
<check type="uninstall" condition="exists" path="Adobe Reader 7.0" />
</pre>

This checks to see if Firefox version 1.5.0.6 is installed in the installation list:

<pre>
<check type="uninstall" condition="exists" path="Mozilla Firefox (1.5.0.6)" />
</pre>


'''Logical Conditions'''

There can be zero or more conditions verified during the existence checks. If no conditions are supplied, WPKG attempts to install the package regardless of whether it's currently
installed or not. To facilitate using more than one condition, there is a 4th type of condition that can be added, called the logical condition. Logical conditions allow you to create
multiple conditions while checking for the presence of an existing package. Logical conditions are top level conditions, with the real check conditions as subnodes in the XML.

The following logical conditions are available: ''not'', ''and'', ''or'', ''atleast'', and ''atmost''.

Examples:

Let's say, for the sake of argument, that you have an Adobe Reader 7.0.8 package that you want installed, but you only want it installed on workstations
that are running Windows XP Service Pack 2 or higher, due to some strange incompatibility. Let's also say that some workstations can't be
upgraded to Windows XP Service Pack 2 until those workstations are upgraded from 256MB of memory to 512MB of memory. For a scenario like this, you could
(and probably should!) use multiple profiles and have those SP1 workstations in one profile, while the SP2 workstations are in another. However, just
for example purposes, let's say all workstations are in a single profile. You can provide a logical condition in order for only those workstations
running SP2 to be upgraded to Adobe Reader 7.0.8:

<pre>
<check type="logical" condition="or">
<check type="registry" condition="exists" path="HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\7.0\Installer\Updates\708" />
<check type="registry" condition="equals" path="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CSDVersion" value="Service Pack 1" />
</check>
</pre>

The 2nd condition here might seem counter intuitive, but remember that you're looking for the absence of things rather than the existence of things when you're writing
check conditions. What the above condition says is "Is Adobe Reader 7.0.8 installed or is Service Pack 1 installed? If either of these conditions equates to true,
the installation will be skipped. In this particular case, Adobe Reader 7.0.8 isn't installed, but the value of CSDVersion is Service Pack 1 (for the SP1 boxes)
so the software will not be installed.


Once all conditions have been tested, if the final result of the conditions is equal to false, WPKG will try to execute the "'''install cmd'''".


After it's executed, WPKG will check the exit code (should be 0 in this example) '''*and*''' verify all the checks.


If '''*any*''' of the checks are not met, software is considered '''*not*''' installed - so enter these values carefully!


Remember that you don't have to specify all three check conditions, usually one is enough: if the software you are about to install will show up in Windows' Add/Remove Programs (and not all do), it is sufficient to specify just the "'''uninstall'''" check.

==Actions==

Wpkg understands three actions: '''install''', '''upgrade''' and '''remove'''. Multiple commands for each of these actions can be listed in the config file and wpkg will execute them in the order they are listed.

The '''install''' commands are executed by wpkg when a new package comes into scope for a profile. The '''upgrade''' commands are executed when a new revision of a package comes into scope. The '''remove''' commands are executed when a package is removed from a profile.

In many of the examples in the [[:Category:Silent_Installers]] section, cmd.exe is executed to perform environment variable expansion and to use 'start /wait' to wait on the command being executed. This method of executing commands results in cmd windows appearing on screen. However, this method does not appear to be necessary. The current version of wpkg (0.9.10) executes commands using the WScript.Shell.Exec() function, which should expand environment variables. This isn't explicitly stated in the Microsoft SDK documentation, but seems to be the case. Wpkg then waits until the command is completed before continuing.

The correct method of executing a command interpreter is to use the %comspec% environment variable, not specifying cmd.exe explicitly. This is needed to run commands that are built into the interpreter and are not separate executables.

When the ouput of a command (think of: copy,cacls) is too much, the command will fail. You have to redirect the output to NUL or a file (example: "%command% >nul").

Typical examples:

<pre>
<install cmd="msiexec /qn /i %SOFTWARE%/package.msi" />
<install cmd="msiexec /qn /i %SOFTWARE%/package.msi" timeout="1800" />
<install cmd="%comspec% /c copy %SOFTWARE%/file.dll %WINDIR%" />
<remove cmd="msiexec /qn /x %SOFTWARE%/package.msi" />
</pre>

The timeout option tells wpkg how long to wait for the command to complete. It is in seconds and the default is 3600 seconds.

You can set reboot to "true" with the following:
<pre>
<install cmd="msiexec /qn /i %SOFTWARE%/package.msi" >
<exit code="3010" reboot="true" />
<exit code="0" />
</install>
</pre>

==Quick examples==

Other example - WPKG checks if the package is installed only in Windows' Add/Remove Programs before deciding to install it (to make sure it is not installed already):

<pre>
<package
id="wpkg3"
name="Windows Packager sample 3"
revision="1"
reboot="false"
priority="1">

<!--
This is a comment.
Checks in Windows' Add/Remove Programs only.
-->
<check type="uninstall" condition="exists" path="WPKG" />

<install cmd='%PACKAGES%\package.exe /quiet /install' />

<remove cmd='%PACKAGES%\package.exe /quiet /uninstall' />

<upgrade cmd='%PACKAGES%\package.exe /quiet /install' />

</package>
</pre>



In the example below, there are no check conditions.
This means that WPKG will execute it each time - so this is rather useful for executing scripts that need to be run each time the machine is booted, than installing software:

<pre>
<package
id="backupfiles"
name="Makes backup of some file"
revision="1"
reboot="false"
priority="0">

<!--
This is a comment.
'''No check conditions; script will be executed *each time* wpkg.js is called - each time PC is booted.'''
-->

<install cmd='\\server\path\script.bat' />
</package>
</pre>


Similar example, without any conditions, either.
Note the '''execute="once"''' entry - this means that that script will be executed only once. It is useful for the tasks you want
to do one time only, like disk defragmenting, some testing, changing printers etc.

<pre>
<package
id="backupfiles"
name="Makes backup of some file"
revision="1"
reboot="false"
execute="once"
priority="0">

<install cmd='\\server\path\script.bat' />
</package>
</pre>

Similarly, you may want to execute a program or script each time - use "always" instead of "once". For more info on this functionality, check [[Execute_once_/_always|here]].

==Package dependencies==

Packages can also depend on other packages, see [[package dependencies]] for more info.


==Individual XML package files==

If you would rather keep your package XML description in separate files, you can of course do it: just create a <code>packages</code> directory where <code>wpkg.js</code> is, and place individual XML files there (i.e., thunderbird.xml, firefox.xml etc.). The syntax is the same as that of packages.xml.

Note, if you decide to keep all your packages in separate XML files, still, you need to have <code>packages.xml</code> file. It should at least contain an empty <code></code> entry:

<pre>
<packages>
</packages>
</pre>

==See also==
* [[profiles.xml]] - defines the profiles.
* [[hosts.xml]] - defines the hosts.
* [[wpkg.js]] - WPKG engine.
* [[package dependencies]] - package dependencies.

[[category:Documentation]]
[[category:Installation]]
[[category:Config_Files]]
40
edits