Hello,

I like the installer to download a file based on the IF condition returning true. False then do not download.

This is for MAC OS installer. During installation a text file is downloaded which has a file version number. The text file needs to be read for the version number in first line. If that version number is higher than only the download needs to take place.

How do i do that?

asked 26 May '13, 05:01

Codename%20K's gravatar image

Codename K
246596371
accept rate: 50%


You could use the below code:

<httpGet>
    <filename>${system_temp_directory}/version.txt</filename>
    <url>http://example.com/version.txt</url>
</httpGet>
<readFile>
    <name>file_version</name>
    <path>${system_temp_directory}/version.txt</path>
</readFile>
<setInstallerVariableFromRegEx>
    <name>file_version</name>
    <pattern>(^[^\n]+).*</pattern>
    <substitution>\1</substitution>
    <text>${file_version}</text>
</setInstallerVariableFromRegEx>
<httpGet>
    <filename>${system_temp_directory}/file-to-download</filename>
    <url>http://example.com/file-to-download</url>
    <ruleList>
        <compareVersions>
            <logic>greater</logic>
            <version1>${file_version}</version1>
            <version2>${project.version}</version2>
        </compareVersions>
    </ruleList>
</httpGet>
link

answered 26 May '13, 14:52

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

Thanks. What does this mean "(^[^n]+).*" in the above code?

(29 May '13, 01:46) Codename K
1

It is used to take the first line of the text. I says: take all the first characters that are no new lines from the beginning of the text and capture them (enclosing them in parentheses so we can use them using \1) and match all others characters afterwards. That matches all the text in the file, and saves the first line to be available as \1. Then we use that \1 in the substitution.

(29 May '13, 03:13) juanjo ♦♦

Thanks. This is helpful.

(29 May '13, 03:27) Codename K
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:

×130
×50
×27
×24
×21
×2

Asked: 26 May '13, 05:01

Seen: 1,195 times

Last updated: 29 May '13, 03:27