Skip to content
⌘ NSIS Forum Archive

Sections not executing even when selected, Ubuntu bug?

9 posts

dtca#

Sections not executing even when selected, Ubuntu bug?

Hello!

I'm new to NSIS as a concept but I couldn't find any information regarding why this is happening. This doesn't seem like expected behavior, especially since it's affecting a known-good NSI script[1].

For some reason, when using makensis 2.50-1 on Ubuntu 16.04, only the first section is processed. Consider the following script:

Section -pre
DetailPrint "-pre"
MessageBox MB_OK "-pre"
SectionEnd

Section test1 sec1_id
DetailPrint "test1"
MessageBox MB_OK "test1"
SectionEnd

Section test2 sec2_id
DetailPrint "test2"
MessageBox MB_OK "test2"
SectionEnd

Function .onInit
SectionGetFlags ${sec1_id} $0
MessageBox MB_OK "sec1_id flags:$\n$0"

SectionGetFlags ${sec2_id} $0
MessageBox MB_OK "sec2_id flags:$\n$0"
FunctionEnd
The output is two message boxes showing that sec1_id and sec2_id have the flags set to 0. A message box pops up with the message "-pre" and equally prints it to the log. Sections test1 and test2 never appear to have their code executed, as their respective message boxes and log messages do not appear. Intuitively, reading through the documentation, one can glean that perhaps the problem is that the sections aren't selected. Consider the next script, where the sections are marked as selected:

!include Sections.nsh

Section -pre
DetailPrint "-pre"
MessageBox MB_OK "-pre"
SectionEnd

Section test1 sec1_id
DetailPrint "test1"
MessageBox MB_OK "test1"
SectionEnd

Section test2 sec2_id
DetailPrint "test2"
MessageBox MB_OK "test2"
SectionEnd

Function .onInit
SectionGetFlags ${sec1_id} $0
MessageBox MB_OK "sec1_id flags:$\n$0"
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${sec1_id} $0

SectionGetFlags ${sec2_id} $0
MessageBox MB_OK "sec2_id flags:$\n$0"
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${sec2_id} $0
FunctionEnd
I expect the output to be something like this:

-pre
test1
test2
Or:

-pre
test1
-pre
test2
Instead, this produces strange behavior. Message boxes for the flags of the two sections show up just fine, but strangely, three message boxes with the message -pre pop up, and -pre is printed three times to the log. The message boxes and log messages for test1 and test2 do not appear.

Here's a screenshot to make it a little more clear what the output is:



What am I doing wrong? From reading through everything, the expected behavior should be a message box with "-pre", followed by a message box with "test1" and a message box with "test2," not three message boxes with the text "-pre" in it! Alternatively, I can see how -pre might prefix the message boxes for test1 and test2 as well, though test1 and test2 should execute, but they're not.

Is there a crucial detail I'm missing as to why the other sections aren't being processed properly? Thanks in advance for the help!

[1] The NSI script where I first started having this strange section issue was the OpenVPN NSI script: https://github.com/OpenVPN/openvpn-b...is/openvpn.nsi. None of the defined sections show up in the built installer!
Anders#
The Windows version works correctly so there must be some issue with the build you are using, either in the compiler (makensis) or the stubs used in the generated .exe.

Did you build everything (makensis and stubs) yourself or did you download binaries from somewhere?
dtca#
Originally Posted by Anders View Post
The Windows version works correctly so there must be some issue with the build you are using, either in the compiler (makensis) or the stubs used in the generated .exe.
This is something I'm starting to suspect as well.

Originally Posted by Anders View Post
Did you build everything (makensis and stubs) yourself or did you download binaries from somewhere?
NSIS was pulled from the Ubuntu repositories via `apt-get install nsis`, so I assume the stubs came along with that install.

root@ubuntu:~# dpkg -L nsis
/.
/etc
/etc/nsisconf.nsh
/usr
/usr/bin
/usr/bin/GenPat
/usr/bin/makensis
/usr/bin/LibraryLocal
/usr/share
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/nsis
/usr/share/doc
/usr/share/doc/nsis
/usr/share/doc/nsis/copyright
/usr/share/doc/nsis/README.Debian
/usr/share/doc/nsis/NEWS.Debian.gz
/usr/share/doc/nsis/TODO.txt
/usr/share/doc/nsis/changelog.Debian.gz
/usr/share/doc/nsis/TODO.Debian
/usr/share/doc/nsis/NEWS.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/makensis.1.gz
/usr/share/man/man1/LibraryLocal.1.gz
/usr/share/man/man1/GenPat.1.gz
/usr/bin/genpat
/usr/share/man/man1/genpat.1.gz
root@ubuntu:~# which makensis
/usr/bin/makensis
root@ubuntu:~# apt-cache show nsis
Package: nsis
Priority: optional
Section: universe/devel
Installed-Size: 604
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Thomas Gaugler <thomas@dadie.net>
Architecture: amd64
Version: 2.50-1
Depends: libc6 (>= 2.14), libgcc1 (>= 1:3.0), libstdc++6 (>= 5.2), zlib1g (>= 1:1.1.4), nsis-common (>= 2.50-1)
Suggests: nsis-doc (>= 2.50-1), nsis-pluginapi (>= 2.50-1), mingw-w64 (>= 1.0), wine
Filename: pool/universe/n/nsis/nsis_2.50-1_amd64.deb
Size: 227384
MD5sum: fd3474bae7f69c0b49a6e7d1dcaa51fb
SHA1: b0ac758fc1d83e117ec795852922e533f4f2dd5a
SHA256: f78e785bef24cf8ff1276ed84733c7df8305e7db968535c7844fb02f0dd023fe
Description-en: Nullsoft Scriptable Install System (modified for Debian)
NSIS is a tool for creating quick and user friendly installers for
Microsoft Windows (Win32) operating systems.
.
NSIS creates installers that are capable of installing, uninstalling,
setting system settings, extracting files, etc. Because it's based on
script files, you can fully control every part of your installers. The
script language supports variables, functions, string manipulation,
just like a normal programming language - but designed for the creation
of installers. Even with all these features, NSIS is still the smallest
installer system available. With the default options, it has an overhead
of only 34 KB.
Description-md5: 588a1a18a7c197bf93e0bdc2aee65803
Homepage: http://nsis.sourceforge.net/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu

I hope this was helpful! In the meantime, I'm going to build this version from source to see if the problem still persists.
JasonFriday13#
Originally Posted by Anders View Post
The Windows version works correctly so there must be some issue with the build you are using, either in the compiler (makensis) or the stubs used in the generated .exe.
I agree, when I was testing and debugging the NSIS 3 linux port a few years ago I made a test script with multiple sections and a hidden one, and all of them executed just fine. I was compiling from source code though, I haven't used the 'nsis' package from the repository.

Since the compiler is in the 'nsis' package and the stubs are in the 'nsis-common' package, I guess the main idea is to install the same package version for both, since 'nsis-common' has no dependencies and updates for this could potentially break something. So yeah, if you are having problems, try compiling from source instead.
dtca#
Having trouble building NSIS for POSIX. But that's for another thread.

I wanted to update this issue with something I tried, but didn't work. It was mentioned earlier that the stubs might be the problem, so I decided to copy the stubs out of the binary release and stick them in /usr/share/nsis/Stubs. This unfortunately didn't fix the problem, so perhaps the issue lies in the compiler after all.
dtca#
Fixed it! Compiling from source did the trick.

For anyone with the same issue, here's the steps I took to build:

First, download and extract the binary release somewhere on the system, say $HOME/src/nsis-bin. Then, from the source directory, build the compiler and manually install the dependencies:

$ scons APPEND_CCFLAGS="-fpermissive" NSIS_CONFIG_CONST_DATA=no PREFIX=/usr/local/nsis install-compiler
$ mkdir -p /usr/local/nsis/share/nsis
$ cp -r $HOME/src/nsis-bin/{Contrib,Docs,Examples,Include,Menu,Plugins,Stubs} /usr/local/nsis/share/nsis
Should I file a bug with the maintainer for the NSIS package for Ubuntu? Something may be messed up with the Ubuntu package causing this issue.

edit: Bug has been filed: https://bugs.launchpad.net/ubuntu/+s...s/+bug/1592174
JasonFriday13#
You do realize the paths on ubuntu are different to the windows version for a reason (the binaries, docs and data are in different directories). NSIS_CONFIG_CONST_DATA=no is for windows machines, it's 'yes' for everything else. Your using a windows binary, so this is fine.

Can I assume you don't have a cross-compiler installed? If you do then this should work as well:
sudo scons install
Although I tend to put the install into a folder in my home directory using 'PREFIX', so that I don't have to use sudo (I'm not an nsis team member, I just test and fix problems that I find on ubuntu, with some input from Anders).
dtca#
Originally Posted by JasonFriday13 View Post
Can I assume you don't have a cross-compiler installed? If you do then this should work as well:
I do actually! I couldn't figure out how to pass the correct compiler off to scons (the XGCC variable mentioned in the docs is only applicable to 3.0), so for the sake of time, I opted for a more suboptimal solution that still worked out for me. 🙂
JasonFriday13#
If you install the cross-compiler package using apt-get or Synaptic, scons should find it and use it automatically (MingGW and MinGW-w64 are popular). I don't use XGCC btw, I've never needed it.