| 1 |
#!Nsis Installer Command Script |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (c) 2009, Shao Miller ([email protected]) |
| 5 |
# Copyright (c) 2009, Cyrill Gorcunov ([email protected]) |
| 6 |
# All rights reserved. |
| 7 |
# |
| 8 |
# The script requires NSIS v2.45 (or any later) |
| 9 |
# |
| 10 |
# Redistribution and use in source and binary forms, with or without |
| 11 |
# modification, are permitted provided that the following conditions are met: |
| 12 |
# * Redistributions of source code must retain the above copyright |
| 13 |
# notice, this list of conditions and the following disclaimer. |
| 14 |
# * Redistributions in binary form must reproduce the above copyright |
| 15 |
# notice, this list of conditions and the following disclaimer in the |
| 16 |
# documentation and/or other materials provided with the distribution. |
| 17 |
# |
| 18 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 |
# ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| 20 |
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 21 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR |
| 22 |
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 23 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 24 |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 25 |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 26 |
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 |
|
| 29 |
!addincludedir "${objdir}\nsis" |
| 30 |
!addincludedir "${srcdir}\nsis" |
| 31 |
!include "version.nsh" |
| 32 |
!include "arch.nsh" |
| 33 |
|
| 34 |
!define PRODUCT_NAME "Netwide Assembler" |
| 35 |
!define PRODUCT_SHORT_NAME "nasm" |
| 36 |
!define PACKAGE_NAME "${PRODUCT_NAME} ${VERSION}" |
| 37 |
!define PACKAGE_SHORT_NAME "${PRODUCT_SHORT_NAME}-${VERSION}" |
| 38 |
|
| 39 |
SetCompressor /solid lzma |
| 40 |
|
| 41 |
!if "${NSIS_PACKEDVERSION}" >= 0x3000000 |
| 42 |
Unicode true |
| 43 |
!endif |
| 44 |
|
| 45 |
!define MULTIUSER_EXECUTIONLEVEL Highest |
| 46 |
!define MULTIUSER_MUI |
| 47 |
!define MULTIUSER_INSTALLMODE_COMMANDLINE |
| 48 |
!define MULTIUSER_INSTALLMODE_INSTDIR "NASM" |
| 49 |
!include "NASMMultiUser.nsh" |
| 50 |
|
| 51 |
!insertmacro MULTIUSER_PAGE_INSTALLMODE |
| 52 |
!insertmacro MULTIUSER_INSTALLMODEPAGE_INTERFACE |
| 53 |
|
| 54 |
;-------------------------------- |
| 55 |
;General |
| 56 |
|
| 57 |
;Name and file |
| 58 |
Name "${PACKAGE_NAME}" |
| 59 |
OutFile "${objdir}\${PACKAGE_SHORT_NAME}-installer-${ARCH}.exe" |
| 60 |
|
| 61 |
;Get installation folder from registry if available |
| 62 |
InstallDirRegKey HKCU "Software\${PRODUCT_SHORT_NAME}" "" |
| 63 |
|
| 64 |
;Request application privileges for Windows Vista |
| 65 |
RequestExecutionLevel user |
| 66 |
|
| 67 |
;-------------------------------- |
| 68 |
;Variables |
| 69 |
|
| 70 |
Var StartMenuFolder |
| 71 |
Var CmdFailed |
| 72 |
|
| 73 |
;-------------------------------- |
| 74 |
;Interface Settings |
| 75 |
Caption "${PACKAGE_SHORT_NAME} installation" |
| 76 |
Icon "${srcdir}\nsis\nasm.ico" |
| 77 |
UninstallIcon "${srcdir}\nsis\nasm-un.ico" |
| 78 |
|
| 79 |
!define MUI_ABORTWARNING |
| 80 |
|
| 81 |
;-------------------------------- |
| 82 |
;Pages |
| 83 |
|
| 84 |
!insertmacro MUI_PAGE_COMPONENTS |
| 85 |
!insertmacro MUI_PAGE_DIRECTORY |
| 86 |
|
| 87 |
;Start Menu Folder Page Configuration |
| 88 |
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" |
| 89 |
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${PRODUCT_SHORT_NAME}" |
| 90 |
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_SHORT_NAME}" |
| 91 |
|
| 92 |
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder |
| 93 |
|
| 94 |
!insertmacro MUI_PAGE_INSTFILES |
| 95 |
|
| 96 |
!insertmacro MUI_UNPAGE_CONFIRM |
| 97 |
!insertmacro MUI_UNPAGE_INSTFILES |
| 98 |
|
| 99 |
;-------------------------------- |
| 100 |
;Installer Sections |
| 101 |
|
| 102 |
!insertmacro MUI_LANGUAGE English |
| 103 |
|
| 104 |
Section "NASM" SecNasm |
| 105 |
Sectionin RO |
| 106 |
SetOutPath "$INSTDIR" |
| 107 |
File "${srcdir}\LICENSE" |
| 108 |
File "${objdir}\nasm.exe" |
| 109 |
File "${objdir}\ndisasm.exe" |
| 110 |
File "${srcdir}\nsis\nasm.ico" |
| 111 |
|
| 112 |
;Store installation folder |
| 113 |
WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}" "" $INSTDIR |
| 114 |
|
| 115 |
;Store shortcuts folder |
| 116 |
WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "lnk" $SMPROGRAMS\$StartMenuFolder |
| 117 |
WriteRegStr HKCU "Software\${PRODUCT_SHORT_NAME}\" "bat-lnk" $DESKTOP\${PRODUCT_SHORT_NAME}.lnk |
| 118 |
|
| 119 |
; |
| 120 |
; the bat we need |
| 121 |
StrCpy $CmdFailed "true" |
| 122 |
FileOpen $0 "nasmpath.bat" w |
| 123 |
IfErrors skip |
| 124 |
StrCpy $CmdFailed "false" |
| 125 |
FileWrite $0 "@set path=$INSTDIR;%path%$\r$\n" |
| 126 |
FileWrite $0 "@%comspec%" |
| 127 |
FileClose $0 |
| 128 |
CreateShortCut "$DESKTOP\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasmpath.bat" "" "$INSTDIR\nasm.ico" 0 |
| 129 |
skip: |
| 130 |
;Create uninstaller |
| 131 |
WriteUninstaller "$INSTDIR\Uninstall.exe" |
| 132 |
|
| 133 |
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application |
| 134 |
|
| 135 |
;Create shortcuts |
| 136 |
CreateDirectory "$SMPROGRAMS\$StartMenuFolder" |
| 137 |
StrCmp $CmdFailed "true" +2 |
| 138 |
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}-shell.lnk" "$INSTDIR\nasmpath.bat" |
| 139 |
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${PRODUCT_SHORT_NAME}.lnk" "$INSTDIR\nasm.exe" "" "$INSTDIR\nasm.ico" 0 |
| 140 |
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" |
| 141 |
|
| 142 |
!insertmacro MUI_STARTMENU_WRITE_END |
| 143 |
SectionEnd |
| 144 |
|
| 145 |
Section "Manual" SecManual |
| 146 |
SetOutPath "$INSTDIR" |
| 147 |
File "${objdir}\doc\nasmdoc.pdf" |
| 148 |
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Manual.lnk" "$INSTDIR\nasmdoc.pdf" |
| 149 |
SectionEnd |
| 150 |
|
| 151 |
Section "VS8 integration" SecVS8 |
| 152 |
CreateDirectory "$INSTDIR\VSrules" |
| 153 |
SetOutPath "$INSTDIR\VSrules" |
| 154 |
File "${srcdir}\contrib\VSrules\nasm.README" |
| 155 |
File "${srcdir}\contrib\VSrules\nasm.rules" |
| 156 |
SectionEnd |
| 157 |
|
| 158 |
;-------------------------------- |
| 159 |
;Descriptions |
| 160 |
|
| 161 |
;Language strings |
| 162 |
LangString DESC_SecNasm ${LANG_ENGLISH} "NASM assembler and disassember modules" |
| 163 |
LangString DESC_SecManual ${LANG_ENGLISH} "Complete NASM manual (pdf file)" |
| 164 |
LangString DESC_SecVS8 ${LANG_ENGLISH} "Visual Studio 2008 NASM integration (rules file)" |
| 165 |
|
| 166 |
;Assign language strings to sections |
| 167 |
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN |
| 168 |
!insertmacro MUI_DESCRIPTION_TEXT ${SecNasm} $(DESC_SecNasm) |
| 169 |
!insertmacro MUI_DESCRIPTION_TEXT ${SecManual} $(DESC_SecManual) |
| 170 |
!insertmacro MUI_DESCRIPTION_TEXT ${SecVS8} $(DESC_SecVS8) |
| 171 |
!insertmacro MUI_FUNCTION_DESCRIPTION_END |
| 172 |
|
| 173 |
;-------------------------------- |
| 174 |
;Uninstaller Section |
| 175 |
|
| 176 |
Section "Uninstall" |
| 177 |
; |
| 178 |
; files on HDD |
| 179 |
IfFileExists "$INSTDIR" +3 +1 |
| 180 |
MessageBox MB_OK "No files found, aborting." |
| 181 |
Abort |
| 182 |
MessageBox MB_YESNO "The following directory will be deleted$\n$INSTDIR" IDYES rm_instdir_true IDNO rm_instdir_false |
| 183 |
rm_instdir_true: |
| 184 |
RMDir /r /rebootok "$INSTDIR" |
| 185 |
rm_instdir_false: |
| 186 |
|
| 187 |
; |
| 188 |
; Desktop link |
| 189 |
ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "bat-lnk" |
| 190 |
StrCmp $0 0 +1 +3 |
| 191 |
MessageBox MB_OK "Invalid path to a bat-lnk file, aborting" |
| 192 |
Abort |
| 193 |
IfFileExists $0 +3 +1 |
| 194 |
MessageBox MB_OK "No bat-lnk files found, aborting." |
| 195 |
Abort |
| 196 |
MessageBox MB_YESNO "The following file will be deleted$\n$0" IDYES rm_batlinks_true IDNO rm_batlinks_false |
| 197 |
rm_batlinks_true: |
| 198 |
Delete /rebootok "$0" |
| 199 |
RMDir "$0" |
| 200 |
rm_batlinks_false: |
| 201 |
|
| 202 |
; |
| 203 |
; Start menu folder |
| 204 |
ReadRegStr $0 HKCU Software\${PRODUCT_SHORT_NAME} "lnk" |
| 205 |
StrCmp $0 0 +1 +3 |
| 206 |
MessageBox MB_OK "Invalid path to a lnk file, aborting" |
| 207 |
Abort |
| 208 |
IfFileExists $0 +3 +1 |
| 209 |
MessageBox MB_OK "No lnk files found, aborting." |
| 210 |
Abort |
| 211 |
MessageBox MB_YESNO "The following directory will be deleted$\n$0" IDYES rm_links_true IDNO rm_links_false |
| 212 |
rm_links_true: |
| 213 |
Delete /rebootok "$0\*" |
| 214 |
RMDir "$0" |
| 215 |
rm_links_false: |
| 216 |
DeleteRegKey /ifempty HKCU "Software\${PRODUCT_SHORT_NAME}" |
| 217 |
SectionEnd |
| 218 |
|
| 219 |
; |
| 220 |
; MUI requires this hooks |
| 221 |
Function .onInit |
| 222 |
SetRegView ${BITS} |
| 223 |
!insertmacro MULTIUSER_INIT |
| 224 |
FunctionEnd |
| 225 |
|
| 226 |
Function un.onInit |
| 227 |
!insertmacro MULTIUSER_UNINIT |
| 228 |
FunctionEnd |