1 # NSIS file to create a self-installing exe for Vim.
2 # It requires NSIS version 2.0 or later.
3 # Last change: 2004 May 02
5 # WARNING: if you make changes to this script, look out for $0 to be valid,
6 # because uninstall deletes most files in $0.
8 # Location of gvim_ole.exe, vimd32.exe, GvimExt/*, etc.
9 !define VIMSRC
"..\src"
11 # Location of runtime files
14 # Location of extra tools: diff.exe
15 !define VIMTOOLS
..\
..
17 # Comment the next line if you don't have UPX.
18 # Get it at http://upx.sourceforge.net
21 # comment the next line if you do not want to add Native Language Support
27 # ----------- No configurable settings below this line -----------
29 !include UpgradeDLL
.nsh
# for VisVim.dll
31 Name "Vim ${VER_MAJOR}.${VER_MINOR}"
32 OutFile gvim
${VER_MAJOR}${VER_MINOR}.exe
35 SetDatablockOptimize on
37 ComponentText "This will install Vim ${VER_MAJOR}.${VER_MINOR} on your computer."
38 DirText "Choose a directory to install Vim (must end in 'vim')"
39 Icon icons\vim_16c
.ico
40 # NSIS2 uses a different strategy with six diferent images in a strip...
41 #EnabledBitmap icons\enabled.bmp
42 #DisabledBitmap icons\disabled.bmp
43 UninstallText "This will uninstall Vim ${VER_MAJOR}.${VER_MINOR} from your system."
44 UninstallIcon icons\vim_uninst_16c
.ico
46 # On NSIS 2 using the BGGradient causes trouble on Windows 98, in combination
47 # with the BringToFront.
48 # BGGradient 004000 008200 FFFFFF
49 LicenseText "You should read the following before installing:"
50 LicenseData ${VIMRT}\doc\uganda
.nsis
.txt
53 !packhdr temp
.dat
"upx --best --compress-icons=1 temp.dat"
56 # This adds '\vim' to the user choice automagically. The actual value is
57 # obtained below with ReadINIStr.
58 InstallDir "$PROGRAMFILES\Vim"
60 # Types of installs we can perform:
67 # These are the pages we use
70 Page directory
"" "" CheckInstallDir
72 UninstPage uninstConfirm
75 ##########################################################
79 MessageBox MB_YESNO|
MB_ICONQUESTION \
80 "This will install Vim ${VER_MAJOR}.${VER_MINOR} on your computer.$\n Continue?" \
82 Abort ; causes installer to quit.
85 # run the install program to check for already installed versions
87 File /oname=install
.exe
${VIMSRC}\installw32
.exe
88 ExecWait "$TEMP\install.exe -uninstall-check"
89 Delete $TEMP\install
.exe
91 # We may have been put to the background when uninstall did something.
94 # Install will have created a file for us that contains the directory where
95 # we should install. This is $VIM if it's set. This appears to be the only
96 # way to get the value of $VIM here!?
97 ReadINIStr $INSTDIR $TEMP\vimini
.ini vimini dir
98 Delete $TEMP\vimini
.ini
100 # If ReadINIStr failed or did not find a path: use the default dir.
101 StrCmp $INSTDIR "" 0 IniOK
102 StrCpy $INSTDIR "$PROGRAMFILES\Vim"
105 # Should check for the value of $VIM and use it. Unfortunately I don't know
106 # how to obtain the value of $VIM
107 # IfFileExists "$VIM" 0 No_Vim
108 # StrCpy $INSTDIR "$VIM"
112 # $0 - holds the directory the executables are installed to
113 # $1 - holds the parameters to be passed to install.exe. Starts with OLE
114 # registration (since a non-OLE gvim will not complain, and we want to
115 # always register an OLE gvim).
116 # $2 - holds the names to create batch files for
117 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
118 StrCpy $1 "-register-OLE"
119 StrCpy $2 "gvim evim gview gvimdiff vimtutor"
123 Function .onUserAbort
124 MessageBox MB_YESNO|
MB_ICONQUESTION "Abort install?" IDYES NoCancelAbort
125 Abort ; causes installer to not quit.
129 # We only accept the directory if it ends in "vim". Using .onVerifyInstDir has
130 # the disadvantage that the browse dialog is difficult to use.
131 Function CheckInstallDir
132 StrCpy $0 $INSTDIR 3 -3
133 StrCmp $0 "vim" PathGood
134 MessageBox MB_OK "The path must end in 'vim'."
139 Function .onInstSuccess
140 WriteUninstaller vim
${VER_MAJOR}${VER_MINOR}\uninstall
-gui
.exe
141 MessageBox MB_YESNO|
MB_ICONQUESTION \
142 "The installation process has been successful. Happy Vimming! \
143 $\n$\n Do you want to see the README file now?" IDNO NoReadme
144 Exec '$0\gvim.exe -R "$0\README.txt"'
148 Function .onInstFailed
149 MessageBox MB_OK|
MB_ICONEXCLAMATION "Installation failed. Better luck next time."
152 Function un
.onUnInstSuccess
153 MessageBox MB_OK|MB_ICONINFORMATION \
154 "Vim ${VER_MAJOR}.${VER_MINOR} has been (partly) removed from your system"
157 Function un
.GetParent
158 Exch $0 ; old $0 is on top of stack
172 Exch $0 ; put $0 on top of stack, restore $0 to original value
175 ##########################################################
176 Section "Vim executables and runtime files"
179 # we need also this here if the user changes the instdir
180 StrCpy $0 "$INSTDIR\vim${VER_MAJOR}${VER_MINOR}"
183 File /oname=gvim
.exe
${VIMSRC}\gvim_ole
.exe
184 File /oname=install
.exe
${VIMSRC}\installw32
.exe
185 File /oname=uninstal
.exe
${VIMSRC}\uninstalw32
.exe
186 File ${VIMSRC}\vimrun
.exe
187 File /oname=xxd
.exe
${VIMSRC}\xxdw32
.exe
188 File ${VIMTOOLS}\diff
.exe
189 File ${VIMRT}\vimtutor
.bat
190 File ${VIMRT}\README
.txt
193 File ${VIMRT}\rgb
.txt
196 File ${VIMRT}\colors\
*.*
198 SetOutPath $0\compiler
199 File ${VIMRT}\compiler\
*.*
202 File ${VIMRT}\doc\
*.txt
203 File ${VIMRT}\doc\tags
205 SetOutPath $0\ftplugin
206 File ${VIMRT}\ftplugin\
*.*
209 File ${VIMRT}\indent\
*.*
212 File ${VIMRT}\macros\
*.*
215 File ${VIMRT}\plugin\
*.*
217 SetOutPath $0\autoload
218 File ${VIMRT}\autoload\
*.*
220 SetOutPath $0\autoload\xml
221 File ${VIMRT}\autoload\xml\
*.*
224 File ${VIMRT}\syntax\
*.*
227 File ${VIMRT}\spell\
*.txt
228 File ${VIMRT}\spell\
*.vim
229 File ${VIMRT}\spell\
*.spl
230 File ${VIMRT}\spell\
*.sug
233 File ${VIMRT}\tools\
*.*
236 File ${VIMRT}\tutor\
*.*
239 ##########################################################
240 Section "Vim console program (vim.exe)"
244 ReadRegStr $R0 HKLM \
245 "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
248 File /oname=vim
.exe
${VIMSRC}\vimd32
.exe
252 File /oname=vim
.exe
${VIMSRC}\vimw32
.exe
254 StrCpy $2 "$2 vim view vimdiff"
257 ##########################################################
258 Section "Create .bat files for command line use"
261 StrCpy $1 "$1 -create-batfiles $2"
264 ##########################################################
265 Section "Create icons on the Desktop"
268 StrCpy $1 "$1 -install-icons"
271 ##########################################################
272 Section "Add Vim to the Start Menu"
275 StrCpy $1 "$1 -add-start-menu"
278 ##########################################################
279 Section "Add an Edit-with-Vim context menu entry"
282 # Be aware of this sequence of events:
283 # - user uninstalls Vim, gvimext.dll can't be removed (it's in use) and
284 # is scheduled to be removed at next reboot.
285 # - user installs Vim in same directory, gvimext.dll still exists.
286 # If we now skip installing gvimext.dll, it will disappear at the next
287 # reboot. Thus when copying gvimext.dll fails always schedule it to be
288 # installed at the next reboot. Can't use UpgradeDLL!
289 # We don't ask the user to reboot, the old dll will keep on working.
293 File /oname=gvimext
.dll
${VIMSRC}\GvimExt\gvimext
.dll
294 IfErrors 0 GvimExtDone
296 # Can't copy gvimext.dll, create it under another name and rename it on
298 GetTempFileName $3 $0
299 File /oname=
$3 ${VIMSRC}\GvimExt\gvimext
.dll
300 Rename /REBOOTOK
$3 $0\gvimext
.dll
303 SetOverwrite lastused
305 # We don't have a separate entry for the "Open With..." menu, assume
306 # the user wants either both or none.
307 StrCpy $1 "$1 -install-popup -install-openwith"
310 ##########################################################
311 Section "Create a _vimrc if it doesn't exist"
314 StrCpy $1 "$1 -create-vimrc"
317 ##########################################################
318 Section "Create plugin directories in HOME or VIM"
321 StrCpy $1 "$1 -create-directories home"
324 ##########################################################
325 Section "Create plugin directories in VIM"
328 StrCpy $1 "$1 -create-directories vim"
331 ##########################################################
332 Section "VisVim Extension for MS Visual Studio"
336 !insertmacro UpgradeDLL
"${VIMSRC}\VisVim\VisVim.dll" "$0\VisVim.dll" "$0"
337 File ${VIMSRC}\VisVim\README_VisVim
.txt
340 ##########################################################
342 Section "Native Language Support"
346 File /r
${VIMRT}\lang\
*.*
348 File ${VIMRT}\keymap\README
.txt
349 File ${VIMRT}\keymap\
*.vim
351 File ${VIMRT}\libintl
.dll
355 ##########################################################
356 Section -call_install_exe
358 ExecWait "$0\install.exe $1"
361 ##########################################################
366 ##########################################################
368 # Apparently $INSTDIR is set to the directory where the uninstaller is
369 # created. Thus the "vim61" directory is included in it.
372 # If VisVim was installed, unregister the DLL.
373 IfFileExists "$0\VisVim.dll" Has_VisVim No_VisVim
375 ExecWait "regsvr32.exe /u /s $0\VisVim.dll"
379 # delete the context menu entry and batch files
380 ExecWait "$0\uninstal.exe -nsis"
382 # We may have been put to the background when uninstall did something.
385 # ask the user if the Vim version dir must be removed
386 MessageBox MB_YESNO|
MB_ICONQUESTION \
387 "Would you like to delete $0?$\n \
388 $\nIt contains the Vim executables and runtime files." IDNO NoRemoveExes
390 Delete /REBOOTOK
$0\
*.dll
392 # Remove everything but *.dll files. Avoids that
393 # a lot remains when gvimext.dll cannot be deleted.
414 IfErrors ErrorMess NoErrorMess
416 MessageBox MB_OK|
MB_ICONEXCLAMATION \
417 "Some files in $0 have not been deleted!$\nYou must do it manually."
420 # No error message if the "vim62" directory can't be removed, the
421 # gvimext.dll may still be there.
425 # get the parent dir of the installation
431 # if a plugin dir was created at installation ask the user to remove it
432 # first look in the root of the installation then in HOME
433 IfFileExists $1\vimfiles AskRemove
0
435 StrCmp $1 "" NoRemove
0
437 IfFileExists $1\vimfiles
0 NoRemove
440 MessageBox MB_YESNO|
MB_ICONQUESTION \
441 "Remove all files in your $1\vimfiles directory? \
442 $\nIf you have created something there that you want to keep, click No" IDNO Fin
446 # ask the user if the Vim root dir must be removed
447 MessageBox MB_YESNO|
MB_ICONQUESTION \
448 "Would you like to remove $0?$\n \
449 $\nIt contains your Vim configuration files!" IDNO NoDelete
450 RMDir /r
$0 ; skipped if no
454 Call un
.onUnInstSuccess