How to define dependencies among installers?

Answered

Comments

1 comment

  • Avatar
    wojciechka

    Simplest option is to check for uninstallers' presence. It is also possible to use INI or XML files to store which service packs are installed. You can set appropriate values after installation and uninstallation of service pack:

    <project>
      <!-- ... -->
      <readyToInstallActionList>
        <!-- check if prerequisites are installed; throw an error if not -->
        <iniFileGet>
          <file>${installdir}/servicepacks.ini</file>
          <key>spABC</key>
          <section>ServicePack</section>
          <variable>is_dependency1_met</variable>
        </iniFileGet>
        <iniFileGet>
          <file>${installdir}/servicepacks.ini</file>
          <key>spDEF</key>
          <section>ServicePack</section>
          <variable>is_dependency2_met</variable>
        </iniFileGet>
        <throwError>
          <ruleEvaluationLogic>or</ruleEvaluationLogic>
          <text>This service pack requires ABC and DEF service packs installed</text>
          <ruleList>
            <isFalse>
              <value>${is_dependency1_met}</value>
            </isFalse>
            <isFalse>
              <value>${is_dependency2_met}</value>
            </isFalse>
          </ruleList>
        </throwError>
      </readyToInstallActionList>
    
      <!-- store that service pack XYZ is now installed -->
      <postInstallationActionList>
        <iniFileSet>
          <file>${installdir}/servicepacks.ini</file>
          <key>spXYZ</key>
          <section>ServicePack</section>
          <value>1</value>
        </iniFileSet>
      </postInstallationActionList>
    
      <!-- store that service pack XYZ is no longer installed -->
      <postUninstallationActionList>
        <iniFileSet>
          <file>${installdir}/servicepacks.ini</file>
          <key>spXYZ</key>
          <section>ServicePack</section>
          <value>0</value>
        </iniFileSet>
      </postUninstallationActionList>
    </project>
    

    You can also use the INI/XML file to store which was the last service pack installed and prevent user from uninstalling service pack in order that does not match the order in which they were installed:

    <project>
      <!-- ... -->
      <!-- store information that spXYZ was the most recently installed servicepack -->
      <postInstallationActionList>
        <iniFileSet>
          <file>${installdir}/servicepacks.ini</file>
          <key>MostRecent</key>
          <section>Status</section>
          <value>spXYZ</value>
        </iniFileSet>
      </postInstallationActionList>
      <!-- verify that user has not installed any additional service packs in the meantime -->
      <preUninstallationActionList>
        <iniFileGet>
          <file>${installdir}/servicepacks.ini</file>
          <key>MostRecent</key>
          <section>Status</section>
          <variable>mostrecent_servicepack</variable>
        </iniFileGet>
        <throwError>
          <text>Service pack ${mostrecent_servicepack} should be installed first.</text>
          <ruleList>
            <compareText>
              <logic>does_not_equal</logic>
              <text>${mostrecent_servicepack}</text>
              <value>spXYZ</value>
            </compareText>
          </ruleList>
        </throwError>
      </preUninstallationActionList>
      <!-- revert MostRecent servicepack to previously set servicepack -->
      <postUninstallationActionList>
        <iniFileSet>
          <file>${installdir}/servicepacks.ini</file>
          <key>MostRecent</key>
          <section>Status</section>
          <value>${previous_servicepack}</value>
        </iniFileSet>
    
      <parameterList>
        <!-- ... -->
    
        <!-- not shown to user, stores previous servicepack that was set before this one was installed -->
        <stringParameter>
          <name>previous_servicepack</name>
          <ask>0</ask>
        </stringParameter>
      </parameterList>
    </project>
    

    You can also use rules such as <compareVersions> to verify whether currently installed service pack is newer than service pack user is about to install. This would prevent users from installing a service pack that has been superseded by another service pack.

Please sign in to leave a comment.