Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
We shouldn't install in a location with spaces.
Browse files Browse the repository at this point in the history
- The default install location is now C:\OCaml (sigh...).
- We check for spaces before proceeding, and give the user a chance to return to
  the previous path to pick another install location.

This fixes #14.
  • Loading branch information
protz committed Jul 20, 2012
1 parent 28cd9de commit a83e8ac
Showing 1 changed file with 60 additions and 7 deletions.
67 changes: 60 additions & 7 deletions install.nsi
Expand Up @@ -45,7 +45,7 @@


Name "OCaml" Name "OCaml"
OutFile "ocaml-${MUI_VERSION}-i686-mingw64.exe" OutFile "ocaml-${MUI_VERSION}-i686-mingw64.exe"
InstallDir "$PROGRAMFILES32\${MUI_PRODUCT}" InstallDir "C:\${MUI_PRODUCT}"


!define MUI_WELCOMEPAGE_TITLE "Welcome to the OCaml setup for windows." !define MUI_WELCOMEPAGE_TITLE "Welcome to the OCaml setup for windows."
!define MUI_WELCOMEPAGE_TEXT "This wizard will install OCaml ${MUI_VERSION}, \ !define MUI_WELCOMEPAGE_TEXT "This wizard will install OCaml ${MUI_VERSION}, \
Expand Down Expand Up @@ -96,6 +96,7 @@ Var STARTMENUFOLDER
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENUFOLDER !insertmacro MUI_PAGE_STARTMENU Application $STARTMENUFOLDER
!insertmacro MUI_PAGE_LICENSE ${ROOT_DIR}\License.txt !insertmacro MUI_PAGE_LICENSE ${ROOT_DIR}\License.txt
!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH !insertmacro MUI_PAGE_FINISH
Expand All @@ -116,12 +117,62 @@ Function .onInit


FunctionEnd FunctionEnd


Function CheckForSpaces
Exch $R0
Push $R1
Push $R2
Push $R3
StrCpy $R1 -1
StrCpy $R3 $R0
StrCpy $R0 0
loop:
StrCpy $R2 $R3 1 $R1
IntOp $R1 $R1 - 1
StrCmp $R2 "" done
StrCmp $R2 " " 0 loop
IntOp $R0 $R0 + 1
Goto loop
done:
Pop $R3
Pop $R2
Pop $R1
Exch $R0
FunctionEnd

Function DirectoryLeave

# Call the CheckForSpaces function.
Push $INSTDIR # Input string (install path).
Call CheckForSpaces
Pop $R0 # The function returns the number of spaces found in the input string.

# Check if any spaces exist in $INSTDIR.
StrCmp $R0 0 NoSpaces

# Plural if more than 1 space in $INSTDIR.
StrCmp $R0 1 0 +3
StrCpy $R1 ""
Goto +2
StrCpy $R1 "s"

# Show message box then take the user back to the Directory page.
MessageBox MB_YESNO "The installation directory contains spaces. This is \
likely to cause problem with third-party packages.$\n\
Proceed anyway?" IDYES NoSpaces
Abort

NoSpaces:

FunctionEnd

Section "OCaml" SecOCaml Section "OCaml" SecOCaml


ReadRegStr $1 SHCTX "SOFTWARE\OCaml" "" ReadRegStr $1 SHCTX "SOFTWARE\OCaml" ""


${If} $1 != "" ${If} $1 != ""
MessageBox MB_YESNO "There seems to be a previous version of OCaml installed. It is strongly recommended you uninstall it before proceeding. Proceed anyway?" IDNO end MessageBox MB_YESNO "There seems to be a previous version of OCaml \
installed. It is strongly recommended you uninstall it before proceeding.$\n\
Proceed anyway?" IDNO end
${EndIf} ${EndIf}


SetOutPath "$INSTDIR\bin" SetOutPath "$INSTDIR\bin"
Expand Down Expand Up @@ -241,7 +292,8 @@ Section "ActiveTcl ${ACTIVETCL_VERSION}" SecActiveTcl
MessageBox MB_OK "Couldn't download the ActiveTCL installer: $R0" MessageBox MB_OK "Couldn't download the ActiveTCL installer: $R0"
SetErrors SetErrors
DetailPrint $R0 DetailPrint $R0
DetailPrint "Please download the ActiveTCL installer from activestate.com. Just grab the latest free, 32-bit installer." DetailPrint "Please download the ActiveTCL installer from activestate.com. \
Just grab the latest free, 32-bit installer."
goto end goto end
ok: ok:


Expand Down Expand Up @@ -311,7 +363,8 @@ SectionEnd


Section "Cygwin" SecCygwin Section "Cygwin" SecCygwin
${If} ${FileExists} "$DESKTOP\cygwin-setup.exe" ${If} ${FileExists} "$DESKTOP\cygwin-setup.exe"
MessageBox MB_YESNO "There already is a file called cygwin-setup.exe on your desktop. Overwrite?" IDNO end MessageBox MB_YESNO "There already is a file called cygwin-setup.exe on your \
desktop.$\nOverwrite?" IDNO end
${EndIf} ${EndIf}


NSISdl::download ${CYGWIN_URL} "$DESKTOP\cygwin-setup.exe" NSISdl::download ${CYGWIN_URL} "$DESKTOP\cygwin-setup.exe"
Expand All @@ -326,7 +379,7 @@ Section "Cygwin" SecCygwin
ExecWait "$DESKTOP\cygwin-setup.exe --quiet-mode \ ExecWait "$DESKTOP\cygwin-setup.exe --quiet-mode \
--local-package-dir=c:\cygtmp\ \ --local-package-dir=c:\cygtmp\ \
--site=http://cygwin.cict.fr \ --site=http://cygwin.cict.fr \
--packages=curl,make,mingw64-i686-gcc-g++,mingw64-i686-gcc,patch,rlwrap,libreadline6,diffutils,wget,vim \ --packages=curl,make,mingw64-i686-gcc-g++,mingw64-i686-gcc-core,mingw64-i686-gcc,patch,rlwrap,libreadline6,diffutils,wget,vim \
>NUL 2>&1" >NUL 2>&1"


end: end:
Expand All @@ -342,8 +395,8 @@ LangString DESC_SecActiveTcl ${LANG_ENGLISH} "ActiveTcl is distributed by \
LangString DESC_SecEmacs ${LANG_ENGLISH} "Emacs is a text editor with excellent \ LangString DESC_SecEmacs ${LANG_ENGLISH} "Emacs is a text editor with excellent \
OCaml support. This will download Emacs from the internet, and make sure the \ OCaml support. This will download Emacs from the internet, and make sure the \
OCaml specific scripts are properly installed." OCaml specific scripts are properly installed."
LangString DESC_SecCygwin ${LANG_ENGLISH} "Cygwin provides a Unix-like layer for \ LangString DESC_SecCygwin ${LANG_ENGLISH} "Cygwin provides a Unix-like layer. \
Windows. This is required if you want to run scripts such as odb, or perform \ This is required if you want to run scripts such as odb, or perform \
native-code compilation. This will download Cygwin's setup.exe to your desktop \ native-code compilation. This will download Cygwin's setup.exe to your desktop \
as cygwin-setup.exe" as cygwin-setup.exe"


Expand Down

0 comments on commit a83e8ac

Please sign in to comment.