KERNEL: add new win32 build script
[odoo/odoo.git] / setup.nsi
1 ;NSIS Modern User Interface
2 ;Start Menu Folder Selection Example Script
3 ;Written by Joost Verburg
4
5 ;--------------------------------
6 ;Include Modern UI
7
8   !include "MUI.nsh"
9
10 ;--------------------------------
11 ;General
12
13   ;Name and file
14   Name "TinyERP Server"
15   OutFile "tinyerp-server-setup.exe"
16
17   ;Default installation folder
18   InstallDir "$PROGRAMFILES\TinyERP Server"
19   
20   ;Get installation folder from registry if available
21   InstallDirRegKey HKCU "Software\TinyERP Server" ""
22
23   ;Vista redirects $SMPROGRAMS to all users without this
24   RequestExecutionLevel admin
25
26 ;--------------------------------
27 ;Variables
28
29   Var MUI_TEMP
30   Var STARTMENU_FOLDER
31
32 ;--------------------------------
33 ;Interface Settings
34
35   !define MUI_ABORTWARNING
36
37 ;--------------------------------
38 ;Pages
39
40   !insertmacro MUI_PAGE_WELCOME
41   !insertmacro MUI_PAGE_LICENSE "doc\\License.rtf"
42  # !insertmacro MUI_PAGE_COMPONENTS
43   !insertmacro MUI_PAGE_DIRECTORY
44   
45   ;Start Menu Folder Page Configuration
46   !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" 
47   !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\TinyERP Server"
48   !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "TinyERP Server"
49   
50   !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
51   
52   !insertmacro MUI_PAGE_INSTFILES
53
54   !define MUI_FINISHPAGE_NOAUTOCLOSE
55   !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
56   !define MUI_FINISHPAGE_SHOWREADME $INSTDIR\README.txt
57   !insertmacro MUI_PAGE_FINISH
58
59   
60   !insertmacro MUI_UNPAGE_WELCOME
61   !insertmacro MUI_UNPAGE_CONFIRM
62   !insertmacro MUI_UNPAGE_INSTFILES
63
64 ;--------------------------------
65 ;Languages
66  
67   !insertmacro MUI_LANGUAGE "English"
68
69 ;--------------------------------
70 ;Installer Sections
71
72 Section "TinyERP Server" SecTinyERPServer
73
74   SetOutPath "$INSTDIR"
75   
76   ;ADD YOUR OWN FILES HERE...
77   File /r "dist\\*"
78
79   ;Store installation folder
80   WriteRegStr HKCU "Software\TinyERP Server" "" $INSTDIR
81   
82   ;Create uninstaller
83   WriteUninstaller "$INSTDIR\Uninstall.exe"
84   
85   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
86     
87     ;Create shortcuts
88     CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
89     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\TinyERP Server.lnk" "$INSTDIR\tinyerp-server.exe"
90     CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
91   
92   !insertmacro MUI_STARTMENU_WRITE_END
93
94 SectionEnd
95
96 ;Descriptions
97
98   ;Language strings
99   LangString DESC_SecTinyERPServer ${LANG_ENGLISH} "TinyERP Server."
100
101   ;Assign language strings to sections
102   !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
103     !insertmacro MUI_DESCRIPTION_TEXT ${SecTinyERPServer} $(DESC_SecTinyERPServer)
104   !insertmacro MUI_FUNCTION_DESCRIPTION_END
105  
106 ;--------------------------------
107 ;Uninstaller Section
108
109 Section "Uninstall"
110
111   ;ADD YOUR OWN FILES HERE...
112   Delete "$INSTDIR\Uninstall.exe"
113   Push "$INSTDIR\addons"
114   Push ""
115   Call un.RmFilesButOne
116   Delete "$INSTDIR\*"
117   Delete "$INSTDIR\Uninstall.exe"
118
119   Push "$INSTDIR\addons"
120   Push ""
121   Call un.RmDirsButOne
122   RMDir "$INSTDIR\addons"
123   RMDir "$INSTDIR"
124   
125   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
126     
127   Delete "$SMPROGRAMS\$MUI_TEMP\TinyERP Server.lnk"
128   Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
129   
130   ;Delete empty start menu parent diretories
131   StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
132  
133   startMenuDeleteLoop:
134         ClearErrors
135     RMDir $MUI_TEMP
136     GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
137     
138     IfErrors startMenuDeleteLoopDone
139   
140     StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
141   startMenuDeleteLoopDone:
142
143   DeleteRegKey /ifempty HKCU "Software\TinyERP Server"
144
145 SectionEnd
146
147 Function un.RmDirsButOne
148  Exch $R0 ; exclude dir
149  Exch
150  Exch $R1 ; route dir
151  Push $R2
152  Push $R3
153  
154   FindFirst $R3 $R2 "$R1\*.*"
155   IfErrors Exit
156  
157   Top:
158    StrCmp $R2 "." Next
159    StrCmp $R2 ".." Next
160    StrCmp $R2 $R0 Next
161    IfFileExists "$R1\$R2\*.*" 0 Next
162     RmDir /r "$R1\$R2"
163  
164    #Goto Exit ;uncomment this to stop it being recursive
165  
166    Next:
167     ClearErrors
168     FindNext $R3 $R2
169     IfErrors Exit
170    Goto Top
171  
172   Exit:
173   FindClose $R3
174  
175  Pop $R3
176  Pop $R2
177  Pop $R1
178  Pop $R0
179 FunctionEnd
180
181 Function un.RmFilesButOne
182  Exch $R0 ; exclude file
183  Exch
184  Exch $R1 ; route dir
185  Push $R2
186  Push $R3
187  
188   FindFirst $R3 $R2 "$R1\*.*"
189   IfErrors Exit
190  
191   Top:
192    StrCmp $R2 "." Next
193    StrCmp $R2 ".." Next
194    StrCmp $R2 $R0 Next
195    IfFileExists "$R1\$R2\*.*" Next
196     Delete "$R1\$R2"
197  
198    #Goto Exit ;uncomment this to stop it being recursive
199  
200    Next:
201     ClearErrors
202     FindNext $R3 $R2
203     IfErrors Exit
204    Goto Top
205  
206   Exit:
207   FindClose $R3
208  
209  Pop $R3
210  Pop $R2
211  Pop $R1
212  Pop $R0
213 FunctionEnd