Changes
New page: Package templates are useful for groups of almost identical packages, e.g. Windows Hotfixes. Templates can be defined by leveraging XML entities to parameterize the boilerplate definition...
Package templates are useful for groups of almost identical packages, e.g. Windows Hotfixes. Templates can be defined by leveraging XML entities to parameterize the boilerplate definition of such packages. Make sure to save any templates '''outside''' the [[Packages.xml#Individual_XML_package_files|''packages/'']] directory in order not to confuse WPKG. A dedicated ''templates/'' directory might be appropriate.
Here is an example template for install-only packages for Windows Hotfixes (watch out for the language tag):
<source lang="xml">
<package id='xp-kb&kb-number;' name='Windows XP KB&kb-number;'>
<check type='registry' condition='equals'
path='HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB&kb-number;\Installed' value='1' />
<install cmd='"%SOFTWARE%\hotfix\windowsxp-kb&kb-number;-x86-enu.exe" /quiet /norestart /nobackup'>
<exit code='3010' reboot='postponed' />
</install>
</package>
</source>
This way, adding a new hotfix becomes a matter of dropping a file like this into ''packages/'' (assuming the above is called ''../templates/xp-update.xml'' relative to the ''packages/'' directory):
<source lang="xml">
<!DOCTYPE hotfix [ <!ENTITY kb-number "123456"> <!ENTITY xp-update SYSTEM "../templates/xp-update.xml"> ]>
<packages>&xp-update;</packages>
</source>
Now those files still only differ in the KB number, but it only appears once reducing the risk of copy and paste errors.
Here is an example template for install-only packages for Windows Hotfixes (watch out for the language tag):
<source lang="xml">
<package id='xp-kb&kb-number;' name='Windows XP KB&kb-number;'>
<check type='registry' condition='equals'
path='HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\KB&kb-number;\Installed' value='1' />
<install cmd='"%SOFTWARE%\hotfix\windowsxp-kb&kb-number;-x86-enu.exe" /quiet /norestart /nobackup'>
<exit code='3010' reboot='postponed' />
</install>
</package>
</source>
This way, adding a new hotfix becomes a matter of dropping a file like this into ''packages/'' (assuming the above is called ''../templates/xp-update.xml'' relative to the ''packages/'' directory):
<source lang="xml">
<!DOCTYPE hotfix [ <!ENTITY kb-number "123456"> <!ENTITY xp-update SYSTEM "../templates/xp-update.xml"> ]>
<packages>&xp-update;</packages>
</source>
Now those files still only differ in the KB number, but it only appears once reducing the risk of copy and paste errors.