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

Last change on this file since 27246 was 27246, checked in by donvip, 13 years ago

Add French locale for JOSM Windows installer

File size: 17.1 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 "French"
85 !insertmacro MUI_LANGUAGE "German"
86
87;--------------------------------
88;Translations
89
90 !define JOSM_DEFAULT_LANGFILE "locale\english.nsh"
91
92 !include "langmacros.nsh"
93
94 !insertmacro JOSM_MACRO_INCLUDE_LANGFILE "ENGLISH" "locale\english.nsh"
95 !insertmacro JOSM_MACRO_INCLUDE_LANGFILE "FRENCH" "locale\french.nsh"
96 !insertmacro JOSM_MACRO_INCLUDE_LANGFILE "GERMAN" "locale\german.nsh"
97
98; Uninstall stuff
99!define MUI_UNCONFIRMPAGE_TEXT_TOP ${un.JOSM_UNCONFIRMPAGE_TEXT_TOP}
100
101; ============================================================================
102; Installation types
103; ============================================================================
104
105InstType "$(JOSM_FULL_INSTALL)"
106
107InstType "un.$(un.JOSM_DEFAULT_UNINSTALL)"
108InstType "un.$(un.JOSM_FULL_UNINSTALL)"
109
110; ============================================================================
111; Reserve Files
112; ============================================================================
113
114 ;Things that need to be extracted on first (keep these lines before any File command!)
115 ;Only useful for BZIP2 compression
116
117!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
118
119; ============================================================================
120; Section macros
121; ============================================================================
122!include "Sections.nsh"
123
124; ========= Macro to unselect and disable a section =========
125
126!macro DisableSection SECTION
127
128 Push $0
129 SectionGetFlags "${SECTION}" $0
130 IntOp $0 $0 & ${SECTION_OFF}
131 IntOp $0 $0 | ${SF_RO}
132 SectionSetFlags "${SECTION}" $0
133 Pop $0
134
135!macroend
136
137; ========= Macro to enable (unreadonly) a section =========
138!define SECTION_ENABLE 0xFFFFFFEF
139!macro EnableSection SECTION
140
141 Push $0
142 SectionGetFlags "${SECTION}" $0
143 IntOp $0 $0 & ${SECTION_ENABLE}
144 SectionSetFlags "${SECTION}" $0
145 Pop $0
146
147!macroend
148
149; ============================================================================
150; Command Line
151; ============================================================================
152!include "FileFunc.nsh"
153
154; ============================================================================
155; Directory selection page configuration
156; ============================================================================
157; The text to prompt the user to enter a directory
158DirText $(JOSM_DIR_TEXT)
159
160; The default installation directory
161InstallDir $PROGRAMFILES\JOSM\
162
163; See if this is an upgrade; if so, use the old InstallDir as default
164InstallDirRegKey HKEY_LOCAL_MACHINE SOFTWARE\JOSM "InstallDir"
165
166
167; ============================================================================
168; Install page configuration
169; ============================================================================
170ShowInstDetails show
171ShowUninstDetails show
172
173; ============================================================================
174; Functions and macros
175; ============================================================================
176
177; update file extension icons
178!macro UpdateIcons
179 Push $R0
180 Push $R1
181 Push $R2
182
183 !define UPDATEICONS_UNIQUE ${__LINE__}
184
185 IfFileExists "$SYSDIR\shell32.dll" UpdateIcons.next1_${UPDATEICONS_UNIQUE} UpdateIcons.error1_${UPDATEICONS_UNIQUE}
186UpdateIcons.next1_${UPDATEICONS_UNIQUE}:
187 GetDllVersion "$SYSDIR\shell32.dll" $R0 $R1
188 IntOp $R2 $R0 / 0x00010000
189 IntCmp $R2 4 UpdateIcons.next2_${UPDATEICONS_UNIQUE} UpdateIcons.error2_${UPDATEICONS_UNIQUE}
190UpdateIcons.next2_${UPDATEICONS_UNIQUE}:
191 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
192 Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
193
194UpdateIcons.error1_${UPDATEICONS_UNIQUE}:
195 MessageBox MB_OK|MB_ICONSTOP $(JOSM_UPDATEICONS_ERROR1)
196 Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
197UpdateIcons.error2_${UPDATEICONS_UNIQUE}:
198 MessageBox MB_OK|MB_ICONINFORMATION $(JOSM_UPDATEICONS_ERROR2)
199 Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
200UpdateIcons.quit_${UPDATEICONS_UNIQUE}:
201 !undef UPDATEICONS_UNIQUE
202 Pop $R2
203 Pop $R1
204 Pop $R0
205
206!macroend
207
208; associate a file extension to an icon
209Function Associate
210 ; $R0 should contain the prefix to associate to JOSM
211 Push $R1
212
213 ReadRegStr $R1 HKCR $R0 ""
214 StrCmp $R1 "" Associate.doRegister
215 Goto Associate.end
216Associate.doRegister:
217 ;The extension is not associated to any program, we can do the link
218 WriteRegStr HKCR $R0 "" ${OSM_ASSOC}
219Associate.end:
220 pop $R1
221FunctionEnd
222
223; disassociate a file extension from an icon
224Function un.unlink
225 ; $R0 should contain the prefix to unlink
226 Push $R1
227
228 ReadRegStr $R1 HKCR $R0 ""
229 StrCmp $R1 ${OSM_ASSOC} un.unlink.doUnlink
230 Goto un.unlink.end
231un.unlink.doUnlink:
232 ; The extension is associated with JOSM so, we must destroy this!
233 DeleteRegKey HKCR $R0
234un.unlink.end:
235 pop $R1
236FunctionEnd
237
238Function .onInit
239 ;Extract InstallOptions INI files
240; !insertmacro MUI_INSTALLOPTIONS_EXTRACT "AdditionalTasksPage.ini"
241 !insertmacro MUI_LANGDLL_DISPLAY
242FunctionEnd
243
244Function un.onInit
245
246 !insertmacro MUI_UNGETLANGUAGE
247
248FunctionEnd
249
250; ============================================================================
251; Installation execution commands
252; ============================================================================
253
254Section "-Required"
255;-------------------------------------------
256
257;
258; Install for every user
259;
260SectionIn 1 2 RO
261SetShellVarContext current
262
263SetOutPath $INSTDIR
264
265; Write the uninstall keys for Windows
266WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "DisplayVersion" "${VERSION}"
267WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "DisplayName" "JOSM ${VERSION}"
268WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "UninstallString" '"$INSTDIR\uninstall.exe"'
269WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "Publisher" "The OpenStreetMap developer community, http://www.openstreetmap.org/"
270WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "HelpLink" "mailto:newbies@openstreetmap.org."
271WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "URLInfoAbout" "http://www.openstreetmap.org/"
272WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "URLUpdateInfo" "http://wiki.openstreetmap.org/index.php/JOSM"
273WriteRegDWORD HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "NoModify" 1
274WriteRegDWORD HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "NoRepair" 1
275WriteUninstaller "uninstall.exe"
276
277; Write an entry for ShellExecute
278WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\josm.exe" "" '$INSTDIR\josm.exe'
279WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\josm.exe" "Path" '$INSTDIR'
280
281SectionEnd ; "Required"
282
283
284Section $(JOSM_SEC_JOSM) SecJosm
285;-------------------------------------------
286SectionIn 1
287SetOutPath $INSTDIR
288File "josm.exe"
289File "josm-tested.jar"
290
291; XXX - should be provided/done by josm.jar itself and not here!
292SetShellVarContext current
293SetOutPath "$APPDATA\JOSM"
294
295SectionEnd
296
297
298SectionGroup $(JOSM_SEC_PLUGINS_GROUP) SecPluginsGroup
299
300Section $(JOSM_SEC_OPENSTREETBUGS_PLUGIN) SecOpenStreetBugsPlugin
301;-------------------------------------------
302SectionIn 1 2
303SetShellVarContext current
304SetOutPath $APPDATA\JOSM\plugins
305File "..\dist\openstreetbugs.jar"
306SectionEnd
307
308Section $(JOSM_SEC_TURNRESTRICTIONS_PLUGIN) SecTurnrestrictionsPlugin
309;-------------------------------------------
310SectionIn 1 2
311SetShellVarContext current
312SetOutPath $APPDATA\JOSM\plugins
313File "..\dist\turnrestrictions.jar"
314SectionEnd
315
316Section $(JOSM_SEC_WMS) SecWMS
317;-------------------------------------------
318SectionIn 1 2
319SetShellVarContext current
320SetOutPath $INSTDIR\imageformats
321File "webkit-image\imageformats\qjpeg4.dll"
322SetOutPath $INSTDIR
323File "webkit-image\mingwm10.dll"
324File "webkit-image\QtCore4.dll"
325File "webkit-image\QtGui4.dll"
326File "webkit-image\QtNetwork4.dll"
327File "webkit-image\QtWebKit4.dll"
328File "webkit-image\webkit-image.exe"
329SectionEnd
330
331SectionGroupEnd ; "Plugins"
332
333Section $(JOSM_SEC_STARTMENU) SecStartMenu
334;-------------------------------------------
335SectionIn 1 2
336; To quote "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch11d.asp":
337; "Do not include Readme, Help, or Uninstall entries on the Programs menu."
338CreateShortCut "$SMPROGRAMS\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" $(JOSM_LINK_TEXT)
339SectionEnd
340
341Section $(JOSM_SEC_DESKTOP_ICON) SecDesktopIcon
342;-------------------------------------------
343; SectionIn 1 2
344; Create desktop icon
345; Desktop icon for a program should not be installed as default!
346CreateShortCut "$DESKTOP\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" $(JOSM_LINK_TEXT)
347SectionEnd
348
349Section $(JOSM_SEC_QUICKLAUNCH_ICON) SecQuickLaunchIcon
350;-------------------------------------------
351SectionIn 1 2
352; Create quick launch icon
353CreateShortCut "$QUICKLAUNCH\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" $(JOSM_LINK_TEXT)
354SectionEnd
355
356Section $(JOSM_SEC_FILE_EXTENSIONS) SecFileExtensions
357;-------------------------------------------
358SectionIn 1 2
359; Create File Extensions
360WriteRegStr HKCR ${OSM_ASSOC} "" "OpenStreetMap data"
361WriteRegStr HKCR "${OSM_ASSOC}\Shell\open\command" "" '"$INSTDIR\josm.exe" "%1"'
362WriteRegStr HKCR "${OSM_ASSOC}\DefaultIcon" "" '"$INSTDIR\josm.exe",0'
363push $R0
364 StrCpy $R0 ".osm"
365 Call Associate
366 StrCpy $R0 ".gpx"
367 Call Associate
368; if somethings added here, add it also to the uninstall section
369pop $R0
370!insertmacro UpdateIcons
371SectionEnd
372
373
374Section "-PluginSetting"
375;-------------------------------------------
376SectionIn 1 2
377;MessageBox MB_OK "PluginSetting!" IDOK 0
378; XXX - should better be handled inside JOSM (recent plugin manager is going in the right direction)
379SetShellVarContext current
380!include LogicLib.nsh
381IfFileExists "$APPDATA\JOSM\preferences" settings_exists
382IfFileExists "$APPDATA\JOSM\preferences.xml" settings_exists
383FileOpen $R0 "$APPDATA\JOSM\preferences.xml" w
384FileWrite $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>"
385FileClose $R0
386settings_exists:
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 ; "Uninstall"
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\preferences.xml"
463Delete "$APPDATA\JOSM\bookmarks"
464RMDir "$APPDATA\JOSM"
465SectionEnd
466
467
468Section "-Un.Finally"
469;-------------------------------------------
470SectionIn 1 2
471; this test must be done after all other things uninstalled (e.g. Global Settings)
472IfFileExists "$INSTDIR" 0 NoFinalErrorMsg
473 MessageBox MB_OK $(un.JOSM_INSTDIR_ERROR) IDOK 0 ; skipped if dir doesn't exist
474NoFinalErrorMsg:
475SectionEnd
476
477
478; ============================================================================
479; PLEASE MAKE SURE, THAT THE DESCRIPTIVE TEXT FITS INTO THE DESCRIPTION FIELD!
480; ============================================================================
481!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
482 !insertmacro MUI_DESCRIPTION_TEXT ${SecJosm} $(JOSM_SECDESC_JOSM)
483 !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsGroup} $(JOSM_SECDESC_PLUGINS_GROUP)
484 !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenStreetBugsPlugin} $(JOSM_SECDESC_OPENSTREETBUGS_PLUGIN)
485 !insertmacro MUI_DESCRIPTION_TEXT ${SecTurnrestrictionsPlugin} $(JOSM_SECDESC_TURNRESTRICTIONS_PLUGIN)
486 !insertmacro MUI_DESCRIPTION_TEXT ${SecWMS} $(JOSM_SECDESC_WMS)
487 !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(JOSM_SECDESC_STARTMENU)
488 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopIcon} $(JOSM_SECDESC_DESKTOP_ICON)
489 !insertmacro MUI_DESCRIPTION_TEXT ${SecQuickLaunchIcon} $(JOSM_SECDESC_QUICKLAUNCH_ICON)
490 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileExtensions} $(JOSM_SECDESC_FILE_EXTENSIONS)
491
492
493!insertmacro MUI_FUNCTION_DESCRIPTION_END
494
495!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
496 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUinstall} $(un.JOSM_SECDESC_UNINSTALL)
497 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecPersonalSettings} $(un.JOSM_SECDESC_PERSONAL_SETTINGS)
498!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
499
500; ============================================================================
501; Callback functions
502; ============================================================================
503
Note: See TracBrowser for help on using the repository browser.