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

Last change on this file since 2683 was 2601, checked in by ulf, 18 years ago

very first (alpha) version of an osm Win32 installer

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