packagesdev / packages

Integrated Packaging Environment for OS X
312 stars 44 forks source link

New Installer Requirements for CFBundleShortVersionString #141

Open SpacePenguinCrew opened 1 year ago

SpacePenguinCrew commented 1 year ago

Hi,

I am creating an installer that will update an already installed application in a particular directory. Currently the installer will always override the currently installed app, which is perfect. However, I need to add a set of requirements for the installer to check, which is linked to checking the already installed applications info.plist file.

An example of what I need: Check a particular application already exist in a location (Can be done using Requirements and Resources) Check the CFBundleShortVersionString of the above application is greater than or equal to a defined value.

This used to be able to be done in the old Apple PackageMaker. I was wondering can this already be done in Packages, if so how? If it cannot be done, could an extra feature be added to the following section, that allows me to select a file and choose aspects of the info.plist to check before installation:

Screenshot 2023-08-25 at 12 47 17

Any help with this would be amazing, I really love Packages, please keep uptake good work.

Thanks

packagesdev commented 1 year ago

I guess you coud use a JavaScript requirement:

function checkInfoPlist()
{
    var plist = system.files.plistAtPath("/Applications/TextEdit.app/Contents/Info.plist");

    system.log(plist);

    if (plist == null)
        return true;

    var shortVersion = plist["CFBundleShortVersionString"];

    system.log(shortVersion);

    if (shortVersion == null)
        return true;

    if (system.compareVersions(shortVersion, "2.0") == 1)
    {
        return true;
    }

    return false;
}

Reference:

https://developer.apple.com/documentation/installer_js

SpacePenguinCrew commented 1 year ago

Thanks, I'll try that out.