]>
Dogcows Code - chaz/yoink/blob - make-win32-installer.sh.in
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"
22 DLLS
= "SDL SDL_image zlib1 libpng12-0 OpenAL32 libalut-0 libvorbis-0 libogg-0"
23 DLLS
= " $DLLS libvorbisfile-3"
26 ${STRIP:-strip} " $ROOT_DIR /src/yoink.exe"
32 # Set installer definitions and strings.
33 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35 HKLM_PATH
= 'SOFTWARE\Games\Yoink'
36 UNINSTALL_KEY
= 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yoink'
37 APP_PATHS_KEY
= 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\yoink.exe'
38 START_RUN_KEY
= 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
41 PROMPT1
= "Not enough rights to install, aborting. :-("
42 PROMPT2
= "Unable to uninstall the currently installed version of Yoink. The new version will be installed without removing the currently installed version."
44 SEC_INSTALL
= "Install Yoink!"
45 SEC_INSTALL_DESC
= "Installs Yoink to your computer."
46 SEC_UNINSTALL
= "Uninstall previous version."
47 SEC_SHORTCUTS
= "Install Shortcuts."
48 SEC_SHORTCUTS_DESC
= "Install shortcuts at various locations."
49 SEC_SHORTCUT1
= "Place a shortcut on the desktop."
50 SEC_SHORTCUT2
= "Place a shortcut in the start menu."
51 SEC_SHORTCUT3
= "Place an uninstall shortcut in the start menu."
53 WEBSITE_LINK
= "Visit the Yoink website"
57 # Begin output of installer script.
58 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 ; based on MUI Welcome/Finish Page Example Script written by Joost Verburg
63 !include "Sections.nsh"
64 !include "LogicLib.nsh"
65 !include "FileFunc.nsh"
67 !insertmacro GetParent
70 VIProductVersion "@PVERSION@"
71 VIAddVersionKey "FileDescription" "Yoink Setup"
72 VIAddVersionKey "ProductName" "Yoink"
73 VIAddVersionKey "FileVersion" "@VERSION@"
74 VIAddVersionKey "ProductVersion" "@VERSION@"
75 VIAddVersionKey "LegalCopyright" "Copyright 2009 Charles McGarvey et al."
78 OutFile " $ROOT_DIR /yoinksetup-@VERSION@.exe"
79 SetCompressor $COMPRESSION
81 ShowUninstDetails show
83 RequestExecutionLevel highest
86 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
87 ;; Modern UI Configuration ;;
88 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
90 !define MUI_ICON " $ROOT_DIR /src/yoink.ico"
91 !define MUI_UNICON " $ROOT_DIR /src/yoink.ico"
93 !define MUI_LANGDLL_ALWAYSSHOW
94 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
95 !define MUI_LANGDLL_REGISTRY_KEY " $HKLM_PATH "
96 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
98 !define MUI_COMPONENTSPAGE_SMALLDESC
99 !define MUI_ABORTWARNING
100 ; Do not close dialogs, allow to check installation result
101 !define MUI_FINISHPAGE_NOAUTOCLOSE
102 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
104 !define MUI_FINISHPAGE_RUN "\ $INSTDIR \\yoink.exe"
105 !define MUI_FINISHPAGE_RUN_NOTCHECKED
106 !define MUI_FINISHPAGE_LINK " $WEBSITE_LINK "
107 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.dogcows.com/"
109 ;--------------------------------
112 !insertmacro MUI_PAGE_WELCOME
113 !insertmacro MUI_PAGE_COMPONENTS
114 !insertmacro MUI_PAGE_DIRECTORY
115 !insertmacro MUI_PAGE_INSTFILES
116 !insertmacro MUI_PAGE_FINISH
118 !insertmacro MUI_UNPAGE_WELCOME
119 !insertmacro MUI_UNPAGE_CONFIRM
120 !insertmacro MUI_UNPAGE_INSTFILES
121 !insertmacro MUI_UNPAGE_FINISH
123 ;--------------------------------
125 !insertmacro MUI_LANGUAGE "English"
127 ;--------------------------------
129 ;If you are using solid compression, files that are required before
130 ;the actual installation should be stored first in the data block,
131 ;because this will make your installer start faster.
133 !insertmacro MUI_RESERVEFILE_LANGDLL
135 ;--------------------------------
136 ;Folder-selection page
137 InstallDir "\ $PROGRAMFILES \\Yoink"
138 ; Registry key to check for directory (so if you install again, it will
139 ; overwrite the old one automatically)
140 InstallDirRegKey HKLM " $HKLM_PATH " "Path"
141 AutoCloseWindow false
143 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
144 ;; Start Install Sections ;;
145 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
147 ;-----------------------------------------
148 ;Create folder only if it doesnt exist yet
149 !macro CreateDirectoryOnce FOLDER
150 IfFileExists "\ ${FOLDER} \\*.*" +1
151 CreateDirectory "\ ${FOLDER} "
154 ;--------------------------------
155 ;Check (un)install rights
156 !macro CheckUserInstallRightsMacro UN
157 Function \ ${UN} CheckUserInstallRights
164 UserInfo::GetAccountType
167 StrCmp \ $1 "Admin" 0 +3
170 StrCmp \ $1 "Power" 0 +3
173 StrCmp \ $1 "User" 0 +3
176 StrCmp \ $1 "Guest" 0 +3
192 !insertmacro CheckUserInstallRightsMacro ""
193 !insertmacro CheckUserInstallRightsMacro "un."
195 ;--------------------------------
196 ; Uninstall any old version of Yoink
198 ; Section hidden because automatically selected by the installer
199 Section " $SEC_UNINSTALL " SecUninstallOldYoink
200 ; Check install rights..
201 StrCpy \ $R3 $HKLM_PATH
202 StrCpy \ $R4 $UNINSTALL_KEY
203 StrCpy \ $R5 "uninstall.exe"
204 Call CheckUserInstallRights
206 ; "NONE" case already handled at start
207 StrCmp \ $R0 "HKCU" _hkcu
208 ReadRegStr \ $R1 HKLM \ $R3 ""
209 ReadRegStr \ $R2 HKLM "\ $R4 " "UninstallString"
213 ReadRegStr \ $R1 HKCU \ $R3 ""
214 ReadRegStr \ $R2 HKCU "\ $R4 " "UninstallString"
216 ; If a previous version exists, remove it
218 ; If first string is unavailable, Yoink was probably not installed
220 ; Check if we have uninstall string..
221 IfFileExists \ $R2 0 no_file
222 ; Have uninstall string, go ahead and uninstall.
224 ; Need to copy uninstaller outside of the install dir
226 CopyFiles /SILENT \ $R2 "\ $TEMP \\\ $R5 "
228 IfErrors uninstall_problem
229 ; Ready to uninstall..
231 ExecWait '"\ $TEMP \\\ $R5 " /S _?=\ $R1 '
233 Delete "\ $TEMP \\\ $R5 "
237 Delete "\ $TEMP \\\ $R5 "
238 Goto uninstall_problem
241 MessageBox MB_OK "No uninstaller exe found" /SD IDOK IDOK done
244 ; We cant uninstall. Either the user must manually uninstall or
245 ; we ignore and reinstall over it.
246 MessageBox MB_OKCANCEL " $PROMPT2 " /SD IDOK IDCANCEL done
252 ;--------------------------------
255 Section " $SEC_INSTALL " SecInstallYoink
256 ; Create install and config folders
257 CreateDirectory "\ $INSTDIR "
258 ; Set output path to the installation directory.
259 SetOutPath "\ $INSTDIR "
260 File " $ROOT_DIR /src/yoink.ico"
261 ; Executing in tmpdir, looking for file in folder below
262 File " $ROOT_DIR /src/yoink.exe"
264 File /r /x Makefile* /x *.desktop " $ROOT_DIR /data"
266 WriteUninstaller "uninstall.exe"
271 # Add DLL's to installer
272 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276 cat >> " $SCRIPT " <<EOF
277 File "@prefix@/bin/ $dll .dll"
283 # Continue writing the installer
284 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
286 cat >> " $SCRIPT " <<EOF
287 Call CheckUserInstallRights
289 ; "NONE" case already handled at start
290 StrCmp \ $R0 "HKCU" _hkcu
291 WriteRegStr HKLM " $APP_PATHS_KEY " "" "\ $INSTDIR \\yoink.exe"
292 WriteRegStr HKLM " $HKLM_PATH " "" "\ $INSTDIR "
293 WriteRegStr HKLM " $HKLM_PATH " "Version" "@VERSION@"
294 WriteRegStr HKLM " $UNINSTALL_KEY " "DisplayName" "Yoink"
295 WriteRegStr HKLM " $UNINSTALL_KEY " "DisplayVersion" "@VERSION@"
296 WriteRegStr HKLM " $UNINSTALL_KEY " "UninstallString" "\ $INSTDIR \\uninstall.exe"
297 ;Write language to the registry (for the uninstaller)
298 WriteRegStr HKLM " $HKLM_PATH " "Installer Language" \ $LANGUAGE
299 ; Sets scope of the desktop and Start Menu entries for all users.
300 SetShellVarContext "all"
304 WriteRegStr HKCU " $HKLM_PATH " "" "\ $INSTDIR "
305 WriteRegStr HKCU " $HKLM_PATH " "Version" "@VERSION@"
306 WriteRegStr HKCU " $UNINSTALL_KEY " "DisplayName" "Yoink"
307 WriteRegStr HKCU " $UNINSTALL_KEY " "DisplayVersion" "@VERSION@"
308 WriteRegStr HKCU " $UNINSTALL_KEY " "UninstallString" "\ $INSTDIR \\uninstall.exe"
309 ;Write language to the registry (for the uninstaller)
310 WriteRegStr HKCU " $HKLM_PATH " "Installer Language" \ $LANGUAGE
311 ;SetShellVarContext "current"
314 SectionEnd ; Installer section
316 ;--------------------------------
318 SectionGroup /e " $SEC_SHORTCUTS " SecShortcuts
321 Section /o " $SEC_SHORTCUT1 " SecDesktopShortcut
323 CreateShortCut "\ $DESKTOP \\Yoink.lnk" "\ $INSTDIR \\yoink.exe" \
324 "" "\ $INSTDIR \\yoink.exe" 0
328 ; Yoink shortcut in start menu
329 Section " $SEC_SHORTCUT2 " SecStartMenuShortcut
331 !insertmacro CreateDirectoryOnce "\ $SMPROGRAMS \\Yoink"
332 CreateShortCut "\ $SMPROGRAMS \\Yoink\\Play Yoink!.lnk" \
333 "\ $INSTDIR \\yoink.exe" "" "\ $INSTDIR \\yoink.exe" 0
337 ; Yoink uninstall shortcut in start menu
338 ; Might be forced if user has no install rights,
339 ; because it would be complex otherwise:
340 ; - No uninstall available in Windows "Program uninstall"
341 ; - Folder lost in APPDATA, which can be hidden, etc
342 Section " $SEC_SHORTCUT3 " SecUninstallShortcut
344 !insertmacro CreateDirectoryOnce "\ $SMPROGRAMS \\Yoink"
345 CreateShortCut "\ $SMPROGRAMS \\Yoink\\Uninstall.lnk" \
346 "\ $INSTDIR \\uninstall.exe" "" "\ $INSTDIR \\uninstall.exe" 0
353 ;--------------------------------
356 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
357 !insertmacro MUI_DESCRIPTION_TEXT \ ${SecInstallYoink} " $SEC_INSTALL_DESC "
358 !insertmacro MUI_DESCRIPTION_TEXT \ ${SecShortcuts} " $SEC_SHORTCUTS_DESC "
359 !insertmacro MUI_DESCRIPTION_TEXT \ ${SecDesktopShortcut} " $SEC_SHORTCUT1 "
360 !insertmacro MUI_DESCRIPTION_TEXT \ ${SecStartMenuShortcut} " $SEC_SHORTCUT2 "
361 !insertmacro MUI_DESCRIPTION_TEXT \ ${SecUninstallShortcut} " $SEC_SHORTCUT3 "
362 !insertmacro MUI_FUNCTION_DESCRIPTION_END
365 ;--------------------------------
369 ; Set install path according to user rights
370 Call un.CheckUserInstallRights
372 StrCmp \ $R0 "HKLM" _hklm
374 ; Also used as fallback by HKLM case
376 ReadRegStr \ $R0 HKCU " $HKLM_PATH " ""
377 StrCmp \ $R0 "\ $INSTDIR " 0 _next
378 ; HKCU install path matches our INSTDIR so uninstall
379 DeleteRegKey HKCU " $HKLM_PATH "
380 DeleteRegKey HKCU " $UNINSTALL_KEY "
384 ReadRegStr \ $R0 HKLM " $HKLM_PATH " ""
385 StrCmp \ $R0 \ $INSTDIR 0 _hkcu
386 ; HKLM install path matches our INSTDIR so uninstall
387 DeleteRegKey HKLM " $APP_PATHS_KEY "
388 DeleteRegKey HKLM " $HKLM_PATH "
389 DeleteRegKey HKLM " $UNINSTALL_KEY "
390 SetShellVarContext all
393 ; Remove Language preference info
394 DeleteRegValue HKCU " $HKLM_PATH " "Installer Language"
395 ; remove shortcuts, if any.
396 Delete "\ $SMPROGRAMS \\Yoink\\*.*"
397 RMDir "\ $SMPROGRAMS \\Yoink"
398 Delete "\ $SMPROGRAMS \\Yoink.lnk"
399 Delete "\ $DESKTOP \\Yoink.lnk"
406 !insertmacro MUI_LANGDLL_DISPLAY
408 IntOp \ $R0 \ ${SF_RO} | \ ${SF_SELECTED}
409 SectionSetFlags \ ${SecInstallYoink} \ $R0
410 SectionSetFlags \ ${SecUninstallOldYoink} \ $R0
412 ; Set install path according to user rights
413 Call CheckUserInstallRights
415 StrCmp \ $R0 "NONE" _none
416 StrCmp \ $R0 "HKLM" 0 _hkcu
417 StrCpy \ $INSTDIR "\ $PROGRAMFILES \\Yoink"
422 \ ${GetParent} \ $SMPROGRAMS \ $R2
423 \ ${GetParent} \ $R2 \ $R2
424 StrCpy \ $INSTDIR "\ $R2 \\Yoink"
425 ; In this case uninstall shortcut *must* be available because
426 ; the alternative are complex for the user
427 IntOp \ $R0 \ ${SF_RO} | \ ${SF_SELECTED}
428 SectionSetFlags \ ${SecUninstallShortcut} \ $R0
432 ; Not going to bother
433 MessageBox MB_OK " $PROMPT1 " /SD IDOK
439 ; INSTDIR will be determined by reading a registry key
441 !insertmacro MUI_UNGETLANGUAGE
442 ; Set install path according to user rights
443 Call un.CheckUserInstallRights
445 StrCmp \ $R0 "NONE" _none
449 ; Not going to bother
450 MessageBox MB_OK " $PROMPT1 " /SD IDOK
459 # Compile the installer and cleanup.
460 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
462 if ! " ${MAKENSIS:-makensis} " " $SCRIPT "
464 echo "makensis failed, aborting..."
This page took 0.048589 seconds and 4 git commands to generate.