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

Last change on this file since 30580 was 30580, checked in by donvip, 10 years ago

[josm_nsis] see #josm5302 - prepare ground for 64-bit binaries

File size: 16.5 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; Used to refresh the display of file association
10!define SHCNE_ASSOCCHANGED 0x08000000
11!define SHCNF_IDLIST 0
12
13; Used to add associations between file extensions and JOSM
14!define OSM_ASSOC "josm-file"
15
16; ============================================================================
17; Header configuration
18; ============================================================================
19; The name of the installer
20!define PROGRAM_NAME "JOSM"
21
22Name "${PROGRAM_NAME} ${VERSION}"
23
24; The file to write
25OutFile "${DEST}-setup-${VERSION}.exe"
26
27XPStyle on
28
29Var /GLOBAL plugins
30
31; ============================================================================
32; Modern UI
33; ============================================================================
34
35!include "MUI.nsh"
36
37; Icon of installer and uninstaller
38!define MUI_ICON "logo.ico"
39!define MUI_UNICON "logo.ico"
40
41!define MUI_COMPONENTSPAGE_SMALLDESC
42!define MUI_FINISHPAGE_NOAUTOCLOSE
43!define MUI_UNFINISHPAGE_NOAUTOCLOSE
44!define MUI_WELCOMEFINISHPAGE_BITMAP "josm-nsis-brand.bmp"
45!define MUI_WELCOMEPAGE_TEXT $(JOSM_WELCOME_TEXT)
46
47!define MUI_FINISHPAGE_RUN "$INSTDIR\${DEST}.exe"
48
49
50; ============================================================================
51; MUI Pages
52; ============================================================================
53
54!insertmacro MUI_PAGE_WELCOME
55!insertmacro MUI_PAGE_LICENSE "..\core\LICENSE"
56!insertmacro MUI_PAGE_COMPONENTS
57;Page custom DisplayAdditionalTasksPage
58!insertmacro MUI_PAGE_DIRECTORY
59!insertmacro MUI_PAGE_INSTFILES
60!insertmacro MUI_PAGE_FINISH
61
62!insertmacro MUI_UNPAGE_WELCOME
63!insertmacro MUI_UNPAGE_CONFIRM
64!insertmacro MUI_UNPAGE_COMPONENTS
65!insertmacro MUI_UNPAGE_INSTFILES
66!insertmacro MUI_UNPAGE_FINISH
67
68; ============================================================================
69; MUI Languages
70; ============================================================================
71
72 ;Remember the installer language
73 !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
74 !define MUI_LANGDLL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM"
75 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
76
77 ;; English goes first because its the default. The rest are
78 ;; in alphabetical order (at least the strings actually displayed
79 ;; will be).
80
81 !insertmacro MUI_LANGUAGE "English"
82 !insertmacro MUI_LANGUAGE "French"
83 !insertmacro MUI_LANGUAGE "German"
84
85;--------------------------------
86;Translations
87
88 !define JOSM_DEFAULT_LANGFILE "locale\english.nsh"
89
90 !include "langmacros.nsh"
91
92 !insertmacro JOSM_MACRO_INCLUDE_LANGFILE "ENGLISH" "locale\english.nsh"
93 !insertmacro JOSM_MACRO_INCLUDE_LANGFILE "FRENCH" "locale\french.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 JOSM developers team, https://josm.openstreetmap.de"
268WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "HelpLink" "mailto:josm-dev@openstreetmap.org."
269WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "URLInfoAbout" "https://josm.openstreetmap.de"
270WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "URLUpdateInfo" "https://josm.openstreetmap.de"
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\${DEST}.exe" "" '$INSTDIR\${DEST}.exe'
277WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\${DEST}.exe" "Path" '$INSTDIR'
278
279SectionEnd ; "Required"
280
281
282Section $(JOSM_SEC_JOSM) SecJosm
283;-------------------------------------------
284SectionIn 1
285SetOutPath $INSTDIR
286File "${DEST}.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
293SectionEnd
294
295SectionGroup $(JOSM_SEC_PLUGINS_GROUP) SecPluginsGroup
296
297Section $(JOSM_SEC_TURNRESTRICTIONS_PLUGIN) SecTurnrestrictionsPlugin
298;-------------------------------------------
299SectionIn 1 2
300SetShellVarContext current
301SetOutPath $APPDATA\JOSM\plugins
302File "..\dist\turnrestrictions.jar"
303StrCpy $plugins "$plugins<entry value='turnrestrictions'/>"
304SectionEnd
305
306Section $(JOSM_SEC_WMS) SecWMS
307;-------------------------------------------
308SectionIn 1 2
309SetShellVarContext current
310SetOutPath $INSTDIR\imageformats
311File "webkit-image\imageformats\qjpeg4.dll"
312SetOutPath $INSTDIR
313File "webkit-image\mingwm10.dll"
314File "webkit-image\QtCore4.dll"
315File "webkit-image\QtGui4.dll"
316File "webkit-image\QtNetwork4.dll"
317File "webkit-image\QtWebKit4.dll"
318File "webkit-image\webkit-image.exe"
319SectionEnd
320
321SectionGroupEnd ; "Plugins"
322
323Section $(JOSM_SEC_STARTMENU) SecStartMenu
324;-------------------------------------------
325SectionIn 1 2
326; To quote "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch11d.asp":
327; "Do not include Readme, Help, or Uninstall entries on the Programs menu."
328CreateShortCut "$SMPROGRAMS\JOSM.lnk" "$INSTDIR\${DEST}.exe" "" "$INSTDIR\${DEST}.exe" 0 "" "" $(JOSM_LINK_TEXT)
329SectionEnd
330
331Section $(JOSM_SEC_DESKTOP_ICON) SecDesktopIcon
332;-------------------------------------------
333; Create desktop icon
334; Desktop icon for a program should not be installed as default!
335CreateShortCut "$DESKTOP\JOSM.lnk" "$INSTDIR\${DEST}.exe" "" "$INSTDIR\${DEST}.exe" 0 "" "" $(JOSM_LINK_TEXT)
336SectionEnd
337
338Section $(JOSM_SEC_QUICKLAUNCH_ICON) SecQuickLaunchIcon
339;-------------------------------------------
340; Create quick launch icon. Does not really exist as of Windows 7/8 but still advanced users use it.
341; Only disable it by default, see #10241
342CreateShortCut "$QUICKLAUNCH\JOSM.lnk" "$INSTDIR\${DEST}.exe" "" "$INSTDIR\${DEST}.exe" 0 "" "" $(JOSM_LINK_TEXT)
343SectionEnd
344
345Section $(JOSM_SEC_FILE_EXTENSIONS) SecFileExtensions
346;-------------------------------------------
347SectionIn 1 2
348; Create File Extensions
349WriteRegStr HKCR ${OSM_ASSOC} "" "OpenStreetMap data"
350WriteRegStr HKCR "${OSM_ASSOC}\Shell\open\command" "" '"$INSTDIR\${DEST}.exe" "%1"'
351WriteRegStr HKCR "${OSM_ASSOC}\DefaultIcon" "" '"$INSTDIR\${DEST}.exe",0'
352push $R0
353 StrCpy $R0 ".osm"
354 Call Associate
355 StrCpy $R0 ".gpx"
356 Call Associate
357; if somethings added here, add it also to the uninstall section
358pop $R0
359!insertmacro UpdateIcons
360SectionEnd
361
362
363Section "-PluginSetting"
364;-------------------------------------------
365SectionIn 1 2
366;MessageBox MB_OK "PluginSetting!" IDOK 0
367; XXX - should better be handled inside JOSM (recent plugin manager is going in the right direction)
368SetShellVarContext current
369!include LogicLib.nsh
370IfFileExists "$APPDATA\JOSM\preferences" settings_exists
371IfFileExists "$APPDATA\JOSM\preferences.xml" settings_exists
372FileOpen $R0 "$APPDATA\JOSM\preferences.xml" w
373FileWrite $R0 "<?xml version='1.0' encoding='UTF-8'?><preferences xmlns='http://josm.openstreetmap.de/preferences-1.0' version='4660'><list key='plugins'>$plugins</list></preferences>"
374FileClose $R0
375settings_exists:
376
377SectionEnd
378
379
380Section "un.$(un.JOSM_SEC_UNINSTALL)" un.SecUinstall
381;-------------------------------------------
382
383;
384; UnInstall for every user
385;
386SectionIn 1 2
387SetShellVarContext current
388
389Delete "$INSTDIR\josm-tested.jar"
390IfErrors 0 NoJOSMErrorMsg
391 MessageBox MB_OK $(un.JOSM_IN_USE_ERROR) IDOK 0 ;skipped if josm.jar removed
392 Abort $(un.JOSM_IN_USE_ERROR)
393NoJOSMErrorMsg:
394Delete "$INSTDIR\${DEST}.exe"
395Delete "$INSTDIR\imageformats\qjpeg4.dll"
396RMDir "$INSTDIR\imageformats"
397Delete "$INSTDIR\mingwm10.dll"
398Delete "$INSTDIR\QtCore4.dll"
399Delete "$INSTDIR\QtGui4.dll"
400Delete "$INSTDIR\QtNetwork4.dll"
401Delete "$INSTDIR\QtWebKit4.dll"
402Delete "$INSTDIR\webkit-image.exe"
403Delete "$INSTDIR\uninstall.exe"
404
405DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM"
406DeleteRegKey HKEY_LOCAL_MACHINE "Software\${DEST}.exe"
407DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\${DEST}.exe"
408
409; Remove Language preference info
410DeleteRegKey HKCU "Software/JOSM" ;${MUI_LANGDLL_REGISTRY_ROOT} ${MUI_LANGDLL_REGISTRY_KEY}
411
412push $R0
413 StrCpy $R0 ".osm"
414 Call un.unlink
415 StrCpy $R0 ".gpx"
416 Call un.unlink
417pop $R0
418
419DeleteRegKey HKCR ${OSM_ASSOC}
420DeleteRegKey HKCR "${OSM_ASSOC}\Shell\open\command"
421DeleteRegKey HKCR "${OSM_ASSOC}\DefaultIcon"
422!insertmacro UpdateIcons
423
424Delete "$SMPROGRAMS\josm.lnk"
425Delete "$DESKTOP\josm.lnk"
426Delete "$QUICKLAUNCH\josm.lnk"
427
428RMDir "$INSTDIR"
429
430SectionEnd ; "Uninstall"
431
432Section /o "un.$(un.JOSM_SEC_PERSONAL_SETTINGS)" un.SecPersonalSettings
433;-------------------------------------------
434SectionIn 2
435SetShellVarContext current
436Delete "$APPDATA\JOSM\plugins\turnrestrictions\*.*"
437RMDir "$APPDATA\JOSM\plugins\turnrestrictions"
438Delete "$APPDATA\JOSM\plugins\openstreetbugs\*.*"
439RMDir "$APPDATA\JOSM\plugins\openstreetbugs"
440Delete "$APPDATA\JOSM\plugins\*.*"
441RMDir "$APPDATA\JOSM\plugins"
442
443Delete "$APPDATA\JOSM\motd.html"
444Delete "$APPDATA\JOSM\preferences.xml"
445RMDir "$APPDATA\JOSM"
446SectionEnd
447
448
449Section "-Un.Finally"
450;-------------------------------------------
451SectionIn 1 2
452; this test must be done after all other things uninstalled (e.g. Global Settings)
453IfFileExists "$INSTDIR" 0 NoFinalErrorMsg
454 MessageBox MB_OK $(un.JOSM_INSTDIR_ERROR) IDOK 0 ; skipped if dir doesn't exist
455NoFinalErrorMsg:
456SectionEnd
457
458
459; ============================================================================
460; PLEASE MAKE SURE, THAT THE DESCRIPTIVE TEXT FITS INTO THE DESCRIPTION FIELD!
461; ============================================================================
462!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
463 !insertmacro MUI_DESCRIPTION_TEXT ${SecJosm} $(JOSM_SECDESC_JOSM)
464 !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsGroup} $(JOSM_SECDESC_PLUGINS_GROUP)
465 !insertmacro MUI_DESCRIPTION_TEXT ${SecTurnrestrictionsPlugin} $(JOSM_SECDESC_TURNRESTRICTIONS_PLUGIN)
466 !insertmacro MUI_DESCRIPTION_TEXT ${SecWMS} $(JOSM_SECDESC_WMS)
467 !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(JOSM_SECDESC_STARTMENU)
468 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopIcon} $(JOSM_SECDESC_DESKTOP_ICON)
469 !insertmacro MUI_DESCRIPTION_TEXT ${SecQuickLaunchIcon} $(JOSM_SECDESC_QUICKLAUNCH_ICON)
470 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileExtensions} $(JOSM_SECDESC_FILE_EXTENSIONS)
471
472
473!insertmacro MUI_FUNCTION_DESCRIPTION_END
474
475!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
476 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUinstall} $(un.JOSM_SECDESC_UNINSTALL)
477 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecPersonalSettings} $(un.JOSM_SECDESC_PERSONAL_SETTINGS)
478!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
479
480; ============================================================================
481; Callback functions
482; ============================================================================
483
Note: See TracBrowser for help on using the repository browser.