Fri, 02 Mar 2007 03:32:05 +0000
merge of '1ff837dbed01c1cc93fd5c864db0a5c86dcc3ac5'
and '2db42c6a13fa126506b07b1de005fbe2ab3e4a46'
| 11578 | 1 | ;; |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
2 | ;; Windows Pidgin NSIS installer plugin helper utilities |
| 11578 | 3 | ;; Copyright 2005, Daniel Atallah <daniel_atallah@yahoo.com> |
| 4 | ;; | |
| 5 | ;; Include in plugin installer scripts using: | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
6 | ;; !addincludedir "${PATH_TO_PIDGIN_SRC}\pidgin\win32\nsis" |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
7 | ;; !include "pidgin-plugin.nsh" |
| 11578 | 8 | ;; |
| 9 | ||
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
10 | !define PIDGIN_REG_KEY "SOFTWARE\pidgin" |
| 11578 | 11 | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
12 | !define PIDGIN_VERSION_OK 0 |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
13 | !define PIDGIN_VERSION_INCOMPATIBLE 1 |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
14 | !define PIDGIN_VERSION_UNDEFINED 2 |
| 11578 | 15 | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
16 | ; Extract the Pidgin Version from the registry |
| 11578 | 17 | ; This will set the Error flag if unable to determine the value |
| 18 | ; Pop the value of the stack after calling this to get the value (unless Error Flag is set) | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
19 | Function GetPidginVersion |
| 11578 | 20 | Push $R0 |
| 21 | ||
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
22 | ; Read the pidgin version |
| 11578 | 23 | ClearErrors |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
24 | ReadRegStr $R0 HKLM ${PIDGIN_REG_KEY} "Version" |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
25 | IfErrors +1 GetPidginVersion_found |
| 11578 | 26 | ; fall back to the HKCU registry key |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
27 | ReadRegStr $R0 HKCU ${PIDGIN_REG_KEY} "Version" |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
28 | IfErrors GetPidginVersion_done ; Keep the error flag set |
| 11578 | 29 | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
30 | GetPidginVersion_found: |
| 11578 | 31 | Push $R0 ; Push the value onto the stack |
| 32 | Exch | |
| 33 | ||
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
34 | GetPidginVersion_done: |
| 11578 | 35 | ; restore $R0 |
| 36 | Pop $R0 | |
| 37 | FunctionEnd | |
| 38 | ||
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
39 | ; Check that the currently installed Pidgin version is compatible |
| 11578 | 40 | ; with the plugin version we are installing |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
41 | ; Push the Plugin's Pidgin Version onto the Stack before calling |
| 11578 | 42 | ; After calling, the top of the Stack will contain the result of the check: |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
43 | ; PIDGIN_VERSION_OK - If the installed Pidgin version is compatible w/ the version specified |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
44 | ; PIDGIN_VERSION_INCOMPATIBLE - If the installed Pidgin version isn't compatible w/ the version specified |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
45 | ; PIDGIN_VERSION_UNDEFINED - If the installed Pidgin version can't be determined |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
46 | Function CheckPidginVersion |
| 11578 | 47 | ; Save the Variable values that we will use in the stack |
| 48 | Push $R4 | |
| 49 | Exch | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
50 | Pop $R4 ; Get the plugin's Pidgin Version |
| 11578 | 51 | Push $R0 |
| 52 | Push $R1 | |
| 53 | Push $R2 | |
| 54 | ||
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
55 | ; Read the pidgin version |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
56 | Call GetPidginVersion |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
57 | IfErrors checkPidginVersion_noPidginInstallFound |
| 11578 | 58 | Pop $R0 |
| 59 | ||
| 60 | ;If they are exactly the same, we don't need to look at anything else | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
61 | StrCmp $R0 $R4 checkPidginVersion_VersionOK |
| 11578 | 62 | |
| 63 | ; Versions are in the form of X.Y.Z | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
64 | ; If X is different or plugin's Y > pidgin's Y, then we shouldn't install |
| 11578 | 65 | |
| 66 | ;Check the Major Version | |
| 67 | Push $R0 | |
| 68 | Push 0 | |
| 69 | Call GetVersionComponent | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
70 | IfErrors checkPidginVersion_noPidginInstallFound ;We couldn't extract 'X' from the installed pidgin version |
| 11578 | 71 | Pop $R2 |
| 72 | Push $R4 | |
| 73 | Push 0 | |
| 74 | Call GetVersionComponent | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
75 | IfErrors checkPidginVersion_BadVersion ; this isn't a valid version, so don't bother even checking |
| 11578 | 76 | Pop $R1 |
| 77 | ;Check that both versions' X is the same | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
78 | StrCmp $R1 $R2 +1 checkPidginVersion_BadVersion |
| 11578 | 79 | |
| 80 | ;Check the Minor Version | |
| 81 | Push $R0 | |
| 82 | Push 1 | |
| 83 | Call GetVersionComponent | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
84 | IfErrors checkPidginVersion_noPidginInstallFound ;We couldn't extract 'Y' from the installed pidgin version |
| 11578 | 85 | Pop $R2 |
| 86 | Push $R4 | |
| 87 | Push 1 | |
| 88 | Call GetVersionComponent | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
89 | IfErrors checkPidginVersion_BadVersion ; this isn't a valid version, so don't bother even checking |
| 11578 | 90 | Pop $R1 |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
91 | ;Check that plugin's Y <= pidgin's Y |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
92 | IntCmp $R1 $R2 checkPidginVersion_VersionOK checkPidginVersion_VersionOK checkPidginVersion_BadVersion |
| 11578 | 93 | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
94 | checkPidginVersion_BadVersion: |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
95 | Push ${PIDGIN_VERSION_INCOMPATIBLE} |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
96 | goto checkPidginVersion_done |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
97 | checkPidginVersion_noPidginInstallFound: |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
98 | Push ${PIDGIN_VERSION_UNDEFINED} |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
99 | goto checkPidginVersion_done |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
100 | checkPidginVersion_VersionOK: |
|
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
101 | Push ${PIDGIN_VERSION_OK} |
| 11578 | 102 | |
|
15805
a80eb333bae9
Updates to the win32 installer. It isn't complete yet, but this a good saving point.
Daniel Atallah <datallah@pidgin.im>
parents:
15435
diff
changeset
|
103 | checkPidginVersion_done: |
| 11578 | 104 | ; Restore the Variables that we used |
| 105 | Exch | |
| 106 | Pop $R2 | |
| 107 | Exch | |
| 108 | Pop $R1 | |
| 109 | Exch | |
| 110 | Pop $R0 | |
| 111 | Exch | |
| 112 | Pop $R4 | |
| 113 | FunctionEnd | |
| 114 | ||
| 115 | ; Extract the part of a string prior to "." (or the whole string if there is no ".") | |
| 116 | ; If no "." was found, the ErrorFlag will be set | |
| 117 | ; Before this is called, Push ${VERSION_STRING} must be called, and then Push 0 for Major, 1 for Minor, etc | |
| 118 | ; Pop should be called after to retrieve the new value | |
| 119 | Function GetVersionComponent | |
| 120 | ClearErrors | |
| 121 | ||
| 122 | ; Save the Variable values that we will use in the stack | |
| 123 | Push $1 | |
|
14512
7584322a65a2
[gaim-migrate @ 17164]
Daniel Atallah <datallah@pidgin.im>
parents:
14253
diff
changeset
|
124 | Exch |
| 11578 | 125 | Pop $1 ;The version component which we want to extract (0, 1, 2) |
| 126 | Exch | |
| 127 | Push $0 | |
| 128 | Exch | |
| 129 | Pop $0 ;The string from which to extract the version component | |
| 130 | ||
| 131 | Push $2 | |
| 132 | Push $3 | |
| 133 | Push $4 | |
| 134 | Push $5 | |
| 135 | Push $6 | |
| 136 | Push $7 | |
| 137 | ||
| 138 | StrCpy $2 "0" ;Initialize our string index counter | |
| 139 | StrCpy $7 "0" ;Index of last "." | |
| 140 | StrCpy $3 "0" ;Initialize our version index counter | |
| 141 | ||
| 142 | startGetVersionComponentLoop: | |
| 143 | ;avoid infinite loop (if we have gotten the whole initial string, exit the loop and set the error flag) | |
| 144 | StrCmp $6 $0 GetVersionComponentSetErrorFlag | |
| 145 | IntOp $2 $2 + 1 | |
| 146 | StrCpy $6 $0 $2 ;Update the infinite loop preventing string | |
| 147 | ;Determine the correct substring (only the current index component) | |
| 148 | IntOp $5 $2 - $7 | |
| 149 | StrCpy $4 $0 $5 $7 ;Append the current character in $0 to $4 | |
| 150 | StrCpy $5 $0 1 $2 ;store the next character in $5 | |
| 151 | ||
| 152 | ;if the next character is ".", $4 will contain the version component prior to "." | |
| 153 | StrCmp $5 "." +1 startGetVersionComponentLoop | |
| 154 | StrCmp $3 $1 doneGetVersionComponent ;If it is the version component we're looking for, stop | |
| 155 | IntOp $3 $3 + 1 ;Increment the version index counter | |
| 156 | IntOp $2 $2 + 1 ;Increment the version string index to "." (so it will be skipped) | |
| 157 | StrCpy $7 $2 ;Keep track of the index of the last "." | |
| 158 | StrCpy $6 $0 $2 ;Update the infinite loop preventing string | |
| 159 | goto startGetVersionComponentLoop | |
| 160 | ||
| 161 | GetVersionComponentSetErrorFlag: | |
| 162 | SetErrors | |
| 163 | ||
| 164 | doneGetVersionComponent: | |
| 165 | ; Restore the Variables that we used | |
| 166 | Pop $7 | |
| 167 | Pop $6 | |
| 168 | Pop $5 | |
| 169 | Push $4 ;This is the value we're returning | |
| 170 | Exch | |
| 171 | Pop $4 | |
| 172 | Exch | |
| 173 | Pop $3 | |
| 174 | Exch | |
| 175 | Pop $2 | |
| 176 | Exch | |
| 177 | Pop $0 | |
| 178 | Exch | |
| 179 | Pop $1 | |
| 180 | FunctionEnd | |
| 181 |