Defining File Overwrite Options Per File, Not Globally

Comments

18 comments

  • Avatar
    wojciechka

    Unfortunately the setting is global. However, it is possible to use <actionList> in one or more <folder> objects to set the overwritePolicy by modifying the project.overwritePolicy variable - for example:

    <folderList>
           <!-- folders before this one will use project's global overwritePolicy -->
           <!-- ... -->
           <folder>
               <name>dummy1</name>
               <actionList>
                   <!-- change policy to never overwrite files -->
                   <setInstallerVariable name="project.overwritePolicy"
                  value="never"/>
               </actionList>
           </folder>
           <folder>
               <name>files</name>
               <destination>${installdir}</destination>
               <distributionFileList>
                   <distributionDirectory origin="/path/to/the/files"/>
               </distributionFileList>
           </folder>
           <folder>
               <name>dummy2</name>
               <actionList>
                   <!-- change policy to always overwrite files -->
                   <setInstallerVariable name="project.overwritePolicy"
                  value="always"/>
               </actionList>
           </folder>
           <!-- folders after one above will have overwritePolicy set to always -->
       </folderList>
    0
    Comment actions Permalink
  • Avatar
    Nathanial Woolls

    Note that the above instructions will leave behind an empty "newfolder" directory in the installation directory unless you specify destination elements for the dummy folder entries, e.g.:

    <destination>${installdir}</destination>

    0
    Comment actions Permalink
  • Avatar
    michiel

    Hi Nathanial,

    Thank you for sharing this with the community.

    Regards,

     

    Michiel D'Hont

    0
    Comment actions Permalink
  • Avatar
    Lam
    Hi, 

    Does this overwritePolicy method only works under "folder"? Can I use it in such a way that if a certain parameter is called, then set my new overwritePolicy rule?

    Example:
    <actionList>
    <setEnvironmentVariable>
    <name>project.overwritePolicy</name>
    <value>always</value>
    <ruleList>
    <isTrue>
    <value>${force}</value>
    </isTrue>
    </ruleList>
    </setEnvironmentVariable>
    </actionList>
    0
    Comment actions Permalink
  • Avatar
    michiel

    You can set it as a preInstallation action. For example:

    <preInstallationActionList>
       <setInstallerVariable name="project.overwritePolicy" value="onlyIfNewer"/>
    </preInstallationActionList> 

    But you can't set it for each folder, as a folder's actionList triggers after the folder has already been copied.

    0
    Comment actions Permalink
  • Avatar
    Lam

    Hi,

    What am I doing wrong here...? the default overwritePolicy is "Always", below is what I wanted to set if my parameter is passing in. I am still seeing "always" from ShowInfo Dialog.

    <preInstallationActionList>
    <setEnvironmentVariable>
    <name>project.overwritePolicy</name>
    <value>onlyIfNewer</value>
    <ruleList>
    <compareText>
    <logic>equals</logic>
    <text>${myparam}</text>
    <value>1</value>
    </compareText>
    </ruleList>
    </setEnvironmentVariable>
    </preInstallationActionList>
    0
    Comment actions Permalink
  • Avatar
    michiel

    You are using <setEnvironmentVariable> instead of <setInstallerVariable>

    0
    Comment actions Permalink
  • Avatar
    Lam

    Thanks Michiel, sorry for the basic mistake.

    I am using <setInstallerVariable>, but I received an error. Below are the snippet, I replied to the email with debug logs when I can't attach it here.

    <setInstallerVariable>
          <name>project.overwritePolicy</name>
          <value>Always</value>   
          <ruleList>
               <compareText>
                   <logic>equals</logic>
                   <text>${myparam}</text>
                   <value>1</value>
              </compareText>
          </ruleList>
    </setInstallerVariable>
    0
    Comment actions Permalink
  • Avatar
    michiel

    Can you check the ${myparam} value? Also, could you try using <compareValues>?

    0
    Comment actions Permalink
  • Avatar
    Lam

    Hi Michiel,

    So I:

    1. Checked project.overwritePolicy before changing and it's set to 'OnlyifNewer".
    2. Checked project.overwritePolicy after changing and it's set to 'Always".
    3. Checked ${myparam} and it's set to 1 (which is correct)

    Still failing to install with the same pop up error.

    0
    Comment actions Permalink
  • Avatar
    michiel

    Can you tell me which error exactly? Can you share a sample project which reproduces the issue?

    0
    Comment actions Permalink
  • Avatar
    Paula

    I also encountered a pop error when changing the project.overwritePolicy to "Always" and fails the installation to continue.

    There has been an error. A debug file has been created at:

    /tmp/bitrock_debug_8072.xml

    Please attach it to any bug report.
    The application will exit now.
    0
    Comment actions Permalink
  • Avatar
    BitRock support

    We have replied to this issue from our Help Desk. We will continue helping you there.

    0
    Comment actions Permalink
  • Avatar
    Paula

    Setting project.overwritePolicy to 'always' (small caps) solved the error.

    0
    Comment actions Permalink
  • Avatar
    Jeff Lazarus

    I've been trying to follow the steps in this thread and can't get it to work.

    I set the setInstallerVariable like this:

    <preInstallationActionList>
    <setInstallerVariable name="project.overwritePolicy" value="always"/>

    ...

    </preInstallationActionList>

     

    And then selectively apply to folders like this:

    <folder>
    <description>Mix App Support</description>
    <destination>/Library/Application Support/RMS/RMS Mix</destination>
    <name>app_support_mx</name>
    <platforms>osx</platforms>
    <actionList>
    <!-- change policy to overwrite files only if newer -->

    <setInstallerVariable name="project.overwritePolicy" value="onlyIfNewer"/>
    </actionList>
    <distributionFileList>
    <distributionDirectory>
    <origin>/Library/Application Support/RMS/RMS Mix/samples</origin>
    </distributionDirectory>
    <distributionFile>
    <origin>/Library/Application Support/RMS/RMS Mix/overwrite if newer test</origin>
    </distributionFile>
    </distributionFileList>
    </folder>

     

    However, my global overwrite settings still hol sway.

    Can you help me understand what I'm doing wrong?

    ...

     

    0
    Comment actions Permalink
  • Avatar
    michiel

    Hi,

    The folder's actionList is executed after the files are installed. So changing the overwritePolicy will be too late. However, it should be possible changing it in the previous folder's actionList, so right after installing the files, you are setting the policy for the next folder. Could you check if that works for you?

    Regards,

    Michiel

     

    0
    Comment actions Permalink
  • Avatar
    Jeff Lazarus

    Hi Michiel - 

    That was an improvement, yes. The precise location of the actionlist had not been clear to me. Placing theh command in the folder above the one I wanted to change did indeed have an effect on overwrite policies. Thanks.

     

    I'm still having a problem though. I am hoping to set differing overwrite policies to different items within the same directory. I attempted to do this by defining separate folders with the same path - and then reassigning the overwrite accordingly. However, only my initial overwrite change is working.

    Posting my code below. Is what I'm trying to do possible? Can you advise on any error?

    ...

    <folder>
    <description>Sinfonia App Support</description>
    <destination>/Library/Application Support/RMS/Sinfonia</destination>
    <name>app_support_snf</name>
    <platforms>osx</platforms>
    <actionList>
    <!-- change policy on files below this one to overwrite only if newer -->

    <setInstallerVariable name="project.overwritePolicy" value="onlyIfNewer"/>
    </actionList>
    <distributionFileList>
    <distributionDirectory>
    <origin>/Library/Application Support/RMS/Sinfonia/icons</origin>
    </distributionDirectory>
    </distributionFileList>
    </folder>
    <folder>
    <description>Mix App Individual Overwrite Test</description>
    <destination>/Library/Application Support/RMS/RMS Mix</destination>
    <name>app_support_mx_overwrite</name>
    <platforms>osx</platforms>
    <actionList>
    <!-- change policy on files below this one to overwrite always -->

    <setInstallerVariable name="project.overwritePolicy" value="always"/>
    </actionList>
    <distributionFileList>
    <distributionFile>
    <origin>/Library/Application Support/RMS/RMS Mix/overwrite if newer test</origin>
    </distributionFile>
    </distributionFileList>
    </folder>
    <folder>
    <description>Mix App Support</description>
    <destination>/Library/Application Support/RMS/RMS Mix</destination>
    <name>app_support_mx</name>
    <platforms>osx</platforms>
    <distributionFileList>
    <distributionDirectory>
    <origin>/Library/Application Support/RMS/RMS Mix/samples</origin>
    </distributionDirectory>
    </distributionFileList>
    </folder>

    ...

     

    0
    Comment actions Permalink
  • Avatar
    michiel

    Hi,

    It should be possible. Could you try the following sample:

                   <folder>
    <description>Program Files</description>
    <destination>${installdir}</destination>
    <name>programfiles1</name>
    <actionList>
    <setInstallerVariable name="project.overwritePolicy" value="never"/>
    </actionList>
    <distributionFileList>
    <distributionFile>
    <origin>file1</origin>
    </distributionFile>
    </distributionFileList>
    <platforms>all</platforms>
    </folder>
    <folder>
    <description>Program Files</description>
    <destination>${installdir}</destination>
    <name>programfiles2</name>
    <actionList>
    <setInstallerVariable name="project.overwritePolicy" value="onlyIfNewer"/>
    </actionList>
    <distributionFileList>
    <distributionFile>
    <origin>file2</origin>
    </distributionFile>
    </distributionFileList>
    <platforms>all</platforms>
    </folder>
    <folder>
    <description>Program Files</description>
    <destination>${installdir}</destination>
    <name>programfiles3</name>
    <distributionFileList>
    <distributionFile>
    <origin>file3</origin>
    </distributionFile>
    </distributionFileList>
    <platforms>all</platforms>
    </folder>

    The result should be that only file1 and file3 are overwritten if they are newer, and the installer is running in upgrade mode.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.