Archive: Updater


Updater
  Ok i need to know how to make a program that would connect to a site and check if there are any downloads available on the site and return to the user a list of downloads that are available then the user could download them.

I have made installers with NSIS but i am probably in the novice stage so if anyone can tell me how to do it or even if its possible i would greatly appreciate it. Thanx:)


You can use the NSISdl plug-in to download and the InstallOptios plug-in to display the list of downloads.


Ok thanx but can u please give me an example on how to do it


Thanx again.


Writing this whole system will take quite some time. Please read the documentation yourself and if you have any problems with specific features, post a question.


Ok i have made a downloader but everytime i get to the install part it connects then it gets a download error is there anyway i can find out what kind of error it is?


there's a readme for that plugin, it says:


NSISdl::download /TIMEOUT=30000 http://www.domain.com/file localfile.exe

The return value is pushed to the stack:

"cancel" if cancelled
"success" if success
otherwise, an error string describing the error


Sorry but i already figured out my problem but thanx anyway.

Now can anybody tell me how to write a line to an .ini file like say that i want to add

;Hello

on line 5

how would i go about doing it?


Why would you want to write a comment to an INI file? Use WriteINIStr and ReadINIStr, it's much easier. If you want to write lines that are not in the INI format use FileOpen, FileWrite, FileRead and FileClose.


D-Day Updater
  I have written an updater program in NSIS for our D-Day: Normandy computer game.
It's finished now, after releasing the final changes yesterday (build v1.00b4)
It downloads a list of community maps from our Internet server(s) to the users' PC, and then checks which map names on the downloaded list exist on his/her's hard drive.
If the maps, or downloaded zips do not exist, then it adds the zips to a list for download.

The full program can be downloaded here (1.13mb):
http://www.planetquake.com/ddc/gbr-release

Main source:
http://myweb.tiscali.co.uk/imker/dda...dayupdater.nsi

-Stu


ok i can write a line to an ini file using WriteINIStr but is there anyway to write something just like

blahblah instead of

[whatever]
text=blahblah


Also is there a way that i can scan an online folder and return to the user a list of files that are in that folder.

Thanx alot guys for all your help my updater is starting to look better and better.:)


for writing normal text in a ini, you need the FileOpen/FileWrite/FileClose combo that kichik told you.

To find files you need the FindFirst/FindNext/FindClose combo.

Maybe difficult to use at first, but once you wrote one you can copy it for the rest of your live ;)

mmm... I found no examples for this combos in nsis archives, may I wrote them?


You can't scan the list of files on a server unless the server gives you a method to do it. It would be a lot simpler to just include an online file that contains the file the user can download.

n0On3, there are some examples in the Archive. But if you think something is missing, a basic example, a more descriptive explanation or anything else, go ahead and add it. The more the merrier :)


Yes please write it so u can help many noobish people like me :)


Isnt there anyway i can get rid of the setion_name using WriteINIStr
Because im using it like this

WriteINIStr "$INSTDIR\plugins.ini" "i need to get rid of this" "blah.amx ;" "description"

And it looks like this

[i need to get rid of this]
blah.amx ;=description

See its perfect except the part i need to get rid of i dont even need to get rid of it but is there a way i can put a ; or // in front of it


if you do:

FileOpen $4 "whateverfile.txt" a
FileSeek $4 0 END
FileWrite $4 "blahblah"
FileClose $4

you'll have that blahblah at the end of the file. I am not sure about the '0' though.


I wrote an example here:

http://nsis.sourceforge.net/archive/...29&instances=0

tell me what you think, and what to change ;)


Please could you move it to the Text File Manipulation subdir so that it can be found more easily.

Edit: Soorry, never mind it's in examples anyway :)

-Stu


:) Thank u it worked perfectly thank u a 1000 times and great post it was very helpful.


Thanks, I am glad it helped you :)

And yes, I put it in the examples section because that code is not something to use, but just to see how they work together.

I am still not sure about the "FileSeek $4 0 END" is it correct?


The 0 is fine. Will set the file pointer at the end.


Now how can i do this find a line that starts with gamedll and replace it with a new line. Also is there anyway i can write "" in a file?

Thanx again in advance


Also one more thing sorry i had to post twice but it slipped my mind

how can i read a string from an ini and if that string exists to stop a file from appearing in the components list?


How can i write quotes ("") to a text file


To compare only the first part of the string to another stirng use StrCpy with a limit first. StrCpy allows you to copy just a certain number of chars from the string. Specify the length of the string you want to compare to and compare the result.

To write quotes to a text file, or use them anywhere else, simply quote the string with other types of quotes (' for example). See Section 4.1 for more information.

To read from an INI file use ReadINIStr.

If you want to hide a section from the components page simply set its name to "" using SectionSetText.


OOps sorry i messed up my post


Ok here is my script so far i have it to write the string to a file named installed.ini but how can i make it to where it will read the installed.ini file next time around and if the current version is the same as in the ini for that file not to show up in the components list. i only have the WriteINIStr in the first section but i will add it to the others once u guys help with this part and i think i could get the rest of it own my own. Thanx once again for all the help.


Can you please repeat that? I didn't understand what you wanted to ask.

I have seen usage of FileOpen, FileRead, FileWrite and FileClose in your script for INIs in your script. If you're already using an INI use WriteINIStr and ReadINIStr instead of messing with File*. It's so much simpler...


I just need u to tell me how to read the string from an ini version is the same for the component not to show up on the components list

[AMX]
version=0.9.6

Im sorry this is kinda of hard for me to explain heres an example

if

[AMX]
version=0.9.5

and there is an installer for amx version 0.9.5 i dont want it to show up in the components list

I hope it was clear enough


To skip the component list simply call Abort from the component's page pre function. To skip according to the version number use something like:

ReadINIStr $0 file.ini section name
StrCmp $0 "0.9.6" 0 +2
Abort


Ok i dont know how to set the function up as a component pre function i have tried using Function .onGUIInit but it says there is already a function named that so what do i do and also i dont want the installer to abort i just dont want that section to appear so i used

ReadINIStr $0 "$INSTDIR\addons\downloaded\installed.ini" "Metamod" "Version"
StrCmp $0 "1.16.2" 0 +2
SectionSetText "SEC1" ""

And i dunno if its right because i dunno how to use it. So if anyone has any advice for my noobish self i would appreciate it. And thanx a lot Kichik u have helped me with almost all of my problems and u rock.


See the following page for more information about page callbacks:

http://nsis.sourceforge.net/Docs/Chapter4.html#4.5.3

If you aren't using the latest CVS version find the same section on your local documentation. The one online is only for the latest CVS version.

After that, read the MUI readme to find how to set pre function using the MUI (the normal method won't work as you expect with the MUI).


Ok i added the function and now it works but how can i make the subsection dissapear.

also how can i make all check boxes off by default i know i have seen it before but where i tried searching and i couldnt find it. Sorry


And i mean by that is that i want to make the subsections not show in the components section so what do i use

+Section
--subsection
--subsection

i want to make those subsections dissappear


You can hide a section by setting an empty name.


I tried that and it didnt work i used

SectionSetText "SEC1" ""

and when i did that nothing happened also how would i check more than one ini prior to the components section i think i got it i just did this but im not sure if its right...


"check"

ReadINIStr $0 "$INSTDIR\addons\downloaded\installed.ini" "Metamod" "Version"
StrCmp $0 "1.16.2" 0 +2
SectionSetText "SEC2" ""

ReadINIStr $0 "$INSTDIR\addons\downloaded\installed.ini" "AMX" "Version"
StrCmp $0 "0.9.6j" 0 +2
SectionSetText "SECA2" ""
>FunctionEnd
>

He means;

Section "Section Name" SecID
SectionEnd

Then use;

SectionSetText ${SecID} ""

-Stu


Alright thanx it worked perfectly


So are u guys absolutely sure there is no way to find a list of files that are available not even using a mySQL database or somethin like that?


You can't scan the list of files on a server unless the server gives you a method to do it.
I didn't say it's impossible, I said the server needs to supply such a method. For example, it's very much possible to let the server create an INI file and send that to you as the response. This can be done with PHP, Perl, JSP, ASP, you name it.