summaryrefslogtreecommitdiff
path: root/amiga/dist/Install
blob: e32096498d1925b39504443c243524c43b12de05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
; Installation script for NetSurf

(procedure p_setmimetype #type #mimetype
	(transcript "Setting MIME Type " #mimetype " for default " #type " icon")

	(set #fullpath (cat "ENVARC:Sys/def_" #type))

	(tooltype
		(prompt "Setting MIME type")
		(help @tooltype-help)
		(dest #fullpath)
		(settooltype "MIMETYPE" #mimetype)
	)
)

; The below procedure is part of "fitr", see
; http://www.unsatisfactorysoftware.co.uk/fitr
(procedure p_fitr #filename #text #comment #flags
	(set #comstring "")
	(if #comment (set #comstring (cat "COMMENT=\"" #comment "\"")))
	(set #comment "")
	(set #switches "")
	(if #flags (set #switches (cat " " #flags)))
	(set #flags "")

	(if #text
		(
			(transcript "Adding " @app-name " section to " #filename)

			(textfile
				(dest "t:fitr-installer.tmp")
				(append #text)
			)

			(run (cat "fitr \"" #filename "\" \"" @app-name "\" t:fitr-installer.tmp " #comstring #switches))
			(delete "t:fitr-installer.tmp")
		)
;else
		(
			(transcript "Removing " @app-name " section from " #filename)
			(run (cat "fitr \"" #filename "\" \"" @app-name "\" " #comstring #switches))
		)
	)
)

(procedure p_failedsobjs
	(if #failedsobjs
		(message "The following shared objects failed to copy.  These will be updated on next reboot.\n\n" #failedsobjs)
	)
)

(procedure p_schedulesobj #sobj
	(transcript "Scheduling update of " #sobj " for next reboot")

	(set #failedsobjs (cat #failedsobjs "\n" #sobj))

	(makedir "SObjs:so-installer")

	(copyfiles
		(source (tackon "SObjs" #sobj))
		(dest "SObjs:so-installer")
	)

	(startup "Shared object installer"
		(prompt "Adding commands to user-startup to schedule copy of " #sobj " on next reboot")
		(help @startup-help)
		(command "if EXISTS SObjs:so-installer\n")
		(command "  copy SObjs:so-installer SObjs: CLONE FORCE QUIET\n")
		(command "  delete SObjs:so-installer ALL FORCE QUIET\n")
		(command "endif\n")
	)
)

(procedure p_comparesobj2 #sobj1_full #sobj2_full
	(set #same 0)

	(set #sobj-version (getversion (#sobj1_full)))
	(if (= #sobj-version 0)
		(
			(if (exists (#sobj2_full))
				(
					(set #file-newer (earlier (#sobj2_full) (#sobj1_full)))
					(set #old-size (getsize (#sobj2_full)))
					(set #new-size (getsize (#sobj1_full)))

					(if (AND (= #old-size #new-size) (= #file-newer 0)) (set #same 1))
				)
			)
		)
		; else if version info is available
		(
			(set #sobj-oldversion (getversion (#sobj2_full)))

			(if (<= #sobj-version #sobj-oldversion) (set #same 1))
		)
	)
)

(procedure p_comparesobj #sobj
	(set #sobj1 (tackon "SObjs/" #sobj))
	(set #sobj2 (tackon "SObjs:" #sobj))

	(p_comparesobj2 #sobj1 #sobj2)
)

(procedure p_linksobj #sobj #sobj_link
	(set #sobj2 (tackon "SObjs:" #sobj_link))

	(p_comparesobj2 (tackon "SObjs/" #sobj) #sobj2)

	(if (= #same 0) ;if #sobj is newer than that pointed to by #sobj_link
		(
			(if (exists (#sobj2))
				(transcript "Deleting " #sobj2)
				(delete #sobj2 (optional "force")) ;prevent dodgy recursive links
			)
			(set #linkcmd (cat "makelink " #sobj2 " SObjs:" #sobj " soft"))
			(transcript "Running " #linkcmd)
			(run #linkcmd)
		)
	)
)

(procedure p_copysobj #sobj
	(set #sobj-version (getversion (tackon "SObjs/" #sobj)))

	(if (= #sobj-version 0)
		(
			(transcript "Date compare " #sobj)

			(if (exists (tackon "SObjs:" #sobj))
				(
					(set #file-newer (earlier (tackon "SObjs:" #sobj) (tackon "SObjs/" #sobj)))

					(if (= #file-newer 0)
						(
							(set #newer-text "has an older datestamp")
						)
						;else
						(
							(set #newer-text "has a newer datestamp")
						)
					)

					(set #old-size (getsize (tackon "SObjs:" #sobj)))
					(set #new-size (getsize (tackon "SObjs/" #sobj)))

					(if (AND (= #old-size #new-size) (= #file-newer 0))
						(
							(set #copy 0)
						)
						;else
						(
							(if (OR (= @user-level 2) (AND (= @user-level 1) (<> #file-newer 0)))
; Expert users are always prompted
; Average users are prompted if the file trying to be copied is newer
; Novice users are never prompted
; This is roughly equivalent to (copylib (confirm))
; No prompting occurs if the destination does not exist (silent copy)
; or the files are the same size and the one being copied isn't newer (don't copy)
								(
									(set #copy
										(askbool
											(prompt "Copying " #sobj "...\n\n"
												"Version to install: " #new-size " bytes\n"
												"Version currently installed: " #old-size " bytes\n\n"
												"The file to copy " #newer-text)
											(help @askbool-help)
											(default #file-newer)
											(choices "Proceed with copy" "Skip this part")
										)
									)
								)
								;else
								(
									(set #copy #file-newer)
								)
							)
						)
					)
				)
				; else if dest file does not exist
				(
					(set #copy 1)
				)
			)

			(if (<> #copy 0)
				(
					(if (<> #AutoInstall 1)
						(
							(copyfiles
								(prompt "Copying " #sobj "...")
								(help @copyfiles-help)
								(source (tackon "SObjs/" #sobj))
								(dest "SObjs:")
								(optional "nofail" "force")
							)
						)
						;else
						(
							(run "CopyStore SObjs/" #sobj " SObjs:")
						)
					)

					(p_comparesobj #sobj)
					(if (= #same 0)
						(
							(p_schedulesobj #sobj)
						)
					)
				)
			)
		)
		; else if version info is available
		(
			(if (<> #AutoInstall 1)
				(
					(copylib
						(prompt "Copying " #sobj "...")
						(help @copylib-help)
						(source (tackon "SObjs/" #sobj))
						(dest "SObjs:")
						(optional "nofail" "force")
						(confirm "expert")
					)
				)
				;else
				(
					(run "CopyStore SObjs/" #sobj " SObjs:")
				)
			)

			(p_comparesobj #sobj)
			(if (= #same 0)
				(
					(p_schedulesobj #sobj)
				)
			)
		)
	)
)

(procedure p_copylib #lib
	(if (<> #AutoInstall 1)
		(
			(copylib
				(prompt "Copying " #lib "...")
				(help @copylib-help)
				(source (tackon "Libs/" #lib))
				(dest "Libs:")
				(optional "nofail" "force")
				(confirm "expert")
			)
		)
		;else
		(
			(run "CopyStore Libs/" #lib " Libs:")
		)
	)
)

(procedure p_chk_launch-handler #protocol
	(run "C:Search >T:NS_Install.tmp " (tackon "ENVARC:launch-handler/URL" #protocol) " NetSurf" (safe))
	(set #has_entry (getsize "T:NS_Install.tmp"))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Script execution starts here ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (= @app-name "NetSurfAutoInstall") (set #AutoInstall 1))
(set @app-name "NetSurf")

(if (<> #AutoInstall 1) (welcome))

(complete 0)

(set @default-dest (getenv "AppPaths/NetSurf"))

; If env-var did not exist, this is a first time install.
; For novice users we must take care to put the files somewhere sensible.
(if (= @default-dest "")
	(
		; Workaround for Installer bug picking TEXTCLIP: as a sensible location
		(if (= @default-dest "TextClip:") (set @default-dest "SYS:Internet"))

		(if (= @user-level 0)
			(
				(makedir (tackon @default-dest "NetSurf") (infos))
				(set @default-dest (tackon @default-dest "NetSurf"))
			)
		)
	)
)

(set @default-dest
	(askdir
		(prompt "Where would you like to install NetSurf?\n"
				"(a drawer WILL NOT be created)")
		(help @askdir-help)
		(default @default-dest)
	)
)

(complete 5)

(working "Checking existing installation...")
(set #icon-exists (exists (tackon @default-dest "NetSurf.info")))
(set osver (getversion))
(set osver (/ osver 65536))
(set #versions-available 0)

(set #static-filename "NetSurf")
(set #cairo-filename "NetSurf")

(if (exists "NetSurf")
	(
		(if (exists "SObjs")
			(
				(if (>= osver 53) 
					(
						(set #cairo-name "Shared objects/part-Cairo")
						(set #versions-available (+ #versions-available 1))
						(set #cairo-version 1)
					)
					;else
					(
						(set #cairo-version 0)
						(set #cairo-name "")
					)
				)
			)
			;else
			(
				; assume static if sobjs is not present
				(set #static-name "Static/graphics.library")
				(set #versions-available (+ #versions-available 1))
				(set #cairo-version 0)
				(set #static-filename "NetSurf")
			)
		)
	)
	; else
	(
		(set #cairo-version 0)
		(set #cairo-name "")		
	)
)

(transcript "Versions avaiable for install: " #versions-available "  " #static-name "  " #cairo-name)

(if (= #versions-available 0)
	(
		(abort "Did not find any compatible versions of NetSurf to install!\n\n"
			"NetSurf requires AmigaOS 4.1 or higher.")
	)
)

(complete 10)

(if (AND (> @user-level 0) (> #versions-available 1))
	(
		(set #cairo-version
			(askchoice
				(prompt "Which version of NetSurf would you like to install?")
				(help "The Cairo version has anti-aliasing of graphical elements.\n\n"
					@askchoice-help)
				(choices #static-name #cairo-name)
				(default #cairo-version)
			)
		)
	)
)

(complete 15)

(set #user (getenv "user"))
(if (= #user "") (set #user "Default"))

(set #user-dir (tackon (tackon @default-dest "Users") #user))
(set #user-options (tackon #user-dir "Choices"))
(set #options-exist (exists #user-options))
(set #searchengines-exist (exists (tackon @default-dest "Resources/SearchEngines")))
(set #aiss-theme "")

(if (= #options-exist 0)
	(
		(if (exists "TBimages:" (noreq))
			(set #aiss-theme "AISS")
		)

		(set #themename
   			(askchoice
  				(prompt "Please select theme")
 	      		(help "AISS theme requires AISS (and def_pointers for 32-bit "
						"pointers), and will only be shown as an option if "
						"AISS is installed.\n\n"
						@askchoice-help)
				(choices "Default" #aiss-theme)
       			(default 0)
   			)
		)

		(select #themename
			(set #themeshort "Default")
			(set #themeshort "AISS")
		)

		(set #theme (tackon "PROGDIR:Resources/Themes/" #themeshort))
	)
)

(complete 18)

(if (>= osver 53)
	(
		(set #addlaunchhandler
			(askbool
				(prompt "Add NetSurf to launch-handler? (recommended)")
				(help "launch-handler is part of OS4.1 which opens URLs "
					" by launching a web browser.\n\n"
					"The installation will update the configuration of "
					"OS4.1 to allow URLs to be opened by NetSurf.")
			)
		)
	)
	;else
	(
		(set #addlaunchhandler 0)
	)
)

(complete 19)

(set #runfixfonts
	(askbool
		(prompt "Installer will run FixFonts after NetSurf is installed.  "
			"Unless you have a *very* good reason you should not skip this step.")
		(help "FixFonts corrects inconsistencies in the Amiga FONTS: structure. "
			"Running it will prevent NetSurf hitting problems when the fonts are scanned.")
		(default 1)
		(choices "Run FixFonts" "Skip")
	)
)

(complete 20)

(set #netsurf-name (select #cairo-version #static-filename #cairo-filename))

(working "Installing NetSurf")

(if (= #AutoInstall 0)
	(
		(copyfiles
			(prompt "Copying NetSurf...")
			(help @copyfiles-help)
			(source #netsurf-name)
			(dest @default-dest)
			(newname "NetSurf")
			(optional "askuser" "force" "oknodelete")
			(confirm "expert")
		)
	)
;else
	(
		(run "CopyStore NetSurf" @default-dest)
	)
)

(complete 30)

(if #searchengines-exist
	(rename (tackon @default-dest "Resources/SearchEngines") (tackon @default-dest "Resources/SearchEngines.backup"))
)

(run "c:filenote Rexx/CloseTabs.nsrx \"Close other tabs\"")
(run "c:filenote Rexx/ViewSource.nsrx \"View source\"")
(run "c:filenote Rexx/GetVideo.nsrx \"Get video\"")

(copyfiles
	(prompt "Copying files")
	(source "")
	(choices "Resources" "Rexx" "NetSurf.guide" "NetSurf.readme")
	(help @copyfiles-help)
	(dest @default-dest)
	(infos)
	(optional "nofail")
;	(all)
)

(copyfiles
	(prompt "Copying additional documentation")
	(source "")
	(pattern "(COPYING|ChangeLog)")
	(help @copyfiles-help)
	(dest @default-dest)
	(infos)
	(optional "nofail")
)

(set #complete 40)
(working "Copying Libraries")

(if (exists "Libs")
	(
		(foreach "Libs" "#?"
			(complete #complete)
			(p_copylib @each-name)
			(set #complete (+ #complete 2))
		)
	)
)

(set #complete 60)

(if (= #cairo-version 1)
	(
		(working "Copying Shared Objects")

		(foreach "SObjs" "#?"
			(complete #complete)
			(p_copysobj @each-name)
			(set #complete (+ #complete 1))
		)
	)
)

(complete 90)

(if #themeshort
	(
		(set #theme-icon
			(tackon "Resources/Themes"
				(tackon #themeshort "NetSurf.info")
			)
		)

		(if (exists #theme-icon)
			(
				(copyfiles
					(prompt "Copying theme icon")
					(help @copyfiles-help)
					(source #theme-icon)
					(dest @default-dest)
				)
			)
		)

		(makedir #user-dir)

		(textfile
			(prompt "Setting default options")
			(help @textfile-help)
			(dest #user-options)
			(append "theme:" #theme "\n")
			(append "use_pubscreen:Workbench\n")
		)
	)
)

(complete 95)

(if (= (exists "ENVARC:Sys/def_css.info") 0)
	(copyfiles
		(prompt "Copying default CSS icon")
		(source "Resources/default.css.info")
		(newname "def_css.info")
		(help @copyfiles-help)
		(dest "ENVARC:Sys")
		(optional "nofail")
	)
)

(complete 96)

(working "Setting MIME types")
(p_setmimetype "css" "text/css")
(p_setmimetype "html" "text/html")
(p_setmimetype "ascii" "text/plain")
(p_setmimetype "jpeg" "image/jpeg")
(p_setmimetype "gif" "image/gif")
(p_setmimetype "png" "image/png")
(p_setmimetype "jng" "image/jng")
(p_setmimetype "mng" "image/mng")
(p_setmimetype "svg" "image/svg")
(p_setmimetype "bmp" "image/bmp")
(p_setmimetype "ico" "image/ico")
(p_setmimetype "sprite" "image/x-riscos-sprite")
(p_setmimetype "webp" "image/webp")
(p_setmimetype "lha" "application/x-lha")
(p_setmimetype "zip" "application/x-zip")

(complete 98)

(if (= #addlaunchhandler 1)
	(
; We use fitr here so that the sections are only added once.
; We also check for string "NetSurf" within the files as saving
; the config will overwrite fitr's tags.
; This probably needs rewriting to not use fitr as it isn't really necessary now.

		(working "Adding NetSurf to launch-handler config")
		(if (= (p_chk_launch-handler "FILE.LH") 0)
			(p_fitr "ENVARC:launch-handler/URL/FILE.LH" "ClientName=\"NETSURF\"   ClientPath=\"APPDIR:NETSURF\"   CMDFORMAT=\"URL=*\"file:///%s*\"\"")
		)

		(if (= (p_chk_launch-handler "HTTP.LH") 0)
			(p_fitr "ENVARC:launch-handler/URL/HTTP.LH" "ClientName=\"NETSURF\"   ClientPath=\"APPDIR:NETSURF\"   CMDFORMAT=\"URL=*\"http://%s*\"\"")
		)

		(if (= (p_chk_launch-handler "HTTPS.LH") 0)
			(p_fitr "ENVARC:launch-handler/URL/HTTPS.LH" "ClientName=\"NETSURF\"   ClientPath=\"APPDIR:NETSURF\"   CMDFORMAT=\"URL=*\"https://%s*\"\"")
		)

		(if (= (p_chk_launch-handler "WWW.LH") 0)
			(p_fitr "ENVARC:launch-handler/URL/WWW.LH" "ClientName=\"NETSURF\"   ClientPath=\"APPDIR:NETSURF\"   CMDFORMAT=\"URL=*\"http://www.%s*\"\"")
		)

;		(if (= (p_chk_launch-handler "FTP.LH") 0)
;			(p_fitr "ENVARC:launch-handler/URL/FTP.LH" "ClientName=\"NETSURF\"   ClientPath=\"APPDIR:NETSURF\"   CMDFORMAT=\"URL=*\"ftp://%s*\"\"")
;		)
	)
)

(complete 99)

(working "Running FixFonts")

(if #runfixfonts
	(
		(run "SYS:System/FixFonts")
	)
)

(complete 100)

(if (= #AutoInstall 1)
	(
		(exit (quiet))
	)
	(
		(p_failedsobjs)
		(exit)
	)
)