to explain further: how can i set up blocks of commands that will be run if a given condition is met? i have to install a database on each OS that we support. so i want to pull in the proper installer package for the OS i generating the installer for. I then need to run a few programs to dump an existing db's contents, update the schema, and then reimport the db contents. this would only be run on a new installation, a schema update or a Db upgrade. The way i would conceptual look at this would be: if windows
if db installed if old version installed run db.exe run dbdump.exe run db.exe run createdb.bat run psql.exe run db import.exe else continue else run db.exe run createdb.bat run psql.exe

if mac if db installed if old version installed run db.(mac ext) ...

asked 04 Nov '11, 12:52

shawn's gravatar image

shawn
5668
accept rate: 0%


The below schematic code explains how to do it on Windows:

<actionGroup>
   <actionList>
      <!-- Check if db is installed with some custom logic.
      For example checking if some dir exists -->
      <if>
        <conditionRuleList>
          <fileExists path="${installdir}/db"/>
        </conditionRuleList>
        <actionList>
           <!-- If an installed db was detected ... -->
           <!-- Check the current version with some specific actions
           and store it into installed_version -->

           <!-- Specific actions to check the version go here
           ...
           ...
           -->
           <actionGroup>
              <actionList>
                  <!-- if old version installed ... -->
                  <runProgram program="db.exe" programArguments="..."/> 
                  <runProgram program="dbdump.exe" programArguments="..."/> 
                  <runProgram program="db.exe" programArguments="..."/> 
                  <runProgram program="createdb.bat" programArguments="..."/> 
                  <runProgram program="psql.exe" programArguments="..."/> 
                  <runProgram program="dbimport.exe" programArguments="..."/> 
              </actionList>
              <ruleList>
                <compareVersions>
                   <version1>${current_packed_version}</version1>
                   <logic>greater</logic>
                   <version2>${installed_version}</version2>
                </compareVersions>
              </ruleList>
           </actionGroup>
        </actionList>
        <elseActionList>
          <!-- If not installation was detected ... -->
          <runProgram program="db.exe" programArguments="..."/> 
          <runProgram program="createdb.bat" programArguments="..."/> 
          <runProgram program="psql.exe" programArguments="..."/> 
        </elseActionList>
      </if>
   </actionList>
   <ruleList>
      <platformTest type="windows"/>
   </ruleList>
</actionGroup>

On OS X you just need to change the <type> in the <platformTest> rule to osx and modify the commands executed for each situation.

link

answered 04 Nov '11, 14:16

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×36
×2
×1

Asked: 04 Nov '11, 12:52

Seen: 1,633 times

Last updated: 04 Nov '11, 14:16