source: subversion/applications/rendering/tahwin/tahwin-setup.nsi @ 34399

Last change on this file since 34399 was 28426, checked in by stephankn, 7 years ago

commit what I have on disk so in case we re-animate tah we can re-use it

  • Property svn:eol-style set to native
File size: 20.5 KB
Line 
1; This program is free software: you can redistribute it and/or modify
2; it under the terms of the GNU General Public License as published by
3; the Free Software Foundation, either version 3 of the License, or
4; (at your option) any later version.
5;
6; This program is distributed in the hope that it will be useful,
7; but WITHOUT ANY WARRANTY; without even the implied warranty of
8; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9; GNU General Public License for more details.
10;
11; You should have received a copy of the GNU General Public License
12; along with this program.  If not, see <http://www.gnu.org/licenses/>.
13;
14; Check http://www.osm-tools.org/ for updates.
15;
16; Copyright 2009-2011 Stephan Knauss <osm@stephans-server.de>
17
18; This installer is based on the ideas of the abandoned installer hosted on sourceforge
19; http://sourceforge.net/projects/wintah/
20; Thanks to Eddi di Pieri for creating the initial version and providing some windows scripts!
21
22!include WinMessages.nsh
23!include "StrFunc.nsh"
24!include "LogicLib.nsh"
25!include "WordFunc.nsh"
26!insertmacro WordFind
27!insertmacro WordFind2x
28;  !insertmacro WordReplace
29!include MUI2.nsh
30
31${StrRep}
32
33; used plugins are included with the script for a convenient build of installer. Set directories or 3rd party stuff here
34!AddIncludeDir "include"
35!AddPluginDir "plugins"
36
37!include FontReg.nsh
38!include FontName.nsh
39
40
41; ===== Installer Attributes, compiler settings and version information =====
42; AddBrandingImage
43; BrandingText
44; DirText
45;InstallDir $PROGRAMFILES\TilesAtHome  probleme mit spaces und svn update
46InstallDir C:\TilesAtHome
47; InstallDirRegKey    verwenden um update beim späteren install. Install muss Pfad in registry schreiben
48; InstType      klappt damit die Umschaltung zwischen 32bit und 64 bit?
49LicenseForceSelection checkbox
50Name "Tiles@Home for Windows"
51!define VERSION 1.0.1.3
52OutFile "tahwin-setup_${VERSION}.exe"
53RequestExecutionLevel admin
54ShowInstDetails show
55ShowUninstDetails show
56XPStyle on
57
58SetCompressor /SOLID /FINAL lzma
59
60VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Tiles@Home for Windows"
61VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Tiles@Home for Windows setup"
62VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "download and install all components needed to run Tiles@Home on a windows system."
63VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "GPL installer, contact osm@stephans-server.de"
64VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${VERSION}"
65VIProductVersion "${VERSION}"
66
67
68!define ppmInstall "!insertmacro ppmInstall"
69!macro ppmInstall Target Ppd
70  Push ${Target}
71  Push ${Ppd}
72  Call ppmInstall
73!macroend
74
75!define fileDownload "!insertmacro fileDownload"
76!macro fileDownload Target Url FileName Md5
77  Push ${Target}
78  Push ${Url}
79  Push ${FileName}
80  Push ${Md5}
81  Call fileDownload
82!macroend
83
84; use script http://nsis.sourceforge.net/Java_Runtime_Environment_Dynamic_Installer for java runtime detection and installation
85!define JRE_VERSION "1.6"
86; to get download link, browse http://java.com/en/download/manual.jsp
87; http://javadl.sun.com/webapps/download/AutoDL?BundleId=44457   JRE-6u23
88; http://javadl.sun.com/webapps/download/AutoDL?BundleId=49024   JRE-6u26
89!define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=49024"
90!include "JREDyna.nsh"
91
92VAR HTTPPROXY
93VAR HTTPSPROXY
94VAR IPADDRESS1
95VAR PORT1
96VAR IPADDRESS2
97VAR PORT2
98
99VAR TAHDL
100
101; store the silent mode requested by user (/S command line for silent)
102VAR SILENTMODE
103
104
105; ===== Pages =====
106!define MUI_HEADERIMAGE
107!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\orange.bmp" ; optional
108!define MUI_ABORTWARNING
109!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-full.ico"
110
111; Pages in the order to be displayed by the installer
112!insertmacro MUI_PAGE_LICENSE "license.txt"
113!insertmacro MUI_PAGE_COMPONENTS
114!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Installing in a different directory is not yet supported. Plese don't change it!"
115!insertmacro MUI_PAGE_DIRECTORY
116!insertmacro CUSTOM_PAGE_JREINFO
117!insertmacro MUI_PAGE_INSTFILES
118;!insertmacro MUI_PAGE_FINISH
119
120; Pages in the order to be displayed by the uninstaller
121!insertmacro MUI_UNPAGE_CONFIRM
122; TODO ask to uninstall fonts !insertmacro MUI_UNPAGE_COMPONENTS
123!insertmacro MUI_UNPAGE_INSTFILES
124
125!insertmacro MUI_LANGUAGE "English"
126
127
128; ===== Sections =====
129SectionGroup /e "Main Program"
130
131Section "Core Components" SecCoreComponents
132
133  SectionIn RO
134
135  ; add the bytes we download and install
136  AddSize 140000
137
138  ; Set output path to the installation directory.
139  SetOutPath $INSTDIR
140
141  ; Put file there
142  File tah.ico
143  File tah.pl
144
145  SetOutPath $INSTDIR\pngnq
146  File /r /x .svn binary-source\pngnq\*.*
147
148  SetOutPath $INSTDIR\svn
149  File /r /x .svn binary-source\svn\*.*
150
151  SetOutPath $INSTDIR\xmlstarlet
152  File /r /x .svn binary-source\xmlstarlet\*.*
153
154  SetOutPath $INSTDIR\optipng
155  File /r /x .svn binary-source\optipng\*.*
156
157  SetOutPath $INSTDIR\pngcrush
158  File /r /x .svn binary-source\pngcrush\*.*
159
160  SetOutPath $INSTDIR\zip
161  File /r /x .svn binary-source\zip\*.*
162
163  SetOutPath $INSTDIR
164
165  StrCpy $TAHDL "$EXEDIR\tahwin-setup"
166  CreateDirectory $TAHDL
167
168  Call ConnectInternet
169
170  ;Font installer need local repository of fonts... so I can't download before
171  ;NSISdl::download http://surfnet.dl.sourceforge.net/sourceforge/dejavu/dejavu-fonts-ttf-2.25.zip $INSTDIR\binary-source\fonts
172  ;goto xmlstarlet_done
173                                                                                                                                                                                                                                                                               
174; !!BATIK  ${FileDownload} "$TAHDL" "http://inkscape.modevia.com/win32"                         "inkscape-0.46.win32.7z"                        "ff2d2c7950a7747c77b19ac7cf2a7c6a"
175; !!BATIK   RMDir /r "$INSTDIR\inkscape"
176; !!BATIK   nsExec::ExecToLog '"$INSTDIR\zip\7za" "x" "-o$INSTDIR" "$TAHDL\$0"'
177; !!BATIK   Pop $0
178; !!BATIK   DetailPrint '"7za" "x" "$TAHDL\$0" returned $0'
179; !!BATIK   RMDir /r "$INSTDIR\packaging"
180; !!BATIK   RMDir /r "$INSTDIR\src"
181
182
183  ; Activestate does not allow redistribution of their software. So download is needed
184  ${FileDownload} "$TAHDL" "http://downloads.activestate.com/ActivePerl/releases/5.14.1.1401"   "ActivePerl-5.14.1.1401-MSWin32-x86-294969.zip" "b787066279f5f5aa1288faae3403e6b0"
185    RMDir /r "$INSTDIR\perl"
186    ZipDLL::extractall $TAHDL\$0 $INSTDIR\tmp
187    Rename $INSTDIR\tmp\ActivePerl-5.14.1.1401-MSWin32-x86-294969\perl $INSTDIR\perl
188    RMDir /r $INSTDIR\tmp
189    ${StrRep} $0 "$INSTDIR\perl" "\" "\\"
190    nsExec::ExecToLog '"$INSTDIR\perl\bin\wperl.exe" "$INSTDIR\perl\bin\reloc_perl" "$0"'
191    Pop $0
192    DetailPrint "reloc_perl returned $0"
193    ${If} $0 != 0
194        Abort
195    ${EndIf}
196
197  ${fileDownload} "$TAHDL" "http://www.bribes.org/perl/ppm"                                             "IPC-Run.ppd"                "222E0B3EF0EAD5B51CFFE11432D95648"
198  ${fileDownload} "$TAHDL" "http://www.bribes.org/perl/ppm"                                             "IPC-Run-0.89-PPM514.tar.gz" "4bb2f08bd90abdfb77c40c016d37b5ab"
199 
200  ${ppmInstall}   "$TAHDL" "$TAHDL\IPC-Run.ppd"
201  ${ppmInstall}   "$TAHDL" "Win32-GUI"
202  ${ppmInstall}   "$TAHDL" "AppConfig"
203  ${ppmInstall}   "$TAHDL" "Math-Vec"
204  ${ppmInstall}   "$TAHDL" "libxml-perl"
205  ${ppmInstall}   "$TAHDL" "XML-XPath"
206  ${ppmInstall}   "$TAHDL" "Set-Object"
207  ${ppmInstall}   "$TAHDL" "XML-Writer"
208  ${ppmInstall}   "$TAHDL" "Error"
209  ${ppmInstall}   "$TAHDL" "Module-Pluggable"
210
211  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
212  ; Download Tiles@home using svn
213  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
214  Call GetProxySettings
215  DetailPrint "Proxy-host $IPADDRESS1"
216  DetailPrint "Proxy-port $PORT1"
217  ${If} $IPADDRESS1 != ""
218    CreateDirectory $APPDATA\Subversion
219    FileOpen $9 $APPDATA\Subversion\servers w ;Opens a Empty File an fills it
220    FileWrite $9 "[global]$\r$\n"
221    FileWrite $9 "http-proxy-host = $IPADDRESS1$\r$\n"
222    FileWrite $9 "http-proxy-port = $PORT1$\r$\n"
223    FileClose $9 ;Closes the filled file
224  ${EndIf}
225  SetOutPath $INSTDIR
226  nsExec::ExecToLog '"$INSTDIR\svn\bin\svn" "co" "http://svn.openstreetmap.org/applications/rendering/tilesAtHome-dev/tags/Vizag" tilesAtHome'
227  Pop $0
228  DetailPrint "svn checkout returned $0"
229  RMDir /r $APPDATA\Subversion
230  ${If} $0 != 0
231        Abort
232  ${EndIf}
233
234;  DetailPrint "Adjusting settings in config file"
235;  Push Rasterizer=Inkscape #text to be replaced
236;  Push Rasterizer=Batik #replace with
237;  Push all #replace all occurrences
238;  Push all #replace all occurrences
239;  Push $INSTDIR\tilesAtHome\tilesAtHome.conf.windows #file to replace in
240;  Call AdvReplaceInFile
241
242  CreateDirectory $INSTDIR\tmp
243  SetOutPath $INSTDIR
244
245  ; Start Menu creation
246  CreateDirectory $SMPROGRAMS\TilesAtHome
247  CreateShortCut "$SMPROGRAMS\TilesAtHome\TilesAtHome GUI.lnk" "$INSTDIR\perl\bin\perl.exe" '"$INSTDIR\tah.pl"' "$INSTDIR\tah.ico" 0
248
249;Store installation folder
250;  WriteRegStr HKCU "Software\Modern UI Test" "" $INSTDIR
251
252  ; http://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs
253  ; uninstaller creation and registration
254  WriteUninstaller "uninstall.exe"
255  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
256                 "DisplayName" "$(^Name)"
257  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
258                 "DisplayIcon" "$\"$INSTDIR\tah.ico$\""
259  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
260                 "DisplayVersion" "${VERSION}"
261  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
262                 "Publisher" "T@H for OSM"
263  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
264                 "Contact" "osm@stephans-server.de"
265  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
266                 "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
267  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
268                 "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
269  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
270                 "InstallLocation" "$\"$INSTDIR\$\""
271  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
272                 "NoModify" "1"
273  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
274                 "NoRepair" "1"
275  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
276                 "EstimatedSize" "165000"
277  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
278                 "Comments" "Tiles@Home for Windows: collaborative rendering for the OSM map"
279  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
280                 "URLInfoAbout" "http://wiki.openstreetmap.org/wiki/Windows%40home"
281;  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome" \
282;                 "Readme" "http://wiki.openstreetmap.org/wiki/Windows%40home"
283                 
284                 
285                 
286SectionEnd ; end the section
287
288; The stuff to install
289Section "Fonts" SecFonts
290  SectionIn RO
291
292  StrCpy $FONT_DIR $FONTS
293
294  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSans-Bold.ttf'
295  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSans-BoldOblique.ttf'
296  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSans-ExtraLight.ttf'
297  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSans-Oblique.ttf'
298  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSans.ttf'
299  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSansCondensed-Bold.ttf'
300  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSansCondensed-BoldOblique.ttf'
301  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSansCondensed-Oblique.ttf'
302  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSansCondensed.ttf'
303  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSansMono-Bold.ttf'
304  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSansMono-BoldOblique.ttf'
305  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSansMono-Oblique.ttf'
306  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSansMono.ttf'
307  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSerif-Bold.ttf'
308  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSerif-BoldItalic.ttf'
309  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSerif-Italic.ttf'
310  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSerif.ttf'
311  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSerifCondensed-Bold.ttf'
312  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSerifCondensed-BoldItalic.ttf'
313  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSerifCondensed-Italic.ttf'
314  !insertmacro InstallTTFFont 'binary-source\fonts\DejaVuSerifCondensed.ttf'
315  !insertmacro InstallTTFFont 'binary-source\fonts\unifont.ttf'
316
317  SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000
318
319SectionEnd
320
321Section "Batik Renderer" SecBatik
322   SectionIn RO
323
324   AddSize 21000
325
326   ; force java install to be always silent. restore previous state afterwards
327   ; TODO: java installer not silent. lib setting wrong argument. Disabled for now.
328   ;SetSilent silent
329   call DownloadAndInstallJREIfNecessary
330   StrCmp $SILENTMODE "normal" 0 +2
331   SetSilent normal
332   
333
334   SetOutPath $INSTDIR\batik
335   File /r /x .svn binary-source\batik\*.*
336
337SectionEnd
338
339Section "Downloaded Cache" SecDownload
340   SectionIn RO
341   AddSize 50000
342SectionEnd
343
344Section "-PostInstall" SecPostInstall
345
346; $::HKEY_CURRENT_USER->Open("SOFTWARE\\openstreetmap.org\\tah", $tahreg)
347; $tahreg->QueryValueEx("http_proxy_enable", $type, $http_proxy_enabled);
348; $tahreg->QueryValueEx("http_proxy_exceptions", $type, $http_proxy_exceptions);
349; $tahreg->QueryValueEx("http_proxy_host", $type, $http_proxy_host);
350; $tahreg->QueryValueEx("http_proxy_port", $type, $http_proxy_port);
351; $tahreg->QueryValueEx("http_proxy_username", $type, $http_proxy_username);
352; $tahreg->QueryValueEx("http_proxy_password", $type, $http_proxy_password);
353; $tahreg->QueryValueEx("authentication_username", $type, $authentication_username);
354; $tahreg->QueryValueEx("authentication_password", $type, $authentication_password);
355; $tahreg->QueryValueEx("console_visible", $type, $console_visible);
356
357  WriteRegDWORD HKCU "Software\openstreetmap.org\tah" "batikRasterizer" 0x1
358
359
360SectionEnd
361
362SectionGroupEnd
363
364Section "Uninstall"
365
366  ; Remove registry keys
367  ;DeleteRegKey HKLM SOFTWARE\NSIS_Example2
368
369  ; Remove files and uninstaller
370  Delete $INSTDIR\tah.ico
371  Delete $INSTDIR\tah.pl
372  Delete $INSTDIR\uninstall.exe
373
374  ; Remove shortcuts, if any
375  Delete "$SMPROGRAMS\TilesAtHome\*.*"
376
377  ; Remove directories used
378  RMDir "$SMPROGRAMS\TilesAtHome"
379  RMDir /r "$INSTDIR\TilesAtHome"
380  RMDir /r "$INSTDIR\perl"
381  RMDir /r "$INSTDIR\zip"
382  RMDir /r "$INSTDIR\pngcrush"
383  RMDir /r "$INSTDIR\pngnq"
384  RMDir /r "$INSTDIR\optipng"
385  RMDir /r "$INSTDIR\xmlstarlet"
386  RMDir /r "$INSTDIR\batik"
387; !!BATIK  RMDir /r "$INSTDIR\inkscape"
388  RMDir /r "$INSTDIR\tmp"
389  RMDIR /r "$INSTDIR\svn"
390  RMDir "$INSTDIR"
391
392  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\TilesAtHome"
393
394; TODO remove tah keys (maybe ask user if deep clean is desired (remind update might uninstall first
395
396; TODO ask user if also remove fonts
397
398SectionEnd
399
400Section "un.Fonts"
401 ; TODO uninstall fonts. nullsoft wiki talks about problems with RemoveTTF
402SectionEnd
403
404 ;Language strings
405LangString DESC_SecFonts ${LANG_ENGLISH} "DejaVu fonts needed for renderer"
406LangString DESC_SecDownload ${LANG_ENGLISH} "Cached download of 3rd party components"
407LangString DESC_SecCoreComponents ${LANG_ENGLISH} "Tiles@Home core components"
408LangString DESC_SecBatik ${LANG_ENGLISH} "Batik rasterizer, requires Java"
409!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
410  !insertmacro MUI_DESCRIPTION_TEXT ${SecFonts} $(DESC_SecFonts)
411  !insertmacro MUI_DESCRIPTION_TEXT ${SecDownload} $(DESC_SecDownload)
412  !insertmacro MUI_DESCRIPTION_TEXT ${SecCoreComponents} $(DESC_SecCoreComponents)
413  !insertmacro MUI_DESCRIPTION_TEXT ${SecBatik} $(DESC_SecBatik)
414!insertmacro MUI_FUNCTION_DESCRIPTION_END
415
416
417Function .onInit
418
419   IfSilent 0 +3
420      StrCpy $SILENTMODE "silent"
421      goto +2
422      StrCpy $SILENTMODE "normal"
423
424FunctionEnd
425
426Function ConnectInternet
427
428        Push $R0
429    ClearErrors
430    Dialer::AttemptConnect
431    IfErrors noie3
432
433    Pop $R0
434    StrCmp $R0 "online" connected
435        MessageBox MB_OK|MB_ICONSTOP "Cannot connect to the internet."
436        Quit
437
438    noie3:
439        ; IE3 not installed
440        MessageBox MB_OK|MB_ICONINFORMATION "Please connect to the internet now."
441
442    connected:
443        Pop $R0
444FunctionEnd
445
446; TODO still needed? check download plugin. Consider reading from registry previous installation
447Function GetProxySettings
448        ReadRegDWORD $R0 HKCU "Software\Microsoft\Windows\CurrentVersion\Internet Settings" ProxyEnable ;Check registry to see if proxy is enabled
449        ${If} $R0 = 1
450                ReadRegStr $R0 HKCU "Software\Microsoft\Windows\CurrentVersion\Internet Settings" ProxyServer ;Read the proxy string from the reg.
451                ${WordFind2X} "$R0" "http=" ";" "E+1" $3 ;Get http proxy data. if error, set to 1
452                ${If} $3 = 1
453                        StrCpy $HTTPPROXY $R0
454                        ${WordFind} "$HTTPPROXY" ":" "+1" $IPADDRESS1   
455                        ${WordFind} "$HTTPPROXY" ":" "-1" $PORT1
456                ${EndIf}
457                ${If} $3 != 1 ;If there is no error, do the following
458                        StrCpy $HTTPPROXY $3
459                        ${WordFind} "$HTTPPROXY" ":" "+1" $IPADDRESS1   
460                        ${WordFind} "$HTTPPROXY" ":" "-1" $PORT1
461                ${EndIf}
462                ${WordFind2X} "$R0" "https=" ";" "E+1" $3 ;Get https proxy data. if error, set to 1
463                ${If} $3 != 1 ;If there is no error, do the follwing:
464                        StrCpy $HTTPSPROXY $3
465                        ${WordFind} "$HTTPSPROXY" ":" "+1" $IPADDRESS2   ;Split it up
466                        ${WordFind} "$HTTPSPROXY" ":" "-1" $PORT2
467                ${EndIf}
468;       ${ElseIf} $R0 = 0
469;               MessageBox MB_OK "No Proxy Data Found. Assuming Direct Connection to Internet"
470        ${EndIf}
471FunctionEnd
472
473Function fileDownload
474        ClearErrors
475        Pop $4
476        Pop $3
477        Pop $2
478        Pop $1
479        Push $3
480        md5dll::GetMD5File "$1\$3"
481        Pop $0
482        ${If} $0 == $4
483                DetailPrint "MD5 $3 Ok"
484        ${Else}
485                DetailPrint "Wrong MD5 $0... Downloading..."
486                NSISdl::download $2/$3 $1\$3
487                Pop $0
488                ${If} $0 == "success"
489                        DetailPrint "Download $3 finished!!"
490                        md5dll::GetMD5File "$1\$3"
491                        Pop $0
492                        ${If} $0 != $4
493                                DetailPrint "Downloaded MD5 differs. Using file with new MD5: $0"
494                        ${EndIf}
495                ${Else}
496                        SetDetailsView show
497                        DetailPrint "Download $3 failed: $0"
498                        Abort
499                ${EndIf}
500        ${EndIf}
501        Pop $0
502FunctionEnd     
503
504Function ppmInstall
505        ClearErrors
506        Pop $2
507        Pop $1
508        SetOutPath $1
509    DetailPrint 'Installing perl module $2 ...'
510    nsExec::ExecToLog '"$INSTDIR\perl\bin\wperl.exe" "$INSTDIR\perl\bin\ppm" "install" "$2"'
511    Pop $0
512    DetailPrint '... "ppm install $2" returned $0'
513    ${If} $0 != 0
514        Abort
515    ${EndIf}
516FunctionEnd
517
518; http://nsis.sourceforge.net/More_advanced_replace_text_in_file
519Function AdvReplaceInFile
520Exch $0 ;file to replace in
521Exch
522Exch $1 ;number to replace after
523Exch
524Exch 2
525Exch $2 ;replace and onwards
526Exch 2
527Exch 3
528Exch $3 ;replace with
529Exch 3
530Exch 4
531Exch $4 ;to replace
532Exch 4
533Push $5 ;minus count
534Push $6 ;universal
535Push $7 ;end string
536Push $8 ;left string
537Push $9 ;right string
538Push $R0 ;file1
539Push $R1 ;file2
540Push $R2 ;read
541Push $R3 ;universal
542Push $R4 ;count (onwards)
543Push $R5 ;count (after)
544Push $R6 ;temp file name
545 
546  GetTempFileName $R6
547  FileOpen $R1 $0 r ;file to search in
548  FileOpen $R0 $R6 w ;temp file
549   StrLen $R3 $4
550   StrCpy $R4 -1
551   StrCpy $R5 -1
552 
553loop_read:
554 ClearErrors
555 FileRead $R1 $R2 ;read line
556 IfErrors exit
557 
558   StrCpy $5 0
559   StrCpy $7 $R2
560 
561loop_filter:
562   IntOp $5 $5 - 1
563   StrCpy $6 $7 $R3 $5 ;search
564   StrCmp $6 "" file_write2
565   StrCmp $6 $4 0 loop_filter
566 
567StrCpy $8 $7 $5 ;left part
568IntOp $6 $5 + $R3
569IntCmp $6 0 is0 not0
570is0:
571StrCpy $9 ""
572Goto done
573not0:
574StrCpy $9 $7 "" $6 ;right part
575done:
576StrCpy $7 $8$3$9 ;re-join
577 
578IntOp $R4 $R4 + 1
579StrCmp $2 all file_write1
580StrCmp $R4 $2 0 file_write2
581IntOp $R4 $R4 - 1
582 
583IntOp $R5 $R5 + 1
584StrCmp $1 all file_write1
585StrCmp $R5 $1 0 file_write1
586IntOp $R5 $R5 - 1
587Goto file_write2
588 
589file_write1:
590 FileWrite $R0 $7 ;write modified line
591Goto loop_read
592 
593file_write2:
594 FileWrite $R0 $R2 ;write unmodified line
595Goto loop_read
596 
597exit:
598  FileClose $R0
599  FileClose $R1
600 
601   SetDetailsPrint none
602  Delete $0
603  Rename $R6 $0
604  Delete $R6
605   SetDetailsPrint both
606 
607Pop $R6
608Pop $R5
609Pop $R4
610Pop $R3
611Pop $R2
612Pop $R1
613Pop $R0
614Pop $9
615Pop $8
616Pop $7
617Pop $6
618Pop $5
619Pop $0
620Pop $1
621Pop $2
622Pop $3
623Pop $4
624FunctionEnd
625
Note: See TracBrowser for help on using the repository browser.