Archive: Basket 'o bugs


Basket 'o bugs
Hello. I am trying to do what I think is something simple, but I am having the most difficult problems.

Firstly, I am just trying to test to see if a file exists which has some install parameters in it, so I do:
${GetOptions} "$R0" "/INI=" $R1
${If} ${FileExists} $R1 ;this always fails with a relative path

So, how do I get around the limitation of having to use an absolute path? Well, we try to get the current directory, using ${GetExePath}, and I have !include FileFunc.nsh, but I get an error Invalid command: ${GetExePath}. I am using version 2.2.2, so I am not sure what the deal is.

So, the next problem I have, is when I pass in multiple options on the command line, win32.installer.exe /INI=C:\od4\DON\install\settings.ini -silent -path=c:\usr\local\bin\test, I am having problems getting option values out using ${GetOption} "$R0" "/INI=" $R1.

Now, $R1=C:\od4\DON\install\settings.ini -silent -path=c:\usr\local\bin\test, so all of my settings are basically junked out. I didn't see anything close to what I am looking for in the examples -- if someone could point me in the right direction, it would save me a lot of time.

Anyway, this is just the top layer in my basket 'o bugs. Any/all help is appreciated. If any changes to the NSIS interface could make these items easier to deal with, that would be great to add to the next feature list, too.


So, how do I get around the limitation of having to use an absolute path? Well, we try to get the current directory, using ${GetExePath}, and I have !include FileFunc.nsh, but I get an error Invalid command: ${GetExePath}. I am using version 2.2.2, so I am not sure what the deal is.
Did you remember !insertmacro GetExePath
http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.9


So, the next problem I have, is when I pass in multiple options on the command line, win32.installer.exe /INI=C:\od4\DON\install\settings.ini -silent -path=c:\usr\local\bin\test, I am having problems getting option values out using ${GetOption} "$R0" "/INI=" $R1.
win32.installer.exe /INI=C:\od4\DON\install\settings.ini -silent /path=c:\usr\local\bin\test
${GetOptions} "$R0" "/INI=" $R1

http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.12

Wow, awesome help. Someone should consider adding !insertmacro GetExePath to all of the examples in the help. I would have never searched through the documentation that long. And, I guess in the end it wasn't a help anyway, because it just returned an temp directory anyway. Argh. I guess I will need to dick around with that for a few hours to figure where I can snag the path so it will return the correct path so I can feed it into my IfFileExists call. Is there any way to make IfFileExists work when a simple filename like test.ini is used as the argument? Seems to me like a simple request, but I have wasted a ton of time trying to get this to work. Maybe the documentation should state that only absolute paths work for this function, if this is the case.

I am still lost trying to figure out the GetOptions function. I am staring at the examples, seeing that it looks identical to what I have, and wondering what I am doing wrong. Does order matter? Can I use / and - interchangeably? I don't feed in any quotations, so why doesn't it truncate after the first parameter?

How do I build the equivalent of the case statement? It looks like all of the options go into the first parameter -- do I have to keep repeating it? What if I have a lot of parameters, and then want to add just one?

${GetOptions} "$R0" "/INI=" $R1
MessageBox MB_OK "Here we are $R1..."
;This prints Here we are C:\od4\DON\install\settings.ini -silent -path=c:\usr\local\bin\test..., when the input is:
;/ini=C:\od4\DON\install\settings.ini -silent -path=c:\usr\local\bin\test
${Unless} ${Errors}
...snip...
;do a bunch of processing if we have an ini file
...snip...
${EndUnless}
MessageBox MB_OK "Just after EndUnless."
${Else}
MessageBox MB_OK "detected -ms option $R1."
; Support for the deprecated -ms command line argument. The new command
; line arguments are not supported when -ms is used.
SetSilent silent
${EndIf}
; this crap is all hopelessly broken...
; ${GetOptions} "$R0" "-ira" $R1
; ${If} ${!Errors}
; MessageBox MB_OK "detected -ira option $R1."
; ${EndIf}
; ${GetOptions} "$R0" "-ma" $R1
; ${If} ${!Errors}
; MessageBox MB_OK "detected -ma option $R1."
; ${EndIf}

Oh, I just found silent.nsi somewhere in the online documentation. I would like to recommend putting that in the example scripts page. I am not sure if it works, and can't recall how I found it, but it seems like it is what I am looking for.

Thanks again for the tips,

-Kevin


Well, you define "/" as separator, so GetOptions gets the options from this separator until the next "/".
This is the way it works.
${GetOptions} 'file.ext /INI=file.ini /silent /path=<path>' '/INI=' '$R1'

EDIT:
When you call IfFIleExists without a given path, obviously the installer looks for the file in the current directory, either where it's running, or, where the SetOutPath is pointed. So, when you call IfFileExists to look for a file on some other location you need to provide the full path. This call would never search the entire system for a file or files.


So, what you are saying is that my GetOptions problem is probably mixing / and -? I will have to try to see what I get out of it.

I am not sure what to say about IfFileExists. I am running it in the same directory, and it is unable to find it. I actually use a batch file to execute it -- the batch file, the install executable, and the ini file are all in the same directory. If I add the fully qualified path to the batch file, it will work fine.

As a note -- I am trying to tweak the install for firefox. It may be possible that they are doing some funny compression, which might explain why all of the directories are in temp folders. I find it hard to believe that they tweak it so hard I can't figure out what directory the thing is starting from, though.

The switching of - and / for the options is a mix of old-installer/new-installer conventions, which I was hoping to maintain for backwards compatibility.

Thanks again,

-Kevin


Check the following attached example about get options,
about firefox this thread might be of your interest,
http://forums.winamp.com/showthread....hreadid=262535

I am not sure what to say about IfFileExists. I am running it in the same directory, and it is unable to find it.
In this case the call should be,
IfFileExists '$EXEDIR\file.ext'

Just added to the attached test the IfFileExists issue :)