-
Notifications
You must be signed in to change notification settings - Fork 19
NSIS Installer for Windows
Shoes uses the NSIS program to create installers for Windows. It is sufficiently strange that it needs some additional documentation.
I'm using NSIS 3.03 which was released a few days ago. It includes the long strings patch needed for Shoes and provides for Multiple Language scripts (with unicode support) should Shoes ever get multi-lingual install scripts.
Building it is a bit of a puzzle but it can be done. I do it on Linux but OSX could do it if you work hard. You need the mingw cross compilers and a thing called scons
which is a python based make or rake. It wants a Zlib1 (aka libz) that has been cross compiled to a windows dll.
Get zlib-1.2.11.tar.gz, untar it and cd into it. It too has a unique build process. Create a script like this
!/bin/bash
PREFIXDIR=$HOME/Projects/nsis/Zlib-1.2.11-win32-x86
make -f win32/Makefile.gcc BINARY_PATH=$PREFIXDIR/bin INCLUDE_PATH=$PREFIXDIR/include LIBRARY_PATH=$PREFIXDIR/lib SHARED_MODE=1 PREFIX=i686-w64-mingw32- install
Run the script from inside zlib-1.2.11 directory and the dll will be placed in that PREFIXDIR.
NSIS could be told many things that don't make a lot of sense to me. Just create a script - I call mine nsis.sh and chmod +x the script. Cd into the nsis-3.03-src directory and run the script.
scons PREFIX=/home/ccoupe/Projects/nsis/nsis3 ZLIB_W32=/home/ccoupe/Projects/nsis/Zlib-1.2.11-win3
2-x86 VERSION=3.03 UNICODE=yes NSIS_MAX_STRLEN=8192 install
That will build the Linux version (makensis) and the Windows version (makensis.exe) in the nsis3 directory. If you change the PREFIX to /usr/local then it would install there but you'd have to sudo and I like to avoid that. Of course, you have to call makensis with a full path instead of depending on $PATH and /usr/local. We have a fix.
Add two lines.
Installer: nsis
InstallerLoc: /home/ccoupe/Projects/nsis/nsis3/bin/makensis
It is also useful to build (cross build) NSIS for Windows and make an installer for it. To avoid confusion it's going to be called shoesnsis and the installer will be shoesnsis_setup.exe
We need a full copy of an installed NSIS. Download and install Nsis-3.03-setup.exe on Windows. Using the magic available to you with networks and tar or zip, get a copy of that and put it in ~/Projects/nsis/nsis-3.03-window Expand the archive. With luck or patience you'll have an NSIS directory in there. Tar that up so you'll have a copy
ccoupe@bronco:~/Projects/nsis/nsis-3.03-windows$ ls NSIS
Bin Docs makensis.exe NSIS.chm Plugins
Contrib Examples makensisw.exe nsisconf.nsh Stubs
COPYING Include Menu NSIS.exe uninst-nsis.exe
Download the NSIS strlen zip. Expand it into a directory (nsis-3.03-strlen/ ) and make a tar for safety. We have to copy it's contents over the the NSIS directory seen in the step above. I made a short script, I call merge.sh
#!/bin/bash
tar xf NSIS.tgz
tar xf nsis-3.03-strlen.tgz
cp -R nsis-3.03-strlen/* NSIS/
After running the script you have an updated NSIS, on your linux box.
I wish Nullsoft would offer that installer on their site but they don't. You and I can for Shoes users. I wish I could find the installer .nsh script the Nullsoft uses to build their installer. I couldn't. But we can modify the nsh that Shoes uses, change up some names and icons to make it a little shoes specific. Here's shoes-nsis.nsi :
; Shoes definitions
!define SHOES_NAME "shoesnsis"
!define SHOES_VERSION "3.03"
!define SHOES_PUBLISHER "shoesrb"
!define SHOES_WEB_SITE "http://shoesrb.com/"
!define SHOES_INST_KEY "Software\Hackety.org\${SHOES_NAME}"
!define SHOES_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\$
{SHOES_NAME}"
!define SHOES_UNINST_ROOT_KEY "HKLM"
SetCompressor /SOLID lzma
!include "MUI.nsh"
!include "LogicLib.nsh"
!include "FileFunc.nsh"
!include "FileAssociation.nsh"
;!include "EnvVarUpdate.nsh"
Var StartMenuFolder
Var UninstallerHasFinished
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON nsis3-install.ico
!define MUI_UNICON nsis3-uninstall.ico
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_WELCOMEFINISHPAGE_BITMAP installer-1.bmp
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP installer-2.bmp
!define MUI_COMPONENTSPAGE_NODESC
; MUI Pages
!insertmacro MUI_PAGE_WELCOME
!define MUI_PAGE_HEADER_TEXT "Shoes is MIT Licensed"
!define MUI_PAGE_HEADER_SUBTEXT "You are free to do as you please with Shoes."
!define MUI_LICENSEPAGE_TEXT_TOP "When you are ready to continue with Setup, cl
ick I Agree."
!define MUI_LICENSEPAGE_TEXT_BOTTOM " "
;!insertmacro MUI_PAGE_LICENSE "..\COPYING.txt"
; MUI Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${SHOES_NAME}"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${SHOES_INST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_TITLE_3LINES
;!define MUI_FINISHPAGE_RUN "$INSTDIR\${SHOES_NAME}.exe"
!insertmacro MUI_PAGE_FINISH
; MUI uninstaller pages
!insertmacro MUI_UNPAGE_DIRECTORY
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
; NSIS Output information
Name "${SHOES_NAME} ${SHOES_VERSION}"
OutFile "${SHOES_NAME}_setup.exe"
InstallDir "$PROGRAMFILES\${SHOES_NAME}"
InstallDirRegKey HKLM "${SHOES_INST_KEY}" ""
RequestExecutionLevel admin
ShowInstDetails show
ShowUnInstDetails show
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\${SHOES_NAME}"
CreateShortCut "$SMPROGRAMS\${SHOES_NAME}\${SHOES_NAME}.lnk" "$INSTDIR\ma
kensisw.exe"
;CreateShortCut "$SMPROGRAMS\${SHOES_NAME}\Manual.lnk" "$INSTDIR\${SHOES_
NAME}.exe" "--manual"
;CreateShortCut "$SMPROGRAMS\${SHOES_NAME}\Packager.lnk" "$INSTDIR\${SHOE
S_NAME}.exe" "--package"
!insertmacro MUI_STARTMENU_WRITE_END
;CreateShortCut "$DESKTOP\${SHOES_NAME}.lnk" "$INSTDIR\${SHOES_NAME}.exe"
File /r /x nsis NSIS\*.*
;${EnvVarUpdate} $0 "PATH" "A" HKLM $INSTDIR
;${registerExtension} "$INSTDIR\${SHOES_NAME}.exe" ".shy" "Shoes Application
"
;DetailPrint "Building Incon cache, this may take a while..."
;ExecWait '"$INSTDIR\gtk-update-icon-cache.exe" "$INSTDIR\share\icons\Adwait
a"'
SectionEnd
Section -AdditionalIcons
CreateShortCut "$SMPROGRAMS\${SHOES_NAME}\Uninstall.lnk" "$INSTDIR\uninst.ex
e"
SectionEnd
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${SHOES_INST_KEY}" "" "$INSTDIR\makensisw.exe"
;WriteRegStr HKLM "${SHOES_INST_KEY}" "base" "$INSTDIR"
WriteRegStr ${SHOES_UNINST_ROOT_KEY} "${SHOES_UNINST_KEY}" "DisplayName" "$(
^Name)"
WriteRegStr ${SHOES_UNINST_ROOT_KEY} "${SHOES_UNINST_KEY}" "UninstallString"
"$INSTDIR\uninst.exe"
WriteRegStr ${SHOES_UNINST_ROOT_KEY} "${SHOES_UNINST_KEY}" "DisplayIcon" "$I
NSTDIR\makensisw.exe"
WriteRegStr ${SHOES_UNINST_ROOT_KEY} "${SHOES_UNINST_KEY}" "DisplayVersion"
"${SHOES_VERSION}"
WriteRegStr ${SHOES_UNINST_ROOT_KEY} "${SHOES_UNINST_KEY}" "URLInfoAbout" "$
{SHOES_WEB_SITE}"
WriteRegStr ${SHOES_UNINST_ROOT_KEY} "${SHOES_UNINST_KEY}" "Publisher" "${SH
OES_PUBLISHER}"
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "${SHOES_UNINST_KEY}" "EstimatedSize" "$0"
SectionEnd
Section Uninstall
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
;Delete "$DESKTOP\${SHOES_NAME}.lnk"
;Delete "$SMPROGRAMS\${SHOES_NAME}\Manual.lnk"
;Delete "$SMPROGRAMS\${SHOES_NAME}\Packager.lnk"
Delete "$SMPROGRAMS\${SHOES_NAME}\${SHOES_NAME}.lnk"
Delete "$SMPROGRAMS\${SHOES_NAME}\Uninstall.lnk"
RMDir "$SMPROGRAMS\${SHOES_NAME}"
RMDir /r "$INSTDIR\*.*"
RMDir "$INSTDIR"
;${unregisterExtension} ".shy" "Shoes Application"
;${un.EnvVarUpdate} $0 "PATH" "R" HKLM $INSTDIR
DeleteRegKey ${SHOES_UNINST_ROOT_KEY} "${SHOES_UNINST_KEY}"
DeleteRegKey HKLM "${SHOES_INST_KEY}"
SetAutoClose true
StrCpy $UninstallerHasFinished true
SectionEnd
Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Uninstall $(^Name)?" IDYE
S +2
FunctionEnd
Function un.onUninstSuccess
${If} $UninstallerHasFinished == true
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) has been uninstalled."
${EndIf}
FunctionEnd
And a small script, package.sh, to use the Linux nsis to create the shoesnsis_setup.exe
#!/bin/bash
../nsis3/bin/makensis shoes-nsis.nsi
You'll need some more files to actually use that shoe-nsis.nsi script. These can be found in Shoes in lib/package/nsis/* .I grabbed a copy of some icons out of the NSIS directory so it's not using the Shoes icon. Here what I have in ~/Projects/nsis/nsis-3.03-windows/
ccoupe@bronco:~/Projects/nsis/nsis-3.03-windows$ ls
EnvVarUpdate.nsh NSIS NSIS.tgz
FileAssociation.nsh nsis-3.03-strlen package.sh
installer-1.bmp nsis-3.03-strlen.tgz README.md
installer-2.bmp nsis3-install.ico shoes-nsis.nsi
merge.sh nsis3-uninstall.ico shoesnsis_setup.exe
To test it you have to move the shoesnsis_setup.exe to Windows, run the installer and use it to create something that can be installed. No so simple b
Menu
In This Section:
- Shoes Rakefiles
- Rake files
- App.yaml secrets
- Custom.yaml
- Gems for Shoes
- Build with Vagrant
- Building Shoes on Linux
- Building Shoes on Pi2
- Mingw Dependencies
- Building Shoes on Windows
- Cross compile mingw
- OSX 10.10 Dependencies
- OSX 10.9 Dependencies
- OSX 10.6 Dependencies
- Caution Using brew 10.6
- Build-MinGW-with-OSX
- NSIS Installer for Windows
- MSYS2 cross compiling
- Cross-compile-for-arm-(raspberry)
- MXE-Dependencies
- FreeBSD and Shoes