blob: 7b69e7d9cb6b8e40f84004b19ee2d65d990a7b57 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001# NSIS file to create a self-installing exe for Vim.
2# It requires NSIS version 2.0 or later.
Bram Moolenaar8b682772010-07-30 21:49:40 +02003# Last Change: 2010 Jul 30
Bram Moolenaar071d4272004-06-13 20:20:40 +00004
5# WARNING: if you make changes to this script, look out for $0 to be valid,
6# because uninstall deletes most files in $0.
7
Bram Moolenaarba460752013-07-04 22:35:01 +02008# Location of gvim_ole.exe, vimw32.exe, GvimExt/*, etc.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009!define VIMSRC "..\src"
10
11# Location of runtime files
12!define VIMRT ".."
13
14# Location of extra tools: diff.exe
15!define VIMTOOLS ..\..
16
17# Comment the next line if you don't have UPX.
18# Get it at http://upx.sourceforge.net
19!define HAVE_UPX
20
21# comment the next line if you do not want to add Native Language Support
22!define HAVE_NLS
23
24!define VER_MAJOR 7
Bram Moolenaar3b1db362013-08-10 15:00:24 +020025!define VER_MINOR 4
Bram Moolenaar071d4272004-06-13 20:20:40 +000026
27# ----------- No configurable settings below this line -----------
28
29!include UpgradeDLL.nsh # for VisVim.dll
Bram Moolenaar442b4222010-05-24 21:34:22 +020030!include LogicLib.nsh
31!include x64.nsh
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
33Name "Vim ${VER_MAJOR}.${VER_MINOR}"
34OutFile gvim${VER_MAJOR}${VER_MINOR}.exe
35CRCCheck force
36SetCompressor lzma
37SetDatablockOptimize on
Bram Moolenaar442b4222010-05-24 21:34:22 +020038RequestExecutionLevel highest
Bram Moolenaar071d4272004-06-13 20:20:40 +000039
40ComponentText "This will install Vim ${VER_MAJOR}.${VER_MINOR} on your computer."
41DirText "Choose a directory to install Vim (must end in 'vim')"
42Icon icons\vim_16c.ico
Bram Moolenaar266411a2013-07-05 20:01:32 +020043# NSIS2 uses a different strategy with six different images in a strip...
Bram Moolenaar071d4272004-06-13 20:20:40 +000044#EnabledBitmap icons\enabled.bmp
45#DisabledBitmap icons\disabled.bmp
46UninstallText "This will uninstall Vim ${VER_MAJOR}.${VER_MINOR} from your system."
47UninstallIcon icons\vim_uninst_16c.ico
48
49# On NSIS 2 using the BGGradient causes trouble on Windows 98, in combination
50# with the BringToFront.
51# BGGradient 004000 008200 FFFFFF
52LicenseText "You should read the following before installing:"
53LicenseData ${VIMRT}\doc\uganda.nsis.txt
54
55!ifdef HAVE_UPX
56 !packhdr temp.dat "upx --best --compress-icons=1 temp.dat"
57!endif
58
Bram Moolenaar266411a2013-07-05 20:01:32 +020059SetCompressor /SOLID lzma
60XPStyle on
61
Bram Moolenaar071d4272004-06-13 20:20:40 +000062# This adds '\vim' to the user choice automagically. The actual value is
63# obtained below with ReadINIStr.
64InstallDir "$PROGRAMFILES\Vim"
65
66# Types of installs we can perform:
67InstType Typical
68InstType Minimal
69InstType Full
70
71SilentInstall normal
72
73# These are the pages we use
74Page license
75Page components
76Page directory "" "" CheckInstallDir
77Page instfiles
78UninstPage uninstConfirm
79UninstPage instfiles
80
81##########################################################
82# Functions
83
84Function .onInit
85 MessageBox MB_YESNO|MB_ICONQUESTION \
86 "This will install Vim ${VER_MAJOR}.${VER_MINOR} on your computer.$\n Continue?" \
87 IDYES NoAbort
88 Abort ; causes installer to quit.
89 NoAbort:
90
91 # run the install program to check for already installed versions
92 SetOutPath $TEMP
93 File /oname=install.exe ${VIMSRC}\installw32.exe
94 ExecWait "$TEMP\install.exe -uninstall-check"
95 Delete $TEMP\install.exe
96
97 # We may have been put to the background when uninstall did something.
98 BringToFront
99
100 # Install will have created a file for us that contains the directory where
101 # we should install. This is $VIM if it's set. This appears to be the only
102 # way to get the value of $VIM here!?
103 ReadINIStr $INSTDIR $TEMP\vimini.ini vimini dir
104 Delete $TEMP\vimini.ini
105
106 # If ReadINIStr failed or did not find a path: use the default dir.
107 StrCmp $INSTDIR "" 0 IniOK
108 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
109 IniOK:
110
111 # Should check for the value of $VIM and use it. Unfortunately I don't know
112 # how to obtain the value of $VIM
113 # IfFileExists "$VIM" 0 No_Vim
114 # StrCpy $INSTDIR "$VIM"
115 # No_Vim:
116
117 # User variables:
118 # $0 - holds the directory the executables are installed to
119 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
120 # registration (since a non-OLE gvim will not complain, and we want to
121 # always register an OLE gvim).
122 # $2 - holds the names to create batch files for
123 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
124 StrCpy $1 "-register-OLE"
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000125 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000126
127FunctionEnd
128
129Function .onUserAbort
130 MessageBox MB_YESNO|MB_ICONQUESTION "Abort install?" IDYES NoCancelAbort
131 Abort ; causes installer to not quit.
132 NoCancelAbort:
133FunctionEnd
134
135# We only accept the directory if it ends in "vim". Using .onVerifyInstDir has
136# the disadvantage that the browse dialog is difficult to use.
137Function CheckInstallDir
138 StrCpy $0 $INSTDIR 3 -3
139 StrCmp $0 "vim" PathGood
140 MessageBox MB_OK "The path must end in 'vim'."
141 Abort
142 PathGood:
143FunctionEnd
144
145Function .onInstSuccess
146 WriteUninstaller vim${VER_MAJOR}${VER_MINOR}\uninstall-gui.exe
147 MessageBox MB_YESNO|MB_ICONQUESTION \
Bram Moolenaarf2330482008-06-24 20:19:36 +0000148 "The installation process has been successful. Happy Vimming! \
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149 $\n$\n Do you want to see the README file now?" IDNO NoReadme
150 Exec '$0\gvim.exe -R "$0\README.txt"'
151 NoReadme:
152FunctionEnd
153
154Function .onInstFailed
155 MessageBox MB_OK|MB_ICONEXCLAMATION "Installation failed. Better luck next time."
156FunctionEnd
157
158Function un.onUnInstSuccess
159 MessageBox MB_OK|MB_ICONINFORMATION \
160 "Vim ${VER_MAJOR}.${VER_MINOR} has been (partly) removed from your system"
161FunctionEnd
162
163Function un.GetParent
164 Exch $0 ; old $0 is on top of stack
165 Push $1
166 Push $2
167 StrCpy $1 -1
168 loop:
169 StrCpy $2 $0 1 $1
170 StrCmp $2 "" exit
171 StrCmp $2 "\" exit
172 IntOp $1 $1 - 1
173 Goto loop
174 exit:
175 StrCpy $0 $0 $1
176 Pop $2
177 Pop $1
178 Exch $0 ; put $0 on top of stack, restore $0 to original value
179FunctionEnd
180
181##########################################################
182Section "Vim executables and runtime files"
183 SectionIn 1 2 3
184
185 # we need also this here if the user changes the instdir
186 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
187
188 SetOutPath $0
189 File /oname=gvim.exe ${VIMSRC}\gvim_ole.exe
190 File /oname=install.exe ${VIMSRC}\installw32.exe
191 File /oname=uninstal.exe ${VIMSRC}\uninstalw32.exe
192 File ${VIMSRC}\vimrun.exe
193 File /oname=xxd.exe ${VIMSRC}\xxdw32.exe
194 File ${VIMTOOLS}\diff.exe
195 File ${VIMRT}\vimtutor.bat
196 File ${VIMRT}\README.txt
197 File ..\uninstal.txt
198 File ${VIMRT}\*.vim
199 File ${VIMRT}\rgb.txt
200
201 SetOutPath $0\colors
202 File ${VIMRT}\colors\*.*
203
204 SetOutPath $0\compiler
205 File ${VIMRT}\compiler\*.*
206
207 SetOutPath $0\doc
208 File ${VIMRT}\doc\*.txt
209 File ${VIMRT}\doc\tags
210
211 SetOutPath $0\ftplugin
212 File ${VIMRT}\ftplugin\*.*
213
214 SetOutPath $0\indent
215 File ${VIMRT}\indent\*.*
216
217 SetOutPath $0\macros
218 File ${VIMRT}\macros\*.*
219
220 SetOutPath $0\plugin
221 File ${VIMRT}\plugin\*.*
222
Bram Moolenaar7fcab2a2006-03-25 21:46:12 +0000223 SetOutPath $0\autoload
224 File ${VIMRT}\autoload\*.*
225
Bram Moolenaar18144c82006-04-12 21:52:12 +0000226 SetOutPath $0\autoload\xml
227 File ${VIMRT}\autoload\xml\*.*
228
Bram Moolenaar071d4272004-06-13 20:20:40 +0000229 SetOutPath $0\syntax
230 File ${VIMRT}\syntax\*.*
231
Bram Moolenaarc01140a2006-03-24 22:21:52 +0000232 SetOutPath $0\spell
233 File ${VIMRT}\spell\*.txt
234 File ${VIMRT}\spell\*.vim
235 File ${VIMRT}\spell\*.spl
236 File ${VIMRT}\spell\*.sug
237
Bram Moolenaar071d4272004-06-13 20:20:40 +0000238 SetOutPath $0\tools
239 File ${VIMRT}\tools\*.*
240
241 SetOutPath $0\tutor
242 File ${VIMRT}\tutor\*.*
243SectionEnd
244
245##########################################################
246Section "Vim console program (vim.exe)"
247 SectionIn 1 3
248
249 SetOutPath $0
250 ReadRegStr $R0 HKLM \
251 "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
252 IfErrors 0 lbl_winnt
Bram Moolenaarba460752013-07-04 22:35:01 +0200253 # Windows 95/98/ME: not supported
Bram Moolenaar071d4272004-06-13 20:20:40 +0000254 Goto lbl_done
255 lbl_winnt:
Bram Moolenaar266411a2013-07-05 20:01:32 +0200256 # Windows NT/2000/XP and later
Bram Moolenaar071d4272004-06-13 20:20:40 +0000257 File /oname=vim.exe ${VIMSRC}\vimw32.exe
258 lbl_done:
259 StrCpy $2 "$2 vim view vimdiff"
260SectionEnd
261
262##########################################################
263Section "Create .bat files for command line use"
264 SectionIn 3
265
266 StrCpy $1 "$1 -create-batfiles $2"
267SectionEnd
268
269##########################################################
270Section "Create icons on the Desktop"
271 SectionIn 1 3
272
273 StrCpy $1 "$1 -install-icons"
274SectionEnd
275
276##########################################################
277Section "Add Vim to the Start Menu"
278 SectionIn 1 3
279
280 StrCpy $1 "$1 -add-start-menu"
281SectionEnd
282
283##########################################################
284Section "Add an Edit-with-Vim context menu entry"
285 SectionIn 1 3
286
287 # Be aware of this sequence of events:
288 # - user uninstalls Vim, gvimext.dll can't be removed (it's in use) and
289 # is scheduled to be removed at next reboot.
290 # - user installs Vim in same directory, gvimext.dll still exists.
291 # If we now skip installing gvimext.dll, it will disappear at the next
292 # reboot. Thus when copying gvimext.dll fails always schedule it to be
293 # installed at the next reboot. Can't use UpgradeDLL!
294 # We don't ask the user to reboot, the old dll will keep on working.
295 SetOutPath $0
296 ClearErrors
297 SetOverwrite try
Bram Moolenaar442b4222010-05-24 21:34:22 +0200298 ${If} ${RunningX64}
299 File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext64.dll
300 ${Else}
301 File /oname=gvimext.dll ${VIMSRC}\GvimExt\gvimext.dll
302 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000303 IfErrors 0 GvimExtDone
304
305 # Can't copy gvimext.dll, create it under another name and rename it on
306 # next reboot.
307 GetTempFileName $3 $0
Bram Moolenaar442b4222010-05-24 21:34:22 +0200308 ${If} ${RunningX64}
309 File /oname=$3 ${VIMSRC}\GvimExt\gvimext64.dll
310 ${Else}
311 File /oname=$3 ${VIMSRC}\GvimExt\gvimext.dll
312 ${EndIf}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000313 Rename /REBOOTOK $3 $0\gvimext.dll
314
315 GvimExtDone:
316 SetOverwrite lastused
317
318 # We don't have a separate entry for the "Open With..." menu, assume
319 # the user wants either both or none.
320 StrCpy $1 "$1 -install-popup -install-openwith"
321SectionEnd
322
323##########################################################
324Section "Create a _vimrc if it doesn't exist"
325 SectionIn 1 3
326
327 StrCpy $1 "$1 -create-vimrc"
328SectionEnd
329
330##########################################################
331Section "Create plugin directories in HOME or VIM"
332 SectionIn 1 3
333
334 StrCpy $1 "$1 -create-directories home"
335SectionEnd
336
337##########################################################
338Section "Create plugin directories in VIM"
339 SectionIn 3
340
341 StrCpy $1 "$1 -create-directories vim"
342SectionEnd
343
344##########################################################
345Section "VisVim Extension for MS Visual Studio"
346 SectionIn 3
347
348 SetOutPath $0
349 !insertmacro UpgradeDLL "${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
350 File ${VIMSRC}\VisVim\README_VisVim.txt
351SectionEnd
352
353##########################################################
354!ifdef HAVE_NLS
355 Section "Native Language Support"
356 SectionIn 1 3
357
358 SetOutPath $0\lang
359 File /r ${VIMRT}\lang\*.*
360 SetOutPath $0\keymap
361 File ${VIMRT}\keymap\README.txt
362 File ${VIMRT}\keymap\*.vim
363 SetOutPath $0
364 File ${VIMRT}\libintl.dll
365 SectionEnd
366!endif
367
368##########################################################
369Section -call_install_exe
370 SetOutPath $0
371 ExecWait "$0\install.exe $1"
372SectionEnd
373
374##########################################################
375Section -post
376 BringToFront
377SectionEnd
378
379##########################################################
380Section Uninstall
381 # Apparently $INSTDIR is set to the directory where the uninstaller is
382 # created. Thus the "vim61" directory is included in it.
383 StrCpy $0 "$INSTDIR"
384
385 # If VisVim was installed, unregister the DLL.
386 IfFileExists "$0\VisVim.dll" Has_VisVim No_VisVim
387 Has_VisVim:
388 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
389
390 No_VisVim:
391
392 # delete the context menu entry and batch files
393 ExecWait "$0\uninstal.exe -nsis"
394
395 # We may have been put to the background when uninstall did something.
396 BringToFront
397
398 # ask the user if the Vim version dir must be removed
399 MessageBox MB_YESNO|MB_ICONQUESTION \
400 "Would you like to delete $0?$\n \
401 $\nIt contains the Vim executables and runtime files." IDNO NoRemoveExes
402
403 Delete /REBOOTOK $0\*.dll
404 ClearErrors
405 # Remove everything but *.dll files. Avoids that
406 # a lot remains when gvimext.dll cannot be deleted.
Bram Moolenaar408b5852006-05-13 10:44:07 +0000407 RMDir /r $0\autoload
Bram Moolenaar071d4272004-06-13 20:20:40 +0000408 RMDir /r $0\colors
409 RMDir /r $0\compiler
410 RMDir /r $0\doc
411 RMDir /r $0\ftplugin
412 RMDir /r $0\indent
413 RMDir /r $0\macros
414 RMDir /r $0\plugin
Bram Moolenaar408b5852006-05-13 10:44:07 +0000415 RMDir /r $0\spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000416 RMDir /r $0\syntax
417 RMDir /r $0\tools
418 RMDir /r $0\tutor
419 RMDir /r $0\VisVim
420 RMDir /r $0\lang
421 RMDir /r $0\keymap
422 Delete $0\*.exe
423 Delete $0\*.bat
424 Delete $0\*.vim
425 Delete $0\*.txt
426
427 IfErrors ErrorMess NoErrorMess
428 ErrorMess:
429 MessageBox MB_OK|MB_ICONEXCLAMATION \
430 "Some files in $0 have not been deleted!$\nYou must do it manually."
431 NoErrorMess:
432
433 # No error message if the "vim62" directory can't be removed, the
434 # gvimext.dll may still be there.
435 RMDir $0
436
437 NoRemoveExes:
438 # get the parent dir of the installation
439 Push $INSTDIR
440 Call un.GetParent
441 Pop $0
442 StrCpy $1 $0
443
444 # if a plugin dir was created at installation ask the user to remove it
445 # first look in the root of the installation then in HOME
446 IfFileExists $1\vimfiles AskRemove 0
447 ReadEnvStr $1 "HOME"
448 StrCmp $1 "" NoRemove 0
449
450 IfFileExists $1\vimfiles 0 NoRemove
451
452 AskRemove:
453 MessageBox MB_YESNO|MB_ICONQUESTION \
Bram Moolenaare04abda2010-08-01 22:35:43 +0200454 "Remove all files in your $1\vimfiles directory?$\n \
Bram Moolenaar760d14a2010-07-31 22:03:44 +0200455 $\nCAREFUL: If you have created something there that you want to keep, click No" IDNO Fin
Bram Moolenaar071d4272004-06-13 20:20:40 +0000456 RMDir /r $1\vimfiles
457 NoRemove:
458
459 # ask the user if the Vim root dir must be removed
460 MessageBox MB_YESNO|MB_ICONQUESTION \
461 "Would you like to remove $0?$\n \
462 $\nIt contains your Vim configuration files!" IDNO NoDelete
463 RMDir /r $0 ; skipped if no
464 NoDelete:
465
466 Fin:
467 Call un.onUnInstSuccess
468
469SectionEnd