diff options
Diffstat (limited to 'nsis')
-rwxr-xr-x | nsis/MultiUser.nsh | 470 | ||||
-rw-r--r-- | nsis/getpearch.pl | 74 | ||||
-rw-r--r-- | nsis/nasm.nsi | 234 |
3 files changed, 778 insertions, 0 deletions
diff --git a/nsis/MultiUser.nsh b/nsis/MultiUser.nsh new file mode 100755 index 00000000..a04048ab --- /dev/null +++ b/nsis/MultiUser.nsh @@ -0,0 +1,470 @@ +/*
+
+MultiUser.nsh
+
+Installer configuration for multi-user Windows environments
+
+Copyright 2008-2009 Joost Verburg
+Updated 2016 by H. Peter Anvin to handle 64-bit Windows
+
+*/
+
+!ifndef MULTIUSER_INCLUDED
+!define MULTIUSER_INCLUDED
+!verbose push
+!verbose 3
+
+;Standard NSIS header files
+
+!ifdef MULTIUSER_MUI
+ !include MUI2.nsh
+!endif
+!include nsDialogs.nsh
+!include LogicLib.nsh
+!include WinVer.nsh
+!include FileFunc.nsh
+
+;Variables
+
+Var MultiUser.Privileges
+Var MultiUser.InstallMode
+
+;Command line installation mode setting
+
+!ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
+ !include StrFunc.nsh
+ !ifndef StrStr_INCLUDED
+ ${StrStr}
+ !endif
+ !ifndef MULTIUSER_NOUNINSTALL
+ !ifndef UnStrStr_INCLUDED
+ ${UnStrStr}
+ !endif
+ !endif
+
+ Var MultiUser.Parameters
+ Var MultiUser.Result
+!endif
+
+;Installation folder stored in registry
+
+!ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
+ Var MultiUser.InstDir
+!endif
+
+!ifdef MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY & MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
+ Var MultiUser.DefaultKeyValue
+!endif
+
+;Windows Vista UAC setting
+
+!if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
+ RequestExecutionLevel admin
+ !define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
+!else if "${MULTIUSER_EXECUTIONLEVEL}" == Power
+ RequestExecutionLevel admin
+ !define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
+!else if "${MULTIUSER_EXECUTIONLEVEL}" == Highest
+ RequestExecutionLevel highest
+ !define MULTIUSER_EXECUTIONLEVEL_ALLUSERS
+!else
+ RequestExecutionLevel user
+!endif
+
+/*
+
+Install modes
+
+*/
+
+!macro MULTIUSER_INSTALLMODE_ALLUSERS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
+
+ ;Install mode initialization - per-machine
+
+ ${ifnot} ${IsNT}
+ ${orif} $MultiUser.Privileges == "Admin"
+ ${orif} $MultiUser.Privileges == "Power"
+
+ StrCpy $MultiUser.InstallMode AllUsers
+
+ SetShellVarContext all
+
+ !if "${UNINSTALLER_PREFIX}" != UN
+ ;Set default installation location for installer
+ !ifdef MULTIUSER_INSTALLMODE_INSTDIR
+ StrCpy $INSTDIR "${GLOBALINSTDIR}\${MULTIUSER_INSTALLMODE_INSTDIR}"
+ !endif
+ !endif
+
+ !ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
+
+ ReadRegStr $MultiUser.InstDir HKLM "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
+
+ ${if} $MultiUser.InstDir != ""
+ StrCpy $INSTDIR $MultiUser.InstDir
+ ${endif}
+
+ !endif
+
+ !ifdef MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION
+ Call "${MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION}"
+ !endif
+
+ ${endif}
+
+!macroend
+
+!macro MULTIUSER_INSTALLMODE_CURRENTUSER UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
+
+ ;Install mode initialization - per-user
+
+ ${if} ${IsNT}
+
+ StrCpy $MultiUser.InstallMode CurrentUser
+
+ SetShellVarContext current
+
+ !if "${UNINSTALLER_PREFIX}" != UN
+ ;Set default installation location for installer
+ !ifdef MULTIUSER_INSTALLMODE_INSTDIR
+ ${if} ${AtLeastWin2000}
+ StrCpy $INSTDIR "$LOCALAPPDATA\bin\${MULTIUSER_INSTALLMODE_INSTDIR}"
+ ${else}
+ StrCpy $INSTDIR "${GLOBALINSTDIR}\${MULTIUSER_INSTALLMODE_INSTDIR}"
+ ${endif}
+ !endif
+ !endif
+
+ !ifdef MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY & MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME
+
+ ReadRegStr $MultiUser.InstDir HKCU "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME}"
+
+ ${if} $MultiUser.InstDir != ""
+ StrCpy $INSTDIR $MultiUser.InstDir
+ ${endif}
+
+ !endif
+
+ !ifdef MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION
+ Call "${MULTIUSER_INSTALLMODE_${UNINSTALLER_PREFIX}FUNCTION}"
+ !endif
+
+ ${endif}
+
+!macroend
+
+Function MultiUser.InstallMode.AllUsers
+ !insertmacro MULTIUSER_INSTALLMODE_ALLUSERS "" ""
+FunctionEnd
+
+Function MultiUser.InstallMode.CurrentUser
+ !insertmacro MULTIUSER_INSTALLMODE_CURRENTUSER "" ""
+FunctionEnd
+
+!ifndef MULTIUSER_NOUNINSTALL
+
+Function un.MultiUser.InstallMode.AllUsers
+ !insertmacro MULTIUSER_INSTALLMODE_ALLUSERS UN .un
+FunctionEnd
+
+Function un.MultiUser.InstallMode.CurrentUser
+ !insertmacro MULTIUSER_INSTALLMODE_CURRENTUSER UN .un
+FunctionEnd
+
+!endif
+
+/*
+
+Installer/uninstaller initialization
+
+*/
+
+!macro MULTIUSER_INIT_QUIT UNINSTALLER_FUNCPREFIX
+
+ !ifdef MULTIUSER_INIT_${UNINSTALLER_FUNCPREFIX}FUNCTIONQUIT
+ Call "${MULTIUSER_INIT_${UNINSTALLER_FUNCPREFIX}FUCTIONQUIT}
+ !else
+ Quit
+ !endif
+
+!macroend
+
+!macro MULTIUSER_INIT_TEXTS
+
+ !ifndef MULTIUSER_INIT_TEXT_ADMINREQUIRED
+ !define MULTIUSER_INIT_TEXT_ADMINREQUIRED "$(^Caption) requires Administrator priviledges."
+ !endif
+
+ !ifndef MULTIUSER_INIT_TEXT_POWERREQUIRED
+ !define MULTIUSER_INIT_TEXT_POWERREQUIRED "$(^Caption) requires at least Power User priviledges."
+ !endif
+
+ !ifndef MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE
+ !define MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE "Your user account does not have sufficient privileges to install $(^Name) for all users of this compuetr."
+ !endif
+
+!macroend
+
+!macro MULTIUSER_INIT_CHECKS UNINSTALLER_PREFIX UNINSTALLER_FUNCPREFIX
+
+ ;Installer initialization - check privileges and set install mode
+
+ !insertmacro MULTIUSER_INIT_TEXTS
+
+ UserInfo::GetAccountType
+ Pop $MultiUser.Privileges
+
+ ${if} ${IsNT}
+
+ ;Check privileges
+
+ !if "${MULTIUSER_EXECUTIONLEVEL}" == Admin
+
+ ${if} $MultiUser.Privileges != "Admin"
+ MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ADMINREQUIRED}"
+ !insertmacro MULTIUSER_INIT_QUIT "${UNINSTALLER_FUNCPREFIX}"
+ ${endif}
+
+ !else if "${MULTIUSER_EXECUTIONLEVEL}" == Power
+
+ ${if} $MultiUser.Privileges != "Power"
+ ${andif} $MultiUser.Privileges != "Admin"
+ ${if} ${AtMostWinXP}
+ MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_POWERREQUIRED}"
+ ${else}
+ MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ADMINREQUIRED}"
+ ${endif}
+ !insertmacro MULTIUSER_INIT_QUIT "${UNINSTALLER_FUNCPREFIX}"
+ ${endif}
+
+ !endif
+
+ !ifdef MULTIUSER_EXECUTIONLEVEL_ALLUSERS
+
+ ;Default to per-machine installation if possible
+
+ ${if} $MultiUser.Privileges == "Admin"
+ ${orif} $MultiUser.Privileges == "Power"
+ !ifndef MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
+ !else
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
+ !endif
+
+ !ifdef MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY & MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME
+
+ ;Set installation mode to setting from a previous installation
+
+ !ifndef MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
+ ReadRegStr $MultiUser.DefaultKeyValue HKLM "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
+ ${if} $MultiUser.DefaultKeyValue == ""
+ ReadRegStr $MultiUser.DefaultKeyValue HKCU "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
+ ${if} $MultiUser.DefaultKeyValue != ""
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
+ ${endif}
+ ${endif}
+ !else
+ ReadRegStr $MultiUser.DefaultKeyValue HKCU "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
+ ${if} $MultiUser.DefaultKeyValue == ""
+ ReadRegStr $MultiUser.DefaultKeyValue HKLM "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY}" "${MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME}"
+ ${if} $MultiUser.DefaultKeyValue != ""
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
+ ${endif}
+ ${endif}
+ !endif
+
+ !endif
+
+ ${else}
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
+ ${endif}
+
+ !else
+
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
+
+ !endif
+
+ !ifdef MULTIUSER_INSTALLMODE_COMMANDLINE
+
+ ;Check for install mode setting on command line
+
+ ${${UNINSTALLER_FUNCPREFIX}GetParameters} $MultiUser.Parameters
+
+ ${${UNINSTALLER_PREFIX}StrStr} $MultiUser.Result $MultiUser.Parameters "/CurrentUser"
+
+ ${if} $MultiUser.Result != ""
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.CurrentUser
+ ${endif}
+
+ ${${UNINSTALLER_PREFIX}StrStr} $MultiUser.Result $MultiUser.Parameters "/AllUsers"
+
+ ${if} $MultiUser.Result != ""
+ ${if} $MultiUser.Privileges == "Admin"
+ ${orif} $MultiUser.Privileges == "Power"
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
+ ${else}
+ MessageBox MB_OK|MB_ICONSTOP "${MULTIUSER_INIT_TEXT_ALLUSERSNOTPOSSIBLE}"
+ ${endif}
+ ${endif}
+
+ !endif
+
+ ${else}
+
+ ;Not running Windows NT, per-user installation not supported
+
+ Call ${UNINSTALLER_FUNCPREFIX}MultiUser.InstallMode.AllUsers
+
+ ${endif}
+
+!macroend
+
+!macro MULTIUSER_INIT
+ !verbose push
+ !verbose 3
+
+ !insertmacro MULTIUSER_INIT_CHECKS "" ""
+
+ !verbose pop
+!macroend
+
+!ifndef MULTIUSER_NOUNINSTALL
+
+!macro MULTIUSER_UNINIT
+ !verbose push
+ !verbose 3
+
+ !insertmacro MULTIUSER_INIT_CHECKS Un un.
+
+ !verbose pop
+!macroend
+
+!endif
+
+/*
+
+Modern UI 2 page
+
+*/
+
+!ifdef MULTIUSER_MUI
+
+!macro MULTIUSER_INSTALLMODEPAGE_INTERFACE
+
+ !ifndef MULTIUSER_INSTALLMODEPAGE_INTERFACE
+ !define MULTIUSER_INSTALLMODEPAGE_INTERFACE
+ Var MultiUser.InstallModePage
+
+ Var MultiUser.InstallModePage.Text
+
+ Var MultiUser.InstallModePage.AllUsers
+ Var MultiUser.InstallModePage.CurrentUser
+
+ Var MultiUser.InstallModePage.ReturnValue
+ !endif
+
+!macroend
+
+!macro MULTIUSER_PAGEDECLARATION_INSTALLMODE
+
+ !insertmacro MUI_SET MULTIUSER_${MUI_PAGE_UNINSTALLER_PREFIX}INSTALLMODEPAGE ""
+ !insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE
+
+ !insertmacro MUI_DEFAULT MULTIUSER_INSTALLMODEPAGE_TEXT_TOP "$(MULTIUSER_INNERTEXT_INSTALLMODE_TOP)"
+ !insertmacro MUI_DEFAULT MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS "$(MULTIUSER_INNERTEXT_INSTALLMODE_ALLUSERS)"
+ !insertmacro MUI_DEFAULT MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER "$(MULTIUSER_INNERTEXT_INSTALLMODE_CURRENTUSER)"
+
+ PageEx custom
+
+ PageCallbacks MultiUser.InstallModePre_${MUI_UNIQUEID} MultiUser.InstallModeLeave_${MUI_UNIQUEID}
+
+ Caption " "
+
+ PageExEnd
+
+ !insertmacro MULTIUSER_FUNCTION_INSTALLMODEPAGE MultiUser.InstallModePre_${MUI_UNIQUEID} MultiUser.InstallModeLeave_${MUI_UNIQUEID}
+
+ !undef MULTIUSER_INSTALLMODEPAGE_TEXT_TOP
+ !undef MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS
+ !undef MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER
+
+!macroend
+
+!macro MULTIUSER_PAGE_INSTALLMODE
+
+ ;Modern UI page for install mode
+
+ !verbose push
+ !verbose 3
+
+ !ifndef MULTIUSER_EXECUTIONLEVEL_ALLUSERS
+ !error "A mixed-mode installation requires MULTIUSER_EXECUTIONLEVEL to be set to Admin, Power or Highest."
+ !endif
+
+ !insertmacro MUI_PAGE_INIT
+ !insertmacro MULTIUSER_PAGEDECLARATION_INSTALLMODE
+
+ !verbose pop
+
+!macroend
+
+!macro MULTIUSER_FUNCTION_INSTALLMODEPAGE PRE LEAVE
+
+ ;Page functions of Modern UI page
+
+ Function "${PRE}"
+
+ ${ifnot} ${IsNT}
+ Abort
+ ${endif}
+
+ ${if} $MultiUser.Privileges != "Power"
+ ${andif} $MultiUser.Privileges != "Admin"
+ Abort
+ ${endif}
+
+ !insertmacro MUI_PAGE_FUNCTION_CUSTOM PRE
+ !insertmacro MUI_HEADER_TEXT_PAGE $(MULTIUSER_TEXT_INSTALLMODE_TITLE) $(MULTIUSER_TEXT_INSTALLMODE_SUBTITLE)
+
+ nsDialogs::Create 1018
+ Pop $MultiUser.InstallModePage
+
+ ${NSD_CreateLabel} 0u 0u 300u 20u "${MULTIUSER_INSTALLMODEPAGE_TEXT_TOP}"
+ Pop $MultiUser.InstallModePage.Text
+
+ ${NSD_CreateRadioButton} 20u 50u 280u 10u "${MULTIUSER_INSTALLMODEPAGE_TEXT_ALLUSERS}"
+ Pop $MultiUser.InstallModePage.AllUsers
+
+ ${NSD_CreateRadioButton} 20u 70u 280u 10u "${MULTIUSER_INSTALLMODEPAGE_TEXT_CURRENTUSER}"
+ Pop $MultiUser.InstallModePage.CurrentUser
+
+ ${if} $MultiUser.InstallMode == "AllUsers"
+ SendMessage $MultiUser.InstallModePage.AllUsers ${BM_SETCHECK} ${BST_CHECKED} 0
+ ${else}
+ SendMessage $MultiUser.InstallModePage.CurrentUser ${BM_SETCHECK} ${BST_CHECKED} 0
+ ${endif}
+
+ !insertmacro MUI_PAGE_FUNCTION_CUSTOM SHOW
+ nsDialogs::Show
+
+ FunctionEnd
+
+ Function "${LEAVE}"
+ SendMessage $MultiUser.InstallModePage.AllUsers ${BM_GETCHECK} 0 0 $MultiUser.InstallModePage.ReturnValue
+
+ ${if} $MultiUser.InstallModePage.ReturnValue = ${BST_CHECKED}
+ Call MultiUser.InstallMode.AllUsers
+ ${else}
+ Call MultiUser.InstallMode.CurrentUser
+ ${endif}
+
+ !insertmacro MUI_PAGE_FUNCTION_CUSTOM LEAVE
+ FunctionEnd
+
+!macroend
+
+!endif
+
+!verbose pop
+!endif
diff --git a/nsis/getpearch.pl b/nsis/getpearch.pl new file mode 100644 index 00000000..25155536 --- /dev/null +++ b/nsis/getpearch.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl +# +# Get the appropriate variables to make an NSIS installer file +# based on the PE architecture of a specific file +# + +use strict; + +my %archnames = ( + 0x01de => 'am33', + 0x8664 => 'x64', + 0x01c0 => 'arm32', + 0x01c4 => 'thumb', + 0xaa64 => 'arm64', + 0x0ebc => 'efi', + 0x014c => 'x86', + 0x0200 => 'ia64', + 0x9041 => 'm32r', + 0x0266 => 'mips16', + 0x0366 => 'mips', + 0x0466 => 'mips16', + 0x01f0 => 'powerpc', + 0x01f1 => 'powerpc', + 0x0166 => 'mips', + 0x01a2 => 'sh3', + 0x01a3 => 'sh3', + 0x01a6 => 'sh4', + 0x01a8 => 'sh5', + 0x01c2 => 'arm32', + 0x0169 => 'wcemipsv2' +); + +my ($file) = @ARGV; +open(my $fh, '<', $file) + or die "$0: cannot open file: $file: $!\n"; + +read($fh, my $mz, 2); +exit 0 if ($mz ne 'MZ'); + +exit 0 unless (seek($fh, 0x3c, 0)); +exit 0 unless (read($fh, my $pe_offset, 1) == 1); +$pe_offset = unpack("C", $pe_offset); + +exit 0 unless (seek($fh, $pe_offset, 0)); +read($fh, my $pe, 4); +exit 0 unless ($pe eq "PE\0\0"); + +exit 0 unless (read($fh, my $arch, 2) == 2); +$arch = $archnames{unpack("v", $arch)}; +if (defined($arch)) { + print "!define ARCH ${arch}\n"; +} + +exit 0 unless (seek($fh, 14, 1)); +exit 0 unless (read($fh, my $auxheaderlen, 2) == 2); +exit 0 unless (unpack("v", $auxheaderlen) >= 2); + +exit 0 unless (seek($fh, 2, 1)); +exit 0 unless (read($fh, my $petype, 2) == 2); +$petype = unpack("v", $petype); +if ($petype == 0x010b) { + # It is a 32-bit PE32 file + print "!define BITS 32\n"; + print "!define GLOBALINSTDIR \$PROGRAMFILES\n"; +} elsif ($petype == 0x020b) { + # It is a 64-bit PE32+ file + print "!define BITS 64\n"; + print "!define GLOBALINSTDIR \$PROGRAMFILES64\n"; +} else { + # No idea... +} + +close($fh); +exit 0; diff --git a/nsis/nasm.nsi b/nsis/nasm.nsi new file mode 100644 index 00000000..42411032 --- /dev/null +++ b/nsis/nasm.nsi @@ -0,0 +1,234 @@ +#!Nsis Installer Command Script + +# +# Copyright (c) 2009, Shao Miller (shao.miller@yrdsb.edu.on.ca) +# Copyright (c) 2009, Cyrill Gorcunov (gorcunov@gmail.com) +# All rights reserved. +# +# The script requires NSIS v2.45 (or any later) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +!include "version.nsh" +!include /nonfatal "arch.nsh" + +!define PRODUCT_NAME "Netwide Assembler" +!define PRODUCT_SHORT_NAME "nasm" +!define PACKAGE_NAME "${PRODUCT_NAME} ${VERSION}" +!define PACKAGE_SHORT_NAME "${PRODUCT_SHORT_NAME}-${VERSION}" + +SetCompressor lzma + +!define MULTIUSER_EXECUTIONLEVEL Highest +!define MULTIUSER_MUI +!define MULTIUSER_INSTALLMODE_COMMANDLINE +!define MULTIUSER_INSTALLMODE_INSTDIR "NASM" +!include "MultiUser.nsh" + +!insertmacro MULTIUSER_PAGE_INSTALLMODE +!insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE + +;-------------------------------- +;General + +;Name and file +Name "${PACKAGE_NAME}" +OutFile "../${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe" + +;Get installation folder from registry if available +InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" "" + +;Request application privileges for Windows Vista +RequestExecutionLevel user + +;-------------------------------- +;Variables + +Var StartMenuFolder +Var CmdFailed + +;-------------------------------- +;Interface Settings +Caption "${PACKAGE_SHORT_NAME} installation" +Icon "nasm.ico" +UninstallIcon "nasm-un.ico" + +!define MUI_ABORTWARNING + +;-------------------------------- +;Pages + +!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_DIRECTORY + +;Start Menu Folder Page Configuration +!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" +!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODUCT_SHORT_NAME}" +!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_SHORT_NAME}" + +!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder + +!insertmacro MUI_PAGE_INSTFILES + +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +;Installer Sections + +!insertmacro MUI_LANGUAGE English + +Section "NASM" SecNasm + Sectionin RO + SetOutPath "$INSTDIR" + File "../LICENSE" + File "../nasm.exe" + File "../ndisasm.exe" + File "nasm.ico" + + ;Store installation folder + WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR + + ;Store shortcuts folder + WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "lnk" $SMPROGRAMS\$StartMenuFolder + WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "bat-lnk" $DESKTOP\${PRODUCT_SHORT_NAME}.lnk + + ; + ; the bat we need + StrCpy $CmdFailed "true" + FileOpen $0 "nasmpath.bat" w + IfErrors skip + StrCpy $CmdFailed "false" + FileWrite $0 "@set path=$INSTDIR;%path%$\r$\n" + FileWrite $0 "@%comspec%" + FileClose $0 + CreateShortCut "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasmpath.bat" "" "$INSTDIR\nasm.ico" 0 +skip: + ;Create uninstaller + WriteUninstaller "$INSTDIR\Uninstall.exe" + + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + + ;Create shortcuts + CreateDirectory "$SMPROGRAMS\$StartMenuFolder" + StrCmp $CmdFailed "true" +2 + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}-shell.lnk" "$INSTDIR\nasmpath.bat" + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasm.exe" "" "$INSTDIR\nasm.ico" 0 + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" + + !insertmacro MUI_STARTMENU_WRITE_END +SectionEnd + +Section "RDOFF" SecRdoff + File "../rdoff/ldrdf.exe" + File "../rdoff/rdf2bin.exe" + File "../rdoff/rdf2com.exe" + File "../rdoff/rdf2ith.exe" + File "../rdoff/rdf2ihx.exe" + File "../rdoff/rdf2srec.exe" + File "../rdoff/rdfdump.exe" + File "../rdoff/rdflib.exe" +SectionEnd + +Section "Manual" SecManual + SetOutPath "$INSTDIR" + File "../doc/nasmdoc.pdf" + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\nasmdoc.pdf" +SectionEnd + +Section "VS8 integration" SecVS8 + CreateDirectory "$INSTDIR\VSrules" + SetOutPath "$INSTDIR\VSrules" + File "../contrib/VSrules/nasm.README" + File "../contrib/VSrules/nasm.rules" +SectionEnd + +;-------------------------------- +;Descriptions + + ;Language strings + LangString DESC_SecNasm ${LANG_ENGLISH} "NASM assembler and disassember modules" + LangString DESC_SecManual ${LANG_ENGLISH} "Complete NASM manual (pdf file)" + LangString DESC_SecRdoff ${LANG_ENGLISH} "RDOFF utilities (you may not need it if you don't know what is it)" + LangString DESC_SecVS8 ${LANG_ENGLISH} "Visual Studio 2008 NASM integration (rules file)" + + ;Assign language strings to sections + !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN + !insertmacro MUI_DESCRIPTION_TEXT ${SecNasm} $(DESC_SecNasm) + !insertmacro MUI_DESCRIPTION_TEXT ${SecRdoff} $(DESC_SecRdoff) + !insertmacro MUI_DESCRIPTION_TEXT ${SecManual} $(DESC_SecManual) + !insertmacro MUI_DESCRIPTION_TEXT ${SecVS8} $(DESC_SecVS8) + !insertmacro MUI_FUNCTION_DESCRIPTION_END + +;-------------------------------- +;Uninstaller Section + +Section "Uninstall" + ; + ; files on HDD + IfFileExists "$INSTDIR" +3 +1 + MessageBox MB_OK "No files found, aborting." + Abort + MessageBox MB_YESNO "The following directory will be deleted$\n$INSTDIR" IDYES rm_instdir_true IDNO rm_instdir_false + rm_instdir_true: + RMDir /r /rebootok "$INSTDIR" + rm_instdir_false: + + ; + ; Desktop link + ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "bat-lnk" + StrCmp $0 0 +1 +3 + MessageBox MB_OK "Invalid path to a bat-lnk file, aborting" + Abort + IfFileExists $0 +3 +1 + MessageBox MB_OK "No bat-lnk files found, aborting." + Abort + MessageBox MB_YESNO "The following file will be deleted$\n$0" IDYES rm_batlinks_true IDNO rm_batlinks_false + rm_batlinks_true: + Delete /rebootok "$0" + RMDir "$0" + rm_batlinks_false: + + ; + ; Start menu folder + ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "lnk" + StrCmp $0 0 +1 +3 + MessageBox MB_OK "Invalid path to a lnk file, aborting" + Abort + IfFileExists $0 +3 +1 + MessageBox MB_OK "No lnk files found, aborting." + Abort + MessageBox MB_YESNO "The following directory will be deleted$\n$0" IDYES rm_links_true IDNO rm_links_false + rm_links_true: + Delete /rebootok "$0\*" + RMDir "$0" + rm_links_false: + DeleteRegKey /ifempty HKCU "Software\${PRODUCT_SHORT_NAME}" +SectionEnd + +; +; MUI requires this hooks +Function .onInit + !insertmacro MULTIUSER_INIT +FunctionEnd + +Function un.onInit + !insertmacro MULTIUSER_UNINIT +FunctionEnd |