[wpkg-users] Define conditionally a variable...
Adam Thorn
alt36 at cam.ac.uk
Mon Mar 23 16:43:37 CET 2026
On 16/03/2026 09:48, Marco Gaiarin wrote:
> Mandi! Marco Schmidt
> In chel di` si favelave...
>
>> For me it was not really clear.
>> Maybe you could provide an example ?
>
> Suppose i have two variables like:
>
> NETNAME = mydomain.it
> LOCALNET = local
By "variable", do you mean "environment variable on the client system"?
You can use <check> elements inside a <varable>. For example: I have
some CI tests that check out wpkg installers and I know that the
GITLAB_CI environment variable is set to true inside a CI job, and unset
otherwise. I thus have the following to set %msi_options% to one thing
inside the CI job and to otherwise ensure it is empty for "normal" usage:
<!-- set msi_options inside CI -->
<variable name="msi_options" value="ADDLOCAL=x,y,z">
<condition>
<check type="host" condition="environment" value="GITLAB_CI=true" />
</condition>
</variable>
<!-- unset msi_options outside CI -->
<variable name="msi_options" value="">
<condition>
<check type="host" condition="environment" value="GITLAB_CI=^$" />
</condition>
</variable>
<install cmd='msiexec /qn %msi_options% /i example.msi' />
That same pattern works for anything you can express as a <check>
condition, e.g. the return value of a custom script (i.e.
type="execute"), the value of a registry key ...
(if anyone is curious, the CI job does trial runs of
/install:packagename ; /remove:packagename . In this case I have an MSI
that includes a bundled driver which is needed for normal usage but
doesn't install correctly inside my CI environment, so I set ADDLOCAL=
to exclude the driver there but still test the rest of the packaging
logic is working)
Adam
More information about the wpkg-users
mailing list