[fpc-pascal] Methods for autoupdating fpc programs?

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sun Oct 4 11:53:16 CEST 2015

waldo kitty wrote:
> On 10/03/2015 02:30 PM, Bo Berglund wrote:
>> The program will probably be started by cron every minute to check if
>> it has anything to do and if so execute its data collection task and
>> quit. Otherwise just quit, but here maybe also check for an update on
>> the web?
>> But how could one exchange a running program on the pi from within
>> itself?
> off the top of my head:
> since you're running from cron and exiting, this could be pretty simple...
> 1. at start up, check if self is named known temp name. if yes, copy 
> self to normal name, spawn normal name and die.
> 2. at start up pull md5 checksum file from server and compare with own 
> md5 checksum.

Check size first in case somebody has inadvertently put up a binary with 
a couple of dozen Mb debug info attached :-)

One way round this is to use (something like) Subversion at both ends of 
the link, since this implements a fairly efficient check and is 
generally OK for binaries.

> 3. if md5 sums are different, download new version to known temp name.
> 4. at end of execution, see if known temp name exists. if it does, spawn 
> it and die.
> maybe something like that... of course, somewhere in there you'll still 
> do your required processing... the end of execution will wait for 
> everything to be done before doing step 4...
> one might also use a special command line parameter to tell the known 
> temp name to copy itself over to the normal name in step 1.

i)   Does the program need to detect changes while it's running?

ii)  What provision is made for ensuring that a new version of the 
program comes from the designated builder?

iii) Assuming that the program's not being rebuilt from source on the 
machine it's to run on, does the binary name include the name of the 
architecture etc.?

I've looked a bit at (i) for graphical programs. It can be done fairly 
reliably using dynamically-linked libraries (.so files on unix) but not 
IME quite reliably enough for remote sites. And while we're in the UK, 
we have kit scattered around from Sweden to Turkey.

Code signing is not really implemented on Linux, so (ii) is a problem.

Considering (iii), Lazarus can be told to put the architecture etc. in 
the name of a generated binary, but going further than that- and in 
particular specifying subarchitectures like the HF on the RPi- is a 
problem hardly helped by the fact that there's no provision for this in 
the ELF header.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list