[wpkg-users] Problem with variables
Rainer Meier
r.meier at wpkg.org
Thu Feb 5 14:44:25 CET 2009
Hi Daniel,
Daniel Dehennin wrote:
> I have a problem when using variables in a package definition:
It's correct that the code to set variables needs some
re-work/re-design. This is one of the reasons I recommend not to use
them extensively at the moment.
> =====
> <?xml version='1.0' encoding='utf-8'?>
> <packages>
> <package
> id='disable-network-services'
> name='Windows XP disabled network services'
> revision='1'
> reboot='false'
> priority='700'>
>
> <variable name='NETCFG' value='%WPKGBIN%\snetcfg_wxp.exe'/>
>
> <check type='logical' condition='and'>
> <check type='execute' path='%ComSpec% /c %NETCFG% -q ms_psched | %WPKGBIN%\grep.exe "is not installed"'/>
> <check type='execute' path='%ComSpec% /c %NETCFG% -q ms_alg | %WPKGBIN%\grep.exe "is not installed"'/>
> <check type='execute' path='%ComSpec% /c %NETCFG% -q ms_gpc | %WPKGBIN%\grep.exe "is not installed"'/>
> </check>
Did you think about moving these extensive execute script from the
single-liner within the package XML file to a CMD script?
Such a script could also handle setting the variable accordingly.
Personally I am not a friend of such scripts squeezed into single lines
in order to push them somehow into the XML file. Instead I would
personally prefer something as follows:
<check type='logical' condition='and'>
<check type='execute' path='%SOFTWARE%\ms_psched-check.cmd'/>
<check type='execute' path='%SOFTWARE%\ms_alg-check.cmd'/>
<check type='execute' path='%SOFTWARE%\ms_gpc-check.cmd'/>
</check>
This gives you much more flexibility to extend/refine checks as needed
and format them in a much more user-readable way.
> <install cmd='%ComSpec% /c %NETCFG% -u ms_psched'>
> <exit code='0'/>
> <exit code='1'/>
> </install>
>
> <install cmd='%ComSpec% /c %NETCFG% -u ms_alg'>
> <exit code='0'/>
> <exit code='1'/>
> </install>
>
> <install cmd='%ComSpec% /c %NETCFG% -u ms_gpc'>
> <exit code='0'/>
> <exit code='1'/>
> </install>
Also here I would rather go for simple cmd scripts which would solve the
problem with variables while still giving more maintainability and
flexibility.
> The check works:
OK
> but not the install commands with the variable:
>
> ====
> Executing command : %ComSpec% /c %WPKGBIN%\snetcfg_wxp.exe -u ms_psched
> Command '%ComSpec% /c %WPKGBIN%\snetcfg_wxp.exe -u ms_psched' returned exit code [1]. This exit code is not an error
> Command in installation of Windows XP disabled network services returned exit code [1]. This exit code indicates success
> Executing command : %ComSpec% /c %WPKGBIN%\snetcfg_wxp.exe -u ms_alg
> Command '%ComSpec% /c %WPKGBIN%\snetcfg_wxp.exe -u ms_alg' returned exit code [0]. This exit code is not an error.
> Command in installation of Windows XP disabled network services returned exit code [0]. This exit code indicates success.
> Executing command : %ComSpec% /c %NETCFG% -u ms_gpc
> Command '%ComSpec% /c %NETCFG% -u ms_gpc' returned exit code [1]. This exit code is not an error.
> Command in installation of Windows XP disabled network services returned exit code [1]. This exit code indicates success.
> ====
Interesting that only the last command looks different.
I will have a look at the variable definition code. In the meantime try
following my suggestion as a work-around.
br,
Rainer
More information about the wpkg-users
mailing list