~fabien-morin/unifield-web/fm-us-1026

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"
4774.4.17 by jf
US-812: AIO fix config file for Win
154
    File "/oname=openerp-web.cfg" ".\doc\openerp-web-win.cfg"
4774.4.14 by jf
US-804: AIO Builder: copy extra config file
155
    File "/oname=openerp-web-oc.cfg" ".\doc\openerp-web-oc.cfg"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
156
157
    !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
158
        ;Create shortcuts
159
        CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
160
        
161
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Start OpenERP Web.lnk" "$INSTDIR\service\start.bat"
162
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Stop OpenERP Web.lnk" "$INSTDIR\service\stop.bat"
4774.4.14 by jf
US-804: AIO Builder: copy extra config file
163
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Edit Web Config.lnk" "notepad.exe" "$INSTDIR\conf\openerp-web-oc.cfg"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
164
        CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe"
165
        !insertmacro CreateInternetShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Forum" "http://www.openerp.com/forum"
166
        !insertmacro CreateInternetShortcut "$SMPROGRAMS\$STARTMENU_FOLDER\Translation" "https://translations.launchpad.net/openobject"
167
    !insertmacro MUI_STARTMENU_WRITE_END
168
SectionEnd
169
170
Section -RestartService
171
    nsExec::Exec '"$INSTDIR\service\OpenERPWebService.exe" -auto -install'
172
    sleep 2
173
    nsExec::Exec "net start openerp-web-6.0"
174
    sleep 2
175
SectionEnd
176
177
Section -Post
178
    WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
179
    WriteRegExpandStr HKLM "${UNINSTALL_REGISTRY_KEY}" "InstallLocation" "$INSTDIR"
180
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "DisplayName" "${DISPLAY_NAME}"
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
181
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${MAJOR_VERSION}.${MINOR_VERSION}"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
182
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "Publisher" "${PUBLISHER}"
183
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "Version" "${VERSION}"
4209 by Stephane Wirtel
[FIX] Add new parameters in the setup.nsi
184
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "VersionMajor" "${MAJOR_VERSION}.${MINOR_VERSION}"
185
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "VersionMinor" "${REVISION_VERSION}"
4204 by Stephane Wirtel
[IMP] Change the Win32 Installer
186
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "HelpLink" "support@openerp.com"
187
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "HelpTelephone" "+32.81.81.37.00"
188
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "URLInfoAbout" "http://www.openerp.com"
189
    WriteRegStr HKLM       "${UNINSTALL_REGISTRY_KEY}" "Contact" "sales@openerp.com"
190
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "NoModify" "1"
191
    WriteRegDWORD HKLM     "${UNINSTALL_REGISTRY_KEY}" "NoRepair" "1"
192
    WriteUninstaller "$INSTDIR\Uninstall.exe"
193
SectionEnd
194
195
Section "Uninstall"
196
    nsExec::Exec "net stop openerp-web-6.0"
197
    sleep 2
198
    nsExec::Exec '"$INSTDIR\service\OpenERPWebService.exe" -remove'
199
    sleep 2
200
201
    Rmdir /r "$INSTDIR"
202
203
204
    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
205
    Delete "$SMPROGRAMS\$MUI_TEMP\Forum.url"
206
    Delete "$SMPROGRAMS\$MUI_TEMP\Translation.url"
207
    Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
208
    Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
209
    Delete "$SMPROGRAMS\$MUI_TEMP\Start OpenERP Web.lnk"
210
    Delete "$SMPROGRAMS\$MUI_TEMP\Stop OpenERP Web.lnk"
211
    Delete "$SMPROGRAMS\$MUI_TEMP\Edit Web Config.lnk"
212
213
    ;Delete empty start menu parent diretories
214
    StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
215
 
216
    startMenuDeleteLoop:
217
        ClearErrors
218
        RMDir $MUI_TEMP
219
        GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
220
221
        IfErrors startMenuDeleteLoopDone
222
223
        StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
224
225
    startMenuDeleteLoopDone:
226
227
    DeleteRegKey HKLM "${UNINSTALL_REGISTRY_KEY}"
228
229
SectionEnd
230
231
Function .onInit
232
    Push $R0
233
234
    ${GetParameters} $cmdLineParams
235
    ClearErrors
236
237
    Pop $R0
238
239
    StrCpy $Option_AllInOne 0
240
241
    Push $R0
242
    ${GetOptions} $cmdLineParams '/allinone' $R0
243
    IfErrors +2 0
244
    StrCpy $Option_AllInOne 1
245
    Pop $R0
246
247
    StrCmp $Option_AllInOne 1 AllInOneMode
248
    StrCmp $Option_AllInOne 0 NoAllInOneMode
249
250
    AllInOneMode:
251
        MessageBox MB_OK|MB_ICONINFORMATION "All In One"
252
253
    NoAllInOneMode:
254
    
255
    !insertmacro MUI_LANGDLL_DISPLAY
256
257
FunctionEnd