S0ulM1ke
S0ulM1ke

Reputation: 11

How to properly auto-update MacOS app using pkg?

I have faced some inconvenience performing auto-update with .pkg (installer.app) on my Qt app.

Update sequence:

  1. Check against server if new version available
  2. Download installer (.pkg)
  3. Run installer detached
  4. Quit app

What have I tried:

First of all I tried installer:

    // Get full path to installer
    QString installer = Path::getCacheFileInfo(Constants::INSTALLER_NAME).filePath();
    QStringList args;

    args << "installer" << "-pkg" << installer << "-target" << "/" << "-store";
    QProcess::startDetached("sudo", args);

But - 1. Requires sudo; 2. Installation progress is not shown to user.

Also I tried just to use open on downloaded .pkg - this one seems to be the best approach. But I wish that installer performs "update" only (skip welcome page, EULA agreement etc.). As far as I know pkg installer must detect if it must perform installation or upgrade (if app was already installed but version is higher)

Quote from pkgbuild docs:

 --version pkg-version
   Specify a version for the package. Packages with the same identifier are compared >using this version, to determine if the package
   is an upgrade or downgrade. If you don't specify a version, a default of zero is >assumed, but this may prevent proper
   upgrade/downgrade checking.

If I try to run installer with the same version installed it seems that installer do nothing about it, it looks like "fresh" installation.

I assume that may be achieved using scripts in distribution.xml

Possible solutions:

  1. Deal with packaging installation to make action if app was installed previously and version is non-equal to installed. Is there any "native" way to perform "upgrade"? I think key is BundleOverwriteAction
  2. Use custom-made installer app (Platypus for example)

EDIT

I have tried to define BundleOverwriteAction with Components.plist. It's have no effect on installation ui. Probably is just effect installation process itself. So I think I should try to work with distribution.xml to find a way to skip unnecessary pages for upgrade. Or build update-only package.

The more I trying to deal with pkg, the more I understand that build own installation app is may be most simple solution to deliver updates to user. But still hope that you can configure pkg like Inno Setup with /SILENT

Upvotes: 0

Views: 108

Answers (0)

Related Questions