VMware Cloud Community
truhlik_fredy
Contributor
Contributor

Have custom default installdir yet allow the prefix to work

I didn't like the default installdir value so I started using my own by overriding them (see snippet below).

But now I lost the --prefix functionally in an unattended installation, can I use my own default installdirs which are different for each platform yet allow it to be overruled when --prefix is used?

 

    <preInstallationActionList>
        <setInstallerVariable>
            <name>installdir</name>
            <value>${env(SYSTEMDRIVE)}/${project.vendor}/${product_shortname}-v${product_version}</value>
            <ruleList>
                <platformTest>
                    <type>windows</type>
                </platformTest>
            </ruleList>
        </setInstallerVariable>
        <setInstallerVariable>
            <name>installdir</name>
            <value>${env(HOME)}/${project.vendor}/${product_shortname}-v${product_version}</value>
            <ruleList>
                <platformTest>
                    <type>linux</type>
                </platformTest>
            </ruleList>
        </setInstallerVariable>
    </preInstallationActionList>

 

 

0 Kudos
2 Replies
michieldhont_
Hot Shot
Hot Shot

Hi @truhlik_fredy,

You could check that the value of installer_command_line_arguments does not contain prefix:

<preInstallationActionList>

   <setInstallerVariable name="prefixSet" value="1">
      <ruleList>
         <compareText text="${installer_command_line_arguments}" logic="contains" value="prefix"/>
      </ruleList>
   </setInstallerVariable> 

</preInstallationActionList>

 

Then you can use the prefixSet value to conditionally set the installdir:

        <setInstallerVariable>
            <name>installdir</name>
            <value>${env(SYSTEMDRIVE)}/${project.vendor}/${product_shortname}-v${product_version}</value>
            <ruleList>
                <platformTest>
                    <type>windows</type>
                    <isTrue negate="1" value="prefixSet"/>
                </platformTest>
            </ruleList>
        </setInstallerVariable>

Would that work for you?

Regards,

Michiel

truhlik_fredy
Contributor
Contributor

Thank you very much @michieldhont_ 

It almost worked straight away out of the box, made only 2 small changes, moved the condition outside the platform test and used variable syntex for the prefixSet and now it does exactly what I was hopping for:

 

        <setInstallerVariable>
            <name>installdir</name>
            <value>${env(SYSTEMDRIVE)}/${project.vendor}/${product_shortname}-v${product_version}</value>
            <ruleList>
                <platformTest>
                    <type>windows</type>
                </platformTest>
                <isTrue negate="1" value="${prefixSet}"/>
            </ruleList>
        </setInstallerVariable>

 

 

0 Kudos