5 # Run this script to create a win32 installer.
6 # This was blatantly yoinked and adapted from the Wormux Project.
17 COMPRESSION
="/solid lzma"
18 DEST
="tmp-yoink-win32"
19 SCRIPT
="$DEST/yoink.nsi"
20 OUT_FILE
=${1:-yoinksetup-@VERSION@.exe}
23 DLLS
="SDL SDL_image zlib1 libpng12-0 OpenAL32 libalut-0 libvorbis-0 libogg-0"
24 DLLS
="$DLLS libvorbisfile-3 lua51"
27 ${STRIP:-strip} "$ROOT_DIR/src/yoink.exe"
33 # Set installer definitions and strings.
34 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36 HKLM_PATH
='SOFTWARE\Games\Yoink'
37 UNINSTALL_KEY
='SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yoink'
38 APP_PATHS_KEY
='SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\yoink.exe'
39 START_RUN_KEY
='SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
42 PROMPT1
="Not enough rights to install, aborting. :-("
43 PROMPT2
="Unable to uninstall the currently installed version of Yoink. The new version will be installed without removing the currently installed version."
45 SEC_INSTALL
="Install Yoink!"
46 SEC_INSTALL_DESC
="Installs Yoink to your computer."
47 SEC_UNINSTALL
="Uninstall previous version."
48 SEC_SHORTCUTS
="Install Shortcuts."
49 SEC_SHORTCUTS_DESC
="Install shortcuts at various locations."
50 SEC_SHORTCUT1
="Place a shortcut on the desktop."
51 SEC_SHORTCUT2
="Place a shortcut in the start menu."
52 SEC_SHORTCUT3
="Place an uninstall shortcut in the start menu."
54 WEBSITE_LINK
="Visit the Yoink website"
58 # Begin output of installer script.
59 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 ; based on MUI Welcome/Finish Page Example Script written by Joost Verburg
64 !include "Sections.nsh"
65 !include "LogicLib.nsh"
66 !include "FileFunc.nsh"
68 !insertmacro GetParent
71 VIProductVersion "@PVERSION@"
72 VIAddVersionKey "FileDescription" "Yoink Setup"
73 VIAddVersionKey "ProductName" "Yoink"
74 VIAddVersionKey "FileVersion" "@VERSION@"
75 VIAddVersionKey "ProductVersion" "@VERSION@"
76 VIAddVersionKey "LegalCopyright" "Copyright 2009 Charles McGarvey et al."
79 OutFile "$ROOT_DIR/$OUT_FILE"
80 SetCompressor $COMPRESSION
82 ShowUninstDetails show
84 RequestExecutionLevel highest
87 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
88 ;; Modern UI Configuration ;;
89 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
91 !define MUI_ICON "$ROOT_DIR/src/setup.ico"
92 !define MUI_UNICON "$ROOT_DIR/src/uninstall.ico"
94 !define MUI_LANGDLL_ALWAYSSHOW
95 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
96 !define MUI_LANGDLL_REGISTRY_KEY "$HKLM_PATH"
97 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
99 !define MUI_COMPONENTSPAGE_SMALLDESC
100 !define MUI_ABORTWARNING
101 ; Do not close dialogs, allow to check installation result
102 !define MUI_FINISHPAGE_NOAUTOCLOSE
103 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
105 !define MUI_FINISHPAGE_RUN "\$INSTDIR\\yoink.exe"
106 !define MUI_FINISHPAGE_RUN_NOTCHECKED
107 !define MUI_FINISHPAGE_LINK "$WEBSITE_LINK"
108 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.dogcows.com/"
110 ;--------------------------------
113 !insertmacro MUI_PAGE_WELCOME
114 !insertmacro MUI_PAGE_COMPONENTS
115 !insertmacro MUI_PAGE_DIRECTORY
116 !insertmacro MUI_PAGE_INSTFILES
117 !insertmacro MUI_PAGE_FINISH
119 !insertmacro MUI_UNPAGE_WELCOME
120 !insertmacro MUI_UNPAGE_CONFIRM
121 !insertmacro MUI_UNPAGE_INSTFILES
122 !insertmacro MUI_UNPAGE_FINISH
124 ;--------------------------------
126 !insertmacro MUI_LANGUAGE "English"
128 ;--------------------------------
130 ;If you are using solid compression, files that are required before
131 ;the actual installation should be stored first in the data block,
132 ;because this will make your installer start faster.
134 !insertmacro MUI_RESERVEFILE_LANGDLL
136 ;--------------------------------
137 ;Folder-selection page
138 InstallDir "\$PROGRAMFILES\\Yoink"
139 ; Registry key to check for directory (so if you install again, it will
140 ; overwrite the old one automatically)
141 InstallDirRegKey HKLM "$HKLM_PATH" "Path"
142 AutoCloseWindow false
144 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
145 ;; Start Install Sections ;;
146 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
148 ;-----------------------------------------
149 ;Create folder only if it doesnt exist yet
150 !macro CreateDirectoryOnce FOLDER
151 IfFileExists "\${FOLDER}\\*.*" +1
152 CreateDirectory "\${FOLDER}"
155 ;--------------------------------
156 ;Check (un)install rights
157 !macro CheckUserInstallRightsMacro UN
158 Function \${UN}CheckUserInstallRights
165 UserInfo::GetAccountType
168 StrCmp \$1 "Admin" 0 +3
171 StrCmp \$1 "Power" 0 +3
174 StrCmp \$1 "User" 0 +3
177 StrCmp \$1 "Guest" 0 +3
193 !insertmacro CheckUserInstallRightsMacro ""
194 !insertmacro CheckUserInstallRightsMacro "un."
196 ;--------------------------------
197 ; Uninstall any old version of Yoink
199 ; Section hidden because automatically selected by the installer
200 Section "$SEC_UNINSTALL" SecUninstallOldYoink
201 ; Check install rights..
202 StrCpy \$R3 $HKLM_PATH
203 StrCpy \$R4 $UNINSTALL_KEY
204 StrCpy \$R5 "uninstall.exe"
205 Call CheckUserInstallRights
207 ; "NONE" case already handled at start
208 StrCmp \$R0 "HKCU" _hkcu
209 ReadRegStr \$R1 HKLM \$R3 ""
210 ReadRegStr \$R2 HKLM "\$R4" "UninstallString"
214 ReadRegStr \$R1 HKCU \$R3 ""
215 ReadRegStr \$R2 HKCU "\$R4" "UninstallString"
217 ; If a previous version exists, remove it
219 ; If first string is unavailable, Yoink was probably not installed
221 ; Check if we have uninstall string..
222 IfFileExists \$R2 0 no_file
223 ; Have uninstall string, go ahead and uninstall.
225 ; Need to copy uninstaller outside of the install dir
227 CopyFiles /SILENT \$R2 "\$TEMP\\\$R5"
229 IfErrors uninstall_problem
230 ; Ready to uninstall..
232 ExecWait '"\$TEMP\\\$R5" /S _?=\$R1'
234 Delete "\$TEMP\\\$R5"
238 Delete "\$TEMP\\\$R5"
239 Goto uninstall_problem
242 MessageBox MB_OK "No uninstaller exe found" /SD IDOK IDOK done
245 ; We cant uninstall. Either the user must manually uninstall or
246 ; we ignore and reinstall over it.
247 MessageBox MB_OKCANCEL "$PROMPT2" /SD IDOK IDCANCEL done
253 ;--------------------------------
256 Section "$SEC_INSTALL" SecInstallYoink
257 ; Create install and config folders
258 CreateDirectory "\$INSTDIR"
259 ; Set output path to the installation directory.
260 SetOutPath "\$INSTDIR"
261 File "$ROOT_DIR/src/yoink.ico"
262 ; Executing in tmpdir, looking for file in folder below
263 File "$ROOT_DIR/src/yoink.exe"
265 File /r /x Makefile* /x *.desktop "$ROOT_DIR/data"
267 File "$ROOT_DIR/AUTHORS" "$ROOT_DIR/ChangeLog" "$ROOT_DIR/COPYING"
268 File "$ROOT_DIR/README" "$ROOT_DIR/TODO" "$ROOT_DIR/doc/screenshot.png"
269 File /r "$ROOT_DIR/doc/licenses"
271 WriteUninstaller "uninstall.exe"
276 # Add DLL's to installer
277 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
281 cat >> "$SCRIPT" <<EOF
282 File "@prefix@/bin/$dll.dll"
288 # Continue writing the installer
289 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291 cat >> "$SCRIPT" <<EOF
292 Call CheckUserInstallRights
294 ; "NONE" case already handled at start
295 StrCmp \$R0 "HKCU" _hkcu
296 WriteRegStr HKLM "$APP_PATHS_KEY" "" "\$INSTDIR\\yoink.exe"
297 WriteRegStr HKLM "$HKLM_PATH" "" "\$INSTDIR"
298 WriteRegStr HKLM "$HKLM_PATH" "Version" "@VERSION@"
299 WriteRegStr HKLM "$UNINSTALL_KEY" "DisplayName" "Yoink"
300 WriteRegStr HKLM "$UNINSTALL_KEY" "DisplayVersion" "@VERSION@"
301 WriteRegStr HKLM "$UNINSTALL_KEY" "UninstallString" "\$INSTDIR\\uninstall.exe"
302 ;Write language to the registry (for the uninstaller)
303 WriteRegStr HKLM "$HKLM_PATH" "Installer Language" \$LANGUAGE
304 ; Sets scope of the desktop and Start Menu entries for all users.
305 SetShellVarContext "all"
309 WriteRegStr HKCU "$HKLM_PATH" "" "\$INSTDIR"
310 WriteRegStr HKCU "$HKLM_PATH" "Version" "@VERSION@"
311 WriteRegStr HKCU "$UNINSTALL_KEY" "DisplayName" "Yoink"
312 WriteRegStr HKCU "$UNINSTALL_KEY" "DisplayVersion" "@VERSION@"
313 WriteRegStr HKCU "$UNINSTALL_KEY" "UninstallString" "\$INSTDIR\\uninstall.exe"
314 ;Write language to the registry (for the uninstaller)
315 WriteRegStr HKCU "$HKLM_PATH" "Installer Language" \$LANGUAGE
316 ;SetShellVarContext "current"
319 SectionEnd ; Installer section
321 ;--------------------------------
323 SectionGroup /e "$SEC_SHORTCUTS" SecShortcuts
326 Section /o "$SEC_SHORTCUT1" SecDesktopShortcut
328 CreateShortCut "\$DESKTOP\\Yoink.lnk" "\$INSTDIR\\yoink.exe" \
329 "" "\$INSTDIR\\yoink.exe" 0
333 ; Yoink uninstall shortcut in start menu
334 ; Might be forced if user has no install rights,
335 ; because it would be complex otherwise:
336 ; - No uninstall available in Windows "Program uninstall"
337 ; - Folder lost in APPDATA, which can be hidden, etc
338 Section "$SEC_SHORTCUT3" SecUninstallShortcut
340 !insertmacro CreateDirectoryOnce "\$SMPROGRAMS\\Yoink"
341 CreateShortCut "\$SMPROGRAMS\\Yoink\\Uninstall.lnk" \
342 "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
346 ; Yoink shortcut in start menu
347 Section "$SEC_SHORTCUT2" SecStartMenuShortcut
349 !insertmacro CreateDirectoryOnce "\$SMPROGRAMS\\Yoink"
350 CreateShortCut "\$SMPROGRAMS\\Yoink\\Play Yoink!.lnk" \
351 "\$INSTDIR\\yoink.exe" "" "\$INSTDIR\\yoink.exe" 0
358 ;--------------------------------
361 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
362 !insertmacro MUI_DESCRIPTION_TEXT \${SecInstallYoink} "$SEC_INSTALL_DESC"
363 !insertmacro MUI_DESCRIPTION_TEXT \${SecShortcuts} "$SEC_SHORTCUTS_DESC"
364 !insertmacro MUI_DESCRIPTION_TEXT \${SecDesktopShortcut} "$SEC_SHORTCUT1"
365 !insertmacro MUI_DESCRIPTION_TEXT \${SecStartMenuShortcut} "$SEC_SHORTCUT2"
366 !insertmacro MUI_DESCRIPTION_TEXT \${SecUninstallShortcut} "$SEC_SHORTCUT3"
367 !insertmacro MUI_FUNCTION_DESCRIPTION_END
370 ;--------------------------------
374 ; Set install path according to user rights
375 Call un.CheckUserInstallRights
377 StrCmp \$R0 "HKLM" _hklm
379 ; Also used as fallback by HKLM case
381 ReadRegStr \$R0 HKCU "$HKLM_PATH" ""
382 StrCmp \$R0 "\$INSTDIR" 0 _next
383 ; HKCU install path matches our INSTDIR so uninstall
384 DeleteRegKey HKCU "$HKLM_PATH"
385 DeleteRegKey HKCU "$UNINSTALL_KEY"
389 ReadRegStr \$R0 HKLM "$HKLM_PATH" ""
390 StrCmp \$R0 \$INSTDIR 0 _hkcu
391 ; HKLM install path matches our INSTDIR so uninstall
392 DeleteRegKey HKLM "$APP_PATHS_KEY"
393 DeleteRegKey HKLM "$HKLM_PATH"
394 DeleteRegKey HKLM "$UNINSTALL_KEY"
395 SetShellVarContext all
398 ; Remove Language preference info
399 DeleteRegValue HKCU "$HKLM_PATH" "Installer Language"
400 ; remove shortcuts, if any.
401 Delete "\$SMPROGRAMS\\Yoink\\*.*"
402 RMDir "\$SMPROGRAMS\\Yoink"
403 Delete "\$SMPROGRAMS\\Yoink.lnk"
404 Delete "\$DESKTOP\\Yoink.lnk"
411 !insertmacro MUI_LANGDLL_DISPLAY
413 IntOp \$R0 \${SF_RO} | \${SF_SELECTED}
414 SectionSetFlags \${SecInstallYoink} \$R0
415 SectionSetFlags \${SecUninstallOldYoink} \$R0
417 ; Set install path according to user rights
418 Call CheckUserInstallRights
420 StrCmp \$R0 "NONE" _none
421 StrCmp \$R0 "HKLM" 0 _hkcu
422 StrCpy \$INSTDIR "\$PROGRAMFILES\\Yoink"
427 \${GetParent} \$SMPROGRAMS \$R2
428 \${GetParent} \$R2 \$R2
429 StrCpy \$INSTDIR "\$R2\\Yoink"
430 ; In this case uninstall shortcut *must* be available because
431 ; the alternative are complex for the user
432 IntOp \$R0 \${SF_RO} | \${SF_SELECTED}
433 SectionSetFlags \${SecUninstallShortcut} \$R0
437 ; Not going to bother
438 MessageBox MB_OK "$PROMPT1" /SD IDOK
444 ; INSTDIR will be determined by reading a registry key
446 !insertmacro MUI_UNGETLANGUAGE
447 ; Set install path according to user rights
448 Call un.CheckUserInstallRights
450 StrCmp \$R0 "NONE" _none
454 ; Not going to bother
455 MessageBox MB_OK "$PROMPT1" /SD IDOK
464 # Compile the installer and cleanup.
465 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
467 if ! "${MAKENSIS:-makensis}" "$SCRIPT"
469 echo "makensis failed, aborting..."
This page took 0.049406 seconds and 4 git commands to generate.