- NSIS Discussion
- Complex s/w updater question
Archive: Complex s/w updater question
memph
29th July 2004 17:14 UTC
Complex s/w updater question
Hi,
I've got to create an application updater which is able to update an existing installation over http with the following requirements:
- It has update a file if the local version is older than the remote one
- It has to download a file if it does not exists locally.
I think I've got to make a "versioning" file which contains some version number for all files. It could contain a line for each file, containing the filename (including the relative path) and a version number. This versioning file would have a local and a remote copy and the difference between these files would tell which files shall I replace or download.
Because the number of the files in question may vary, and quite large, I believe I cannot rely making an INI file (though it would be so easy :( ) and read it via ReadIniStr, since I don't know all the filenames and there's no iterator in NSIS AFAIK.
I think if creating a small 'diff' plugin which would do the task, however before digging into plugin creation I thought I ask you if there's another, easier to do this.
Regards,
Memph
P.S.:
BTW, is it possible to use C++ STL classes in an NSIS plugin?
Afrow UK
29th July 2004 17:40 UTC
The easiest thing would be to do it in these steps:
1. Download a file off HTTP containing latest version using NSISdl plugin.
2. Compare it to the last version which should exist in registry.
3. If versions differ, write new version to registry.
4. Download new file using NSISdl (if versions differ).
To see if a file exists, use IfFileExists "file" jumpto_ifexists jumpto_ifnotexists
So, if the file does not exist, use NSISdl to grab the file!
-Stu
memph
30th July 2004 08:45 UTC
Hi Afrow UK,
The file you're talking about is the version file I mentioned? Then how would you do the comparison? By reading the file line by line and checking the a value - data pair in the registry if it already exists and is lower than the one in the file?
Regards,
Zoltan
Afrow UK
30th July 2004 12:11 UTC
Well, it doesn't have to check if the version value is higher or lower than the one in the registry. If it's not the same then obviously the user has an older version (because he can't have an older version than the server!)
Ass for the version file, it would be easiest to use an INI file.
E.g.
[Version]
Latest=1.0.0.2
In your script, simply use
ReadINIStr $R0 "downloaded\file.ini" "Version" "Latest"
With INI files, I also added other stuff in there including news of what's in the latest release which was listed in a IO textarea!
-Stu
Afrow UK
30th July 2004 12:13 UTC
Oh and btw, the program I'm talking about (written with NSIS 2.0b CVS) you can see screenshots here.
-Stu
memph
30th July 2004 12:55 UTC
So the version file contains a version number (so the updater cand check if an update is needed), and a ListBox whose Text contains the list of the files that have changed since the last version..
What if the a user missed update?
Regards,
Memph
deguix
30th July 2004 13:07 UTC
@Afrow UK: Wow, the "download filters" and "download options" dialogs are made mixing Banner plugin w/ InstallOptions. You even tried to put the pictures in the background, that means, you tried to bypass NSIS limitations to make that. That's great (only looking at it, I didn't test it because I don't play the game, sorry).
@memph: I have a suggestion:
- Put the date when the file was modified for every file.
Afrow UK
30th July 2004 13:54 UTC
The dialogue is actually an extracted NSIS exe without
WS_MINIMIZEBOX, WS_CAPTION and WS_SYSMENU.
Good ol' Resource Hacker.
I made that about a year ago now. It still amazes me how much I put into it (the game I made it for is pretty dead now.)
The code was pretty advanced. It updated itself as well as the game I made it for. It also checked for file differences (size to be exact) for updating as well as non existent files and game dll's.
Edit: Not to mention it even had random BMP's on the side, plus messages on the task-bar. It also downloaded Zip files and extracted them to the correct folders for you!!
-Stu
deguix
30th July 2004 14:06 UTC
The game I made it for is pretty dead now.
Oh yeah, that's for sure. The problem is that I do for one that's even older than your game. I don't even play it because it's boring.
The code was pretty advanced. It updated itself as well as the game I made it for. It also checked for file differences (size to be exact) for updating as well as non existent files and game dll's.
Probably you're using CVS from a site, isn't it?
[quote]Not to mention it even had random BMP's on the side, plus messages on the task-bar.[\quote]
Doesn't these BMP consume much size?
Afrow UK
30th July 2004 15:02 UTC
The whole download was one exe of about 2.5mb. The random BMP's consisted of about 5 different ones that were in the exe (uncompressed to temp).
No CVS. Just a basic file which would be downloaded and parsed which contained download URL's, download info, download versions etc.
-Stu
memph
30th July 2004 16:24 UTC
Afrow,
Could you please post the download INI? May be I'll get the clue.
Regards,
Memph
Afrow UK
30th July 2004 16:33 UTC
As far as I know, the server that hosted the TXT (INI) file is no longer running.
However, the secondary TXT file with other information is still on my ISP webspace: http://myweb.tiscali.co.uk/imker/dda...du_objects.txt
-Stu
memph
30th July 2004 17:24 UTC
Thanks
Memph
solwolf
27th September 2006 07:48 UTC
extra help
Currently running into the same problem. Here are the steps i have in my logic.
1. !define homeurl "http://www.somewebsite.com/downloads/"
2. use Inetload to download update.ini
3. Read in each line of the file and parse the 2 into differnt variables $R0 & $R1 (for example) $R0 == File name $R1 == timestamp of modified date.
4. do a IfFileExists on the $R0 if so timestamp it and store in in $R2 if not jump to HomeUrl$R0 (see step 1)using inetload
5. strCmp $R1 $R2 "" HomeUrl$R0 (using inetload)
***********
I created a php page that dynamically searches the server where the files are located and does a timestamp to the file and stores in a txt then i rename it after i am done to an ini. (for some reason couldn't write to ini) *see attachment for my ini file*
I read in the line by line and i tried parsing and it works but it seems to never get out of my parsing loop. and i have been stuck at that point for couple days really rattling my brain.
If you guys could point me in the right direction to how i can read from a ini file (dynamically) and parse line into 2 sections and pop them to 2 different variables? Your help would greatly be appreciated.
zbd
8th November 2006 04:38 UTC
I really wouldn't have a clue...but
what if you wrote the filename to one line and then the timestamp on the next line... no idea if this would be useful
Striker53
24th March 2007 13:25 UTC
Hey, could anyone give me an example how the *.nsi should looks?