Difference between revisions of "LazAutoUpdater"
From Lazarus wiki
Jump to navigationJump to searchMinesadorada (talk | contribs) m (Tidy up) |
Minesadorada (talk | contribs) m (→Version.xml) |
||
Line 28: | Line 28: | ||
</APPCONFIG> | </APPCONFIG> | ||
− | + | The code to create it: | |
uses XMLConf | uses XMLConf | ||
Var XMLConfig1:TXMLConfig; | Var XMLConfig1:TXMLConfig; | ||
Line 41: | Line 41: | ||
XMLConfig1.Flush; | XMLConfig1.Flush; | ||
end; | end; | ||
+ | |||
+ | The code to read it: | ||
+ | uses XMLConf | ||
+ | Var XMLConfig1 :TXMLConfig; | ||
+ | szAppVer :String; | ||
+ | szOtherMouleVer :String; | ||
+ | begin | ||
+ | XMLConfig1.Clear; | ||
+ | XMLConfig1.RootName := 'APPCONFIG'; | ||
+ | XMLConfig1.Filename := 'version.xml'; | ||
+ | XMLConfig1.OpenKey('ProgramInfo/Version'); | ||
+ | szAppVer:= XMLConfig1.GetValue('GUI', '0.0.0'); // Default is '0.0.0' | ||
+ | szOtherMouleVer:= XMLConfig1.GetValue('OtherModule', '0.0.0'); // Default is '0.0.0' | ||
+ | XMLConfig1.CloseKey; | ||
==Location of files== | ==Location of files== |
Revision as of 18:10, 30 July 2014
Lazarus Auto-Updater
SourceForge Project
Workflow
The Laz AutoUpdater workflow for updating a running application is as follows:
- App downloads a small 'version.xml' file from sourceforge with version info (it can do this at start-up)
- App compares with its own internal version
- If new version available, App downloads it from Sourceforge into an /updates folder
- App uses TProcess to start the console updater, passing it info in the command line
- updater copies a downloaded 'whatsnew.txt' into the App folder and enters Sleep for a few seconds
- Meanwhile App has entered loop checking whether a 'whatsnew.txt' file has been copied into it's directory
- App detects 'whatsnew.txt' and Closes. (in other words the TProcess has started successfully)
- Updater copies /updates/UpdatedApp to App directory.
- Updater uses TProcess to start the updated app
- On Form.Show, App displays 'whatsnew.txt' then deletes it
Version.xml
The format is as follows:
<?xml version="1.0" encoding="utf-8"?> <APPCONFIG> <ProgramInfo> <Version GUI="0.0.2" OtherModule="0.1.0"/> </ProgramInfo> </APPCONFIG>
The code to create it:
uses XMLConf Var XMLConfig1:TXMLConfig; begin XMLConfig1.Clear; XMLConfig1.RootName := 'APPCONFIG'; XMLConfig1.Filename := 'version.xml'; XMLConfig1.OpenKey('ProgramInfo/Version'); XMLConfig1.SetValue('GUI', '0.0.2'); XMLConfig1.SetValue('OtherModule', '0.1.0'); XMLConfig1.CloseKey; XMLConfig1.Flush; end;
The code to read it:
uses XMLConf Var XMLConfig1 :TXMLConfig; szAppVer :String; szOtherMouleVer :String; begin XMLConfig1.Clear; XMLConfig1.RootName := 'APPCONFIG'; XMLConfig1.Filename := 'version.xml'; XMLConfig1.OpenKey('ProgramInfo/Version'); szAppVer:= XMLConfig1.GetValue('GUI', '0.0.0'); // Default is '0.0.0' szOtherMouleVer:= XMLConfig1.GetValue('OtherModule', '0.0.0'); // Default is '0.0.0' XMLConfig1.CloseKey;
Location of files
- In your SourceForge Files section, make a folder called 'updates'
- Upload 'version.xml' into it
- Upload the zip file containing your updated EXE and the file 'whatsnew.txt'
- The application installer (Inno Setup?) goes into your Files section as normal
- The Users should only have to download the installer once. All the subsequent versions will go into the /updates folder as above
Work-In-Progress...