|
1 # Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 my $installScript = $ARGV[0] ? $ARGV[0] : "my_systemmodeltoolkit.nsi"; |
|
17 |
|
18 my $productName = "SystemModelToolkit"; |
|
19 my $productVersion = "1.1"; |
|
20 |
|
21 my $depDir = ".."; # The location of Dep directory |
|
22 |
|
23 # all directory pathnames are relative to DepToolkit\Dep |
|
24 my @subDirsToInstall = ("src\\svg"); |
|
25 my %individualFilesToInstall = (); |
|
26 |
|
27 my @filesToUnistall = (); # w.r.t the root of installation directory |
|
28 my @dirsToUnistall = (); # w.r.t the root of installation directory |
|
29 |
|
30 CreateInstallScript(); |
|
31 |
|
32 sub CreateInstallScript() |
|
33 { |
|
34 open (SCRIPT, ">$installScript") or die "Cannot open $installScript to write to: $!"; |
|
35 print SCRIPT Header(); |
|
36 print SCRIPT InstallationTextSection(); |
|
37 print SCRIPT Middle(); |
|
38 print SCRIPT UninstallationTextSection(); |
|
39 } |
|
40 |
|
41 sub InstallationTextSection() |
|
42 { |
|
43 my $text = "\n;--------------------------- INSTALL SECTION ---------------------------\nSection \"Install Files\" SEC01\n\n"; |
|
44 |
|
45 my $directory = "src\\svg"; |
|
46 |
|
47 # Copy the main script, DrawSvg.pl into the root of installtion directory: |
|
48 $text .= " SetOutPath \"\$INSTDIR\"\n"; |
|
49 $text .= " SetOverwrite try\n"; |
|
50 $text .= " File \"$depDir\\$directory\\DrawSvg.pl\"\n"; |
|
51 push @filesToUnistall, "DrawSvg.pl"; |
|
52 $text .= " File \"$depDir\\$directory\\distribution.policy\"\n"; |
|
53 push @filesToUnistall, "distribution.policy"; |
|
54 $text .= "\n"; |
|
55 |
|
56 # rest of the svg files' in SVG |
|
57 $text .= " SetOutPath \"\$INSTDIR\\svg\"\n"; |
|
58 $text .= " SetOverwrite try\n"; |
|
59 opendir DIR, "$depDir\\$directory" or die "Directory $depDir\\$directory doesn't exist...\n"; |
|
60 my @files = readdir DIR; |
|
61 closedir DIR; |
|
62 foreach my $file (@files) |
|
63 { |
|
64 #next if $file =~ m/^\.+$/; |
|
65 #next if -d $file; # no sub-directories need installing |
|
66 #next if lc $file eq "drawsvg.pl"; # .pl script goes in the root of installation (covered above). |
|
67 |
|
68 # only install the .pm, .xsl, .xml, .ini and .policy files |
|
69 next if lc $file !~ m/\.xsl$/ and |
|
70 lc $file !~ m/\.xml$/ and |
|
71 lc $file !~ m/\.pm$/ and |
|
72 lc $file !~ m/\.ini$/ and |
|
73 lc $file !~ m/\.policy$/; |
|
74 |
|
75 $text .= " File \"$depDir\\$directory\\$file\"\n"; |
|
76 push @filesToUnistall, "svg\\$file"; |
|
77 } |
|
78 $text .= "\n"; |
|
79 push @dirsToUnistall, "svg"; |
|
80 |
|
81 # now copy the common files: |
|
82 $directory = "src\\common"; |
|
83 $text .= " SetOutPath \"\$INSTDIR\\common\"\n"; |
|
84 $text .= " SetOverwrite try\n"; |
|
85 @files = ("DepConstants.pm", "Logger.pm", "LogItem.pm", "distribution.policy"); |
|
86 foreach my $file (@files) |
|
87 { |
|
88 $text .= " File \"$depDir\\$directory\\$file\"\n"; |
|
89 push @filesToUnistall, "common\\$file"; |
|
90 } |
|
91 $text .= "\n"; |
|
92 push @dirsToUnistall, "common"; |
|
93 |
|
94 $directory = "resources\\installed\\Xalan"; |
|
95 $text .= " SetOutPath \"\$INSTDIR\\resources\\installed\\Xalan\"\n"; |
|
96 $text .= " SetOverwrite try\n"; |
|
97 opendir DIR, "$depDir\\$directory" or die "Directory $depDir\\$directory doesn't exist...\n"; |
|
98 my @files = readdir DIR; |
|
99 closedir DIR; |
|
100 foreach my $file (@files) |
|
101 { |
|
102 next if $file =~ m/^\.+$/; |
|
103 next if -d $file; # no sub-directories need installing |
|
104 $text .= " File \"$depDir\\$directory\\$file\"\n"; |
|
105 push @filesToUnistall, "$directory\\$file"; |
|
106 } |
|
107 $text .= "\n"; |
|
108 |
|
109 # now copy the common files: |
|
110 $directory = "resources\\auxiliary"; |
|
111 $text .= " SetOutPath \"\$INSTDIR\\resources\\auxiliary\"\n"; |
|
112 $text .= " SetOverwrite try\n"; |
|
113 opendir DIR, "$depDir\\$directory" or die "Directory $depDir\\$directory doesn't exist...\n"; |
|
114 my @files = readdir DIR; |
|
115 closedir DIR; |
|
116 foreach my $file (@files) |
|
117 { |
|
118 next if $file =~ m/^\.+$/; |
|
119 next if -d $file; # no sub-directories need installing |
|
120 $text .= " File \"$depDir\\$directory\\$file\"\n"; |
|
121 push @filesToUnistall, "$directory\\$file"; |
|
122 } |
|
123 $text .= "\n"; |
|
124 |
|
125 # remember all the resource directories for deletion: |
|
126 push @dirsToUnistall, "resources\\installed\\Xalan"; |
|
127 push @dirsToUnistall, "resources\\installed"; |
|
128 push @dirsToUnistall, "resources\\auxiliary"; |
|
129 push @dirsToUnistall, "resources"; |
|
130 |
|
131 # finally the documentation: |
|
132 $directory = "docs"; |
|
133 $text .= " SetOutPath \"\$INSTDIR\\docs\"\n"; |
|
134 $text .= " SetOverwrite try\n"; |
|
135 @files = ("Building the System Model.doc", "distribution.policy", "dep.css", "sample_drawsvg.ini", "SystemModelToolkitInstaller_main.jpg", "user_guide_system_model_toolkit.html"); |
|
136 foreach my $file (@files) |
|
137 { |
|
138 $text .= " File \"$depDir\\$directory\\$file\"\n"; |
|
139 push @filesToUnistall, "docs\\$file"; |
|
140 } |
|
141 $text .= "\n"; |
|
142 push @dirsToUnistall, "docs"; |
|
143 |
|
144 $text .= "\nSectionEnd\n;-------------------------------------------------------\n\n"; |
|
145 return $text; |
|
146 } |
|
147 |
|
148 sub UninstallationTextSection() |
|
149 { |
|
150 my $text = "\n;--------------------------- UNISTALL SECTION ---------------------------\nSection Uninstall\n\n"; |
|
151 $text .= " Delete \"\$INSTDIR\\uninst.exe\"\n"; |
|
152 |
|
153 foreach $file (@filesToUnistall) |
|
154 { |
|
155 $text .= " Delete \"\$INSTDIR\\$file\"\n"; |
|
156 } |
|
157 |
|
158 $text .= "\n"; |
|
159 foreach $directory (@dirsToUnistall) |
|
160 { |
|
161 $text .= " RMDir \"\$INSTDIR\\$directory\"\n"; |
|
162 } |
|
163 |
|
164 $text .= <<TEXT; |
|
165 RMDir "\$INSTDIR" |
|
166 |
|
167 DeleteRegKey \${PRODUCT_UNINST_ROOT_KEY} "\${PRODUCT_UNINST_KEY}" |
|
168 SetAutoClose true |
|
169 SectionEnd |
|
170 ;------------------------------------------------------- |
|
171 |
|
172 |
|
173 TEXT |
|
174 return $text; |
|
175 } |
|
176 |
|
177 sub Header() |
|
178 { |
|
179 return <<TEXT; |
|
180 |
|
181 ; Script generated by the HM NIS Edit Script Wizard. |
|
182 |
|
183 ; HM NIS Edit Wizard helper defines |
|
184 !define PRODUCT_NAME "$productName" |
|
185 !define PRODUCT_VERSION "$productVersion" |
|
186 !define PRODUCT_PUBLISHER "Symbian Software Ltd" |
|
187 !define PRODUCT_WEB_SITE "http://www.symbian.com" |
|
188 !define PRODUCT_UNINST_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\\${PRODUCT_NAME}" |
|
189 !define PRODUCT_UNINST_ROOT_KEY "HKLM" |
|
190 |
|
191 ; MUI 1.67 compatible ------ |
|
192 !include "MUI.nsh" |
|
193 |
|
194 ; MUI Settings |
|
195 !define MUI_ABORTWARNING |
|
196 !define MUI_ICON "\${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-install-full.ico" |
|
197 !define MUI_UNICON "\${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-uninstall-full.ico" |
|
198 |
|
199 ; Welcome page |
|
200 !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of $productName $productVersion\\n\\nClick Next to continue..." |
|
201 !insertmacro MUI_PAGE_WELCOME |
|
202 ; License page |
|
203 !define MUI_LICENSEPAGE_CHECKBOX |
|
204 !insertmacro MUI_PAGE_LICENSE "license.txt" |
|
205 ; Directory page |
|
206 !insertmacro MUI_PAGE_DIRECTORY |
|
207 ; Instfiles page |
|
208 !insertmacro MUI_PAGE_INSTFILES |
|
209 ; Finish page |
|
210 !insertmacro MUI_PAGE_FINISH |
|
211 |
|
212 ; Uninstaller pages |
|
213 !insertmacro MUI_UNPAGE_INSTFILES |
|
214 |
|
215 ; Language files |
|
216 !insertmacro MUI_LANGUAGE "English" |
|
217 |
|
218 ; MUI end ------ |
|
219 |
|
220 Name "\${PRODUCT_NAME} \${PRODUCT_VERSION}" |
|
221 OutFile "SystemModelToolkitInstaller.exe" |
|
222 InstallDir "D:\\SystemModelToolkit" |
|
223 InstallDirRegKey HKLM "\${PRODUCT_DIR_REGKEY}" "" |
|
224 ShowInstDetails show |
|
225 ShowUnInstDetails show |
|
226 |
|
227 TEXT |
|
228 } |
|
229 |
|
230 sub Middle() |
|
231 { |
|
232 return <<TEXT; |
|
233 |
|
234 Section -Post |
|
235 WriteUninstaller "\$INSTDIR\\uninst.exe" |
|
236 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\${PRODUCT_UNINST_KEY}" "DisplayName" "\$(^Name)" |
|
237 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\${PRODUCT_UNINST_KEY}" "UninstallString" "\$INSTDIR\\uninst.exe" |
|
238 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\${PRODUCT_UNINST_KEY}" "DisplayVersion" "\${PRODUCT_VERSION}" |
|
239 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\${PRODUCT_UNINST_KEY}" "URLInfoAbout" "\${PRODUCT_WEB_SITE}" |
|
240 WriteRegStr \${PRODUCT_UNINST_ROOT_KEY} "\${PRODUCT_UNINST_KEY}" "Publisher" "\${PRODUCT_PUBLISHER}" |
|
241 SectionEnd |
|
242 |
|
243 |
|
244 Function un.onUninstSuccess |
|
245 HideWindow |
|
246 MessageBox MB_ICONINFORMATION|MB_OK "\$(^Name) was successfully removed from your computer." |
|
247 FunctionEnd |
|
248 |
|
249 Function un.onInit |
|
250 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove \$(^Name) and all of its components?" IDYES +2 |
|
251 Abort |
|
252 FunctionEnd |
|
253 |
|
254 TEXT |
|
255 } |
|
256 |
|
257 exit; |