add ask on uninstall, add windows software control panel list entry, check for newer...
authorJohannes Roith <johannes@mono-cvs.ximian.com>
Sat, 15 Mar 2003 15:17:20 +0000 (15:17 -0000)
committerJohannes Roith <johannes@mono-cvs.ximian.com>
Sat, 15 Mar 2003 15:17:20 +0000 (15:17 -0000)
svn path=/trunk/mcs/; revision=12535

mcs/tools/mono-win32-setup.nsi

index aa6b2b6e3035c0ceebd2c41e460070b7bed18919..1e4ef31726b50cc9637acaad5741f429da78dac5 100755 (executable)
@@ -1,7 +1,5 @@
 ; =====================================================\r
-; mono.nsi - Mono Setup Wizard for Windows\r
-;            uses NullSoft Installer System\r
-;            found at http://nsis.sourceforge.net/\r
+; mono.nsi - Mono Setup wizard for windows\r
 ; =====================================================\r
 ;\r
 ; (C) Copyright 2003 by Johannes Roith\r
@@ -12,7 +10,7 @@
 ;       Daniel Morgan <danmorg@sc.rr.com>\r
 ;\r
 ; This .nsi includes code from the NSIS Archives:\r
-; function StrReplace\r
+; function StrReplace and VersionCheck \r
 ; by Hendri Adriaens\r
 ; HendriAdriaens@hotmail.com\r
 ; \r
@@ -27,7 +25,7 @@
 ;\r
 ;\r
   !define MILESTONE "0.23" ;\r
-  !define SOURCE_INSTALL_DIR "c:\mono-0.23\install\\*" ;\r
+  !define SOURCE_INSTALL_DIR "c:\mono-0.23-setup\install\\*" ;\r
 \r
 ; =====================================================\r
 ; BUILDING\r
 ; 2. In your install directory, delete the *.a files.\r
 ;     Most people won't need them and it saves ~ 4 MB.\r
 ;\r
-; 3. Get latest the latest NSIS from cvs or \r
-;    a development snapshot\r
-;    from http://nsis.sourceforge.net/\r
-;\r
-;    Documentation for it can be found\r
+; 3. Get latest nsis from cvs or a development snapshot\r
+;    from http://nsis.sf.net\r
 ;\r
 ; 4. Adapt the MILESTONE\r
 ;\r
 ; 6. Open this script in makensisw.exe\r
 ;\r
 ; 7. The output file is mono-[MILESTONE]-win32-1.exe\r
-;    If there has been a mono-[MILESTONE]-win32-1.exe\r
-;    created, then increment the number after win32- \r
-;    to indicate the win32 package build number, such as,\r
-;    mono-[MILESTONE]-win32-2.exe  \r
-;    Usually, this would be done if there were errors in\r
-;    the 1st package that was released.\r
+;\r
+;\r
+;\r
 ;\r
 ;\r
 ; =====================================================\r
 \r
 Section "Uninstall"\r
 \r
+  MessageBox MB_YESNO "Are you sure you want to uninstall Mono from your system?" IDNO NoUnInstall\r
+\r
   Delete $INSTDIR\Uninst.exe ; delete Uninstaller\r
+  DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} ; Remove Entry in Software List\r
 \r
   MessageBox MB_YESNO "Mono was installed into $INSTDIR. Should this directory be removed completly?" IDNO GoNext1\r
   RMDir /r $INSTDIR\r
@@ -158,13 +153,26 @@ Section "Uninstall"
   Delete $WINDIR\monosn.bat\r
 \r
   GoNext2:\r
-\r
+  NoUnInstall:\r
 \r
 SectionEnd\r
 \r
 \r
-\r
  Section\r
+\r
+ ; Warn people if a newer Mono is already installed\r
+\r
+ ReadRegStr $0 HKEY_LOCAL_MACHINE SOFTWARE\Mono\ DefaultCLR\r
+ Push $0\r
+ Push ${MILESTONE} \r
+ Call VersionCheck\r
+ Pop $0\r
+ StrCmp $0 0 NoAskInstall\r
+ StrCmp $0 2 NoAskInstall\r
+ MessageBox MB_YESNO "A newer Mono version is already installed. Still continue?" IDNO NoInstall\r
+\r
+ NoAskInstall:\r
+\r
  SetOutPath $INSTDIR\r
  File /r "${SOURCE_INSTALL_DIR}"\r
  WriteUninstaller Uninst.exe\r
@@ -175,6 +183,10 @@ SectionEnd
  ;WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} GtkSharpLibPath $INSTDIR\lib\r
  WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR ${MILESTONE}\r
 \r
+ ; Mono Uninstall Entry in Windows Software List in the Control panel\r
+ WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} DisplayName "Mono ${MILESTONE}"\r
+ WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} UninstallString $INSTDIR\uninst.exe\r
+\r
  ;original string is like C:\mono-0.20\install\r
  StrCpy $5 $INSTDIR \r
  Push $5\r
@@ -233,7 +245,7 @@ FileOpen $0 "$INSTDIR\bin\monodis.exe.sh" "w"
 FileWrite $0 "#!/bin/sh$\r$\n"
 FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"
 FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"
-FileWrite $0 '$6/bin/monodis.exe "$$@"'
+FileWrite $0 '$6/bin/mono.exe $6/bin/monodis.exe "$$@"'
 FileClose $0\r
 \r
 ; create bin/monoresgen wrapper to be used if the user has cygwin\r
@@ -249,7 +261,7 @@ FileOpen $0 "$INSTDIR\bin\monoilasm.exe.sh" "w"
 FileWrite $0 "#!/bin/sh$\r$\n"
 FileWrite $0 "export MONO_PATH=$6/lib$\r$\n"
 FileWrite $0 "export MONO_CFG_DIR=$6/etc/mono$\r$\n"
-FileWrite $0 '$6/bin/mono.exe $6/bin/ilasm.exe "$$@"'
+FileWrite $0 '$6/bin/mono.exe $6/bin/monoilasm.exe "$$@"'
 FileClose $0\r
 \r
 ; create bin/monosn wrapper to be used if the user has cygwin\r
@@ -418,7 +430,7 @@ FileWrite $0 "goto loop$\r$\n"
 FileWrite $0 ":done$\r$\n"\r
 FileWrite $0 "setlocal$\r$\n"\r
 FileWrite $0 'set path="%MONO_BASEPATH%\bin\;%MONO_BASEPATH%\lib\;%path%"$\r$\n'\r
-FileWrite $0 "%MONO_BASEPATH%\bin\mono.exe %MONO_BASEPATH%\bin\ilasm.exe %MONOARGS%$\r$\n"\r
+FileWrite $0 "%MONO_BASEPATH%\bin\mono.exe %MONO_BASEPATH%\bin\monoilasm.exe %MONOARGS%$\r$\n"\r
 FileWrite $0 "endlocal$\r$\n"\r
 \r
 FileClose $0\r
@@ -535,6 +547,7 @@ FileWrite $0 "endlocal$\r$\n"
 \r
 FileClose $0\r
 \r
+NoInstall:\r
 SectionEnd\r
 \r
 ; function StrReplace\r
@@ -587,3 +600,57 @@ function StrReplace
   Pop $1\r
   Exch $0\r
 FunctionEnd\r
+\r
+Function VersionCheck\r
+  Exch $0 ;second versionnumber\r
+  Exch\r
+  Exch $1 ;first versionnumber\r
+  Push $R0 ;counter for $0\r
+  Push $R1 ;counter for $1\r
+  Push $3 ;temp char\r
+  Push $4 ;temp string for $0\r
+  Push $5 ;temp string for $1\r
+  StrCpy $R0 "-1"\r
+  StrCpy $R1 "-1"\r
+  Start:\r
+  StrCpy $4 ""\r
+  DotLoop0:\r
+  IntOp $R0 $R0 + 1\r
+  StrCpy $3 $0 1 $R0\r
+  StrCmp $3 "" DotFound0\r
+  StrCmp $3 "." DotFound0\r
+  StrCpy $4 $4$3\r
+  Goto DotLoop0\r
+  DotFound0:\r
+  StrCpy $5 ""\r
+  DotLoop1:\r
+  IntOp $R1 $R1 + 1\r
+  StrCpy $3 $1 1 $R1\r
+  StrCmp $3 "" DotFound1\r
+  StrCmp $3 "." DotFound1\r
+  StrCpy $5 $5$3\r
+  Goto DotLoop1\r
+  DotFound1:\r
+  Strcmp $4 "" 0 Not4\r
+    StrCmp $5 "" Equal\r
+    Goto Ver2Less\r
+  Not4:\r
+  StrCmp $5 "" Ver2More\r
+  IntCmp $4 $5 Start Ver2Less Ver2More\r
+  Equal:\r
+  StrCpy $0 "0"\r
+  Goto Finish\r
+  Ver2Less:\r
+  StrCpy $0 "1"\r
+  Goto Finish\r
+  Ver2More:\r
+  StrCpy $0 "2"\r
+  Finish:\r
+  Pop $5\r
+  Pop $4\r
+  Pop $3\r
+  Pop $R1\r
+  Pop $R0\r
+  Pop $1\r
+  Exch $0\r
+FunctionEnd
\ No newline at end of file