comparison gaim-installer.nsi @ 14450:1a01b1dae517

[gaim-migrate @ 17164] Fix the installer to be more robust in its version checking. John D. Ramsdell noticed this. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 05 Sep 2006 03:14:46 +0000
parents f5f2c3948b48
children 22cb019456bd
comparison
equal deleted inserted replaced
14449:74cdcd0c58b5 14450:1a01b1dae517
37 37
38 ; $name and $INSTDIR are set in .onInit function.. 38 ; $name and $INSTDIR are set in .onInit function..
39 39
40 !include "MUI.nsh" 40 !include "MUI.nsh"
41 !include "Sections.nsh" 41 !include "Sections.nsh"
42
42 !include "FileFunc.nsh" 43 !include "FileFunc.nsh"
43
44 !insertmacro GetParameters 44 !insertmacro GetParameters
45 !insertmacro GetOptions 45 !insertmacro GetOptions
46 !insertmacro GetParent 46 !insertmacro GetParent
47
48 !include "WordFunc.nsh"
49 !insertmacro VersionCompare
47 50
48 ;-------------------------------- 51 ;--------------------------------
49 ;Defines 52 ;Defines
50 53
51 !define GAIM_NSIS_INCLUDE_PATH ".\gtk\win32\nsis" 54 !define GAIM_NSIS_INCLUDE_PATH ".\gtk\win32\nsis"
996 Push $0 999 Push $0
997 Push $INSTDIR 1000 Push $INSTDIR
998 Call VerifyDir 1001 Call VerifyDir
999 Pop $0 1002 Pop $0
1000 StrCmp $0 "0" 0 dir_good 1003 StrCmp $0 "0" 0 dir_good
1001 Abort 1004 Pop $0
1005 Abort
1002 1006
1003 dir_good: 1007 dir_good:
1004 Pop $0 1008 Pop $0
1005 FunctionEnd
1006
1007 ; CheckGtkVersion
1008 ; inputs: Push 2 GTK+ version strings to check. The major value needs to
1009 ; be equal and the minor value needs to be greater or equal.
1010 ;
1011 ; Usage:
1012 ; Push "2.1.0" ; Reference version
1013 ; Push "2.2.1" ; Version to check
1014 ; Call CheckGtkVersion
1015 ; Pop $R0
1016 ; $R0 will now equal "1", because 2.2 is greater than 2.1
1017 ;
1018 Function CheckGtkVersion
1019 ; Version we want to check
1020 Exch $R0
1021 Exch
1022 ; Reference version
1023 Exch $R1
1024 Push $R2
1025 Push $R3
1026
1027 ; Check that the string to check is at least 5 chars long (i.e. x.x.x)
1028 StrLen $R2 $R0
1029 IntCmp $R2 5 0 bad_version
1030
1031 ; Major version check
1032 StrCpy $R2 $R0 1
1033 StrCpy $R3 $R1 1
1034 IntCmp $R2 $R3 check_minor bad_version bad_version
1035
1036 check_minor:
1037 StrCpy $R2 $R0 1 2
1038 StrCpy $R3 $R1 1 2
1039 IntCmp $R2 $R3 good_version bad_version good_version
1040
1041 bad_version:
1042 StrCpy $R0 "0"
1043 Goto done
1044
1045 good_version:
1046 StrCpy $R0 "1"
1047
1048 done:
1049 Pop $R3
1050 Pop $R2
1051 Pop $R1
1052 Exch $R0
1053 FunctionEnd 1009 FunctionEnd
1054 1010
1055 ; 1011 ;
1056 ; Usage: 1012 ; Usage:
1057 ; Call DoWeNeedGtk 1013 ; Call DoWeNeedGtk
1075 ; - If no hkcu gtk+ install, check HKLM 1031 ; - If no hkcu gtk+ install, check HKLM
1076 ; - If HKLM ver exists but old, return as if no ver exits. 1032 ; - If HKLM ver exists but old, return as if no ver exits.
1077 ; - If no rights 1033 ; - If no rights
1078 ; - Check HKLM 1034 ; - Check HKLM
1079 Push $0 1035 Push $0
1036 Push $1
1080 Push $2 1037 Push $2
1081 Push $3
1082 Push $4
1083 Push $5
1084 1038
1085 Call CheckUserInstallRights 1039 Call CheckUserInstallRights
1086 Pop $3 1040 Pop $1
1087 StrCmp $3 "HKLM" check_hklm 1041 StrCmp $1 "HKLM" check_hklm
1088 StrCmp $3 "HKCU" check_hkcu check_hklm 1042 StrCmp $1 "HKCU" check_hkcu check_hklm
1089 check_hkcu: 1043 check_hkcu:
1090 ReadRegStr $0 HKCU ${GTK_REG_KEY} "Version" 1044 ReadRegStr $0 HKCU ${GTK_REG_KEY} "Version"
1091 StrCpy $5 "HKCU" 1045 StrCpy $2 "HKCU"
1092 StrCmp $0 "" check_hklm have_gtk 1046 StrCmp $0 "" check_hklm have_gtk
1093 1047
1094 check_hklm: 1048 check_hklm:
1095 ReadRegStr $0 HKLM ${GTK_REG_KEY} "Version" 1049 ReadRegStr $0 HKLM ${GTK_REG_KEY} "Version"
1096 StrCpy $5 "HKLM" 1050 StrCpy $2 "HKLM"
1097 StrCmp $0 "" no_gtk have_gtk 1051 StrCmp $0 "" no_gtk have_gtk
1098 1052
1099 1053
1100 have_gtk: 1054 have_gtk:
1101 ; GTK+ is already installed.. check version. 1055 ; GTK+ is already installed.. check version.
1102 Push ${GTK_VERSION} ; Minimum GTK+ version needed 1056 ${VersionCompare} ${GTK_VERSION} $0 $0
1103 Push $0 1057 IntCmp $0 1 bad_version good_version good_version
1104 Call CheckGtkVersion 1058
1105 Pop $2
1106 StrCmp $2 "1" good_version bad_version
1107 bad_version: 1059 bad_version:
1108 ; Bad version. If hklm ver and we have hkcu or no rights.. return no gtk 1060 ; Bad version. If hklm ver and we have hkcu or no rights.. return no gtk
1109 StrCmp $3 "NONE" no_gtk ; if no rights.. can't upgrade 1061 StrCmp $1 "NONE" no_gtk ; if no rights.. can't upgrade
1110 StrCmp $3 "HKCU" 0 upgrade_gtk ; if HKLM can upgrade.. 1062 StrCmp $1 "HKCU" 0 upgrade_gtk ; if HKLM can upgrade..
1111 StrCmp $5 "HKLM" no_gtk upgrade_gtk ; have hkcu rights.. if found hklm ver can't upgrade.. 1063 StrCmp $2 "HKLM" no_gtk upgrade_gtk ; have hkcu rights.. if found hklm ver can't upgrade..
1112 1064
1113 upgrade_gtk: 1065 upgrade_gtk:
1114 StrCpy $2 "1"
1115 Push $5
1116 Push $2 1066 Push $2
1067 Push "1"
1117 Goto done 1068 Goto done
1118 1069
1119 good_version: 1070 good_version:
1120 StrCmp $5 "HKLM" have_hklm_gtk have_hkcu_gtk 1071 StrCmp $2 "HKLM" have_hklm_gtk have_hkcu_gtk
1121 have_hkcu_gtk: 1072 have_hkcu_gtk:
1122 ; Have HKCU version 1073 ; Have HKCU version
1123 ReadRegStr $4 HKCU ${GTK_REG_KEY} "Path" 1074 ReadRegStr $0 HKCU ${GTK_REG_KEY} "Path"
1124 Goto good_version_cont 1075 Goto good_version_cont
1125 1076
1126 have_hklm_gtk: 1077 have_hklm_gtk:
1127 ReadRegStr $4 HKLM ${GTK_REG_KEY} "Path" 1078 ReadRegStr $0 HKLM ${GTK_REG_KEY} "Path"
1128 Goto good_version_cont 1079 Goto good_version_cont
1129 1080
1130 good_version_cont: 1081 good_version_cont:
1131 StrCpy $2 "0" 1082 Push $0 ; The path to existing GTK+
1132 Push $4 ; The path to existing GTK+ 1083 Push "0"
1133 Push $2
1134 Goto done 1084 Goto done
1135 1085
1136 no_gtk: 1086 no_gtk:
1137 StrCpy $2 "2" 1087 Push $1 ; our rights
1138 Push $3 ; our rights 1088 Push "2"
1139 Push $2
1140 Goto done 1089 Goto done
1141 1090
1142 done: 1091 done:
1143 ; The top two items on the stack are what we want to return 1092 ; The top two items on the stack are what we want to return
1144 Exch 5 1093 Exch 3
1145 Pop $0 1094 Pop $0
1146 Exch 5 1095 Exch 3
1147 Pop $2 1096 Pop $2
1148 Pop $5 1097 Pop $1
1149 Pop $4
1150 Pop $3
1151 FunctionEnd 1098 FunctionEnd
1152 1099
1153 1100
1154 !macro RunCheckMacro UN 1101 !macro RunCheckMacro UN
1155 Function ${UN}RunCheck 1102 Function ${UN}RunCheck
1156 Push $R0 1103 Push $R0
1157 System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "gaim_is_running") i .R0' 1104 System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "gaim_is_running") i .R0'
1158 IntCmp $R0 0 done 1105 IntCmp $R0 0 done
1159 MessageBox MB_OK|MB_ICONEXCLAMATION $(GAIM_IS_RUNNING) /SD IDOK 1106 MessageBox MB_OK|MB_ICONEXCLAMATION $(GAIM_IS_RUNNING) /SD IDOK
1160 Abort 1107 Abort
1161 done: 1108 done:
1162 Pop $R0 1109 Pop $R0
1163 FunctionEnd 1110 FunctionEnd
1164 !macroend 1111 !macroend
1344 StrCmp $R0 "2" no_gtk no_gtk 1291 StrCmp $R0 "2" no_gtk no_gtk
1345 1292
1346 ; Don't show dir selector.. Upgrades are done to existing path.. 1293 ; Don't show dir selector.. Upgrades are done to existing path..
1347 have_gtk: 1294 have_gtk:
1348 upgrade_gtk: 1295 upgrade_gtk:
1296 Pop $R1
1297 Pop $R0
1349 Abort 1298 Abort
1350 1299
1351 no_gtk: 1300 no_gtk:
1352 StrCmp $R1 "NONE" 0 no_gtk_cont 1301 StrCmp $R1 "NONE" 0 no_gtk_cont
1353 ; Got no install rights.. 1302 ; Got no install rights..
1303 Pop $R1
1304 Pop $R0
1354 Abort 1305 Abort
1355 no_gtk_cont: 1306 no_gtk_cont:
1356 ; Suggest path.. 1307 ; Suggest path..
1357 StrCmp $R1 "HKCU" 0 hklm1 1308 StrCmp $R1 "HKCU" 0 hklm1
1358 ${GetParent} $SMPROGRAMS $R0 1309 ${GetParent} $SMPROGRAMS $R0
1375 Push $GTK_FOLDER 1326 Push $GTK_FOLDER
1376 Call VerifyDir 1327 Call VerifyDir
1377 Pop $R0 1328 Pop $R0
1378 StrCmp $R0 "0" 0 done 1329 StrCmp $R0 "0" 0 done
1379 MessageBox MB_OK $(GTK_BAD_INSTALL_PATH) /SD IDOK 1330 MessageBox MB_OK $(GTK_BAD_INSTALL_PATH) /SD IDOK
1331 Pop $R0
1380 Abort 1332 Abort
1381 done: 1333 done:
1382 Pop $R0 1334 Pop $R0
1383 FunctionEnd 1335 FunctionEnd
1384 !endif 1336 !endif