1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
|
## NSIS (nsis.sf.net) script to produce installer for win32 platform
## Copyright (c) 2009 Marek Januszewski
## $Id: fuse.nsi.in 5010 2013-05-31 18:32:45Z sbaldovi $
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
##
## Author contact information:
##
## E-mail: philip-fuse@shadowmagic.org.uk
!define FUSE_VERSION "@PACKAGE_VERSION@" ; could have letters like -RC1
!define FUSE_FULL_VERSION "@FUSE_FULL_VERSION@" ; must have four numeric tokens
!define DISPLAY_NAME "Free Unix Spectrum Emulator (Fuse) ${FUSE_VERSION}"
!define SETUP_FILENAME "@PACKAGE@-${FUSE_VERSION}-win32-setup"
!define SETUP_FILE "${SETUP_FILENAME}.exe"
!define HKLM_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fuse"
!define PROG_ID "Fuse.Files.1"
;Include Modern UI
!include "MUI2.nsh"
!include "Sections.nsh"
!include "Util.nsh"
;--------------------------------
;General
Name "${DISPLAY_NAME}"
outFile "${SETUP_FILE}"
Caption "${DISPLAY_NAME}"
installDir "$PROGRAMFILES\Fuse"
; [Additional Installer Settings ]
XPStyle on
SetCompress force
SetCompressor lzma
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!insertmacro MUI_PAGE_LICENSE "COPYING.txt"
!define MUI_COMPONENTSPAGE_SMALLDESC
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\fuse.exe"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_SHOWREADME_CHECKED
!define MUI_FINISHPAGE_SHOWREADME ""
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Delete configuration file"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION un.DeleteConfigFile
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Version Information
VIProductVersion ${FUSE_FULL_VERSION}
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" ""
VIAddVersionKey /LANG=${LANG_ENGLISH} "InternalName" "${SETUP_FILENAME}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "@FUSE_COPYRIGHT@"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Fuse"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${FUSE_VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "OriginalFilename" "${SETUP_FILE}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Fuse - the Free Unix Spectrum Emulator"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${FUSE_VERSION}"
;--------------------------------
;File association functions
!macro SelectUnregisteredExtCall _EXTENSION _SECTION
Push `${_EXTENSION}`
Push `${_SECTION}`
${CallArtificialFunction} SelectUnregisteredExt_
!macroend
!macro NewSecExtensionCall _EXTENSION _DESCRIPTION
Section /o "${_DESCRIPTION} File" SEC_${_DESCRIPTION}
${registerExtension} "${_EXTENSION}"
SectionEnd
!macroend
!macro RegisterExtensionCall _EXTENSION
Push `${_EXTENSION}`
${CallArtificialFunction} RegisterExtension_
!macroend
!macro UnRegisterExtensionCall _EXTENSION
Push "${_EXTENSION}"
${CallArtificialFunction} UnRegisterExtension_
!macroend
!macro SelectUnregisteredExt_
Exch $R1 ;section
Exch
Exch $R0 ;extension
Exch
Push $0
ReadRegStr $0 HKLM "Software\Classes\$R0" ""
;Select if already associated with FUSE, i.e., reinstallation
StrCmp $0 "${PROG_ID}" Select 0
;Select if available
StrCmp $0 "" Select NoSelect
Select:
!insertmacro SelectSection $R1
NoSelect:
Pop $0
Pop $R1
Pop $R0
!macroend
!macro RegisterExtension_
Exch $R0 ;extension
Push $0
; Recommend Fuse in the Open With list
WriteRegStr HKLM "Software\Classes\$R0\OpenWithProgids" "${PROG_ID}" ""
; Read global file association
ReadRegStr $0 HKLM "Software\Classes\$R0" ""
StrCmp "$0" "" NoBackup ; is it empty
StrCmp "$0" "${PROG_ID}" NoBackup ; is it our own
; Backup current value
WriteRegStr HKLM "Software\Classes\$R0" "backup_val" "$0"
NoBackup:
; Set global file association
WriteRegStr HKLM "Software\Classes\$R0" "" "${PROG_ID}"
; Set current user (custom) file association
ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$R0" "Progid"
StrCmp "$0" "" NoLocalBackup ; is it empty
StrCmp "$0" "${PROG_ID}" NoLocalBackup ; is it our own
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$R0" "backup_val" "$0"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$R0" "Progid" "${PROG_ID}"
NoLocalBackup:
Pop $0
Pop $R0
!macroend
!macro UnRegisterExtension_
Exch $R0 ;extension
Push $0
; Unregister OpenWith recommendation
DeleteRegValue HKLM "Software\Classes\$R0\OpenWithProgids" "${PROG_ID}"
; Try to delete current file association
ReadRegStr $0 HKLM "Software\Classes\$R0" ""
StrCmp $0 ${PROG_ID} 0 NoOwn ; only do this if we own it
ReadRegStr $0 HKLM "Software\Classes\$R0" "backup_val"
StrCmp $0 "" 0 Restore ; if backup="" then delete the whole key
DeleteRegKey HKLM "Software\Classes\$R0"
Goto NoOwn
Restore:
WriteRegStr HKLM "Software\Classes\$R0" "" $0
DeleteRegValue HKLM "Software\Classes\$R0" "backup_val"
NoOwn:
; Delete programmatic identifier
DeleteRegKey HKLM "Software\Classes\${PROG_ID}";
; Delete current user (custom) file association
ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$R0" "Progid"
StrCmp "$0" "" NoLocalRestore ; is it empty
StrCmp "$0" "${PROG_ID}" 0 NoLocalRestore ; is it our own
ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$R0" "backup_val"
StrCmp "$0" "" 0 +2 ; if no backup -> delete
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$R0"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$R0" "Progid" "$0"
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\$R0" "backup_val"
NoLocalRestore:
Pop $0
Pop $R0
!macroend
!define NewSecExtension `!insertmacro NewSecExtensionCall`
!define SelectUnregisteredExt `!insertmacro SelectUnregisteredExtCall`
!define RegisterExtension `!insertmacro RegisterExtensionCall`
!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
;--------------------------------
; Uninstall previous version
Section "" SecUninstallPrevious
Push $R0
ReadRegStr $R0 HKLM "${HKLM_REG_KEY}" "UninstallString"
; Check if we are upgrading a previous installation
${If} $R0 == '"$INSTDIR\uninstall.exe"'
DetailPrint "Removing previous installation..."
; Run the uninstaller silently
ExecWait '"$INSTDIR\uninstall.exe" /S _?=$INSTDIR'
${EndIf}
Pop $R0
SectionEnd
;--------------------------------
; start default section
section "!Fuse Core Files (required)" SecCore
SectionIn RO
DetailPrint "Installing Fuse Core Files..."
; set the installation directory as the destination for the following actions
setOutPath "$INSTDIR"
; Installation files
File "AUTHORS.txt"
File "ChangeLog.txt"
File "COPYING.txt"
File "fuse.exe"
File "fuse.html"
File "README.txt"
File /nonfatal "README-win32.txt"
File "*.dll"
SetOutPath $INSTDIR\lib
File "lib\*"
SetOutPath "$INSTDIR\roms"
File "roms\*"
; create the uninstaller
writeUninstaller "$INSTDIR\uninstall.exe"
; Write the uninstall keys for Windows
WriteRegStr HKLM "${HKLM_REG_KEY}" "DisplayName" "${DISPLAY_NAME}"
WriteRegStr HKLM "${HKLM_REG_KEY}" "DisplayVersion" "${FUSE_VERSION}"
WriteRegStr HKLM "${HKLM_REG_KEY}" "HelpLink" "@PACKAGE_URL@"
WriteRegStr HKLM "${HKLM_REG_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "${HKLM_REG_KEY}" "NoModify" 1
WriteRegDWORD HKLM "${HKLM_REG_KEY}" "NoRepair" 1
sectionEnd
;--------------------------------
; Create shortcuts
section "Start Menu and Desktop links" SecShortcuts
DetailPrint "Creating Shortcuts..."
CreateDirectory "$SMPROGRAMS\Fuse"
CreateShortCut "$SMPROGRAMS\Fuse\Fuse.lnk" "$INSTDIR\fuse.exe"
CreateShortCut "$SMPROGRAMS\Fuse\Manual.lnk" "$INSTDIR\fuse.html"
CreateShortCut "$SMPROGRAMS\Fuse\Readme.lnk" "$INSTDIR\README.txt"
CreateShortCut "$SMPROGRAMS\Fuse\Uninstall.lnk" "$INSTDIR\uninstall.exe"
CreateShortCut "$DESKTOP\Fuse.lnk" "$INSTDIR\fuse.exe"
sectionEnd
;--------------------------------
; Register common file extensions
SectionGroup /e "Register File Extensions" SecFileExt
${NewSecExtension} ".pzx" "PZX"
${NewSecExtension} ".rzx" "RZX"
${NewSecExtension} ".sna" "SNA"
${NewSecExtension} ".szx" "SZX"
${NewSecExtension} ".tap" "TAP"
${NewSecExtension} ".tzx" "TZX"
${NewSecExtension} ".z80" "Z80"
SectionGroupEnd
Section "-Register Application"
WriteRegStr HKLM "Software\Classes\${PROG_ID}\shell" "" "open"
WriteRegStr HKLM "Software\Classes\${PROG_ID}\DefaultIcon" "" "$INSTDIR\fuse.exe,0"
WriteRegStr HKLM "Software\Classes\${PROG_ID}\shell\open\command" "" '"$INSTDIR\fuse.exe" "%1"'
WriteRegStr HKLM "Software\Classes\Applications\fuse.exe" "NoOpenWith" ""
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
Function .onInit
; Select extensions not associated with other applications
${SelectUnregisteredExt} ".pzx" ${SEC_PZX}
${SelectUnregisteredExt} ".rzx" ${SEC_RZX}
${SelectUnregisteredExt} ".sna" ${SEC_SNA}
${SelectUnregisteredExt} ".szx" ${SEC_SZX}
${SelectUnregisteredExt} ".tap" ${SEC_TAP}
${SelectUnregisteredExt} ".tzx" ${SEC_TZX}
${SelectUnregisteredExt} ".z80" ${SEC_Z80}
FunctionEnd
;--------------------------------
; uninstaller section start
section "uninstall"
; Unregister file extensions association (if owned)
DetailPrint "Deleting Registry Keys..."
${unregisterExtension} ".pzx"
${unregisterExtension} ".rzx"
${unregisterExtension} ".sna"
${unregisterExtension} ".szx"
${unregisterExtension} ".tap"
${unregisterExtension} ".tzx"
${unregisterExtension} ".z80"
; Unregister Application
DeleteRegKey HKLM "Software\Classes\${PROG_ID}"
DeleteRegKey HKLM "Software\Classes\Applications\fuse.exe"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
; Delete the links
DetailPrint "Deleting Shortcuts..."
Delete "$SMPROGRAMS\Fuse\Fuse.lnk"
Delete "$SMPROGRAMS\Fuse\Manual.lnk"
Delete "$SMPROGRAMS\Fuse\Readme.lnk"
Delete "$SMPROGRAMS\Fuse\Uninstall.lnk"
RMDir "$SMPROGRAMS\Fuse"
Delete "$DESKTOP\Fuse.lnk"
; Installation files
DetailPrint "Deleting Files..."
Delete "$INSTDIR\lib\*"
RMDir "$INSTDIR\lib"
Delete "$INSTDIR\roms\*"
RMDir "$INSTDIR\roms"
Delete "$INSTDIR\AUTHORS.txt"
Delete "$INSTDIR\ChangeLog.txt"
Delete "$INSTDIR\COPYING.txt"
Delete "$INSTDIR\fuse.exe"
Delete "$INSTDIR\fuse.html"
Delete "$INSTDIR\README.txt"
Delete "$INSTDIR\README-win32.txt"
Delete "$INSTDIR\*.dll"
RMDir "$INSTDIR"
; Delete the uninstaller and remove the uninstall keys for Windows
DetailPrint "Deleting Uninstaller..."
Delete "$INSTDIR\uninstall.exe"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fuse"
sectionEnd
Function un.DeleteConfigFile
Delete "$PROFILE\fuse.cfg"
FunctionEnd
;--------------------------------
;Descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "The core files required to use Fuse (program, libraries, ROMs, etc.)"
!insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} "Adds icons to your start menu and your desktop for easy access"
!insertmacro MUI_DESCRIPTION_TEXT ${SecFileExt} "Register common file extensions with Fuse: pzx, rzx, sna, szx, tap, tzx and z80"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|