source: osm/applications/editors/josm/nsis/josm.nsi@ 27235

Last change on this file since 27235 was 27235, checked in by stoecker, 14 years ago

try fixing windows installer

File size: 16.9 KB
Line 
1;
2; josm.nsi
3;
4
5; Set the compression mechanism first.
6; If you get an error here, please update to at least NSIS 2.07!
7SetCompressor /SOLID lzma
8
9!define DEST "josm"
10
11; Used to refresh the display of file association
12!define SHCNE_ASSOCCHANGED 0x08000000
13!define SHCNF_IDLIST 0
14
15; Used to add associations between file extensions and JOSM
16!define OSM_ASSOC "josm-file"
17
18; ============================================================================
19; Header configuration
20; ============================================================================
21; The name of the installer
22!define PROGRAM_NAME "JOSM"
23
24Name "${PROGRAM_NAME} ${VERSION}"
25
26; The file to write
27OutFile "${DEST}-setup-${VERSION}.exe"
28
29XPStyle on
30
31
32
33; ============================================================================
34; Modern UI
35; ============================================================================
36
37!include "MUI.nsh"
38
39; Icon of installer and uninstaller
40!define MUI_ICON "logo.ico"
41!define MUI_UNICON "logo.ico"
42
43!define MUI_COMPONENTSPAGE_SMALLDESC
44!define MUI_FINISHPAGE_NOAUTOCLOSE
45!define MUI_UNFINISHPAGE_NOAUTOCLOSE
46!define MUI_WELCOMEFINISHPAGE_BITMAP "josm-nsis-brand.bmp"
47!define MUI_WELCOMEPAGE_TEXT $(JOSM_WELCOME_TEXT)
48
49!define MUI_FINISHPAGE_RUN "$INSTDIR\josm.exe"
50
51
52; ============================================================================
53; MUI Pages
54; ============================================================================
55
56!insertmacro MUI_PAGE_WELCOME
57!insertmacro MUI_PAGE_LICENSE "..\core\LICENSE"
58!insertmacro MUI_PAGE_COMPONENTS
59;Page custom DisplayAdditionalTasksPage
60!insertmacro MUI_PAGE_DIRECTORY
61!insertmacro MUI_PAGE_INSTFILES
62!insertmacro MUI_PAGE_FINISH
63
64!insertmacro MUI_UNPAGE_WELCOME
65!insertmacro MUI_UNPAGE_CONFIRM
66!insertmacro MUI_UNPAGE_COMPONENTS
67!insertmacro MUI_UNPAGE_INSTFILES
68!insertmacro MUI_UNPAGE_FINISH
69
70; ============================================================================
71; MUI Languages
72; ============================================================================
73
74 ;Remember the installer language
75 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
76 !define MUI_LANGDLL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM"
77 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
78
79 ;; English goes first because its the default. The rest are
80 ;; in alphabetical order (at least the strings actually displayed
81 ;; will be).
82
83 !insertmacro MUI_LANGUAGE "English"
84 !insertmacro MUI_LANGUAGE "German"
85
86;--------------------------------
87;Translations
88
89 !define JOSM_DEFAULT_LANGFILE "locale\english.nsh"
90
91 !include "langmacros.nsh"
92
93 !insertmacro JOSM_MACRO_INCLUDE_LANGFILE "ENGLISH" "locale\english.nsh"
94 !insertmacro JOSM_MACRO_INCLUDE_LANGFILE "GERMAN" "locale\german.nsh"
95
96; Uninstall stuff
97!define MUI_UNCONFIRMPAGE_TEXT_TOP ${un.JOSM_UNCONFIRMPAGE_TEXT_TOP}
98
99; ============================================================================
100; Installation types
101; ============================================================================
102
103InstType "$(JOSM_FULL_INSTALL)"
104
105InstType "un.$(un.JOSM_DEFAULT_UNINSTALL)"
106InstType "un.$(un.JOSM_FULL_UNINSTALL)"
107
108; ============================================================================
109; Reserve Files
110; ============================================================================
111
112 ;Things that need to be extracted on first (keep these lines before any File command!)
113 ;Only useful for BZIP2 compression
114
115!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
116
117; ============================================================================
118; Section macros
119; ============================================================================
120!include "Sections.nsh"
121
122; ========= Macro to unselect and disable a section =========
123
124!macro DisableSection SECTION
125
126 Push $0
127 SectionGetFlags "${SECTION}" $0
128 IntOp $0 $0 & ${SECTION_OFF}
129 IntOp $0 $0 | ${SF_RO}
130 SectionSetFlags "${SECTION}" $0
131 Pop $0
132
133!macroend
134
135; ========= Macro to enable (unreadonly) a section =========
136!define SECTION_ENABLE 0xFFFFFFEF
137!macro EnableSection SECTION
138
139 Push $0
140 SectionGetFlags "${SECTION}" $0
141 IntOp $0 $0 & ${SECTION_ENABLE}
142 SectionSetFlags "${SECTION}" $0
143 Pop $0
144
145!macroend
146
147; ============================================================================
148; Command Line
149; ============================================================================
150!include "FileFunc.nsh"
151
152; ============================================================================
153; Directory selection page configuration
154; ============================================================================
155; The text to prompt the user to enter a directory
156DirText $(JOSM_DIR_TEXT)
157
158; The default installation directory
159InstallDir $PROGRAMFILES\JOSM\
160
161; See if this is an upgrade; if so, use the old InstallDir as default
162InstallDirRegKey HKEY_LOCAL_MACHINE SOFTWARE\JOSM "InstallDir"
163
164
165; ============================================================================
166; Install page configuration
167; ============================================================================
168ShowInstDetails show
169ShowUninstDetails show
170
171; ============================================================================
172; Functions and macros
173; ============================================================================
174
175; update file extension icons
176!macro UpdateIcons
177 Push $R0
178 Push $R1
179 Push $R2
180
181 !define UPDATEICONS_UNIQUE ${__LINE__}
182
183 IfFileExists "$SYSDIR\shell32.dll" UpdateIcons.next1_${UPDATEICONS_UNIQUE} UpdateIcons.error1_${UPDATEICONS_UNIQUE}
184UpdateIcons.next1_${UPDATEICONS_UNIQUE}:
185 GetDllVersion "$SYSDIR\shell32.dll" $R0 $R1
186 IntOp $R2 $R0 / 0x00010000
187 IntCmp $R2 4 UpdateIcons.next2_${UPDATEICONS_UNIQUE} UpdateIcons.error2_${UPDATEICONS_UNIQUE}
188UpdateIcons.next2_${UPDATEICONS_UNIQUE}:
189 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
190 Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
191
192UpdateIcons.error1_${UPDATEICONS_UNIQUE}:
193 MessageBox MB_OK|MB_ICONSTOP $(JOSM_UPDATEICONS_ERROR1)
194 Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
195UpdateIcons.error2_${UPDATEICONS_UNIQUE}:
196 MessageBox MB_OK|MB_ICONINFORMATION $(JOSM_UPDATEICONS_ERROR2)
197 Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
198UpdateIcons.quit_${UPDATEICONS_UNIQUE}:
199 !undef UPDATEICONS_UNIQUE
200 Pop $R2
201 Pop $R1
202 Pop $R0
203
204!macroend
205
206; associate a file extension to an icon
207Function Associate
208 ; $R0 should contain the prefix to associate to JOSM
209 Push $R1
210
211 ReadRegStr $R1 HKCR $R0 ""
212 StrCmp $R1 "" Associate.doRegister
213 Goto Associate.end
214Associate.doRegister:
215 ;The extension is not associated to any program, we can do the link
216 WriteRegStr HKCR $R0 "" ${OSM_ASSOC}
217Associate.end:
218 pop $R1
219FunctionEnd
220
221; disassociate a file extension from an icon
222Function un.unlink
223 ; $R0 should contain the prefix to unlink
224 Push $R1
225
226 ReadRegStr $R1 HKCR $R0 ""
227 StrCmp $R1 ${OSM_ASSOC} un.unlink.doUnlink
228 Goto un.unlink.end
229un.unlink.doUnlink:
230 ; The extension is associated with JOSM so, we must destroy this!
231 DeleteRegKey HKCR $R0
232un.unlink.end:
233 pop $R1
234FunctionEnd
235
236Function .onInit
237 ;Extract InstallOptions INI files
238; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "AdditionalTasksPage.ini"
239 !insertmacro MUI_LANGDLL_DISPLAY
240FunctionEnd
241
242Function un.onInit
243
244 !insertmacro MUI_UNGETLANGUAGE
245
246FunctionEnd
247
248; ============================================================================
249; Installation execution commands
250; ============================================================================
251
252Section "-Required"
253;-------------------------------------------
254
255;
256; Install for every user
257;
258SectionIn 1 2 RO
259SetShellVarContext current
260
261SetOutPath $INSTDIR
262
263; Write the uninstall keys for Windows
264WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "DisplayVersion" "${VERSION}"
265WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "DisplayName" "JOSM ${VERSION}"
266WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "UninstallString" '"$INSTDIR\uninstall.exe"'
267WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "Publisher" "The OpenStreetMap developer community, http://www.openstreetmap.org/"
268WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "HelpLink" "mailto:newbies@openstreetmap.org."
269WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "URLInfoAbout" "http://www.openstreetmap.org/"
270WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "URLUpdateInfo" "http://wiki.openstreetmap.org/index.php/JOSM"
271WriteRegDWORD HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "NoModify" 1
272WriteRegDWORD HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "NoRepair" 1
273WriteUninstaller "uninstall.exe"
274
275; Write an entry for ShellExecute
276WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\josm.exe" "" '$INSTDIR\josm.exe'
277WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\josm.exe" "Path" '$INSTDIR'
278
279SectionEnd ; "Required"
280
281
282Section $(JOSM_SEC_JOSM) SecJosm
283;-------------------------------------------
284SectionIn 1
285SetOutPath $INSTDIR
286File "josm.exe"
287File "josm-tested.jar"
288
289; XXX - should be provided/done by josm.jar itself and not here!
290SetShellVarContext current
291SetOutPath "$APPDATA\JOSM"
292
293; don't overwrite existing bookmarks
294IfFileExists preferences dont_overwrite_bookmarks
295File "bookmarks"
296dont_overwrite_bookmarks:
297
298SectionEnd
299
300
301SectionGroup $(JOSM_SEC_PLUGINS_GROUP) SecPluginsGroup
302
303Section $(JOSM_SEC_OPENSTREETBUGS_PLUGIN) SecOpenStreetBugsPlugin
304;-------------------------------------------
305SectionIn 1 2
306SetShellVarContext current
307SetOutPath $APPDATA\JOSM\plugins
308File "..\dist\openstreetbugs.jar"
309SectionEnd
310
311Section $(JOSM_SEC_TURNRESTRICTIONS_PLUGIN) SecTurnrestrictionsPlugin
312;-------------------------------------------
313SectionIn 1 2
314SetShellVarContext current
315SetOutPath $APPDATA\JOSM\plugins
316File "..\dist\turnrestrictions.jar"
317SectionEnd
318
319Section $(JOSM_SEC_WMS) SecWMS
320;-------------------------------------------
321SectionIn 1 2
322SetShellVarContext current
323SetOutPath $INSTDIR\imageformats
324File "webkit-image\imageformats\qjpeg4.dll"
325SetOutPath $INSTDIR
326File "webkit-image\mingwm10.dll"
327File "webkit-image\QtCore4.dll"
328File "webkit-image\QtGui4.dll"
329File "webkit-image\QtNetwork4.dll"
330File "webkit-image\QtWebKit4.dll"
331File "webkit-image\webkit-image.exe"
332SectionEnd
333
334SectionGroupEnd ; "Plugins"
335
336Section $(JOSM_SEC_STARTMENU) SecStartMenu
337;-------------------------------------------
338SectionIn 1 2
339; To qoute "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch11d.asp":
340; "Do not include Readme, Help, or Uninstall entries on the Programs menu."
341CreateShortCut "$SMPROGRAMS\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" $(JOSM_LINK_TEXT)
342SectionEnd
343
344Section $(JOSM_SEC_DESKTOP_ICON) SecDesktopIcon
345;-------------------------------------------
346; SectionIn 1 2
347; Create desktop icon
348; Desktop icon for a program should not be installed as default!
349CreateShortCut "$DESKTOP\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" $(JOSM_LINK_TEXT)
350SectionEnd
351
352Section $(JOSM_SEC_QUICKLAUNCH_ICON) SecQuickLaunchIcon
353;-------------------------------------------
354SectionIn 1 2
355; Create quick launch icon
356CreateShortCut "$QUICKLAUNCH\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" $(JOSM_LINK_TEXT)
357SectionEnd
358
359Section $(JOSM_SEC_FILE_EXTENSIONS) SecFileExtensions
360;-------------------------------------------
361SectionIn 1 2
362; Create File Extensions
363WriteRegStr HKCR ${OSM_ASSOC} "" "OpenStreetMap data"
364WriteRegStr HKCR "${OSM_ASSOC}\Shell\open\command" "" '"$INSTDIR\josm.exe" "%1"'
365WriteRegStr HKCR "${OSM_ASSOC}\DefaultIcon" "" '"$INSTDIR\josm.exe",0'
366push $R0
367 StrCpy $R0 ".osm"
368 Call Associate
369 StrCpy $R0 ".gpx"
370 Call Associate
371; if somethings added here, add it also to the uninstall section
372pop $R0
373!insertmacro UpdateIcons
374SectionEnd
375
376
377Section "-PluginSetting"
378;-------------------------------------------
379SectionIn 1 2
380;MessageBox MB_OK "PluginSetting!" IDOK 0
381; XXX - should better be handled inside JOSM (recent plugin manager is going in the right direction)
382SetShellVarContext current
383!include LogicLib.nsh
384FileOpen $R0 "$APPDATA\JOSM\preferences.xml" w
385FileWrite $R0 "<?xml version='1.0' encoding='UTF-8'?><preferences xmlns='http://josm.openstreetmap.de/preferences-1.0' version='4660'><list key='plugins'><entry value='openstreetbugs'/><entry value='turnrestrictions'/></list></preferences>"
386FileClose $R0
387
388SectionEnd
389
390
391Section "un.$(un.JOSM_SEC_UNINSTALL)" un.SecUinstall
392;-------------------------------------------
393
394;
395; UnInstall for every user
396;
397SectionIn 1 2
398SetShellVarContext current
399
400Delete "$INSTDIR\josm-tested.jar"
401IfErrors 0 NoJOSMErrorMsg
402 MessageBox MB_OK $(un.JOSM_IN_USE_ERROR) IDOK 0 ;skipped if josm.jar removed
403 Abort $(un.JOSM_IN_USE_ERROR)
404NoJOSMErrorMsg:
405Delete "$INSTDIR\josm.exe"
406Delete "$INSTDIR\imageformats\qjpeg4.dll"
407RMDir "$INSTDIR\imageformats"
408Delete "$INSTDIR\mingwm10.dll"
409Delete "$INSTDIR\QtCore4.dll"
410Delete "$INSTDIR\QtGui4.dll"
411Delete "$INSTDIR\QtNetwork4.dll"
412Delete "$INSTDIR\QtWebKit4.dll"
413Delete "$INSTDIR\webkit-image.exe"
414Delete "$INSTDIR\uninstall.exe"
415
416DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM"
417DeleteRegKey HKEY_LOCAL_MACHINE "Software\josm.exe"
418DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\josm.exe"
419
420; Remove Language preference info
421DeleteRegKey HKCU "Software/JOSM" ;${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
422
423push $R0
424 StrCpy $R0 ".osm"
425 Call un.unlink
426 StrCpy $R0 ".gpx"
427 Call un.unlink
428pop $R0
429
430DeleteRegKey HKCR ${OSM_ASSOC}
431DeleteRegKey HKCR "${OSM_ASSOC}\Shell\open\command"
432DeleteRegKey HKCR "${OSM_ASSOC}\DefaultIcon"
433!insertmacro UpdateIcons
434
435Delete "$SMPROGRAMS\josm.lnk"
436Delete "$DESKTOP\josm.lnk"
437Delete "$QUICKLAUNCH\josm.lnk"
438
439RMDir "$INSTDIR"
440
441SectionEnd ; "Uinstall"
442
443Section /o "un.$(un.JOSM_SEC_PERSONAL_SETTINGS)" un.SecPersonalSettings
444;-------------------------------------------
445SectionIn 2
446SetShellVarContext current
447Delete "$APPDATA\JOSM\plugins\turnrestrictions\*.*"
448RMDir "$APPDATA\JOSM\plugins\turnrestrictions"
449Delete "$APPDATA\JOSM\plugins\openstreetbugs\*.*"
450RMDir "$APPDATA\JOSM\plugins\openstreetbugs"
451Delete "$APPDATA\JOSM\plugins\remotecontrol\*.*"
452RMDir "$APPDATA\JOSM\plugins\remotecontrol"
453Delete "$APPDATA\JOSM\plugins\validator\*.*"
454RMDir "$APPDATA\JOSM\plugins\validator"
455Delete "$APPDATA\JOSM\plugins\wmsplugin\*.*"
456RMDir "$APPDATA\JOSM\plugins\wmsplugin"
457Delete "$APPDATA\JOSM\plugins\*.*"
458RMDir "$APPDATA\JOSM\plugins"
459
460Delete "$APPDATA\JOSM\motd.html"
461Delete "$APPDATA\JOSM\preferences"
462Delete "$APPDATA\JOSM\bookmarks"
463RMDir "$APPDATA\JOSM"
464SectionEnd
465
466
467Section "-Un.Finally"
468;-------------------------------------------
469SectionIn 1 2
470; this test must be done after all other things uninstalled (e.g. Global Settings)
471IfFileExists "$INSTDIR" 0 NoFinalErrorMsg
472 MessageBox MB_OK $(un.JOSM_INSTDIR_ERROR) IDOK 0 ; skipped if dir doesn't exist
473NoFinalErrorMsg:
474SectionEnd
475
476
477; ============================================================================
478; PLEASE MAKE SURE, THAT THE DESCRIPTIVE TEXT FITS INTO THE DESCRIPTION FIELD!
479; ============================================================================
480!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
481 !insertmacro MUI_DESCRIPTION_TEXT ${SecJosm} $(JOSM_SECDESC_JOSM)
482 !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsGroup} $(JOSM_SECDESC_PLUGINS_GROUP)
483 !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenStreetBugsPlugin} $(JOSM_SECDESC_OPENSTREETBUGS_PLUGIN)
484 !insertmacro MUI_DESCRIPTION_TEXT ${SecTurnrestrictionsPlugin} $(JOSM_SECDESC_TURNRESTRICTIONS_PLUGIN)
485 !insertmacro MUI_DESCRIPTION_TEXT ${SecWMS} $(JOSM_SECDESC_WMS)
486 !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(JOSM_SECDESC_STARTMENU)
487 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopIcon} $(JOSM_SECDESC_DESKTOP_ICON)
488 !insertmacro MUI_DESCRIPTION_TEXT ${SecQuickLaunchIcon} $(JOSM_SECDESC_QUICKLAUNCH_ICON)
489 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileExtensions} $(JOSM_SECDESC_FILE_EXTENSIONS)
490
491
492!insertmacro MUI_FUNCTION_DESCRIPTION_END
493
494!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
495 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUinstall} $(un.JOSM_SECDESC_UNINSTALL)
496 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecPersonalSettings} $(un.JOSM_SECDESC_PERSONAL_SETTINGS)
497!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
498
499; ============================================================================
500; Callback functions
501; ============================================================================
502
Note: See TracBrowser for help on using the repository browser.