~openerp/openerp/win-installer-trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
##############################################################################
#
# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
###############################################################################
!ifndef VERSION
    !error "Do not forget to specify the version of OpenERP - /DVERSION=<VERSION>"
!endif 

;--------------------------------
;Include Modern UI

!include "MUI.nsh"

;--------------------------------
;General

;Name and file
Name "OpenERP All In One"
OutFile "openerp-allinone-setup-${VERSION}.exe"
SetCompressor lzma
SetCompress auto

;Default installation folder
InstallDir "$PROGRAMFILES\OpenERP AllInOne"

;Get installation folder from registry if available
InstallDirRegKey HKLM "Software\OpenERP AllInOne" ""

BrandingText "OpenERP All In One ${VERSION}"

;Vista redirects $SMPROGRAMS to all users without this
RequestExecutionLevel admin

;--------------------------------
;Variables

;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING

!define REGKEY "SOFTWARE\$(^Name)"
!define MUI_LANGDLL_REGISTRY_ROOT HKLM
!define MUI_LANGDLL_REGISTRY_KEY ${REGKEY}
!define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage

!insertmacro MUI_RESERVEFILE_LANGDLL

;--------------------------------
;Pages

!define MUI_ICON ".\demo\pixmaps\openerp-icon.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP ".\demo\pixmaps\openerp-intro.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP ".\demo\pixmaps\openerp-intro.bmp"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ".\demo\pixmaps\openerp-slogan.bmp"
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_HEADER_TRANSPARENT_TEXT ""
!define MUI_LICENSEPAGE_TEXT_BOTTOM "$(LicenseText)"
!define MUI_LICENSEPAGE_BUTTON "$(LicenseNext)"
!define MUI_WELCOMEPAGE_TEXT "$(WelcomeText)"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ".\demo\doc\License.rtf"
!insertmacro MUI_PAGE_DIRECTORY

;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\OpenERP AllInOne"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "OpenERP AllInOne"

!insertmacro MUI_PAGE_INSTFILES

!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_CHECKED
!define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageText)"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages
 
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"

;--------------------------------
;Installer Sections
Function .onInit 
    ;Language selection dialog
    Push ""
    Push ${LANG_ENGLISH}
    Push English
    Push ${LANG_FRENCH}
    Push French
    Push A ; A means auto count languages
    ; for the auto count to work the first empty push (Push "") must remain
    LangDLL::LangDialog "Installer Language" "Please select the language of the installer"

    Pop $LANGUAGE
    StrCmp $LANGUAGE "cancel" 0 +2
        Abort

    ClearErrors
    ReadRegStr $0 HKLM "Software\OpenERP AllInOne" ""
    IfErrors DoInstall 0
        MessageBox MB_OK "$(CannotInstallServerText)"
        Quit
    DoInstall:
FunctionEnd

Section "OpenERP AllInOne" SecOpenERPDemo
  SetOutPath "$TEMP"
  
  ;ADD YOUR OWN FILES HERE...
  File "server\openerp-server-setup-${VERSION}.exe"
  File "client\openerp-client-setup-${VERSION}.exe"
  File "client-web\openerp-web-setup-${VERSION}.exe"

  nsExec::Exec 'net stop openerp-service'
  sleep 2
  ExecWait '"$TEMP\openerp-server-setup-${VERSION}.exe" /S /D=$INSTDIR\\Server'

  ExecWait '"$TEMP\openerp-client-setup-${VERSION}.exe" /S /D=$INSTDIR\\Client'

  ExecWait '"$TEMP\openerp-web-setup-${VERSION}.exe" /S /D=$INSTDIR\\Web'

  ClearErrors
  EnumRegKey $0 HKLM "SOFTWARE\PostgreSQL" 0
  IfErrors DoInstallPostgreSQL 0
    MessageBox MB_OK "$(CannotPostgreSQLText)"
    Goto Next
  
  DoInstallPostgreSQL:
      File "postgresql-8.3-int.msi"
      ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
      StrCmp $0 "" win9x
      Goto done
      win9x:
        ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName"
      done:
      nsExec::Exec 'net user openpgsvc /delete'

      ExecWait 'msiexec /i "$TEMP\postgresql-8.3-int.msi" /qn INTERNALLAUNCH=1 ADDLOCAL=server,pgadmin SERVICEDOMAIN="$0" SERVICEACCOUNT="openpgsvc" SERVICEPASSWORD="0p3npgsvcPWD" CREATESERVICEUSER=1 SERVICENAME="PostgreSQL4OpenERP" SUPERUSER="openpg" SUPERPASSWORD="openpgpwd" DOINITDB=1 DOSERVICE=1 LISTENPORT=5432 ENCODING=UTF-8 BASEDIR="$INSTDIR\PostgreSQL"'
      WriteRegStr HKLM "Software\OpenERP AllInOne" "HasInstalledPostgreSQL" "True"

  Next:
  SetOutPath "$INSTDIR"
  ;Store installation folder
  WriteRegStr HKLM "Software\OpenERP AllInOne" "" $INSTDIR
  
  ;Create uninstaller
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenERP AllInOne" "DisplayName" "OpenERP All In One ${VERSION}"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenERP AllInOne" "UninstallString" "$INSTDIR\Uninstall.exe"
  WriteUninstaller "$INSTDIR\Uninstall.exe"

  nsExec::Exec '"$INSTDIR\\Server\\openerp-server.exe" --stop-after-init --logfile "$INSTDIR\\Server\\openerp-server.log"  --pg_path="$INSTDIR\\PostgreSQL\\bin" -r openpg -w openpgpwd --db_host=127.0.0.1 --db_port=5432 -c "$INSTDIR\\Server\\openerp-server.conf" -s'
  nsExec::Exec 'net start openerp-service'

SectionEnd


Section "Uninstall"
  ClearErrors
  nsExec::Exec 'net stop openerp-service'
  sleep 2

  ReadRegStr $0 HKLM "Software\OpenERP AllInOne" "HasInstalledPostgreSQL"
  IfErrors UninstallClientServer 0
      nsExec::Exec 'net stop pgsql-8.3'
      sleep 2
      nsExec::Exec 'msiexec /x {B823632F-3B72-4514-8861-B961CE263224} /q'
      sleep 2
      nsExec::Exec 'net user openpgsvc /delete'
      RMDIR /r "$INSTDIR\\PostgreSQL"

  UninstallClientServer:

  ReadRegStr $0 HKLM "Software\OpenERP AllInOne" "UninstallServer"
  ExecWait '"$0" /S'

  ReadRegStr $0 HKLM "Software\OpenERP AllInOne" "UninstallClient"
  ExecWait '"$0" /S'

  ReadRegStr $0 HKLM "Software\OpenERP AllInOne" "UninstallWeb"
  ExecWait '"$0" /S'

  ;ADD YOUR OWN FILES HERE...
  RMDIR /r "$INSTDIR"
  
  DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenERP AllInOne"
  DeleteRegKey HKLM "Software\OpenERP AllInOne\UninstallServer" 
  DeleteRegKey HKLM "Software\OpenERP AllInOne\UninstallClient"
  DeleteRegKey HKLM "Software\OpenERP AllInOne\UninstallWeb"
  DeleteRegKey HKLM "Software\OpenERP AllInOne\HasInstalledPostgreSQL"
  DeleteRegKey /ifempty HKLM "Software\OpenERP AllInOne"

SectionEnd

Function LaunchLink
  ExecShell "" "$INSTDIR\\Client\\openerp-client.exe"
FunctionEnd

LangString WelcomeText ${LANG_ENGLISH} "This wizard will guide you through the installation of OpenERP and all its dependencies, including the database PostgreSQL.\n\nIt it recommended that you close all other applications before starting Setup. This will make it possible to update relevant system files without having to reboot your computer.\n\nClick Next to continue."
LangString WelcomeText ${LANG_FRENCH} "Cet assistant vous guidera à travers l'installation d'OpenERP et de toutes ses dépendances, incluant la base de données PostgreSQL.\n\nIl est recommandé que vous fermiez toutes les autres applications avant de démarrer l'installeur.\n\nCliquez sur Suivant pour continuer."
LangString LicenseText ${LANG_ENGLISH} "Usually, a proprietary license is provided with the software: limited number of users, limited in time usage, etc. This Open Source license is the opposite: it garantees you the right to use, copy, study, distribute and modify Open ERP for free."
LangString LicenseText ${LANG_FRENCH} "Normalement, une licence propriétaire est fournie avec le logiciel: limitation du nombre d'utilisateurs, limitation dans le temps, etc. Cette licence Open Source est l'opposé: Elle vous garantie le droit d'utiliser, de copier, d'étudier, de distribuer et de modifier Open ERP librement."

LangString LicenseNext ${LANG_ENGLISH} "Next >"
LangString LicenseNext ${LANG_FRENCH} "Suivant >"

LangString FinishPageText ${LANG_ENGLISH} "Start OpenERP Client"
LangString FinishPageText ${LANG_FRENCH} "Lancer le client OpenERP"

;Language strings
LangString DESC_SecOpenERPDemo ${LANG_ENGLISH} "OpenERP AllInOne."
LangString DESC_SecOpenERPDemo ${LANG_FRENCH} "OpenERP AllInOne."

LangString CannotInstallServerText ${LANG_ENGLISH} "Can not install the Open ERP because a previous installation already exists on this system. Please uninstall your current installation and relaunch this setup wizard."
LangString CannotInstallServerText ${LANG_FRENCH} "Ne peut pas installer Open ERP parce qu'une installation existe déjà  sur ce système. S'il vous plait, désinstallez votre installation actuelle et relancer l'installeur."

LangString CannotPostgreSQLText ${LANG_ENGLISH} "There is a previous installation of PostgreSQL, the installer will not install the packaged version of PostgreSQL"
LangString CannotPostgreSQLText ${LANG_FRENCH} "Il existe une précédente installation de PostgreSQL, l'installeur n'installera pas la version packagée de PostgreSQL"

!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
    !insertmacro MUI_DESCRIPTION_TEXT ${SecOpenERPDemo} $(DESC_SecOpenERPDemo)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
 
;--------------------------------
;Uninstaller Section