source: osm/applications/nsis/openstreetmap.nsi@ 2855

Last change on this file since 2855 was 2786, checked in by ulf, 18 years ago

slight enhancements of the build process,
the josm mappaint plugin doesn't need an elemstyles.xml file now

File size: 18.5 KB
Line 
1;
2; openstreetmap.nsi
3;
4
5
6; Set the compression mechanism first.
7; As of NSIS 2.07, solid compression which makes installer about 1MB smaller
8; is no longer the default, so use the /SOLID switch.
9; This unfortunately is unknown to NSIS prior to 2.07 and creates an error.
10; So if you get an error here, please update to at least NSIS 2.07!
11SetCompressor /SOLID lzma
12
13; work with JAVA ini strings
14!include "INIStrNS.nsh"
15
16!define DEST "openstreetmap"
17
18InstType "OpenStreetMap (full install)"
19
20InstType "un.Default (keep Personal Settings and plugins)"
21InstType "un.All (remove all)"
22
23; Used to refresh the display of file association
24!define SHCNE_ASSOCCHANGED 0x08000000
25!define SHCNF_IDLIST 0
26
27; Used to add associations between file extensions and JOSM
28!define OSM_ASSOC "josm-file"
29
30; ============================================================================
31; Header configuration
32; ============================================================================
33; The name of the installer
34!define PROGRAM_NAME "OpenStreetMap"
35
36Name "${PROGRAM_NAME} ${VERSION}"
37
38; The file to write
39OutFile "${DEST}-setup-${VERSION}.exe"
40
41; Uninstall stuff (NSIS 2.08: "\r\n" don't work here)
42!define MUI_UNCONFIRMPAGE_TEXT_TOP "The following OpenStreetMap installation will be uninstalled. Click 'Next' to continue."
43
44XPStyle on
45
46
47
48; ============================================================================
49; Modern UI
50; ============================================================================
51
52!include "MUI.nsh"
53;!addplugindir ".\Plugins"
54
55; Icon of installer and uninstaller
56!define MUI_ICON "logo.ico"
57!define MUI_UNICON "logo.ico"
58
59!define MUI_COMPONENTSPAGE_SMALLDESC
60!define MUI_FINISHPAGE_NOAUTOCLOSE
61!define MUI_UNFINISHPAGE_NOAUTOCLOSE
62!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of OpenStreetMap.\r\n\r\nBefore starting the installation, make sure any OpenStreetMap applications are not running.\r\n\r\nClick 'Next' to continue."
63;!define MUI_FINISHPAGE_LINK "Install WinPcap to be able to capture packets from a network!"
64;!define MUI_FINISHPAGE_LINK_LOCATION "http://www.winpcap.org"
65
66; NSIS shows Readme files by opening the Readme file with the default application for
67; the file's extension. "README.win32" won't work in most cases, because extension "win32"
68; is usually not associated with an appropriate text editor. We should use extension "txt"
69; for a text file or "html" for an html README file.
70;!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\NEWS.txt"
71;!define MUI_FINISHPAGE_SHOWREADME_TEXT "Show News"
72;!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
73!define MUI_FINISHPAGE_RUN "$INSTDIR\josm.exe"
74;!define MUI_FINISHPAGE_RUN_NOTCHECKED
75
76
77
78;!define MUI_PAGE_CUSTOMFUNCTION_SHOW myShowCallback
79
80; ============================================================================
81; MUI Pages
82; ============================================================================
83
84!insertmacro MUI_PAGE_WELCOME
85!insertmacro MUI_PAGE_LICENSE "downloads\LICENSE"
86!insertmacro MUI_PAGE_COMPONENTS
87;Page custom DisplayAdditionalTasksPage
88!insertmacro MUI_PAGE_DIRECTORY
89!insertmacro MUI_PAGE_INSTFILES
90!insertmacro MUI_PAGE_FINISH
91
92!insertmacro MUI_UNPAGE_WELCOME
93!insertmacro MUI_UNPAGE_CONFIRM
94!insertmacro MUI_UNPAGE_COMPONENTS
95!insertmacro MUI_UNPAGE_INSTFILES
96!insertmacro MUI_UNPAGE_FINISH
97
98; ============================================================================
99; MUI Languages
100; ============================================================================
101
102!insertmacro MUI_LANGUAGE "English"
103
104; ============================================================================
105; Reserve Files
106; ============================================================================
107
108 ;Things that need to be extracted on first (keep these lines before any File command!)
109 ;Only useful for BZIP2 compression
110
111; ReserveFile "AdditionalTasksPage.ini"
112!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
113
114; ============================================================================
115; Section macros
116; ============================================================================
117!include "Sections.nsh"
118
119; ========= Macro to unselect and disable a section =========
120
121!macro DisableSection SECTION
122
123 Push $0
124 SectionGetFlags "${SECTION}" $0
125 IntOp $0 $0 & ${SECTION_OFF}
126 IntOp $0 $0 | ${SF_RO}
127 SectionSetFlags "${SECTION}" $0
128 Pop $0
129
130!macroend
131
132; ========= Macro to enable (unreadonly) a section =========
133!define SECTION_ENABLE 0xFFFFFFEF
134!macro EnableSection SECTION
135
136 Push $0
137 SectionGetFlags "${SECTION}" $0
138 IntOp $0 $0 & ${SECTION_ENABLE}
139 SectionSetFlags "${SECTION}" $0
140 Pop $0
141
142!macroend
143
144; ============================================================================
145; Command Line
146; ============================================================================
147!include "FileFunc.nsh"
148
149;!insertmacro GetParameters
150;!insertmacro GetOptions
151
152; ============================================================================
153; Directory selection page configuration
154; ============================================================================
155; The text to prompt the user to enter a directory
156DirText "Choose a directory in which to install OpenStreeMap."
157
158; The default installation directory
159InstallDir $PROGRAMFILES\OpenStreetMap\
160
161; See if this is an upgrade; if so, use the old InstallDir as default
162InstallDirRegKey HKEY_LOCAL_MACHINE SOFTWARE\OpenStreetMap "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 "Can't find 'shell32.dll' library. Impossible to update icons"
194 Goto UpdateIcons.quit_${UPDATEICONS_UNIQUE}
195UpdateIcons.error2_${UPDATEICONS_UNIQUE}:
196 MessageBox MB_OK|MB_ICONINFORMATION "You should install the free 'Microsoft Layer for Unicode' to update OpenStreetMap file icons"
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 OpenStreetMap
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 OpenStreetMap 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"
239FunctionEnd
240
241;Function DisplayAdditionalTasksPage
242; !insertmacro MUI_HEADER_TEXT "Select Additional Tasks" "Which additional tasks should be done?"
243; !insertmacro MUI_INSTALLOPTIONS_DISPLAY "AdditionalTasksPage.ini"
244;FunctionEnd
245
246; ============================================================================
247; Installation execution commands
248; ============================================================================
249
250Section "-Required"
251;-------------------------------------------
252
253;
254; Install for every user
255;
256SectionIn 1 2 RO
257SetShellVarContext all
258
259SetOutPath $INSTDIR
260
261; Write the uninstall keys for Windows
262WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "DisplayVersion" "${VERSION}"
263WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "DisplayName" "OpenStreetMap ${VERSION}"
264WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "UninstallString" '"$INSTDIR\uninstall.exe"'
265WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "Publisher" "The OpenStreetMap developer community, http://www.openstreetmap.org/"
266WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "HelpLink" "mailto:newbies@openstreetmap.org."
267WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "URLInfoAbout" "http://www.openstreetmap.org/"
268WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "URLUpdateInfo" "http://www.openstreetmap.org/"
269WriteRegDWORD HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "NoModify" 1
270WriteRegDWORD HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\OSM" "NoRepair" 1
271WriteUninstaller "uninstall.exe"
272
273; Write an entry for ShellExecute
274WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\josm.exe" "" '$INSTDIR\josm.exe'
275WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\josm.exe" "Path" '$INSTDIR'
276
277; Create start menu entries (depending on additional tasks page)
278;ReadINIStr $0 "$PLUGINSDIR\AdditionalTasksPage.ini" "Field 2" "State"
279;StrCmp $0 "0" SecRequired_skip_StartMenu
280; To qoute "http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch11d.asp":
281; "Do not include Readme, Help, or Uninstall entries on the Programs menu."
282CreateShortCut "$SMPROGRAMS\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" "JAVA OpenStreetMap - Editor"
283;SecRequired_skip_StartMenu:
284
285; is command line option "/desktopicon" set?
286;${GetParameters} $R0
287;${GetOptions} $R0 "/desktopicon=" $R1
288;StrCmp $R1 "no" SecRequired_skip_DesktopIcon
289;StrCmp $R1 "yes" SecRequired_install_DesktopIcon
290
291; Create desktop icon (depending on additional tasks page and command line option)
292;ReadINIStr $0 "$PLUGINSDIR\AdditionalTasksPage.ini" "Field 3" "State"
293;StrCmp $0 "0" SecRequired_skip_DesktopIcon
294;SecRequired_install_DesktopIcon:
295CreateShortCut "$DESKTOP\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" "JAVA OpenStreetMap - Editor"
296;SecRequired_skip_DesktopIcon:
297
298; is command line option "/quicklaunchicon" set?
299;${GetParameters} $R0
300;${GetOptions} $R0 "/quicklaunchicon=" $R1
301;StrCmp $R1 "no" SecRequired_skip_QuickLaunchIcon
302;StrCmp $R1 "yes" SecRequired_install_QuickLaunchIcon
303
304; Create quick launch icon (depending on additional tasks page and command line option)
305;ReadINIStr $0 "$PLUGINSDIR\AdditionalTasksPage.ini" "Field 4" "State"
306;StrCmp $0 "0" SecRequired_skip_QuickLaunchIcon
307;SecRequired_install_QuickLaunchIcon:
308CreateShortCut "$QUICKLAUNCH\JOSM.lnk" "$INSTDIR\josm.exe" "" "$INSTDIR\josm.exe" 0 "" "" "JAVA OpenStreetMap - Editor"
309;SecRequired_skip_QuickLaunchIcon:
310
311; Create File Extensions (depending on additional tasks page)
312;ReadINIStr $0 "$PLUGINSDIR\AdditionalTasksPage.ini" "Field 6" "State"
313;StrCmp $0 "0" SecRequired_skip_FileExtensions
314WriteRegStr HKCR ${OSM_ASSOC} "" "OpenStreetMap data"
315WriteRegStr HKCR "${OSM_ASSOC}\Shell\open\command" "" '"$INSTDIR\josm.exe" "%1"'
316WriteRegStr HKCR "${OSM_ASSOC}\DefaultIcon" "" '"$INSTDIR\josm.exe",0'
317push $R0
318 StrCpy $R0 ".osm"
319 Call Associate
320 StrCpy $R0 ".gpx"
321 Call Associate
322; if somethings added here, add it also to the uninstall section and the AdditionalTask page
323pop $R0
324!insertmacro UpdateIcons
325;SecRequired_skip_FileExtensions:
326
327SectionEnd ; "Required"
328
329
330Section "JOSM" SecJosm
331;-------------------------------------------
332SectionIn 1
333SetOutPath $INSTDIR
334File "josm.exe"
335SetShellVarContext current
336SetOutPath "$APPDATA\JOSM"
337
338; don't overwrite existing bookmarks
339IfFileExists preferences dont_overwrite_bookmarks
340File "bookmarks"
341dont_overwrite_bookmarks:
342
343; don't overwrite existing de_streets.xml file
344IfFileExists de-streets.xml dont_overwrite_de_streets
345File "de-streets.xml"
346dont_overwrite_de_streets:
347
348; write reasonable defaults for some preferences
349; XXX - some of this should be done in JOSM itself
350${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "laf" "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
351${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "download.osm" "true"
352${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "layerlist.visible" "true"
353${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "commandstack.visible" "true"
354${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "propertiesdialog.visible" "true"
355${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "draw.segment.direction" "true"
356${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "projection" "org.openstreetmap.josm.data.projection.Epsg4326"
357${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "osm-server.url" "http://www.openstreetmap.org/api"
358${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "annotation.sources" "$APPDATA/JOSM/de-streets.xml"
359SectionEnd
360
361
362SectionGroup /e "Plugins" SecPluginsGroup
363
364Section "mappaint" SecMappaintPlugin
365;-------------------------------------------
366SectionIn 1 2
367SetShellVarContext current
368SetOutPath $APPDATA\JOSM\plugins
369File "downloads\mappaint.jar"
370;SetOutPath $APPDATA\JOSM\plugins\mappaint
371;File "downloads\elemstyles.xml"
372SectionEnd
373
374Section "osmarender" SecOsmarenderPlugin
375;-------------------------------------------
376SectionIn 1 2
377SetShellVarContext current
378SetOutPath $APPDATA\JOSM\plugins
379File "downloads\osmarender.jar"
380${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "osmarender.firefox" "$PROGRAMFILES\Mozilla Firefox\firefox.exe"
381SectionEnd
382
383Section "WMS" SecWMSPlugin
384;-------------------------------------------
385SectionIn 1 2
386SetShellVarContext current
387SetOutPath $APPDATA\JOSM\plugins
388File "downloads\wmsplugin.jar"
389SectionEnd
390
391SectionGroupEnd ; "Plugins"
392
393Section "-PluginSetting"
394;-------------------------------------------
395;MessageBox MB_OK "PluginSetting!" IDOK 0
396SetShellVarContext current
397${WriteINIStrNS} $R0 "$APPDATA\JOSM\preferences" "plugins" "mappaint,osmarender,wmsplugin"
398SectionEnd
399
400
401Section "Uninstall" un.SecUinstall
402;-------------------------------------------
403
404;
405; UnInstall for every user
406;
407SectionIn 1 2
408SetShellVarContext all
409
410Delete "$INSTDIR\josm.exe"
411Delete "$INSTDIR\uninstall.exe"
412IfErrors 0 NoJOSMErrorMsg
413 MessageBox MB_OK "Please note: josm.exe could not be removed, it's probably in use!" IDOK 0 ;skipped if josm.exe removed
414 Abort "Please note: josm.exe could not be removed, it's probably in use! Abort uninstall process!"
415NoJOSMErrorMsg:
416
417DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\Uninstall\JOSM"
418DeleteRegKey HKEY_LOCAL_MACHINE "Software\josm.exe"
419DeleteRegKey HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\josm.exe"
420
421push $R0
422 StrCpy $R0 ".osm"
423 Call un.unlink
424 StrCpy $R0 ".gpx"
425 Call un.unlink
426pop $R0
427
428DeleteRegKey HKCR ${OSM_ASSOC}
429DeleteRegKey HKCR "${OSM_ASSOC}\Shell\open\command"
430DeleteRegKey HKCR "${OSM_ASSOC}\DefaultIcon"
431!insertmacro UpdateIcons
432
433Delete "$SMPROGRAMS\josm.lnk"
434Delete "$DESKTOP\josm.lnk"
435Delete "$QUICKLAUNCH\josm.lnk"
436
437RMDir "$INSTDIR"
438
439SectionEnd ; "Uinstall"
440
441Section /o "Un.Personal Settings" un.SecPersonalSettings
442;-------------------------------------------
443SectionIn 2
444SetShellVarContext current
445Delete "$APPDATA\JOSM\preferences"
446Delete "$APPDATA\JOSM\bookmarks"
447RMDir "$APPDATA\JOSM"
448SectionEnd
449
450Section /o "Un.Plugins" un.SecPlugins
451;-------------------------------------------
452SectionIn 2
453SetShellVarContext current
454Delete "$APPDATA\JOSM\plugins\wmsplugin.jar"
455Delete "$APPDATA\JOSM\plugins\osmarender.jar"
456Delete "$APPDATA\JOSM\plugins\osmarender\*.*"
457Delete "$APPDATA\JOSM\plugins\mappaint.jar"
458;Delete "$APPDATA\JOSM\plugins\mappaint\elemstyles.xml"
459RMDir "$APPDATA\JOSM\plugins\osmarender"
460;RMDir "$APPDATA\JOSM\plugins\mappaint"
461RMDir "$APPDATA\JOSM\plugins"
462RMDir "$APPDATA\JOSM"
463SectionEnd
464
465
466Section "-Un.Finally"
467;-------------------------------------------
468SectionIn 1 2
469; this test must be done after all other things uninstalled (e.g. Global Settings)
470IfFileExists "$INSTDIR" 0 NoFinalErrorMsg
471 MessageBox MB_OK "Please note: The directory $INSTDIR could not be removed!" IDOK 0 ; skipped if dir doesn't exist
472NoFinalErrorMsg:
473SectionEnd
474
475
476; ============================================================================
477; PLEASE MAKE SURE, THAT THE DESCRIPTIVE TEXT FITS INTO THE DESCRIPTION FIELD!
478; ============================================================================
479!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
480 !insertmacro MUI_DESCRIPTION_TEXT ${SecJosm} "JOSM is the JAVA OpenStreetMap editor for .osm files."
481 !insertmacro MUI_DESCRIPTION_TEXT ${SecPluginsGroup} "Various JOSM plugins."
482 !insertmacro MUI_DESCRIPTION_TEXT ${SecMappaintPlugin} "An alternative renderer for the map with colouring, line thickness, icons after tags."
483 !insertmacro MUI_DESCRIPTION_TEXT ${SecOsmarenderPlugin} "Displays the current screen as nicely rendered SVG graphics in FireFox."
484 !insertmacro MUI_DESCRIPTION_TEXT ${SecWMSPlugin} "Display background images from Web Map Service (WMS) sources."
485!insertmacro MUI_FUNCTION_DESCRIPTION_END
486
487!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
488 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecUinstall} "Uninstall JOSM."
489 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecPersonalSettings} "Uninstall personal settings like your preferences and bookmarks from your profile: $PROFILE."
490 !insertmacro MUI_DESCRIPTION_TEXT ${un.SecPlugins} "Uninstall all plugins."
491!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
492
493; ============================================================================
494; Callback functions
495; ============================================================================
496
Note: See TracBrowser for help on using the repository browser.