minor
[cdm-server.git] / src / main / installer / win32 / setup.nsi
1 # Auto-generated by EclipseNSIS Script Wizard
2 # 28.10.2010 13:58:54
3
4 # TODO : preserve $INSTDIR/.cdmLibrary from being deleted if the user desides to keep it, or just warn the user.
5
6 Name "EDIT CDM-Server"
7
8 # General Symbol Definitions
9 !define REGKEY "SOFTWARE\$(^Name)"
10 !define VERSION 3.0
11 !define COMPANY "EDIT - European Distributed Institute of Taxonomy"
12 !define EDIT_PLATFORM "EDIT Platform for Cybertaxonomy"
13 !define URL http://wp5.e-taxonomy.eu/
14 !define URL-EDIT http://www.e-taxonomy.eu/
15
16 # Included files
17 !include Sections.nsh
18
19 # Files and Folders
20 !define OUT_FOLDER "..\..\..\..\dist"
21 !define JAR_FILE_NAME "cdm-server-${VERSION}.jar"
22 !define JAR_FILE "..\..\..\..\target\${JAR_FILE_NAME}"
23 !define CDMLIBRARY_TEMPLATE "..\templates\.cdmLibrary"
24
25 # Reserved Files
26 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
27
28 # Variables
29 Var StartMenuGroup
30
31 # Installer pages
32 Page license
33 Page directory
34 Page custom StartMenuGroupSelect "" ": Start Menu Folder"
35 Page instfiles
36
37 # Installer attributes
38 OutFile "${OUT_FOLDER}\EDIT CDM-Server-${VERSION}.exe"
39 InstallDir "$PROGRAMFILES\EDIT CDM-Server"
40 CRCCheck on
41 XPStyle on
42 Icon "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
43 ShowInstDetails show
44 AutoCloseWindow false
45 LicenseData ..\..\..\..\LICENSE.TXT
46 VIProductVersion 2.5.0.0
47 VIAddVersionKey ProductName "$(^Name)"
48 VIAddVersionKey ProductVersion "${VERSION}"
49 VIAddVersionKey CompanyName "${COMPANY}"
50 VIAddVersionKey CompanyWebsite "${URL}"
51 VIAddVersionKey FileVersion "${VERSION}"
52 VIAddVersionKey FileDescription ""
53 VIAddVersionKey LegalCopyright ""
54 InstallDirRegKey HKLM "${REGKEY}" Path
55 UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
56 ShowUninstDetails show
57
58 # Installer sections
59 Section -Main SEC0000
60 SetOutPath $INSTDIR
61 SetOverwrite on
62 File /r /x .svn /x *.log /x *.jar program-folder\*
63 SetOutPath "$INSTDIR\lib"
64 File ${JAR_FILE}
65 # last but not least the .cdmLibrary folder unlesses it already exists
66 SetOverwrite off
67 SetOutPath $INSTDIR
68 File /r /x .svn ${CDMLIBRARY_TEMPLATE}
69 WriteRegStr HKLM "${REGKEY}\Components" Main 1
70 SectionEnd
71
72 Section -post SEC0001
73 WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
74 WriteRegStr HKLM "${REGKEY}" StartMenuGroup $StartMenuGroup
75 SetOutPath $INSTDIR
76 WriteUninstaller $INSTDIR\uninstall.exe
77 SetOutPath $SMPROGRAMS\$StartMenuGroup
78 CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe
79 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
80 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
81 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
82 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
83 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
84 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
85 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
86 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
87
88 ExecWait '"$INSTDIR\CDMServer.exe" --install "$INSTDIR\etc\CDMServer.conf$\"'
89 ExecWait '"$INSTDIR\CDMServer.exe" --start "$INSTDIR\etc\CDMServer.conf$\"'
90 SectionEnd
91
92 Section -AdditionalIcons SEC0003
93 SetOutPath $INSTDIR
94 WriteIniStr "$INSTDIR\${EDIT_PLATFORM}.url" "InternetShortcut" "URL" "${URL}"
95 WriteIniStr "$INSTDIR\${COMPANY}.url" "InternetShortcut" "URL" "${URL-EDIT}"
96 CreateDirectory "$SMPROGRAMS\$(^Name)"
97 CreateShortCut "$SMPROGRAMS\$(^Name)\${EDIT_PLATFORM}.lnk" "$INSTDIR\${EDIT_PLATFORM}.url"
98 CreateShortCut "$SMPROGRAMS\$(^Name)\${COMPANY}.lnk" "$INSTDIR\${COMPANY}.url"
99 CreateShortCut "$SMPROGRAMS\$(^Name)\Uninstall $(^Name).lnk" "$INSTDIR\uninstall.exe"
100 CreateShortCut "$SMPROGRAMS\$(^Name)\Start $(^Name).lnk" "$INSTDIR\start-service.bat"
101 CreateShortCut "$SMPROGRAMS\$(^Name)\Stop $(^Name).lnk" "$INSTDIR\stop-service.bat"
102 SectionEnd
103
104 # Macro for selecting uninstaller sections
105 !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
106 Push $R0
107 ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
108 StrCmp $R0 1 0 next${UNSECTION_ID}
109 !insertmacro SelectSection "${UNSECTION_ID}"
110 GoTo done${UNSECTION_ID}
111 next${UNSECTION_ID}:
112 !insertmacro UnselectSection "${UNSECTION_ID}"
113 done${UNSECTION_ID}:
114 Pop $R0
115 !macroend
116
117 # Uninstaller sections
118 Section /o -un.Main UNSEC0000
119 ExecWait '"$INSTDIR\CDMServer.exe" --remove "$INSTDIR\etc\CDMServer.conf$\"'
120 RmDir /r /REBOOTOK $INSTDIR
121 DeleteRegValue HKLM "${REGKEY}\Components" Main
122 SectionEnd
123
124 Section -un.post UNSEC0001
125 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
126 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk"
127 Delete /REBOOTOK $INSTDIR\uninstall.exe
128 DeleteRegValue HKLM "${REGKEY}" StartMenuGroup
129 DeleteRegValue HKLM "${REGKEY}" Path
130 DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
131 DeleteRegKey /IfEmpty HKLM "${REGKEY}"
132 RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
133 RmDir /REBOOTOK $INSTDIR
134 SectionEnd
135
136 # Installer functions
137 Function StartMenuGroupSelect
138 Push $R1
139 StartMenu::Select /autoadd /text "Select the Start Menu folder in which to create the program's shortcuts:" /lastused $StartMenuGroup "$(^Name)"
140 Pop $R1
141 StrCmp $R1 success success
142 StrCmp $R1 cancel done
143 MessageBox MB_OK $R1
144 Goto done
145 success:
146 Pop $StartMenuGroup
147 done:
148 Pop $R1
149 FunctionEnd
150
151 Function .onInstSuccess
152
153 FunctionEnd
154
155 Function .onInit
156 InitPluginsDir
157 FunctionEnd
158
159 # Uninstaller functions
160 Function un.onInit
161 ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
162 ReadRegStr $StartMenuGroup HKLM "${REGKEY}" StartMenuGroup
163 !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
164 FunctionEnd
165