Menu

Home

Gordon Bamber

LazAutoUpdate Home Page


Summary

LazAutoUpdater is a visual drop-in component for the Lazarus/FPC IDE to make updating your application easier and simpler.
It is aimed at Lazarus Windows and Linux developers who host their project in SourceForge.
*Drop-in the component, set one property (your sourceforge project name) and call these simple methods:

If LazAutoUpdate.NewVersionAvailable then...
LazAutoUpdate.DownloadNewVersion
LazAutoUpdate.UpdateToNewVersion

..and in your form.activate code:

LazAutoUpdate.ShowWhatsNewIfAvailable

You (the developer) have plenty of control over how the component behaves, yet it is simple to use.
End-users see the updating process as simple and transparent
*Tested and developed in Windows Vista 32-bit and Linux Mint 64-bit


Installation

Download the package source files from the SourceForge Project site
If not already done, compile the laz_synapse package (no need for installation). It is included in LazAutoUpdater for your convenience.
Install the lazautoupate package (it will be in your 'System' tab)
Compile updatehm.lpi for your system architecture (or download a compiled version from the SourceForge site)
**'''You will need to distribute updatehm(.exe) with your application for LazAutoUpdate to work correctly'''


Use

Drop the component onto the main form of your application
Set the SFProjectName property to your SourceForge project name (the same text as appears in the URL for your project page)
*Decide if you want your app to check for updates on startup. If so, in your form.activate handler:

If LazAutoUpdate1.NewVersionAvailable Then
      MessageDlg(Application.Title, 'A new version of ' + Application.Title +
        ' is available.' + LineEnding +
        'Click ''Check for new version'' in Help menu to update', mtConfirmation,
        [mbOK], 0);

*Give the user a chance to update the application. Here's some sample code:

LazAutoUpdate1.SFProjectName := 'lazautoupdate';
If LazAutoUpdate1.NewVersionAvailable Then
  If LazAutoUpdate1.DownloadNewVersion Then
    Begin
    If MessageDlg(Application.Title, 'Download Succeeded.  Click OK to update',
      mtInformation, [mbOK], 0) = 1 Then
      LazAutoUpdate1.UpdateToNewVersion;
    End
  Else
    ShowMessage('Sorry, download of new version failed')
Else
  ShowMessage('Sorry, no new version is available');

*You don't want the user to close your application in the middle of an update! Use this code in the Form.CloseQuery handler:

If LazAutoUpdate1.DownloadInProgress Then
  Begin
  CanClose := False;
  ShowMessage('Please wait. Download is still progress.');
  End;

Or let the component do all this for you - just use

LazAutoUpdate1.AutoUpdate;

This gives you the 'bare bones' of the update code for your application. As you can see, it's all pretty automatic and simple.

Deploying your Application with LazAutoUpdate

  • Make a folder in your SourceForge project files called 'updates' (from the Files root)
  • Make a ZIP file containing the latest version of the executable and a 'whatsnew.txt' (which will be shown to the user)
  • Important: If there is no 'whatsnew.txt' in the Zip then LazAutoUpdate will not work!
  • If the CopyTree property=true then the zip file can contain folders and their contents, which will be unzipped and copied en masse to the application directory (with folder structure intact)
  • Upload the ZIP file to the SourceForge /updates folder
  • Make a 'versions.ini' file with the GUI='n.n.n.n' version number that matches the version number in your updated executable
  • Upload the versions.ini to your SourceForge /updates folder
  • In your installer, be sure that it makes a local /updates folder (relative to the installation destination). This is important for permissions in Windows.
  • In your installer, be sure to include the file 'updatehm.exe'. It should install to the same folder as your application
    *

Project Members: