[fpc-pascal] Methods for autoupdating fpc programs?
Bo Berglund
bo.berglund at gmail.com
Sat Oct 3 23:40:01 CEST 2015
On Sat, 3 Oct 2015 15:04:31 -0400, waldo kitty
<wkitty42 at windstream.net> 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.
>3. if md5 sums are different, download new version to known temp name.
Would this not compare equal for the exact same version? All others
including old and newer would fail and thus trigger an update.
BTW, how does one get the md5 value of ones own executable file?
>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.
Interesting ideas, will have to think about it.
I have not programmed in Linux before so I have no idea if programs
for Linux carry a version resource that can be checked for the version
number. Is this the case or is that only a Windows thingie?
If not then the MD5 checksum seems to be a good way...
I just tested on Lazarus inside the Pi2B and it was simple to do a MD5
sum of one's own executable:
strMD5 := MD5Print(MD5File(Application.Exename));
The only problem is that it seems to take quite some time to do
(several seconds) is that normal?
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list