Old 12th February 2014, 11:00   #1
mojmir
Junior Member
 
Join Date: Feb 2014
Posts: 9
File with variable

Hello,

this is my first install program so i am a bit clumsy with this.

I have at least 4 packages (xp, vista)x(32, 64). i somehow glued the detection from available sources and now i need to do the Section part.
What do I do:
1) create c:\_builds
2) build everything into it, so that it has folders like
code:
blackbox.nsi
vs_vista_32
vs_vista_64
vs_xp_32


3) inside blackbox.nsi i assemble the build name, cca like this
code:
StrCpy $1 $usr_win
StrCpy $2 $usr_bits

StrCpy $builddir "vs_$1_$2"


4) now for the problematic Section, i'd like to do something like this:

code:
Section "BlackBox"
SetOutPath $INSTDIR
File $builddir\"bbnote.exe"
...
SectionEnd



But this gives me error for nonexistent file (bbnote.exe).
So how to achieve it? Or do i have to take an another approach?

Best regards and many thanks for this great installer,
Mojmir
mojmir is offline   Reply With Quote
Old 12th February 2014, 11:46   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,558
You cannot use variables with the file instruction, use !defines...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 12th February 2014, 15:39   #3
mojmir
Junior Member
 
Join Date: Feb 2014
Posts: 9
could you give me a hint how to do that, please?

i tried naive approach, but failed
code:

!define platform_build_dir ${build_dir}

Section "BlackBox"
SetOutPath $INSTDIR
File "${platform_build_dir}\bbnote.exe"

mojmir is offline   Reply With Quote
Old 13th February 2014, 02:50   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,558
Does the compiler not warn you that ${build_dir} is undefined?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th February 2014, 03:10   #5
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 847
Quote:
Originally Posted by mojmir View Post
inside blackbox.nsi i assemble the build name, cca like this
code:
StrCpy $1 $usr_win
StrCpy $2 $usr_bits

StrCpy $builddir "vs_$1_$2"

You're getting confused with compile-time and run-time commands. So based on what your build directories are, you'll want something like this:

Quote:
; your platform define goes here, or you can specify it on the command line with /D.
;!define XP32

!ifdef XP32
!define platform_build_dir "vs_xp_32"
!endif

!ifdef VISTA32
!define platform_build_dir "vs_vista_32"
!endif

!ifdef VISTA64
!define platform_build_dir "vs_vista_64"
!endif

!ifndef platform_build_dir
!error "No platform specified for this installer."
!endif

; you can change the OutFile name based on this define, too.
;OutFile "BlackBox-Setup-${platform_build_dir}.exe"

Section "BlackBox"

SetOutPath $INSTDIR
File "${platform_build_dir}\bbnote.exe"

SectionEnd

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 13th February 2014, 07:23   #6
mojmir
Junior Member
 
Join Date: Feb 2014
Posts: 9
ugh... *scratch my head*.. but is that what i want?

right now i do not want one installer per one build. i want 1 installer to contain N builds, and then, when the installer is executed, autodetect which one of the build will be used, and only that one is installed on target machine.

// although on the other hand the idea of creating N installers for N builds (for users that do know what they want) will be handy too, so thanks for that reponse anyway
mojmir is offline   Reply With Quote
Old 13th February 2014, 08:29   #7
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 847
Quote:
Originally Posted by mojmir View Post
ugh... *scratch my head*.. but is that what i want?

right now i do not want one installer per one build. i want 1 installer to contain N builds, and then, when the installer is executed, autodetect which one of the build will be used, and only that one is installed on target machine.
Oh, right. I didn't get that from your posts. If you don't have a components page in your installer, then it's relatively easy. Create a section for each build (use the '/o' option to deselect them), and include 'Sections.nsh' (for it's defines) to select a section based on what OS it's running on.
Quote:
!include "Sections.nsh"

Section /o "XP32" SecXP32
; XP 32 bit files and stuff here
SectionEnd

Section /o "VISTA32" SecVISTA32
; Vista 32 bit files and stuff here
SectionEnd

Section /o "VISTA64" SecVISTA64
; Vista 64 bit files and stuff here
SectionEnd

Function .onInit
; Windows detection code goes here
; The result will run one of these commands below,
; though if detection fails it's good to set a
; default anyway.

;SectionSetFlags ${SecXP32} ${SF_SELECTED}
;SectionSetFlags ${SecVISTA32} ${SF_SELECTED}
;SectionSetFlags ${SecVISTA64} ${SF_SELECTED}
FunctionEnd
If you do have a components page, then it gets very tricky and will require a lot more work. It would be easier to separate the builds out to their own installers.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 13th February 2014, 10:58   #8
mojmir
Junior Member
 
Join Date: Feb 2014
Posts: 9
okay, i will try that later afternoon. many thanks!

i would like to have components, as the software has some styles and plugins that are optional. do you have a link to some example or similar installer perhaps?
mojmir is offline   Reply With Quote
Old 13th February 2014, 12:24   #9
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 847
I whipped up an example, which wasn't as hard as I thought it might be. You can change the platform by uncommenting a line at the bottom of the script.
Attached Files
File Type: nsi multi-build.nsi (2.6 KB, 107 views)

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 14th February 2014, 08:21   #10
mojmir
Junior Member
 
Join Date: Feb 2014
Posts: 9
yes, this is pure gold, thank you Jason!

i do not think i would figure this out by myself in reasonable time
mojmir is offline   Reply With Quote
Old 17th February 2014, 10:59   #11
mojmir
Junior Member
 
Join Date: Feb 2014
Posts: 9
coming by to thank you once more.

i expanded the example into full blown installer over the weekend and it works great.
mojmir is offline   Reply With Quote
Old 17th February 2014, 17:02   #12
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 847
Glad I could help.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump