Question

We have created .pkg installer for our Java app and every time we run the the newest .pkg installer it delete previous dev versions of the app. I noticed that this newest installer prints "Removing old files..." when it removes one of the old dev versions. This is quite annoying for testers who often would like to keep multiple dev versions for comparison.

Is there a way to force the installer to not remove old files?

To create my final installer I first create a couple of sub .pkg's with calls to pkgbuild:

pkgbuild --root "./Temp"  --identifier "com.agentsheets.agentsheets" --install-location "/Applications" --sign "Developer ID Installer: AgentSheets, Inc." "./build_dir/temp.pkg"
pkgbuild --root "$APP_FOLDER/AgentSheets.app"  --identifier "com.agentsheets.agentsheets.app" --install-location "/Applications/$APP_FOLDER_NAME/AgentSheets.app" --sign "Developer ID Installer: AgentSheets, Inc." "./build_dir/asj_app.pkg"
pkgbuild --root "./AgentSheetsCameraHelper.app"  --identifier "com.agentsheets.agentsheets.camera" --install-location "/Applications/$APP_FOLDER_NAME/Resources/AgentSheetsCameraHelper.app" --sign "Developer ID Installer: AgentSheets, Inc." "./build_dir/camera.pkg"

Then I create the final .pkg with productbuild:

productbuild  --package-path "./build_dir"  --distribution "./Distribution.xml"  --resources "./Resources" --sign "Developer ID Installer: AgentSheets, Inc."  "$FINAL_PKG"

Here is my distribution.xml:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
    <title>AgentSheets</title>
    <background file="background.png" scaling="toFit"/>
    <options customize="never" require-scripts="false"/>
    <pkg-ref id="com.agentsheets.agentsheets"/>
    <pkg-ref id="com.agentsheets.agentsheets.app"/>
    <pkg-ref id="com.agentsheets.agentsheets.camera"/>
    <options customize="never" require-scripts="false"/>
    <choices-outline>
        <line choice="default">
            <line choice="com.agentsheets.agentsheets"/>
            <line choice="com.agentsheets.agentsheets.app"/>
            <line choice="com.agentsheets.agentsheets.camera"/>
        </line>
    </choices-outline>
    <choice id="default"/>
    <choice id="com.agentsheets.agentsheets" visible="false">
        <pkg-ref id="com.agentsheets.agentsheets"/>
    </choice>
    <pkg-ref id="com.agentsheets.agentsheets" version="0" onConclusion="none">temp.pkg</pkg-ref>
    <choice id="com.agentsheets.agentsheets.app" visible="false">
        <pkg-ref id="com.agentsheets.agentsheets.app"/>
    </choice>
    <pkg-ref id="com.agentsheets.agentsheets.app" version="0" onConclusion="none">asj_app.pkg</pkg-ref>
    <choice id="com.agentsheets.agentsheets.camera" visible="false">
        <pkg-ref id="com.agentsheets.agentsheets.camera"/>
    </choice>
    <pkg-ref id="com.agentsheets.agentsheets.camera" version="0" onConclusion="none">camera.pkg</pkg-ref>
</installer-gui-script>
Was it helpful?

Solution

pkgbuild does not support not overwriting the previous version at this time. However, you could use version control, such as git, to track the folder. Better yet, Dropbox also keeps previous revisions of a file, up to 200. Plus, it's free. I recommend you try that out. Once dropbox is installed on your mac, copy the required build resources into the directory and run the command within the 'Dropbox' folder of your user home.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top