~openerp-dev/openobject-client-web/trunk-bug-1156592-priyanka

4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
1
#####################################################################################
2
#
3
# Copyright (c) 2004-TODAY OpenERP S.A. (http://www.openerp.com) All Rights Reserved.
4
#
5
# WARNING: This program as such is intended to be used by professional
6
# programmers who take the whole responsability of assessing all potential
7
# consequences resulting from its eventual inadequacies and bugs
8
# End users who are looking for a ready-to-use solution with commercial
9
# garantees and support are strongly adviced to contract a Free Software
10
# Service Company
11
#
12
# This program is Free Software; you can redistribute it and/or
13
# modify it under the terms of the GNU General Public License
14
# as published by the Free Software Foundation; either version 3
15
# of the License, or (at your option) any later version.
16
#
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
# GNU General Public License for more details.
21
#
22
# You should have received a copy of the GNU General Public License
23
# along with this program; if not, write to the Free Software
24
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
#####################################################################################
26
27
!include 'MUI2.nsh'
28
!include 'FileFunc.nsh'
29
!include 'LogicLib.nsh'
30
!include 'Sections.nsh'
31
32
!define PUBLISHER 'OpenERP S.A.'
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
33
34
!ifndef MAJOR_VERSION
35
    !define MAJOR_VERSION '6'
36
!endif
37
38
!ifndef MINOR_VERSION
39
    !define MINOR_VERSION '0'
40
!endif
41
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
42
!ifndef REVISION_VERSION
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
43
    !define REVISION_VERSION '0'
44
!endif 
45
46
!ifndef BUILD_VERSION
47
    !define VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION_VERSION}"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
48
!else
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
49
    !define VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${REVISION_VERSION}-${BUILD_VERSION}"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
50
!endif
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
51
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
52
!define PRODUCT_NAME "OpenERP Web Client"
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
53
!define DISPLAY_NAME "${PRODUCT_NAME} ${MAJOR_VERSION}.${MINOR_VERSION}"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
54
55
!define UNINSTALL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${DISPLAY_NAME}"
56
57
!define REGISTRY_KEY "Software\${DISPLAY_NAME}"
58
59
Name '${DISPLAY_NAME}'
60
Caption "${PRODUCT_NAME} ${VERSION} Setup"
61
OutFile "openerp-web-setup-${VERSION}.exe"
62
SetCompressor /final /solid lzma
63
SetCompress auto
64
ShowInstDetails show
65
66
XPStyle on
67
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
68
InstallDir "$PROGRAMFILES\OpenERP ${MAJOR_VERSION}.${MINOR_VERSION}\Web"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
69
InstallDirRegKey HKCU "${REGISTRY_KEY}" ""
70
71
BrandingText '${PRODUCT_NAME} ${VERSION}'
72
73
RequestExecutionLevel admin
74
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
75
#VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
76
#VIAddVersionKey "CompanyName" "${PUBLISHER}"
77
#VIAddVersionKey "FileDescription" "Installer of ${DISPLAY_NAME}" 
78
#VIAddVersionKey "LegalCopyright" "${PUBLISHER}"
79
#VIAddVersionKey "LegalTrademark" "OpenERP is a trademark of ${PUBLISHER}"
80
#VIAddVersionKey "FileVersion" "${MAJOR_VERSION}.${MINOR_VERSION}.${RELEASE_VERSION}"
81
#VIProductVersion "${MAJOR_VERSION}.${MINOR_VERSION}.${RELEASE_VERSION}"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
82
83
!insertmacro GetParameters
84
!insertmacro GetOptions
85
86
Var Option_AllInOne
87
Var cmdLineParams
88
89
Var MUI_TEMP
90
Var STARTMENU_FOLDER
91
92
!define MUI_ABORTWARNING
93
!define MUI_ICON ".\pixmaps\openerp-icon.ico"
94
95
!define MUI_WELCOMEFINISHPAGE_BITMAP ".\pixmaps\openerp-intro.bmp"
96
!define MUI_UNWELCOMEFINISHPAGE_BITMAP ".\pixmaps\openerp-intro.bmp"
97
!define MUI_HEADERIMAGE
98
!define MUI_HEADERIMAGE_BITMAP ".\pixmaps\openerp-slogan.bmp"
99
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
100
!define MUI_HEADER_TRANSPARENT_TEXT ""
101
102
!insertmacro MUI_PAGE_WELCOME
103
!insertmacro MUI_PAGE_LICENSE "doc\License.txt"
104
!insertmacro MUI_PAGE_DIRECTORY
105
106
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM" 
107
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${REGISTRY_KEY}"
108
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${DISPLAY_NAME}"
109
110
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
111
!insertmacro MUI_PAGE_INSTFILES
112
113
!define MUI_FINISHPAGE_NOAUTOCLOSE
114
!define MUI_FINISHPAGE_LINK $(DESC_FinishPage_Link) 
115
!define MUI_FINISHPAGE_LINK_LOCATION "http://www.openerp.com/contact"
116
!insertmacro MUI_PAGE_FINISH
117
118
!insertmacro MUI_UNPAGE_WELCOME
119
!insertmacro MUI_UNPAGE_CONFIRM
120
!insertmacro MUI_UNPAGE_INSTFILES
121
!insertmacro MUI_UNPAGE_FINISH
122
123
!insertmacro MUI_LANGUAGE "English"
124
!insertmacro MUI_LANGUAGE "French"
125
!insertmacro MUI_RESERVEFILE_LANGDLL
126
127
!macro CreateInternetShortcut FILENAME URL
128
	WriteINIStr "${FILENAME}.url" "InternetShortcut" "URL" "${URL}"
129
!macroend
130
131
; English
132
LangString DESC_FinishPage_Link ${LANG_ENGLISH} "Contact OpenERP for Partnership and/or Support"
133
134
135
; French
136
LangString DESC_FinishPage_Link ${LANG_FRENCH} "Contactez OpenERP pour un Partenariat et/ou du Support"
137
138
Section -StopService
139
    nsExec::Exec "net stop openerp-web-6.0"
140
    sleep 2
141
SectionEnd
142
143
Section OpenERP_Web_Client SectionOpenERP_Web_Client
144
    SetOutPath '$INSTDIR'
145
146
    File /r "dist\*"
147
148
    SetOutPath '$INSTDIR\service'
149
    File /r "win32\dist\*"
150
    File "win32\start.bat"
151
    File "win32\stop.bat"
152
153
    SetOutPath "$INSTDIR\conf"
4634 by Vo Minh Thu
[FIX] setup.nsi: corrected path to previously moved openerp-web.cfg.
154
    File "/oname=openerp-web.cfg" ".\openerp-web.cfg"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
155
156
    !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
157
        ;Create shortcuts
158
        CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
159
        
160
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Start OpenERP Web.lnk" "$INSTDIR\service\start.bat"
161
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Stop OpenERP Web.lnk" "$INSTDIR\service\stop.bat"
162
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Edit Web Config.lnk" "notepad.exe" "$INSTDIR\conf\openerp-web.cfg"
163
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe"
164
        !insertmacro CreateInternetShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Forum" "http://www.openerp.com/forum"
165
        !insertmacro CreateInternetShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Translation" "https://translations.launchpad.net/openobject"
166
    !insertmacro MUI_STARTMENU_WRITE_END
167
SectionEnd
168
169
Section -RestartService
170
    nsExec::Exec '"$INSTDIR\service\OpenERPWebService.exe" -auto -install'
171
    sleep 2
172
    nsExec::Exec "net start openerp-web-6.0"
173
    sleep 2
174
SectionEnd
175
176
Section -Post
177
    WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
178
    WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "InstallLocation" "$INSTDIR"
179
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "DisplayName" "${DISPLAY_NAME}"
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
180
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${MAJOR_VERSION}.${MINOR_VERSION}"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
181
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${PUBLISHER}"
182
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "Version" "${VERSION}"
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
183
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "VersionMajor" "${MAJOR_VERSION}.${MINOR_VERSION}"
184
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "VersionMinor" "${REVISION_VERSION}"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
185
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "HelpLink" "support@openerp.com"
186
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "HelpTelephone" "+32.81.81.37.00"
187
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "URLInfoAbout" "http://www.openerp.com"
188
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "Contact" "sales@openerp.com"
189
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "NoModify" "1"
190
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "NoRepair" "1"
191
    WriteUninstaller "$INSTDIR\Uninstall.exe"
192
SectionEnd
193
194
Section "Uninstall"
195
    nsExec::Exec "net stop openerp-web-6.0"
196
    sleep 2
197
    nsExec::Exec '"$INSTDIR\service\OpenERPWebService.exe" -remove'
198
    sleep 2
199
200
    Rmdir /r "$INSTDIR"
201
202
203
    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
204
    Delete "$SMPROGRAMS\$MUI_TEMP\Forum.url"
205
    Delete "$SMPROGRAMS\$MUI_TEMP\Translation.url"
206
    Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
207
    Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
208
    Delete "$SMPROGRAMS\$MUI_TEMP\Start OpenERP Web.lnk"
209
    Delete "$SMPROGRAMS\$MUI_TEMP\Stop OpenERP Web.lnk"
210
    Delete "$SMPROGRAMS\$MUI_TEMP\Edit Web Config.lnk"
211
212
    ;Delete empty start menu parent diretories
213
    StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
214
 
215
    startMenuDeleteLoop:
216
        ClearErrors
217
        RMDir $MUI_TEMP
218
        GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
219
220
        IfErrors startMenuDeleteLoopDone
221
222
        StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
223
224
    startMenuDeleteLoopDone:
225
226
    DeleteRegKey HKLM "${UNINSTALL_REGISTRY_KEY}"
227
228
SectionEnd
229
230
Function .onInit
231
    Push $R0
232
233
    ${GetParameters} $cmdLineParams
234
    ClearErrors
235
236
    Pop $R0
237
238
    StrCpy $Option_AllInOne 0
239
240
    Push $R0
241
    ${GetOptions} $cmdLineParams '/allinone' $R0
242
    IfErrors +2 0
243
    StrCpy $Option_AllInOne 1
244
    Pop $R0
245
246
    StrCmp $Option_AllInOne 1 AllInOneMode
247
    StrCmp $Option_AllInOne 0 NoAllInOneMode
248
249
    AllInOneMode:
250
        MessageBox MB_OK|MB_ICONINFORMATION "All In One"
251
252
    NoAllInOneMode:
253
    
254
    !insertmacro MUI_LANGDLL_DISPLAY
255
256
FunctionEnd