toolkit/mozapps/installer/windows/nsis/overrides.nsh

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:e6071bb4b838
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 ################################################################################
6 # Modified versions of macros provided by NSIS
7
8 !ifndef OVERRIDES_INCLUDED
9 !define OVERRIDES_INCLUDED
10
11 !ifndef ___WINVER__NSH___
12 !include WinVer.nsh
13 !endif
14
15 ; When including a file check if its verbose macro is defined to prevent
16 ; loading the file a second time.
17 !ifmacrondef TEXTFUNC_VERBOSE
18 !include TextFunc.nsh
19 !endif
20
21 !ifmacrondef FILEFUNC_VERBOSE
22 !include FileFunc.nsh
23 !endif
24
25 !macro __MOZ__WinVer_DefineOSTests WinVer
26 !insertmacro __WinVer_DefineOSTest AtLeast ${WinVer} ""
27 !insertmacro __WinVer_DefineOSTest Is ${WinVer} ""
28 !insertmacro __WinVer_DefineOSTest AtMost ${WinVer} ""
29 !macroend
30
31 !ifndef WINVER_8
32 !define WINVER_8 0x06020000 ;6.02.9200
33 !insertmacro __MOZ__WinVer_DefineOSTests 8
34 !endif
35
36 !ifndef WINVER_8.1
37 !define WINVER_8.1 0x06030000 ;6.03.9600
38 !insertmacro __MOZ__WinVer_DefineOSTests 8.1
39 !endif
40
41 !ifndef WINVER_2012
42 !define WINVER_2012 0x06020001 ;6.02.9200
43 !insertmacro __MOZ__WinVer_DefineOSTests 2012
44 !endif
45
46 !ifndef WINVER_2012R2
47 !define WINVER_2012R2 0x06030001 ;6.03.9600
48 !insertmacro __MOZ__WinVer_DefineOSTests 2012R2
49 !endif
50
51 !verbose push
52 !verbose 3
53 !ifndef _OVERRIDE_VERBOSE
54 !define _OVERRIDE_VERBOSE 3
55 !endif
56 !verbose ${_OVERRIDE_VERBOSE}
57 !define OVERRIDE_VERBOSE `!insertmacro OVERRIDE_VERBOSE`
58 !define _OVERRIDE_UN
59 !define _OVERRIDE_S
60 !verbose pop
61
62 !macro OVERRIDE_VERBOSE _VERBOSE
63 !verbose push
64 !verbose 3
65 !undef _OVERRIDE_VERBOSE
66 !define _OVERRIDE_VERBOSE ${_VERBOSE}
67 !verbose pop
68 !macroend
69
70 ; Modified version of Locate from the NSIS File Functions Header v3.4 (it has
71 ; the same version in earlier versions of NSIS even though it has changed) that
72 ; is distributed with NSIS v2.46-Unicode. This version has the calls to
73 ; SetDetailsPrint commented out.
74 ; See <NSIS v2.46-Unicode App Dir>/include/FileFunc.nsh for more information.
75 !macro LocateNoDetailsCall _PATH _OPTIONS _FUNC
76 !verbose push
77 !verbose ${_OVERRIDE_VERBOSE}
78 Push $0
79 Push `${_PATH}`
80 Push `${_OPTIONS}`
81 GetFunctionAddress $0 `${_FUNC}`
82 Push `$0`
83 Call LocateNoDetails
84 Pop $0
85 !verbose pop
86 !macroend
87
88 !macro LocateNoDetails
89 !ifndef ${_OVERRIDE_UN}LocateNoDetails
90 !verbose push
91 !verbose ${_OVERRIDE_VERBOSE}
92 !define ${_OVERRIDE_UN}LocateNoDetails `!insertmacro ${_OVERRIDE_UN}LocateNoDetailsCall`
93
94 Function ${_OVERRIDE_UN}LocateNoDetails
95 Exch $2
96 Exch
97 Exch $1
98 Exch
99 Exch 2
100 Exch $0
101 Exch 2
102 Push $3
103 Push $4
104 Push $5
105 Push $6
106 Push $7
107 Push $8
108 Push $9
109 Push $R6
110 Push $R7
111 Push $R8
112 Push $R9
113 ClearErrors
114
115 StrCpy $3 ''
116 StrCpy $4 ''
117 StrCpy $5 ''
118 StrCpy $6 ''
119 StrCpy $7 ''
120 StrCpy $8 0
121 StrCpy $R7 ''
122
123 StrCpy $R9 $0 1 -1
124 StrCmp $R9 '\' 0 +3
125 StrCpy $0 $0 -1
126 goto -3
127 IfFileExists '$0\*.*' 0 error
128
129 option:
130 StrCpy $R9 $1 1
131 StrCpy $1 $1 '' 1
132 StrCmp $R9 ' ' -2
133 StrCmp $R9 '' sizeset
134 StrCmp $R9 '/' 0 -4
135 StrCpy $9 -1
136 IntOp $9 $9 + 1
137 StrCpy $R9 $1 1 $9
138 StrCmp $R9 '' +2
139 StrCmp $R9 '/' 0 -3
140 StrCpy $R8 $1 $9
141 StrCpy $R8 $R8 '' 2
142 StrCpy $R9 $R8 '' -1
143 StrCmp $R9 ' ' 0 +3
144 StrCpy $R8 $R8 -1
145 goto -3
146 StrCpy $R9 $1 2
147 StrCpy $1 $1 '' $9
148
149 StrCmp $R9 'L=' 0 mask
150 StrCpy $3 $R8
151 StrCmp $3 '' +6
152 StrCmp $3 'FD' +5
153 StrCmp $3 'F' +4
154 StrCmp $3 'D' +3
155 StrCmp $3 'DE' +2
156 StrCmp $3 'FDE' 0 error
157 goto option
158
159 mask:
160 StrCmp $R9 'M=' 0 size
161 StrCpy $4 $R8
162 goto option
163
164 size:
165 StrCmp $R9 'S=' 0 gotosubdir
166 StrCpy $6 $R8
167 goto option
168
169 gotosubdir:
170 StrCmp $R9 'G=' 0 banner
171 StrCpy $7 $R8
172 StrCmp $7 '' +3
173 StrCmp $7 '1' +2
174 StrCmp $7 '0' 0 error
175 goto option
176
177 banner:
178 StrCmp $R9 'B=' 0 error
179 StrCpy $R7 $R8
180 StrCmp $R7 '' +3
181 StrCmp $R7 '1' +2
182 StrCmp $R7 '0' 0 error
183 goto option
184
185 sizeset:
186 StrCmp $6 '' default
187 StrCpy $9 0
188 StrCpy $R9 $6 1 $9
189 StrCmp $R9 '' +4
190 StrCmp $R9 ':' +3
191 IntOp $9 $9 + 1
192 goto -4
193 StrCpy $5 $6 $9
194 IntOp $9 $9 + 1
195 StrCpy $1 $6 1 -1
196 StrCpy $6 $6 -1 $9
197 StrCmp $5 '' +2
198 IntOp $5 $5 + 0
199 StrCmp $6 '' +2
200 IntOp $6 $6 + 0
201
202 StrCmp $1 'B' 0 +3
203 StrCpy $1 1
204 goto default
205 StrCmp $1 'K' 0 +3
206 StrCpy $1 1024
207 goto default
208 StrCmp $1 'M' 0 +3
209 StrCpy $1 1048576
210 goto default
211 StrCmp $1 'G' 0 error
212 StrCpy $1 1073741824
213
214 default:
215 StrCmp $3 '' 0 +2
216 StrCpy $3 'FD'
217 StrCmp $4 '' 0 +2
218 StrCpy $4 '*.*'
219 StrCmp $7 '' 0 +2
220 StrCpy $7 '1'
221 StrCmp $R7 '' 0 +2
222 StrCpy $R7 '0'
223 StrCpy $7 'G$7B$R7'
224
225 StrCpy $8 1
226 Push $0
227 ; SetDetailsPrint textonly
228
229 nextdir:
230 IntOp $8 $8 - 1
231 Pop $R8
232
233 StrCpy $9 $7 2 2
234 StrCmp $9 'B0' +3
235 GetLabelAddress $9 findfirst
236 goto call
237 ; DetailPrint 'Search in: $R8'
238
239 findfirst:
240 FindFirst $0 $R7 '$R8\$4'
241 IfErrors subdir
242 StrCmp $R7 '.' 0 dir
243 FindNext $0 $R7
244 StrCmp $R7 '..' 0 dir
245 FindNext $0 $R7
246 IfErrors 0 dir
247 FindClose $0
248 goto subdir
249
250 dir:
251 IfFileExists '$R8\$R7\*.*' 0 file
252 StrCpy $R6 ''
253 StrCmp $3 'DE' +4
254 StrCmp $3 'FDE' +3
255 StrCmp $3 'FD' precall
256 StrCmp $3 'F' findnext precall
257 FindFirst $9 $R9 '$R8\$R7\*.*'
258 StrCmp $R9 '.' 0 +4
259 FindNext $9 $R9
260 StrCmp $R9 '..' 0 +2
261 FindNext $9 $R9
262 FindClose $9
263 IfErrors precall findnext
264
265 file:
266 StrCmp $3 'FDE' +3
267 StrCmp $3 'FD' +2
268 StrCmp $3 'F' 0 findnext
269 StrCpy $R6 0
270 StrCmp $5$6 '' precall
271 FileOpen $9 '$R8\$R7' r
272 IfErrors +3
273 FileSeek $9 0 END $R6
274 FileClose $9
275 System::Int64Op $R6 / $1
276 Pop $R6
277 StrCmp $5 '' +2
278 IntCmp $R6 $5 0 findnext
279 StrCmp $6 '' +2
280 IntCmp $R6 $6 0 0 findnext
281
282 precall:
283 StrCpy $9 0
284 StrCpy $R9 '$R8\$R7'
285
286 call:
287 Push $0
288 Push $1
289 Push $2
290 Push $3
291 Push $4
292 Push $5
293 Push $6
294 Push $7
295 Push $8
296 Push $9
297 Push $R7
298 Push $R8
299 StrCmp $9 0 +4
300 StrCpy $R6 ''
301 StrCpy $R7 ''
302 StrCpy $R9 ''
303 Call $2
304 Pop $R9
305 Pop $R8
306 Pop $R7
307 Pop $9
308 Pop $8
309 Pop $7
310 Pop $6
311 Pop $5
312 Pop $4
313 Pop $3
314 Pop $2
315 Pop $1
316 Pop $0
317
318 IfErrors 0 +3
319 FindClose $0
320 goto error
321 StrCmp $R9 'StopLocateNoDetails' 0 +3
322 FindClose $0
323 goto clearstack
324 goto $9
325
326 findnext:
327 FindNext $0 $R7
328 IfErrors 0 dir
329 FindClose $0
330
331 subdir:
332 StrCpy $9 $7 2
333 StrCmp $9 'G0' end
334 FindFirst $0 $R7 '$R8\*.*'
335 StrCmp $R7 '.' 0 pushdir
336 FindNext $0 $R7
337 StrCmp $R7 '..' 0 pushdir
338 FindNext $0 $R7
339 IfErrors 0 pushdir
340 FindClose $0
341 StrCmp $8 0 end nextdir
342
343 pushdir:
344 IfFileExists '$R8\$R7\*.*' 0 +3
345 Push '$R8\$R7'
346 IntOp $8 $8 + 1
347 FindNext $0 $R7
348 IfErrors 0 pushdir
349 FindClose $0
350 StrCmp $8 0 end nextdir
351
352 error:
353 SetErrors
354
355 clearstack:
356 StrCmp $8 0 end
357 IntOp $8 $8 - 1
358 Pop $R8
359 goto clearstack
360
361 end:
362 ; SetDetailsPrint both
363 Pop $R9
364 Pop $R8
365 Pop $R7
366 Pop $R6
367 Pop $9
368 Pop $8
369 Pop $7
370 Pop $6
371 Pop $5
372 Pop $4
373 Pop $3
374 Pop $2
375 Pop $1
376 Pop $0
377 FunctionEnd
378
379 !verbose pop
380 !endif
381 !macroend
382
383 !macro un.LocateNoDetailsCall _PATH _OPTIONS _FUNC
384 !verbose push
385 !verbose ${_OVERRIDE_VERBOSE}
386 Push $0
387 Push `${_PATH}`
388 Push `${_OPTIONS}`
389 GetFunctionAddress $0 `${_FUNC}`
390 Push `$0`
391 Call un.LocateNoDetails
392 Pop $0
393 !verbose pop
394 !macroend
395
396 !macro un.LocateNoDetails
397 !ifndef un.LocateNoDetails
398 !verbose push
399 !verbose ${_OVERRIDE_VERBOSE}
400 !undef _OVERRIDE_UN
401 !define _OVERRIDE_UN `un.`
402
403 !insertmacro LocateNoDetails
404
405 !undef _OVERRIDE_UN
406 !define _OVERRIDE_UN
407 !verbose pop
408 !endif
409 !macroend
410
411 ; Modified version of TextCompare from the NSIS Text Functions Header v2.4 (it
412 ; has the same version in earlier versions of NSIS even though it has changed)
413 ; that is distributed with NSIS v2.46-Unicode. This version has the calls to
414 ; SetDetailsPrint commented out.
415 ; See <NSIS v2.46-Unicode App Dir>/include/TextFunc.nsh for more information.
416 !macro TextCompareNoDetailsCall _FILE1 _FILE2 _OPTION _FUNC
417 !verbose push
418 !verbose ${_OVERRIDE_VERBOSE}
419 Push $0
420 Push `${_FILE1}`
421 Push `${_FILE2}`
422 Push `${_OPTION}`
423 GetFunctionAddress $0 `${_FUNC}`
424 Push `$0`
425 ${CallArtificialFunction} TextCompareNoDetails_
426 Pop $0
427 !verbose pop
428 !macroend
429
430 !macro TextCompareNoDetailsSCall _FILE1 _FILE2 _OPTION _FUNC
431 !verbose push
432 !verbose ${_OVERRIDE_VERBOSE}
433 Push $0
434 Push `${_FILE1}`
435 Push `${_FILE2}`
436 Push `${_OPTION}`
437 GetFunctionAddress $0 `${_FUNC}`
438 Push `$0`
439 ${CallArtificialFunction} TextCompareNoDetailsS_
440 Pop $0
441 !verbose pop
442 !macroend
443
444
445 !macro TextCompareNoDetailsBody _OVERRIDE_S
446 Exch $3
447 Exch
448 Exch $2
449 Exch
450 Exch 2
451 Exch $1
452 Exch 2
453 Exch 3
454 Exch $0
455 Exch 3
456 Push $4
457 Push $5
458 Push $6
459 Push $7
460 Push $8
461 Push $9
462 ClearErrors
463
464 IfFileExists $0 0 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_error
465 IfFileExists $1 0 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_error
466 StrCmp $2 'FastDiff' +5
467 StrCmp $2 'FastEqual' +4
468 StrCmp $2 'SlowDiff' +3
469 StrCmp $2 'SlowEqual' +2
470 goto TextFunc_TextCompareNoDetails${_OVERRIDE_S}_error
471
472 FileOpen $4 $0 r
473 IfErrors TextFunc_TextCompareNoDetails${_OVERRIDE_S}_error
474 FileOpen $5 $1 r
475 IfErrors TextFunc_TextCompareNoDetails${_OVERRIDE_S}_error
476 ; SetDetailsPrint textonly
477
478 StrCpy $6 0
479 StrCpy $8 0
480
481 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_nextline:
482 StrCmp${_OVERRIDE_S} $4 '' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_fast
483 IntOp $8 $8 + 1
484 FileRead $4 $9
485 IfErrors 0 +4
486 FileClose $4
487 StrCpy $4 ''
488 StrCmp${_OVERRIDE_S} $5 '' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_end
489 StrCmp $2 'FastDiff' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_fast
490 StrCmp $2 'FastEqual' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_fast TextFunc_TextCompareNoDetails${_OVERRIDE_S}_slow
491
492 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_fast:
493 StrCmp${_OVERRIDE_S} $5 '' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_call
494 IntOp $6 $6 + 1
495 FileRead $5 $7
496 IfErrors 0 +5
497 FileClose $5
498 StrCpy $5 ''
499 StrCmp${_OVERRIDE_S} $4 '' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_end
500 StrCmp $2 'FastDiff' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_call TextFunc_TextCompareNoDetails${_OVERRIDE_S}_close
501 StrCmp $2 'FastDiff' 0 +2
502 StrCmp${_OVERRIDE_S} $7 $9 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_nextline TextFunc_TextCompareNoDetails${_OVERRIDE_S}_call
503 StrCmp${_OVERRIDE_S} $7 $9 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_call TextFunc_TextCompareNoDetails${_OVERRIDE_S}_nextline
504
505 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_slow:
506 StrCmp${_OVERRIDE_S} $4 '' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_close
507 StrCpy $6 ''
508 ; DetailPrint '$8. $9'
509 FileSeek $5 0
510
511 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_slownext:
512 FileRead $5 $7
513 IfErrors 0 +2
514 StrCmp $2 'SlowDiff' TextFunc_TextCompareNoDetails${_OVERRIDE_S}_call TextFunc_TextCompareNoDetails${_OVERRIDE_S}_nextline
515 StrCmp $2 'SlowDiff' 0 +2
516 StrCmp${_OVERRIDE_S} $7 $9 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_nextline TextFunc_TextCompareNoDetails${_OVERRIDE_S}_slownext
517 IntOp $6 $6 + 1
518 StrCmp${_OVERRIDE_S} $7 $9 0 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_slownext
519
520 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_call:
521 Push $2
522 Push $3
523 Push $4
524 Push $5
525 Push $6
526 Push $7
527 Push $8
528 Push $9
529 Call $3
530 Pop $0
531 Pop $9
532 Pop $8
533 Pop $7
534 Pop $6
535 Pop $5
536 Pop $4
537 Pop $3
538 Pop $2
539 StrCmp $0 'StopTextCompareNoDetails' 0 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_nextline
540
541 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_close:
542 FileClose $4
543 FileClose $5
544 goto TextFunc_TextCompareNoDetails${_OVERRIDE_S}_end
545
546 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_error:
547 SetErrors
548
549 TextFunc_TextCompareNoDetails${_OVERRIDE_S}_end:
550 ; SetDetailsPrint both
551 Pop $9
552 Pop $8
553 Pop $7
554 Pop $6
555 Pop $5
556 Pop $4
557 Pop $3
558 Pop $2
559 Pop $1
560 Pop $0
561 !macroend
562
563 !define TextCompareNoDetails `!insertmacro TextCompareNoDetailsCall`
564 !define un.TextCompareNoDetails `!insertmacro TextCompareNoDetailsCall`
565
566 !macro TextCompareNoDetails
567 !macroend
568
569 !macro un.TextCompareNoDetails
570 !macroend
571
572 !macro TextCompareNoDetails_
573 !verbose push
574 !verbose ${_OVERRIDE_VERBOSE}
575
576 !insertmacro TextCompareNoDetailsBody ''
577
578 !verbose pop
579 !macroend
580
581 !define TextCompareNoDetailsS `!insertmacro TextCompareNoDetailsSCall`
582 !define un.TextCompareNoDetailsS `!insertmacro TextCompareNoDetailsSCall`
583
584 !macro TextCompareNoDetailsS
585 !macroend
586
587 !macro un.TextCompareNoDetailsS
588 !macroend
589
590 !macro TextCompareNoDetailsS_
591 !verbose push
592 !verbose ${_OVERRIDE_VERBOSE}
593
594 !insertmacro TextCompareNoDetailsBody 'S'
595
596 !verbose pop
597 !macroend
598
599 !endif

mercurial