2 Copyright © 2003-2016, The AROS Development Team. All rights reserved.
6 #define INTUITION_NO_INLINE_STDARG
9 #include <aros/debug.h>
11 #include <libraries/mui.h>
14 #include <exec/types.h>
19 #include <clib/alib_protos.h>
21 #include <intuition/gadgetclass.h>
22 #include <intuition/icclass.h>
23 #include <gadgets/colorwheel.h>
25 #include <libraries/asl.h>
26 #include <libraries/expansionbase.h>
28 #include <devices/trackdisk.h>
29 #include <devices/scsidisk.h>
31 #include <proto/exec.h>
32 #include <proto/intuition.h>
33 #include <proto/dos.h>
34 #include <proto/partition.h>
35 #include <proto/muimaster.h>
36 #include <proto/graphics.h>
37 #include <proto/utility.h>
39 #include <mui/TextEditor_mcc.h>
45 #define kBufSize (4*65536)
46 #define kExallBufSize (4096)
48 #define SYS_PART_NAME "DH0"
49 #define WORK_PART_NAME "DH1"
50 #define USB_SYS_PART_NAME "DU0"
51 #define USB_WORK_PART_NAME "DU1"
52 #define SYS_VOL_NAME "AROS"
53 #define WORK_VOL_NAME "Work"
54 #define USB_SYS_VOL_NAME "AROS Live Drive"
55 #define USB_WORK_VOL_NAME "Briefcase"
57 #define MAX_FFS_SIZE (4L * 1024)
58 #define MAX_SFS_SIZE (124L * 1024)
60 #define INSTALLER_TMP_PATH "T:Installer"
61 #define INSTALLAROS_TMP_PATH "T:Installer/InstallAROS"
63 #define localeFile_path "Prefs/Locale\""
64 #define inputFile_path "Prefs/Input\""
65 #define prefssrc_path "ENV:SYS"
66 #define prefs_path "Prefs/Env-Archive/SYS"
67 #define ARCH_PATH "boot/pc"
68 #define GRUB_PATH "grub"
70 #define locale_prfs_file "locale.prefs" /* please note the suffixed \" */
71 #define input_prfs_file "input.prefs"
73 #define DEF_INSTALL_IMAGE "IMAGES:Logos/install.logo"
74 #define DEF_BACK_IMAGE "IMAGES:Logos/install.logo"
75 #define DEF_LIGHTBACK_IMAGE "IMAGES:Logos/install.logo"
77 #define POST_INSTALL_SCRIPT "PROGDIR:InstallAROS-Post-Install"
78 #define AROS_BOOT_FILE "AROS.boot"
80 #define GRUB_COPY_FILE_LOOP(files) \
81 SET(data->gauge2, MUIA_Gauge_Current, 0); \
83 while (files[file_count] != NULL && data->inst_success == MUIV_Inst_InProgress) \
85 ULONG newSrcLen = strlen(srcPath) + strlen(files[file_count]) + 2; \
86 ULONG newDstLen = strlen(dstPath) + strlen(files[file_count + 1]) + 2; \
88 TEXT srcFile[newSrcLen]; \
89 TEXT dstFile[newDstLen]; \
91 sprintf(srcFile, "%s", srcPath); \
92 sprintf(dstFile, "%s", dstPath); \
93 AddPart(srcFile, files[file_count], newSrcLen); \
94 AddPart(dstFile, files[file_count + 1], newDstLen); \
96 DoMethod(self, MUIM_IC_CopyFile, srcFile, dstFile); \
100 if (numgrubfiles > 0) \
102 SET(data->gauge2, MUIA_Gauge_Current, \
103 (LONG)((100.0 / numgrubfiles) * (file_count / 2.0))); \
108 #define OPTION_PREPDRIVES 1
109 #define OPTION_FORMAT 2
110 #define OPTION_LANGUAGE 3
111 #define OPTION_CORE 4
112 #define OPTION_EXTRAS 5
113 #define OPTION_BOOTLOADER 6
116 #define INSTV_TITLE 101001
117 #define INSTV_LOGO 101002
118 #define INSTV_PAGE 101003
120 #define INSTV_TEXT 101004
121 #define INSTV_SPACE 101005
122 #define INSTV_BOOL 101006
123 #define INSTV_RETURN 101007
125 #define INSTV_CURR 101100
129 BOOTLOADER_NONE
= -1,
134 /* Files to check for. Must be in the same order as enum values before */
135 STRPTR BootLoaderFiles
[] = {
137 "boot/grub/i386-pc/core.img",
141 #define BOOTLOADER_PATH_LEN 20 /* Length of the largest string in BootLoaders array plus 2 */
143 struct ExpansionBase
*ExpansionBase
= NULL
;
145 char *source_Path
= NULL
; /* full path to source "tree" */
146 char *extras_source
= NULL
;
148 char *dest_Path
= NULL
; /* DOS DEVICE NAME of part used to store "aros" */
149 char *work_Path
= NULL
; /* DOS DEVICE NAME of part used to store "work" */
150 TEXT
*extras_path
= NULL
; /* DOS DEVICE NAME of part used to store extras */
152 char *boot_Device
= "ahci.device";
155 Object
*check_copytowork
= NULL
;
156 Object
*check_work
= NULL
;
157 Object
*show_formatsys
= NULL
;
158 Object
*show_formatwork
= NULL
;
159 Object
*check_formatsys
= NULL
;
160 Object
*check_formatwork
= NULL
;
161 Object
*cycle_fstypesys
= NULL
;
162 Object
*cycle_fstypework
= NULL
;
163 Object
*cycle_sysunits
= NULL
;
164 Object
*cycle_workunits
= NULL
;
166 Object
*dest_volume
= NULL
;
167 Object
*work_volume
= NULL
;
169 Object
*dest_device
= NULL
;
170 Object
*cycle_drivetype
= NULL
;
171 Object
*dest_unit
= NULL
;
172 Object
*show_sizesys
= NULL
;
173 Object
*show_sizework
= NULL
;
174 Object
*check_sizesys
= NULL
;
175 Object
*check_sizework
= NULL
;
176 Object
*check_creatework
= NULL
;
177 Object
*sys_size
= NULL
;
178 Object
*work_size
= NULL
;
179 Object
*sys_devname
= NULL
;
180 Object
*work_devname
= NULL
;
182 Object
*grub_device
= NULL
;
183 Object
*grub_unit
= NULL
;
185 Object
*reboot_group
= NULL
;
187 BOOL gfx_font_exists
;
189 ULONG
GuessFirstHD(CONST_STRPTR device
);
190 static struct FileSysStartupMsg
*getDiskFSSM(CONST_STRPTR path
);
191 static LONG
GetPartitionSize(BOOL get_work
);
192 static LONG
FindWindowsPartition(STRPTR device
, LONG unit
);
193 LONG
CopyDirArray(Class
* CLASS
, Object
* self
, CONST_STRPTR sourcePath
,
194 CONST_STRPTR destinationPath
, CONST_STRPTR directories
[]);
196 IPTR
Install__OM_NEW(Class
* CLASS
, Object
* self
, struct opSet
*message
)
198 self
= (Object
*) DoSuperMethodA(CLASS
, self
, (Msg
) message
);
200 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
204 /* We will generate this info shortly */
208 data
->IO_Always_overwrite
= IIO_Overwrite_Ask
;
213 (APTR
) GetTagData(MUIA_WelcomeMsg
, (IPTR
) NULL
,
214 message
->ops_AttrList
);
216 (APTR
) GetTagData(MUIA_FinishedMsg
, (IPTR
) NULL
,
217 message
->ops_AttrList
);
220 (APTR
) GetTagData(MUIA_Page
, (IPTR
) NULL
, message
->ops_AttrList
);
222 (APTR
) GetTagData(MUIA_Gauge1
, (IPTR
) NULL
, message
->ops_AttrList
);
224 (APTR
) GetTagData(MUIA_Gauge2
, (IPTR
) NULL
, message
->ops_AttrList
);
226 (APTR
) GetTagData(MUIA_Install
, (IPTR
) NULL
, message
->ops_AttrList
);
229 (APTR
) GetTagData(MUIA_OBJ_Installer
, (IPTR
) NULL
,
230 message
->ops_AttrList
);
233 (APTR
) GetTagData(MUIA_OBJ_Window
, (IPTR
) NULL
,
234 message
->ops_AttrList
);
236 (APTR
) GetTagData(MUIA_OBJ_WindowContent
, (IPTR
) NULL
,
237 message
->ops_AttrList
);
240 (APTR
) GetTagData(MUIA_OBJ_PageTitle
, (IPTR
) NULL
,
241 message
->ops_AttrList
);
243 (APTR
) GetTagData(MUIA_OBJ_PageHeader
, (IPTR
) NULL
,
244 message
->ops_AttrList
);
246 data
->actioncurrent
=
247 (APTR
) GetTagData(MUIA_OBJ_CActionStrng
, (IPTR
) NULL
,
248 message
->ops_AttrList
);
250 (APTR
) GetTagData(MUIA_OBJ_Back
, (IPTR
) NULL
,
251 message
->ops_AttrList
);
253 (APTR
) GetTagData(MUIA_OBJ_Proceed
, (IPTR
) NULL
,
254 message
->ops_AttrList
);
256 (APTR
) GetTagData(MUIA_OBJ_Cancel
, (IPTR
) NULL
,
257 message
->ops_AttrList
);
259 data
->instc_lic_file
=
260 (char *)GetTagData(MUIA_IC_License_File
, (IPTR
) NULL
,
261 message
->ops_AttrList
);
262 data
->instc_copt_licensemandatory
=
263 (BOOL
) GetTagData(MUIA_IC_License_Mandatory
, (IPTR
) FALSE
,
264 message
->ops_AttrList
);
266 data
->instc_options_main
=
267 (APTR
) GetTagData(MUIA_List_Options
, (IPTR
) NULL
,
268 message
->ops_AttrList
);
269 data
->instc_options_grub
=
270 (APTR
) GetTagData(MUIA_Grub_Options
, (IPTR
) NULL
,
271 message
->ops_AttrList
);
273 data
->instc_copt_undoenabled
=
274 (BOOL
) GetTagData(MUIA_IC_EnableUndo
, (IPTR
) FALSE
,
275 message
->ops_AttrList
);
277 data
->instc_options_main
->partitioned
= FALSE
;
278 data
->instc_options_main
->bootloaded
= FALSE
;
279 data
->instc_options_grub
->bootinfo
= FALSE
;
281 GET(data
->window
, MUIA_Window_Width
, &data
->cur_width
);
282 GET(data
->window
, MUIA_Window_Height
, &data
->cur_height
);
284 SET(data
->welcomeMsg
, MUIA_Text_Contents
, KMsgWelcome
);
285 SET(data
->back
, MUIA_Disabled
, TRUE
);
287 data
->instc_stage_next
= EPartitionOptionsStage
;
289 data
->inst_success
= FALSE
;
290 data
->disable_back
= FALSE
;
292 data
->instc_cflag_driveset
= (BOOL
) DoMethod(self
, MUIM_FindDrives
);
294 /* Default to USB if a USB system volume appears to be present and we
295 * haven't booted from it */
297 lock
= Lock("SYS:", SHARED_LOCK
);
298 NameFromLock(lock
, sys_path
, 100);
299 if (getDiskFSSM(USB_SYS_PART_NAME
":") != NULL
300 && strncmp(sys_path
, USB_SYS_VOL_NAME
":",
301 strlen(USB_SYS_VOL_NAME
) + 1))
303 SET(dest_volume
, MUIA_String_Contents
, USB_SYS_PART_NAME
);
304 SET(work_volume
, MUIA_String_Contents
, USB_WORK_PART_NAME
);
306 SET(cycle_drivetype
, MUIA_Cycle_Active
, 2);
310 boot_Unit
= GuessFirstHD(boot_Device
);
312 DoMethod(data
->proceed
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
) self
,
313 1, MUIM_IC_NextStep
);
314 DoMethod(data
->back
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
) self
, 1,
316 DoMethod(data
->cancel
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
) self
, 1,
317 MUIM_IC_CancelInstall
);
319 DoMethod(self
, MUIM_Notify
, MUIA_InstallComplete
, TRUE
, (IPTR
) self
, 1,
322 /* set up the license info */
324 if (data
->instc_lic_file
)
326 register struct FileInfoBlock
*fib
= NULL
;
330 lock
= (BPTR
) Lock(data
->instc_lic_file
, SHARED_LOCK
);
333 fib
= (void *)AllocVec(sizeof(*fib
), MEMF_PUBLIC
);
337 if ((from
= Open(data
->instc_lic_file
, MODE_OLDFILE
)))
340 ("[INSTALLER.i] Allocating buffer [%d] for license file '%s'!",
341 fib
->fib_Size
, data
->instc_lic_file
));
342 data
->instc_lic_buffer
=
343 AllocVec(fib
->fib_Size
+ 1, MEMF_CLEAR
| MEMF_PUBLIC
);
344 if ((s
= Read(from
, data
->instc_lic_buffer
,
345 fib
->fib_Size
)) == -1)
347 D(bug("[INSTALLER.i] Error processing license file!"));
348 if ((BOOL
) data
->instc_copt_licensemandatory
)
357 DoMethod(data
->instc_options_main
->opt_lic_box
,
358 MUIM_TextEditor_InsertText
, data
->instc_lic_buffer
,
359 MUIV_TextEditor_InsertText_Top
);
371 if (!data
->instc_copt_licensemandatory
)
372 SET(data
->instc_options_main
->opt_lic_mgrp
, MUIA_ShowMe
, FALSE
);
374 DoMethod(data
->instc_options_main
->opt_license
, MUIM_Notify
,
375 MUIA_Selected
, MUIV_EveryTime
, (IPTR
) data
->proceed
, 3,
376 MUIM_Set
, MUIA_Disabled
, MUIV_NotTriggerValue
);
381 if (data
->instc_copt_undoenabled
)
384 NEWLIST((struct List
*)&data
->instc_undorecord
);
385 D(bug("[INSTALLER.i] Prepared UNDO list @ %p\n",
386 &data
->instc_undorecord
));
388 if ((lock
= Lock(INSTALLER_TMP_PATH
, ACCESS_READ
)) != NULL
)
390 D(bug("[INSTALLER.i] Dir '%s' Exists - no nead to create\n",
391 INSTALLER_TMP_PATH
));
396 lock
= CreateDir(INSTALLER_TMP_PATH
);
401 D(bug("[INSTALLER.i] Failed to create dir '%s'!!\n",
402 INSTALLER_TMP_PATH
));
403 data
->inst_success
= MUIV_Inst_Failed
;
408 if ((lock
= Lock(INSTALLAROS_TMP_PATH
, ACCESS_READ
)) != NULL
)
410 D(bug("[INSTALLER.i] Dir '%s' Exists - no nead to create\n",
411 INSTALLAROS_TMP_PATH
));
416 lock
= CreateDir(INSTALLAROS_TMP_PATH
);
421 D(bug("[INSTALLER.i] Failed to create dir '%s'!!\n",
422 INSTALLAROS_TMP_PATH
));
423 data
->inst_success
= MUIV_Inst_Failed
;
434 ULONG
AskRetry(Class
* CLASS
, Object
* self
, CONST_STRPTR message
,
435 CONST_STRPTR file
, CONST_STRPTR opt1
, CONST_STRPTR opt2
,
438 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
439 STRPTR finalmessage
= NULL
;
440 STRPTR finaloptions
= NULL
;
444 AllocVec(strlen(message
) + strlen(file
) + 2,
445 MEMF_CLEAR
| MEMF_PUBLIC
);
447 AllocVec(strlen(opt1
) + strlen(opt2
) + strlen(opt3
) + 5,
448 MEMF_CLEAR
| MEMF_PUBLIC
);
450 sprintf(finalmessage
, message
, file
);
451 sprintf(finaloptions
, "%s|%s|%s", opt1
, opt2
, opt3
);
454 MUI_RequestA(data
->installer
, data
->window
, 0,
455 "IO Error has occured", finaloptions
, finalmessage
, NULL
);
456 FreeVec(finalmessage
);
457 FreeVec(finaloptions
);
462 /* Return the unit number of the drive that's likely to be the first in the
463 * system, or zero if none found */
464 ULONG
GuessFirstHD(CONST_STRPTR device
)
466 struct PartitionHandle
*ph
;
470 for (i
= 0; i
< 8 && !found
; i
++)
472 ph
= OpenRootPartition(device
, i
);
476 CloseRootPartition(ph
);
485 /* Return TRUE if we suspect a floppy disk */
486 BOOL
myCheckFloppy(struct DosEnvec
* DriveEnv
)
488 switch (DriveEnv
->de_HighCyl
)
491 /* Standard Floppy size
492 for PC floppies, DD = 9, HD = 18
493 for Amiga floppies, DD = 11, HD = 22
495 if ((DriveEnv
->de_BlocksPerTrack
== 18) ||
496 (DriveEnv
->de_BlocksPerTrack
== 9) ||
497 (DriveEnv
->de_BlocksPerTrack
== 22) ||
498 (DriveEnv
->de_BlocksPerTrack
== 11))
503 /* Standard Zip (95Mb) */
504 if ((DriveEnv
->de_BlocksPerTrack
== 60) ||
505 (DriveEnv
->de_BlocksPerTrack
== 68))
509 /* Standard Zip & LS120 sizes */
510 if (DriveEnv
->de_BlocksPerTrack
== 1)
515 /* OK - shouldn't be a floppy... */
519 /* Returns the first AROS-supported filesystem's name */
520 char *FindPartition(struct PartitionHandle
*root
)
522 struct PartitionHandle
*partition
= NULL
;
523 char *success
= NULL
;
525 struct PartitionType
*type
= NULL
;
527 ForeachNode(&root
->table
->list
, partition
)
529 D(bug("[INSTALLER.fp] checking part\n"));
530 if (OpenPartitionTable(partition
) == 0)
532 D(bug("[INSTALLER.fp] checking Child Parts... \n"));
533 success
= FindPartition(partition
);
534 ClosePartitionTable(partition
);
535 D(bug("[INSTALLER.fp] Children Done...\n"));
538 D(bug("[INSTALLER.fp] Found '%s'\n", success
));
544 D(bug("[INSTALLER.fp] checking PARTITION\n"));
545 struct PartitionType pttype
;
547 name
= AllocVec(100, MEMF_CLEAR
| MEMF_PUBLIC
);
549 GetPartitionAttrsTags
551 PT_NAME
, (IPTR
) name
, PT_TYPE
, (IPTR
) & pttype
, TAG_DONE
);
555 if (type
->id_len
== 4)
557 D(bug("[INSTALLER.fp] Found RDB Partition!\n"));
558 if ((type
->id
[0] == 68) && (type
->id
[1] == 79)
559 && (type
->id
[2] == 83))
561 D(bug("[INSTALLER.fp] Found AFFS Partition! '%s'\n",
566 if ((type
->id
[0] == 83) && (type
->id
[1] == 70)
567 && (type
->id
[2] == 83))
569 D(bug("[INSTALLER.fp] Found SFS Partition! '%s'\n",
578 if ((!success
) && (name
))
584 IPTR
Install__MUIM_FindDrives(Class
* CLASS
, Object
* self
, Msg message
)
586 struct BootNode
*CurBootNode
= NULL
;
587 struct PartitionHandle
*root
;
589 struct DevInfo
*devnode
= NULL
;
590 struct FileSysStartupMsg
*StartMess
= NULL
;
591 struct DosEnvec
*DriveEnv
= NULL
;
594 BOOL founddisk
= FALSE
;
596 ForeachNode(&ExpansionBase
->MountList
, CurBootNode
)
598 devnode
= CurBootNode
->bn_DeviceNode
;
599 StartMess
= devnode
->dvi_Startup
;
602 D(bug("[INSTALLER.fd] Drive found [%s unit %d]\n",
603 StartMess
->fssm_Device
, StartMess
->fssm_Unit
));
605 DriveEnv
= StartMess
->fssm_Environ
;
607 if (!myCheckFloppy(DriveEnv
))
610 OpenRootPartition(StartMess
->fssm_Device
,
611 StartMess
->fssm_Unit
)) != NULL
)
615 /* First drive in system - save its info for grub */
617 ("[INSTALLER.fd] First DRIVE found [%s unit %d]...\n",
618 StartMess
->fssm_Device
, StartMess
->fssm_Unit
));
620 // boot_Device = StartMess->fssm_Device;
621 // boot_Unit = StartMess->fssm_Unit;
624 if (OpenPartitionTable(root
) == 0)
626 result
= FindPartition(root
);
627 D(bug("[INSTALLER.fd] Partition '%s'\n", result
));
628 ClosePartitionTable(root
);
630 CloseRootPartition(root
);
635 return (IPTR
) result
;
638 static struct FileSysStartupMsg
*getDiskFSSM(CONST_STRPTR path
)
641 struct DeviceNode
*dn
;
645 D(bug("[install] getDiskFSSM('%s')\n", path
));
647 for (i
= 0; (path
[i
]) && (path
[i
] != ':'); i
++)
652 dl
= LockDosList(LDF_READ
);
655 dn
= (struct DeviceNode
*)FindDosEntry(dl
, dname
, LDF_DEVICES
);
656 UnLockDosList(LDF_READ
);
659 if (IsFileSystem(dname
))
661 return (struct FileSysStartupMsg
*)BADDR(dn
->
665 printf("device '%s' doesn't contain a file system\n",
669 // PrintFault(ERROR_OBJECT_NOT_FOUND, dname);
673 printf("'%s' doesn't contain a device name\n", path
);
677 IPTR
Install__MUIM_IC_NextStep(Class
* CLASS
, Object
* self
, Msg message
)
679 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
680 IPTR this_page
= 0, next_stage
= 0, option
= 0;
682 GET(data
->page
, MUIA_Group_ActivePage
, &this_page
);
684 if ((EDoneStage
== this_page
) && (this_page
== data
->instc_stage_next
))
685 set(self
, MUIA_InstallComplete
, TRUE
); //ALL DONE!!
687 SET(data
->back
, MUIA_Disabled
, (BOOL
) data
->disable_back
);
689 next_stage
= data
->instc_stage_next
;
690 data
->instc_stage_prev
= this_page
;
692 SET(data
->back
, MUIA_Selected
, FALSE
);
693 SET(data
->proceed
, MUIA_Selected
, FALSE
);
694 SET(data
->cancel
, MUIA_Selected
, FALSE
);
696 switch (data
->instc_stage_next
)
700 if (data
->instc_lic_file
)
702 if (data
->instc_copt_licensemandatory
)
704 /* Force acceptance of the license */
705 SET(data
->instc_options_main
->opt_license
, MUIA_Selected
,
707 SET(data
->proceed
, MUIA_Disabled
, TRUE
);
709 data
->instc_stage_next
= EInstallOptionsStage
;
710 next_stage
= ELicenseStage
;
713 /* if no license we ignore this step... and go to partition options */
715 case EPartitionOptionsStage
:
716 if (data
->instc_cflag_driveset
)
717 SET(data
->instc_options_main
->opt_partmethod
, MUIA_Radio_Active
,
720 SET(dest_unit
, MUIA_String_Integer
, boot_Unit
);
721 data
->instc_stage_next
= EPartitioningStage
;
722 next_stage
= EPartitionOptionsStage
;
725 case EInstallOptionsStage
:
726 SET(data
->welcomeMsg
, MUIA_Text_Contents
, KMsgInstallOptions
);
727 data
->instc_stage_next
= EDestOptionsStage
;
728 next_stage
= EInstallOptionsStage
;
731 case EDestOptionsStage
:
732 if ((BOOL
) XGET(data
->instc_options_main
->opt_format
,
735 SET(show_formatsys
, MUIA_ShowMe
, TRUE
);
736 SET(show_formatwork
, MUIA_ShowMe
, TRUE
);
740 SET(check_formatsys
, MUIA_Selected
, FALSE
);
741 SET(check_formatwork
, MUIA_Selected
, FALSE
);
742 SET(show_formatsys
, MUIA_ShowMe
, FALSE
);
743 SET(show_formatwork
, MUIA_ShowMe
, FALSE
);
745 data
->instc_stage_next
= EInstallMessageStage
;
746 next_stage
= EDestOptionsStage
;
749 case EInstallMessageStage
:
750 /* PARTITION DRIVES */
752 /* have we already done this? */
753 if (!data
->instc_options_main
->partitioned
)
755 data
->instc_options_main
->partitioned
= TRUE
;
756 data
->instc_stage_next
= EPartitioningStage
;
757 next_stage
= EPartitionOptionsStage
;
758 data
->instc_stage_prev
= this_page
;
766 GET(data
->instc_options_main
->opt_bootloader
, MUIA_Selected
,
770 //have we already done this?
771 if (!data
->instc_options_main
->bootloaded
)
773 data
->instc_options_main
->bootloaded
= TRUE
;
775 if (!data
->instc_options_grub
->bootinfo
)
778 char *tmp_drive
= NULL
;
779 char *tmp_device
= NULL
;
781 char *tmp_grub
= NULL
;
783 struct IOStdReq
*ioreq
= NULL
;
784 struct MsgPort
*mp
= NULL
;
786 struct FileSysStartupMsg
*fssm
;
788 data
->instc_options_grub
->bootinfo
= TRUE
;
791 tmp_drive
= AllocVec(100, MEMF_CLEAR
| MEMF_PUBLIC
);
792 tmp_device
= AllocVec(100, MEMF_CLEAR
| MEMF_PUBLIC
);
794 tmp_grub
= AllocVec(100, MEMF_CLEAR
| MEMF_PUBLIC
);
796 GET(dest_volume
, MUIA_String_Contents
, &option
);
797 sprintf(tmp_grub
, "%s:"ARCH_PATH
"/"GRUB_PATH
,
798 (CONST_STRPTR
) option
);
800 /* Guess the best disk to install GRUB's bootblock to */
801 fssm
= getDiskFSSM(tmp_grub
);
804 boot_Device
= fssm
->fssm_Device
;
805 if (strcmp(fssm
->fssm_Device
, "ahci.device") != 0
806 && strcmp(fssm
->fssm_Device
, "ata.device") != 0)
807 boot_Unit
= fssm
->fssm_Unit
;
812 SET(grub_device
, MUIA_String_Contents
,
814 SET(grub_unit
, MUIA_String_Integer
, boot_Unit
);
817 mp
= CreateMsgPort();
821 (struct IOStdReq
*)CreateIORequest(mp
,
822 sizeof(struct IOStdReq
));
825 if (OpenDevice(boot_Device
, boot_Unit
,
826 (struct IORequest
*)ioreq
, 0) == 0)
828 identify(ioreq
, tmp_drive
);
829 sprintf(tmp_device
, "%s [%s unit %d]",
830 tmp_drive
, boot_Device
, boot_Unit
);
831 CloseDevice((struct IORequest
*)ioreq
);
835 "Unknown Drive [%s unit %d]",
836 boot_Device
, boot_Unit
);
837 DeleteIORequest((struct IORequest
*)ioreq
);
841 "Unknown Drive [%s unit %d]", boot_Device
,
846 sprintf(tmp_device
, "Unknown Drive [%s unit %d]",
847 boot_Device
, boot_Unit
);
849 SET(data
->instc_options_grub
->gopt_drive
,
850 MUIA_Text_Contents
, tmp_device
);
852 SET(data
->instc_options_grub
->gopt_grub
,
853 MUIA_Text_Contents
, tmp_grub
);
856 data
->instc_stage_next
= EInstallMessageStage
;
857 next_stage
= EGrubOptionsStage
;
858 data
->instc_stage_prev
= EInstallOptionsStage
;
861 else if (strlen((STRPTR
) XGET(grub_device
,
862 MUIA_String_Contents
)) == 0)
864 /* Go back if user hasn't entered a device name for GRUB */
865 MUI_RequestA(data
->installer
, data
->window
, 0, "Error",
866 "OK", KMsgNoGrubDevice
, NULL
);
867 data
->instc_stage_next
= EInstallMessageStage
;
868 next_stage
= EGrubOptionsStage
;
869 data
->instc_stage_prev
= EInstallOptionsStage
;
874 if (XGET(check_formatsys
, MUIA_Selected
)
875 || XGET(check_formatwork
, MUIA_Selected
))
876 SET(data
->welcomeMsg
, MUIA_Text_Contents
,
877 KMsgBeginWithPartition
);
879 SET(data
->welcomeMsg
, MUIA_Text_Contents
,
880 KMsgBeginWithoutPartition
);
881 data
->instc_stage_next
= EInstallStage
;
882 next_stage
= EMessageStage
;
885 case EPartitioningStage
:
886 get(data
->instc_options_main
->opt_partmethod
, MUIA_Radio_Active
,
888 if ((int)option
== 0 || (int)option
== 1)
890 LONG syssize
, worksize
;
891 IPTR systype
= 0, worktype
= 0;
893 /* Let user try again if either partition size is too big.
894 Note that C:Partition will ensure that automatically sized
895 partitions are within size limits */
896 syssize
= GetPartitionSize(FALSE
);
897 worksize
= GetPartitionSize(TRUE
);
899 get(cycle_fstypesys
, MUIA_Cycle_Active
, &systype
);
900 get(cycle_fstypework
, MUIA_Cycle_Active
, &worktype
);
902 if (syssize
> (systype
? MAX_SFS_SIZE
: MAX_FFS_SIZE
) ||
903 worksize
> (worktype
? MAX_SFS_SIZE
: MAX_FFS_SIZE
))
905 TEXT msg
[sizeof(KMsgPartitionTooBig
) + 40];
906 sprintf(msg
, KMsgPartitionTooBig
,
907 MAX_SFS_SIZE
/ 1024, MAX_SFS_SIZE
,
908 MAX_FFS_SIZE
/ 1024, MAX_FFS_SIZE
);
909 MUI_RequestA(data
->installer
, data
->window
, 0, "Error",
914 /* Warn user about using non FFS-Intl filesystem for system
915 partition with GRUB */
916 if ((BootLoaderType
== BOOTLOADER_GRUB1
) && (systype
!= 0))
918 if (MUI_RequestA(data
->installer
, data
->window
, 0,
920 "Continue Partitioning|*Cancel Partitioning",
921 KMsgGRUBNonFFSWarning
, NULL
) != 1)
925 data
->disable_back
= TRUE
;
927 SET(data
->page
, MUIA_Group_ActivePage
, EPartitioningStage
);
933 if (DoMethod(self
, MUIM_Partition
) != RETURN_OK
)
935 D(bug("[INSTALLER] Partitioning FAILED!!!!\n"));
936 data
->disable_back
= FALSE
;
937 SET(data
->page
, MUIA_Group_ActivePage
,
938 EInstallMessageStage
);
939 data
->instc_stage_next
= EPartitioningStage
;
940 data
->instc_options_main
->partitioned
= FALSE
;
941 MUI_RequestA(data
->installer
, data
->window
, 0, "Error",
942 "Quit", KMsgPartitioningFailed
, NULL
);
943 DoMethod(self
, MUIM_IC_QuitInstall
);
946 data
->instc_options_main
->partitioned
= TRUE
;
947 next_stage
= EDoneStage
;
948 DoMethod(data
->page
, MUIM_Group_InitChange
);
949 if (XGET(cycle_drivetype
, MUIA_Cycle_Active
) != 2)
950 SET(data
->doneMsg
, MUIA_Text_Contents
, KMsgDoneReboot
);
952 SET(data
->doneMsg
, MUIA_Text_Contents
, KMsgDoneUSB
);
953 SET(reboot_group
, MUIA_ShowMe
, TRUE
);
954 if (XGET(cycle_drivetype
, MUIA_Cycle_Active
) != 2)
955 SET(data
->instc_options_main
->opt_reboot
, MUIA_Selected
,
957 DoMethod(data
->page
, MUIM_Group_ExitChange
);
958 SET(data
->back
, MUIA_Disabled
, TRUE
);
959 SET(data
->cancel
, MUIA_Disabled
, TRUE
);
960 data
->instc_stage_next
= EDoneStage
;
963 data
->disable_back
= FALSE
;
964 data
->instc_options_main
->partitioned
= TRUE
;
965 data
->instc_stage_next
= EDestOptionsStage
;
966 next_stage
= EInstallOptionsStage
;
969 D(bug("[INSTALLER] Launching QuickPart...\n"));
970 Execute("SYS:Tools/QuickPart", NULL
, NULL
);
976 data
->disable_back
= TRUE
;
977 SET(data
->page
, MUIA_Group_ActivePage
, EInstallStage
);
979 DoMethod(self
, MUIM_IC_Install
);
981 next_stage
= EDoneStage
;
982 SET(data
->back
, MUIA_Disabled
, TRUE
);
983 SET(data
->cancel
, MUIA_Disabled
, TRUE
);
984 data
->instc_stage_next
= EDoneStage
;
991 SET(data
->page
, MUIA_Group_ActivePage
, next_stage
);
995 IPTR
Install__MUIM_IC_PrevStep(Class
* CLASS
, Object
* self
, Msg message
)
997 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
1000 GET(data
->page
, MUIA_Group_ActivePage
, &this_page
);
1001 SET(data
->back
, MUIA_Selected
, FALSE
);
1002 SET(data
->proceed
, MUIA_Selected
, FALSE
);
1003 SET(data
->cancel
, MUIA_Selected
, FALSE
);
1005 SET(data
->back
, MUIA_Disabled
, (BOOL
) data
->disable_back
);
1006 data
->instc_stage_next
= this_page
;
1011 /* BACK should only be possible when page != first_page */
1012 if (data
->instc_stage_prev
!= EMessageStage
)
1014 SET(data
->welcomeMsg
, MUIA_Text_Contents
,
1015 KMsgBeginWithPartition
);
1016 if (data
->instc_stage_prev
== EDestOptionsStage
)
1018 SET(data
->page
, MUIA_Group_ActivePage
, EDestOptionsStage
);
1020 data
->instc_stage_prev
= EInstallOptionsStage
;
1024 if (!data
->instc_options_grub
->bootinfo
)
1026 SET(data
->page
, MUIA_Group_ActivePage
,
1027 EPartitionOptionsStage
);
1031 SET(data
->page
, MUIA_Group_ActivePage
,
1034 data
->instc_stage_prev
= EDestOptionsStage
;
1036 data
->instc_stage_next
= EInstallMessageStage
;
1040 case EPartitionOptionsStage
:
1041 if (data
->instc_lic_file
)
1043 SET(data
->instc_options_main
->opt_license
, MUIA_Selected
,
1045 SET(data
->proceed
, MUIA_Disabled
, TRUE
);
1046 SET(data
->page
, MUIA_Group_ActivePage
, EPartitionOptionsStage
);
1047 data
->instc_stage_prev
= ELicenseStage
;
1052 SET(data
->proceed
, MUIA_Disabled
, FALSE
);
1053 SET(data
->back
, MUIA_Disabled
, TRUE
);
1054 SET(data
->welcomeMsg
, MUIA_Text_Contents
, KMsgWelcome
);
1055 SET(data
->page
, MUIA_Group_ActivePage
, EMessageStage
);
1056 data
->instc_stage_prev
= EMessageStage
;
1059 case EInstallOptionsStage
:
1060 SET(data
->instc_options_main
->opt_license
, MUIA_Selected
, FALSE
);
1061 SET(data
->page
, MUIA_Group_ActivePage
, EPartitionOptionsStage
);
1062 data
->instc_stage_prev
= ELicenseStage
;
1063 data
->instc_stage_next
= EPartitioningStage
;
1066 case EDestOptionsStage
:
1067 SET(data
->page
, MUIA_Group_ActivePage
, EInstallOptionsStage
);
1068 data
->instc_stage_next
= EDestOptionsStage
;
1069 data
->instc_stage_prev
= EMessageStage
;
1072 case EGrubOptionsStage
:
1073 SET(data
->page
, MUIA_Group_ActivePage
, EDestOptionsStage
);
1074 data
->instc_options_main
->bootloaded
= FALSE
;
1075 data
->instc_options_grub
->bootinfo
= FALSE
;
1076 data
->instc_stage_next
= EInstallMessageStage
;
1077 data
->instc_stage_prev
= EInstallOptionsStage
;
1080 case EInstallMessageStage
:
1082 /* Back is disabled from here on... */
1084 case EPartitioningStage
:
1094 IPTR Install__MUIM_IC_CancelInstall
1095 (Class
* CLASS
, Object
* self
, Msg message
)
1097 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
1098 struct optionstmp
*backupOptions
= NULL
;
1100 const char *cancelmessage
= NULL
;
1102 if ((backupOptions
= data
->instc_options_backup
) == NULL
)
1105 AllocMem(sizeof(struct optionstmp
), MEMF_CLEAR
| MEMF_PUBLIC
);
1106 data
->instc_options_backup
= backupOptions
;
1109 GET(data
->page
, MUIA_Group_ActivePage
, &this_page
);
1111 GET(data
->back
, MUIA_Disabled
, &data
->status_back
);
1112 GET(data
->proceed
, MUIA_Disabled
, &data
->status_proceed
);
1113 GET(data
->cancel
, MUIA_Disabled
, &data
->status_cancel
);
1117 case EPartitioningStage
:
1120 cancelmessage
= KMsgCancelDanger
;
1123 case EInstallOptionsStage
:
1124 GET(data
->instc_options_main
->opt_format
, MUIA_Disabled
,
1125 &backupOptions
->opt_format
);
1126 GET(data
->instc_options_main
->opt_locale
, MUIA_Disabled
,
1127 &backupOptions
->opt_locale
);
1128 GET(data
->instc_options_main
->opt_copycore
, MUIA_Disabled
,
1129 &backupOptions
->opt_copycore
);
1130 GET(data
->instc_options_main
->opt_copyextra
, MUIA_Disabled
,
1131 &backupOptions
->opt_copyextra
);
1132 GET(data
->instc_options_main
->opt_development
, MUIA_Disabled
,
1133 &backupOptions
->opt_development
);
1134 GET(data
->instc_options_main
->opt_bootloader
, MUIA_Disabled
,
1135 &backupOptions
->opt_bootloader
);
1136 GET(data
->instc_options_main
->opt_reboot
, MUIA_Disabled
,
1137 &backupOptions
->opt_reboot
);
1139 SET(data
->instc_options_main
->opt_format
, MUIA_Disabled
, TRUE
);
1140 SET(data
->instc_options_main
->opt_locale
, MUIA_Disabled
, TRUE
);
1141 SET(data
->instc_options_main
->opt_copycore
, MUIA_Disabled
, TRUE
);
1142 SET(data
->instc_options_main
->opt_copyextra
, MUIA_Disabled
, TRUE
);
1143 SET(data
->instc_options_main
->opt_development
, MUIA_Disabled
, TRUE
);
1144 SET(data
->instc_options_main
->opt_bootloader
, MUIA_Disabled
, TRUE
);
1145 SET(data
->instc_options_main
->opt_reboot
, MUIA_Disabled
, TRUE
);
1148 case EDestOptionsStage
:
1149 SET(dest_volume
, MUIA_Disabled
, TRUE
);
1150 SET(work_volume
, MUIA_Disabled
, TRUE
);
1151 SET(check_copytowork
, MUIA_Disabled
, TRUE
);
1152 SET(check_work
, MUIA_Disabled
, TRUE
);
1155 case EPartitionOptionsStage
:
1156 SET(data
->instc_options_main
->opt_partmethod
, MUIA_Disabled
, TRUE
);
1159 case EGrubOptionsStage
:
1164 cancelmessage
= KMsgCancelOK
;
1168 SET(data
->back
, MUIA_Selected
, FALSE
);
1169 SET(data
->back
, MUIA_Disabled
, TRUE
);
1171 SET(data
->proceed
, MUIA_Selected
, FALSE
);
1172 SET(data
->proceed
, MUIA_Disabled
, TRUE
);
1174 SET(data
->cancel
, MUIA_Selected
, FALSE
);
1175 SET(data
->cancel
, MUIA_Disabled
, TRUE
);
1177 if (!MUI_RequestA(data
->installer
, data
->window
, 0,
1178 "Cancel Installation...", "*Continue Install|Cancel Install",
1179 cancelmessage
, NULL
))
1181 DoMethod(self
, MUIM_IC_QuitInstall
);
1184 DoMethod(self
, MUIM_IC_ContinueInstall
);
1189 IPTR Install__MUIM_IC_ContinueInstall
1190 (Class
* CLASS
, Object
* self
, Msg message
)
1192 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
1193 struct optionstmp
*backupOptions
= NULL
;
1196 backupOptions
= data
->instc_options_backup
;
1198 GET(data
->page
, MUIA_Group_ActivePage
, &this_page
);
1200 if (!(BOOL
) data
->disable_back
)
1201 SET(data
->back
, MUIA_Disabled
, data
->status_back
);
1203 SET(data
->back
, MUIA_Disabled
, TRUE
);
1204 SET(data
->back
, MUIA_Selected
, FALSE
);
1206 SET(data
->proceed
, MUIA_Disabled
, data
->status_proceed
);
1207 SET(data
->proceed
, MUIA_Selected
, FALSE
);
1209 SET(data
->cancel
, MUIA_Disabled
, data
->status_cancel
);
1210 SET(data
->cancel
, MUIA_Selected
, FALSE
);
1214 case EInstallOptionsStage
:
1215 SET(data
->instc_options_main
->opt_format
, MUIA_Disabled
,
1216 (BOOL
) backupOptions
->opt_format
);
1217 SET(data
->instc_options_main
->opt_locale
, MUIA_Disabled
,
1218 (BOOL
) backupOptions
->opt_locale
);
1219 SET(data
->instc_options_main
->opt_copycore
, MUIA_Disabled
,
1220 (BOOL
) backupOptions
->opt_copycore
);
1221 SET(data
->instc_options_main
->opt_copyextra
, MUIA_Disabled
,
1222 (BOOL
) backupOptions
->opt_copyextra
);
1223 SET(data
->instc_options_main
->opt_development
, MUIA_Disabled
,
1224 (BOOL
) backupOptions
->opt_development
);
1225 SET(data
->instc_options_main
->opt_bootloader
, MUIA_Disabled
,
1226 (BOOL
) backupOptions
->opt_bootloader
);
1227 SET(data
->instc_options_main
->opt_reboot
, MUIA_Disabled
,
1228 (BOOL
) backupOptions
->opt_reboot
);
1231 case EDestOptionsStage
:
1232 SET(dest_volume
, MUIA_Disabled
, FALSE
);
1233 SET(check_work
, MUIA_Disabled
, FALSE
);
1236 GET(check_work
, MUIA_Selected
, &reenable
);
1240 SET(check_copytowork
, MUIA_Disabled
, FALSE
);
1241 SET(work_volume
, MUIA_Disabled
, FALSE
);
1245 case EPartitionOptionsStage
:
1246 SET(data
->instc_options_main
->opt_partmethod
, MUIA_Disabled
, FALSE
);
1249 case EGrubOptionsStage
:
1259 IPTR
Install__MUIM_IC_QuitInstall(Class
* CLASS
, Object
* self
, Msg message
)
1261 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
1263 if (data
->inst_success
== MUIV_Inst_InProgress
)
1265 data
->inst_success
= MUIV_Inst_Cancelled
;
1267 DoMethod(self
, MUIM_Reboot
);
1273 /* ****** FUNCTION IS CALLED BY THE PROCEDURE PROCESSOR
1275 IT LAUNCHES THE NECESSARY FUNCTION TO PERFORM WHATEVER IS BEING ASKED TO DO
1278 IPTR Install__MUIM_DispatchInstallProcedure
1279 (Class
* CLASS
, Object
* self
, Msg message
)
1281 // struct Install_DATA* data = INST_DATA(CLASS, self);
1287 static LONG
GetPartitionSize(BOOL get_work
)
1294 if ((BOOL
) XGET(check_sizesys
, MUIA_Selected
))
1296 GET(sys_size
, MUIA_String_Integer
, &tmp
);
1298 if (XGET(cycle_sysunits
, MUIA_Cycle_Active
) == 1)
1304 if ((BOOL
) XGET(check_sizework
, MUIA_Selected
))
1306 GET(work_size
, MUIA_String_Integer
, &tmp
);
1308 if (XGET(cycle_workunits
, MUIA_Cycle_Active
) == 1)
1316 IPTR
Install__MUIM_Partition(Class
* CLASS
, Object
* self
, Msg message
)
1318 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
1319 IPTR option
= FALSE
;
1322 if (data
->inst_success
== MUIV_Inst_InProgress
)
1324 SET(data
->back
, MUIA_Disabled
, TRUE
);
1325 SET(data
->proceed
, MUIA_Disabled
, TRUE
);
1327 char tmpcmd
[150], tmparg
[100];
1328 GET(dest_device
, MUIA_String_Contents
, &tmp
);
1329 GET(dest_unit
, MUIA_String_Integer
, &option
);
1330 sprintf(tmpcmd
, "C:Partition DEVICE=%s UNIT=%ld FORCE QUIET",
1331 (char *)tmp
, option
);
1333 /* Specify SYS size */
1334 GET(check_sizesys
, MUIA_Selected
, &option
);
1337 tmp
= GetPartitionSize(FALSE
);
1338 sprintf(tmparg
, " SYSSIZE=%ld", tmp
);
1339 strcat(tmpcmd
, tmparg
);
1342 /* Specify SYS name */
1343 GET(sys_devname
, MUIA_String_Contents
, &tmp
);
1344 sprintf(tmparg
, " SYSNAME=\"%s\"", (char *)tmp
);
1345 strcat(tmpcmd
, tmparg
);
1347 /* Specify SYS filesystem (defaults to FFSIntl) */
1348 get(cycle_fstypesys
, MUIA_Cycle_Active
, &tmp
);
1350 strcat(tmpcmd
, " SYSTYPE=SFS");
1352 strcat(tmpcmd
, " SYSTYPE=FFSIntl");
1354 /* Specify Work size */
1355 GET(check_creatework
, MUIA_Selected
, &option
);
1358 GET(check_sizework
, MUIA_Selected
, &option
);
1361 tmp
= GetPartitionSize(TRUE
);
1362 sprintf(tmparg
, " WORKSIZE=%ld", tmp
);
1363 strcat(tmpcmd
, tmparg
);
1367 strcat(tmpcmd
, " MAXWORK");
1370 /* Specify WORK filesystem (defaults to SFS) */
1371 get(cycle_fstypework
, MUIA_Cycle_Active
, &tmp
);
1373 strcat(tmpcmd
, " WORKTYPE=FFSIntl");
1375 strcat(tmpcmd
, " WORKTYPE=SFS");
1377 /* Specify WORK name */
1378 GET(work_devname
, MUIA_String_Contents
, &tmp
);
1379 sprintf(tmparg
, " WORKNAME=\"%s\"", (char *)tmp
);
1380 strcat(tmpcmd
, tmparg
);
1383 /* Specify whether to wipe disk or not */
1384 GET(data
->instc_options_main
->opt_partmethod
, MUIA_Radio_Active
,
1388 D(bug("[INSTALLER] Partitioning EVERYTHING! MUAHAHAHA...\n"));
1389 strcat(tmpcmd
, " WIPE");
1392 D(bug("[INSTALLER] Partitioning Free Space...\n"));
1394 D(bug("[INSTALLER] ### Executing '%s'\n", &tmpcmd
));
1395 tmp
= SystemTagList(tmpcmd
, NULL
);
1397 SET(data
->proceed
, MUIA_Disabled
, FALSE
);
1403 void create_environment_variable(CONST_STRPTR envarchiveDisk
,
1404 CONST_STRPTR name
, CONST_STRPTR value
)
1406 BPTR env_variable_fh
= NULL
;
1407 TEXT env_variable_path
[100];
1409 if ((envarchiveDisk
== NULL
) || (name
== NULL
) || (value
== NULL
))
1413 sprintf(env_variable_path
, "%s:", envarchiveDisk
);
1414 AddPart(env_variable_path
, "Prefs/Env-Archive/", 100);
1415 AddPart(env_variable_path
, name
, 100);
1418 ("[INSTALLER] create_environment_variable: Setting Var '%s' to '%s'\n",
1419 env_variable_path
, value
));
1421 if ((env_variable_fh
= Open(env_variable_path
, MODE_NEWFILE
)) != NULL
)
1423 FPuts(env_variable_fh
, value
);
1424 Close(env_variable_fh
);
1428 static BOOL
read_environment_variable(CONST_STRPTR envarchiveDisk
,
1429 CONST_STRPTR name
, STRPTR buffer
, ULONG size
)
1431 BPTR env_variable_fh
= NULL
;
1432 TEXT env_variable_path
[100];
1434 if ((envarchiveDisk
== NULL
) || (name
== NULL
) || (buffer
== NULL
))
1437 sprintf(env_variable_path
, "%s:", envarchiveDisk
);
1438 AddPart(env_variable_path
, "Prefs/Env-Archive/", 100);
1439 AddPart(env_variable_path
, name
, 100);
1441 D(bug("[INSTALLER] read_environment_variable: Getting Var '%s'\n",
1442 env_variable_path
));
1444 if ((env_variable_fh
= Open(env_variable_path
, MODE_OLDFILE
)) != NULL
)
1446 FGets(env_variable_fh
, buffer
, size
);
1447 Close(env_variable_fh
);
1453 LONG
CountFiles(CONST_STRPTR directory
, CONST_STRPTR fileMask
,
1456 UBYTE
*buffer
= NULL
;
1457 TEXT matchString
[3 * strlen(fileMask
)];
1458 BPTR dirLock
= NULL
;
1461 D(bug("[INSTALLER.Count] Entry, directory: %s, mask: %s\n", directory
,
1464 /* Check if directory exists */
1465 dirLock
= Lock(directory
, SHARED_LOCK
);
1467 if (dirLock
== NULL
)
1472 buffer
= AllocVec(kExallBufSize
, MEMF_CLEAR
| MEMF_PUBLIC
);
1480 if (ParsePatternNoCase(fileMask
, matchString
, 3 * strlen(fileMask
)) < 0)
1487 struct ExAllData
*ead
= (struct ExAllData
*)buffer
;
1488 struct ExAllControl
*eac
= AllocDosObject(DOS_EXALLCONTROL
, NULL
);
1489 eac
->eac_LastKey
= 0;
1492 struct ExAllData
*oldEad
= ead
;
1497 loop
= ExAll(dirLock
, ead
, kExallBufSize
, ED_COMMENT
, eac
);
1499 if (!loop
&& IoErr() != ERROR_NO_MORE_ENTRIES
)
1502 if (eac
->eac_Entries
!= 0)
1506 if (ead
->ed_Type
== ST_FILE
1507 && MatchPatternNoCase(matchString
, ead
->ed_Name
))
1510 if (ead
->ed_Type
== ST_USERDIR
&& recursive
)
1512 LONG subFileCount
= 0;
1513 ULONG subDirNameLen
=
1514 strlen(directory
) + strlen(ead
->ed_Name
) + 2;
1515 TEXT subDirName
[subDirNameLen
];
1517 sprintf(subDirName
, "%s", directory
);
1518 AddPart(subDirName
, ead
->ed_Name
, subDirNameLen
);
1521 CountFiles(subDirName
, fileMask
, recursive
);
1523 if (subFileCount
>= 0)
1524 fileCount
+= subFileCount
;
1527 /* Error at lower level */
1528 FreeDosObject(DOS_EXALLCONTROL
, eac
);
1536 while (ead
!= NULL
);
1541 FreeDosObject(DOS_EXALLCONTROL
, eac
);
1548 LONG
InternalCopyFiles(Class
* CLASS
, Object
* self
, CONST_STRPTR srcDir
,
1549 CONST_STRPTR dstDir
, CONST_STRPTR fileMask
, BOOL recursive
,
1550 LONG totalFiles
, LONG totalFilesCopied
)
1552 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
1553 UBYTE
*buffer
= NULL
;
1554 TEXT matchString
[3 * strlen(fileMask
)];
1555 BPTR srcDirLock
= NULL
, dstDirLock
= NULL
;
1556 LONG totalFilesCopiedThis
= 0;
1558 /* Check entry condition */
1559 if (data
->inst_success
!= MUIV_Inst_InProgress
)
1560 return totalFilesCopied
;
1562 /* Check if source directory exists */
1565 srcDirLock
= Lock(srcDir
, SHARED_LOCK
);
1567 if (srcDirLock
== NULL
)
1570 AskRetry(CLASS
, self
, "Could not find %s\nRetry?", srcDir
,
1571 "Yes", "Skip", "Quit");
1579 DoMethod(self
, MUIM_IC_QuitInstall
);
1584 while (srcDirLock
== NULL
);
1586 /* Check if destination directory exists and create it */
1587 dstDirLock
= Lock(dstDir
, SHARED_LOCK
);
1589 if (dstDirLock
!= NULL
)
1593 dstDirLock
= CreateDir(dstDir
);
1594 if (dstDirLock
!= NULL
)
1603 /* Allocate buffer for ExAll */
1604 buffer
= AllocVec(kExallBufSize
, MEMF_CLEAR
| MEMF_PUBLIC
);
1612 if (ParsePatternNoCase(fileMask
, matchString
, 3 * strlen(fileMask
)) < 0)
1619 struct ExAllData
*ead
= (struct ExAllData
*)buffer
;
1620 struct ExAllControl
*eac
= AllocDosObject(DOS_EXALLCONTROL
, NULL
);
1621 eac
->eac_LastKey
= 0;
1624 struct ExAllData
*oldEad
= ead
;
1627 /* Main copy file loop */
1631 loop
= ExAll(srcDirLock
, ead
, kExallBufSize
, ED_COMMENT
, eac
);
1633 if (!loop
&& IoErr() != ERROR_NO_MORE_ENTRIES
)
1636 if (eac
->eac_Entries
!= 0)
1640 if (((ead
->ed_Type
== ST_FILE
)
1641 && MatchPatternNoCase(matchString
, ead
->ed_Name
))
1642 || ((ead
->ed_Type
== ST_USERDIR
) && recursive
))
1644 ULONG srcLen
= strlen(srcDir
);
1645 ULONG dstLen
= strlen(dstDir
);
1646 ULONG newSrcLen
= srcLen
+ strlen(ead
->ed_Name
) + 2;
1647 ULONG newDstLen
= dstLen
+ strlen(ead
->ed_Name
) + 2;
1649 TEXT srcFile
[newSrcLen
];
1650 TEXT dstFile
[newDstLen
];
1652 sprintf(srcFile
, "%s", srcDir
);
1653 sprintf(dstFile
, "%s", dstDir
);
1655 AddPart(srcFile
, ead
->ed_Name
, newSrcLen
);
1656 AddPart(dstFile
, ead
->ed_Name
, newDstLen
);
1658 if (ead
->ed_Type
== ST_FILE
)
1660 totalFilesCopiedThis
+=
1661 (ULONG
) DoMethod(self
, MUIM_IC_CopyFile
,
1666 SET(data
->gauge2
, MUIA_Gauge_Current
,
1667 (LONG
) ((100.0 / totalFiles
) *
1669 totalFilesCopiedThis
)));
1673 if (ead
->ed_Type
== ST_USERDIR
)
1676 LONG totalFilesCopiedSub
=
1677 InternalCopyFiles(CLASS
, self
, srcFile
, dstFile
,
1679 recursive
, totalFiles
,
1680 totalFilesCopied
+ totalFilesCopiedThis
);
1681 if (totalFilesCopiedSub
>= 0)
1682 totalFilesCopiedThis
+= totalFilesCopiedSub
;
1685 /* Do nothing. It will be caught at level of Install__MUIM_IC_CopyFiles */
1692 while ((ead
!= NULL
)
1693 && (data
->inst_success
== MUIV_Inst_InProgress
));
1696 while ((loop
) && (data
->inst_success
== MUIV_Inst_InProgress
));
1698 FreeDosObject(DOS_EXALLCONTROL
, eac
);
1702 return totalFilesCopiedThis
;
1705 IPTR Install__MUIM_IC_CopyFiles
1706 (Class
* CLASS
, Object
* self
, struct MUIP_CopyFiles
* message
)
1708 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
1709 LONG totalFiles
= -1, totalFilesCopied
= 0;
1712 D(bug("[INSTALLER.CFs] Entry, src: %s, dst: %s, mask: %s\n",
1713 message
->srcDir
, message
->dstDir
, message
->fileMask
));
1715 /* Check entry condition */
1716 if (data
->inst_success
!= MUIV_Inst_InProgress
)
1718 D(bug("[INSTALLER.CFs] Installation failed\n"));
1719 return totalFilesCopied
;
1722 SET(data
->gauge2
, MUIA_Gauge_Current
, 0);
1724 /* Get file count */
1728 CountFiles(message
->srcDir
, message
->fileMask
,
1729 message
->recursive
);
1730 D(bug("[INSTALLER.CFs] Found %ld files in %s\n", totalFiles
,
1736 AskRetry(CLASS
, self
, "Error scanning %s\nRetry?",
1737 message
->srcDir
, "Yes", "Skip", "Quit");
1746 DoMethod(self
, MUIM_IC_QuitInstall
);
1747 return totalFilesCopied
;
1751 while (totalFiles
< 0);
1755 InternalCopyFiles(CLASS
, self
, message
->srcDir
, message
->dstDir
,
1756 message
->fileMask
, message
->recursive
, totalFiles
,
1759 /* Check final condition */
1760 if ((data
->inst_success
== MUIV_Inst_InProgress
)
1761 && (totalFiles
!= totalFilesCopied
))
1763 TEXT msg
[strlen(KMsgNotAllFilesCopied
) + strlen(message
->srcDir
) +
1765 sprintf(msg
, KMsgNotAllFilesCopied
, message
->srcDir
);
1767 if (MUI_RequestA(data
->installer
, data
->window
, 0, "Error",
1768 "Continue|*Quit", msg
, NULL
) != 1)
1769 DoMethod(self
, MUIM_IC_QuitInstall
);
1771 return totalFilesCopied
;
1774 return totalFilesCopied
;
1777 IPTR
Install__MUIM_IC_Install(Class
* CLASS
, Object
* self
, Msg message
)
1779 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
1781 IPTR option
= FALSE
;
1783 GET(dest_volume
, MUIA_String_Contents
, &option
);
1784 strcpy(dest_Path
, (STRPTR
) option
);
1785 GET(work_volume
, MUIA_String_Contents
, &option
);
1786 strcpy(work_Path
, (STRPTR
) option
);
1788 SET(data
->back
, MUIA_Disabled
, TRUE
);
1789 SET(data
->proceed
, MUIA_Disabled
, TRUE
);
1791 SET(data
->pagetitle
, MUIA_Text_Contents
, "Installing AROS...");
1793 /* set up destination Work name to use */
1795 GET(check_copytowork
, MUIA_Selected
, &option
);
1796 if (option
&& (data
->inst_success
== MUIV_Inst_InProgress
))
1797 extras_path
= work_Path
;
1799 extras_path
= dest_Path
;
1803 GET(data
->instc_options_main
->opt_format
, MUIA_Selected
, &option
);
1804 if (option
&& data
->inst_success
== MUIV_Inst_InProgress
)
1806 GET(data
->instc_options_main
->opt_partmethod
, MUIA_Radio_Active
,
1809 DoMethod(self
, MUIM_Format
);
1812 /* MAKE SURE THE WORK PART EXISTS TO PREVENT CRASHING! */
1814 if ((BOOL
) XGET(check_work
, MUIA_Selected
))
1817 sprintf(tmp
, "%s:", work_Path
);
1819 ("[INSTALLER] Install : Using a Work partition - checking validity..."));
1820 if ((lock
= Lock(tmp
, SHARED_LOCK
))) /* check the dest dir exists */
1828 ("FAILED!\n[INSTALLER] (Warning) INSTALL - Failed to locate chosen work partition '%s' : defaulting to sys only\n",
1830 extras_path
= dest_Path
;
1836 D(bug("[INSTALLER] Install: Using SYS partition only (%s)\n",
1840 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
1844 GET(data
->instc_options_main
->opt_locale
, MUIA_Selected
, &option
);
1845 if (option
&& (data
->inst_success
== MUIV_Inst_InProgress
))
1847 D(bug("[INSTALLER] Launching Locale Prefs...\n"));
1849 ULONG srcLen
= strlen(source_Path
), dstLen
=
1850 (strlen(dest_Path
) + 1);
1851 ULONG envsrcLen
= strlen(prefssrc_path
), envdstLen
=
1854 ULONG localeFileLen
= srcLen
+ strlen(localeFile_path
) + 3;
1855 ULONG inputFileLen
= srcLen
+ strlen(inputFile_path
) + 3;
1857 ULONG localePFileLen
=
1858 dstLen
+ envdstLen
+ strlen(locale_prfs_file
) + 4;
1860 ULONG inputPFileLen
=
1861 dstLen
+ envdstLen
+ strlen(input_prfs_file
) + 4;
1863 ULONG envdstdirLen
= 1024;
1864 TEXT envDstDir
[envdstdirLen
]; /* "DH0:Prefs/Env-Archive/SYS" */
1866 TEXT localeFile
[localeFileLen
]; /* "CD0:Prefs/Locale" */
1867 TEXT localesrcPFile
[localePFileLen
]; /* "ENV:SYS/locale.prefs" */
1868 TEXT localePFile
[localePFileLen
]; /* "DH0:Prefs/Env-Archive/SYS/locale.prefs" */
1869 TEXT inputFile
[inputFileLen
]; /* "CD0:Prefs/Input" */
1870 TEXT inputsrcPFile
[inputPFileLen
]; /* "ENV:SYS/input.prefs" */
1871 TEXT inputPFile
[inputPFileLen
]; /* "DH0:Prefs/Env-Archive/SYS/input.prefs" */
1873 sprintf(envDstDir
, "%s:", dest_Path
);
1874 sprintf(localeFile
, "\"%s", source_Path
);
1875 CopyMem(prefssrc_path
, localesrcPFile
, envsrcLen
+ 1);
1876 sprintf(localePFile
, "%s:", dest_Path
);
1877 sprintf(inputFile
, "\"%s", source_Path
);
1878 CopyMem(prefssrc_path
, inputsrcPFile
, envsrcLen
+ 1);
1879 sprintf(inputPFile
, "%s:", dest_Path
);
1881 AddPart(localeFile
, inputFile_path
, localeFileLen
);
1883 AddPart(localesrcPFile
, locale_prfs_file
, localePFileLen
);
1885 AddPart(localePFile
, prefs_path
, localePFileLen
);
1886 AddPart(localePFile
, locale_prfs_file
, localePFileLen
);
1888 AddPart(inputFile
, localeFile_path
, inputFileLen
);
1890 AddPart(inputsrcPFile
, input_prfs_file
, inputPFileLen
);
1892 AddPart(inputPFile
, prefs_path
, inputPFileLen
);
1893 AddPart(inputPFile
, input_prfs_file
, inputPFileLen
);
1895 D(bug("[INSTALLER] Excecuting '%s'...\n", localeFile
));
1897 Execute(localeFile
, NULL
, NULL
);
1899 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
1901 D(bug("[INSTALLER] Excecuting '%s'...\n", inputFile
));
1903 Execute(inputFile
, NULL
, NULL
);
1905 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
1907 D(bug("[INSTALLER] Copying Locale Settings...\n"));
1909 //create the dirs "Prefs","Prefs/Env-Archive" and "Prefs/Env-Archive/SYS"
1910 AddPart(envDstDir
, "Prefs", dstLen
+ envdstLen
);
1911 D(bug("[INSTALLER] Create Dir '%s' \n", envDstDir
));
1913 BPTR bootDirLock
= NULL
;
1915 if ((lock
= Lock(envDstDir
, ACCESS_READ
)) != NULL
)
1917 D(bug("[INSTALLER] Dir '%s' Exists - no nead to create\n",
1923 bootDirLock
= CreateDir(envDstDir
);
1924 if (bootDirLock
!= NULL
)
1925 UnLock(bootDirLock
);
1929 D(bug("[INSTALLER] Failed to create %s dir!!\n",
1931 /* TODO: Should prompt on failure to try again/continue anyhow/exit */
1932 goto localecopydone
;
1933 //data->inst_success = MUIV_Inst_Failed;
1941 AddPart(envDstDir
, "Env-Archive", envdstdirLen
);
1942 D(bug("[INSTALLER] Create Dir '%s' \n", envDstDir
));
1943 if ((lock
= Lock(envDstDir
, ACCESS_READ
)) != NULL
)
1945 D(bug("[INSTALLER] Dir '%s' Exists - no nead to create\n",
1951 bootDirLock
= CreateDir(envDstDir
);
1952 if (bootDirLock
!= NULL
)
1953 UnLock(bootDirLock
);
1955 goto createdirfaild
;
1961 AddPart(envDstDir
, "SYS", envdstdirLen
);
1962 D(bug("[INSTALLER] Create Dir '%s' \n", envDstDir
));
1963 if ((lock
= Lock(envDstDir
, ACCESS_READ
)) != NULL
)
1965 D(bug("[INSTALLER] Dir '%s' Exists - no nead to create\n",
1971 bootDirLock
= CreateDir(envDstDir
);
1972 if (bootDirLock
!= NULL
)
1973 UnLock(bootDirLock
);
1975 goto createdirfaild
;
1981 D(bug("[INSTALLER] Copying files\n"));
1983 if ((lock
= Lock(localesrcPFile
, ACCESS_READ
)) != NULL
)
1986 DoMethod(self
, MUIM_IC_CopyFile
, localesrcPFile
, localePFile
);
1992 if ((lock
= Lock(inputsrcPFile
, ACCESS_READ
)) != NULL
)
1995 DoMethod(self
, MUIM_IC_CopyFile
, inputsrcPFile
, inputPFile
);
2001 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
2003 /* STEP : COPY CORE */
2005 GET(data
->instc_options_main
->opt_copycore
, MUIA_Selected
, &option
);
2006 if (option
&& (data
->inst_success
== MUIV_Inst_InProgress
))
2009 BOOL success
= FALSE
;
2010 CONST_STRPTR core_dirs
[] = {
2013 "Classes", "Classes",
2022 "Storage", "Storage",
2025 "Utilities", "Utilities",
2026 "WBStartup", "WBStartup",
2029 ULONG dstLen
= strlen(dest_Path
) + strlen(AROS_BOOT_FILE
) + 2;
2030 TEXT destinationPath
[dstLen
];
2032 /* Copying Core system Files */
2033 D(bug("[INSTALLER] Copying Core files...\n"));
2034 SET(data
->label
, MUIA_Text_Contents
,
2035 "Copying Core System files...");
2036 sprintf(destinationPath
, "%s:", dest_Path
);
2037 CopyDirArray(CLASS
, self
, source_Path
, destinationPath
, core_dirs
);
2039 /* Copy AROS.boot file */
2040 sprintf(tmp
, "%s", source_Path
);
2041 sprintf(destinationPath
, "%s:" AROS_BOOT_FILE
, dest_Path
);
2042 AddPart(tmp
, AROS_BOOT_FILE
, 100);
2043 DoMethod(self
, MUIM_IC_CopyFile
, tmp
, destinationPath
);
2045 /* Make Env-Archive Writeable */
2046 sprintf(tmp
, "Protect ADD FLAGS=W ALL QUIET %s:Prefs/Env-Archive",
2049 ("[INSTALLER] Changing Protection on Env Files (command='%s')\n",
2051 success
= (BOOL
) Execute(tmp
, NULL
, NULL
);
2056 ("[INSTALLER] Changing Protection on Env Files failed: %d\n",
2061 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
2063 /* STEP : COPY EXTRAS */
2065 GET(data
->instc_options_main
->opt_copyextra
, MUIA_Selected
, &option
);
2066 if (option
&& data
->inst_success
== MUIV_Inst_InProgress
)
2068 CONST_STRPTR extras_dirs
[] = {
2074 TEXT extraspath
[100];
2075 BOOL undoenabled
= data
->instc_copt_undoenabled
;
2077 /* Explicitly disable undo. Some users might not have RAM for backup */
2078 data
->instc_copt_undoenabled
= FALSE
;
2080 /* Copying Extras */
2081 D(bug("[INSTALLER] Copying Extras to '%s'...\n", extras_path
));
2082 SET(data
->label
, MUIA_Text_Contents
, "Copying Extra Software...");
2083 sprintf(extraspath
, "%s:", extras_path
);
2084 CopyDirArray(CLASS
, self
, extras_source
, extraspath
, extras_dirs
);
2086 /* Set EXTRASPATH environment variable */
2087 AddPart(extraspath
, "Extras", 100);
2088 create_environment_variable(dest_Path
, "EXTRASPATH", extraspath
);
2090 /* Restore undo state */
2091 data
->instc_copt_undoenabled
= undoenabled
;
2094 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
2096 /* STEP : COPY DEVELOPMENT */
2098 GET(data
->instc_options_main
->opt_development
, MUIA_Selected
, &option
);
2099 if (option
&& (data
->inst_success
== MUIV_Inst_InProgress
))
2101 ULONG srcLen
= strlen(source_Path
);
2102 ULONG developerDirLen
= srcLen
+ strlen("Development") + 2;
2103 TEXT developerDir
[srcLen
+ developerDirLen
];
2105 CopyMem(source_Path
, &developerDir
, srcLen
+ 1);
2106 AddPart(developerDir
, "Development", srcLen
+ developerDirLen
);
2108 if ((lock
= Lock(developerDir
, SHARED_LOCK
)) != NULL
)
2110 CONST_STRPTR developer_dirs
[] = {
2111 "Development", "Development",
2115 TEXT developmentpath
[100];
2116 BOOL undoenabled
= data
->instc_copt_undoenabled
;
2118 /* Explicitly disable undo. Some users might not have RAM for backup */
2119 data
->instc_copt_undoenabled
= FALSE
;
2123 /* Copying Developer stuff */
2124 D(bug("[INSTALLER] Copying Developer Files...\n"));
2125 SET(data
->label
, MUIA_Text_Contents
,
2126 "Copying Developer Files...");
2127 sprintf(developmentpath
, "%s:", extras_path
);
2128 CopyDirArray(CLASS
, self
, source_Path
, developmentpath
,
2131 /* Set DEVELPATH environment variable */
2132 AddPart(developmentpath
, "Development", 100);
2133 create_environment_variable(dest_Path
, "DEVELPATH",
2136 /* Restore undo state */
2137 data
->instc_copt_undoenabled
= undoenabled
;
2140 D(bug("[INSTALLER] Couldn't locate Developer Files...\n"));
2143 if (!option
&& (data
->inst_success
== MUIV_Inst_InProgress
))
2145 /* If not installing Development, delete the package file */
2146 TEXT packagePath
[100];
2147 sprintf(packagePath
, "%s:Prefs/Env-Archive/SYS/Packages/Developer",
2149 D(bug("[INSTALLER] Deleting Developer Package...\n"));
2150 DeleteFile(packagePath
);
2153 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
2155 /* STEP : INSTALL BOOTLOADER */
2157 GET(data
->instc_options_main
->opt_bootloader
, MUIA_Selected
, &option
);
2158 if (option
&& (data
->inst_success
== MUIV_Inst_InProgress
))
2160 int numgrubfiles
= 0, file_count
= 0;
2163 strlen(source_Path
) + strlen(ARCH_PATH
) + strlen(GRUB_PATH
) + 4;
2165 strlen(dest_Path
) + strlen(ARCH_PATH
) + strlen(GRUB_PATH
) + 4;
2166 TEXT srcPath
[srcLen
];
2167 TEXT dstPath
[dstLen
];
2170 /* Installing GRUB */
2171 D(bug("[INSTALLER] Installing Grub...\n"));
2172 SET(data
->label
, MUIA_Text_Contents
, "Installing Grub...");
2173 SET(data
->pageheader
, MUIA_Text_Contents
, KMsgBootLoader
);
2174 SET(data
->label
, MUIA_Text_Contents
, "Copying BOOT files...");
2176 strcpy(srcPath
, source_Path
);
2177 AddPart(srcPath
, ARCH_PATH
, srcLen
);
2178 sprintf(dstPath
, "%s:%s", dest_Path
, ARCH_PATH
);
2180 /* Get drive chosen to install GRUB bootblock to */
2181 GET(grub_device
, MUIA_String_Contents
, &option
);
2182 strcpy(boot_Device
, (STRPTR
) option
);
2183 boot_Unit
= XGET(grub_unit
, MUIA_String_Integer
);
2185 switch (BootLoaderType
)
2187 case BOOTLOADER_GRUB2
:
2188 AddPart(srcPath
, GRUB_PATH
, srcLen
);
2189 AddPart(dstPath
, GRUB_PATH
, dstLen
);
2191 /* Warning: do not modify srcPath or dstPath beyond this point */
2193 /* Grub 2 text/gfx mode */
2194 GET(data
->instc_options_grub
->gopt_grub2mode
, MUIA_Cycle_Active
,
2197 /* Rename _unicode.pf2 <-> unicode.pf2 if necessary */
2200 strlen(dstPath
) + strlen("_unicode.pf2") + 2;
2201 TEXT srcFile
[newDstLen
];
2202 TEXT dstFile
[newDstLen
];
2204 sprintf(srcFile
, "%s", dstPath
);
2205 sprintf(dstFile
, "%s", dstPath
);
2206 AddPart(srcFile
, "_unicode.pf2", newDstLen
);
2207 AddPart(dstFile
, "unicode.pf2", newDstLen
);
2209 if (option
== 1 && !gfx_font_exists
)
2210 Rename(srcFile
, dstFile
);
2211 else if (option
== 0 && gfx_font_exists
)
2212 Rename(dstFile
, srcFile
);
2215 /* Add entry to boot MS Windows if present */
2217 FindWindowsPartition(boot_Device
, boot_Unit
)) != -1
2218 && XGET(cycle_drivetype
, MUIA_Cycle_Active
) != 2)
2220 sprintf(tmp
, "%s", dstPath
);
2221 AddPart(tmp
, "grub.cfg", 256);
2223 BPTR menu_file
= Open(tmp
, MODE_READWRITE
);
2225 if (menu_file
!= NULL
)
2227 Seek(menu_file
, 0, OFFSET_END
);
2228 FPrintf(menu_file
, "\nmenuentry \"Microsoft Windows\" {\n chainloader (hd%ld,%ld)+1\n}\n\n", 0, part_no
+ 1); /* GRUB2 counts partitions from 1 */
2232 ("[INSTALLER] Windows partition found. Adding Windows option to GRUB2 menu.\n"));
2236 "C:Install-grub2-i386-pc DEVICE \"%s\" UNIT %d GRUB \"%s\"",
2237 boot_Device
, boot_Unit
, dstPath
);
2240 case BOOTLOADER_GRUB1
:
2246 TEXT
*grub_files
[] = {
2248 "stage2_hdisk", "stage2",
2249 "menu.lst.DH0", "menu.lst",
2253 GRUB_COPY_FILE_LOOP(grub_files
);
2255 /* Add entry to boot MS Windows if present */
2257 FindWindowsPartition(boot_Device
, boot_Unit
)) != -1)
2259 sprintf(tmp
, "%s", dstPath
);
2260 AddPart(tmp
, "menu.lst", 256);
2262 BPTR menu_file
= Open(tmp
, MODE_READWRITE
);
2263 if (menu_file
!= NULL
)
2265 Seek(menu_file
, 0, OFFSET_END
);
2267 "\ntitle Microsoft Windows\nrootnoverify (hd%ld,%ld)\nchainloader +1\n",
2272 ("[INSTALLER] Windows partition found. Adding Windows option to GRUB menu.\n"));
2276 "C:install-i386-pc DEVICE \"%s\" UNIT %d GRUB \"%s\" FORCELBA",
2277 boot_Device
, boot_Unit
, dstPath
);
2280 /* TODO: support more bootloaders */
2283 D(bug("[INSTALLER] execute: %s\n", tmp
));
2284 Execute(tmp
, NULL
, NULL
);
2285 SET(data
->gauge2
, MUIA_Gauge_Current
, 100);
2288 SET(data
->proceed
, MUIA_Disabled
, FALSE
);
2290 /* STEP : PACKAGE CLEANUP */
2291 /* REMOVED - handled by DEVELPATH and EXTRASPATH variables */
2293 /* STEP : CREATE ENVIRONMENT VARIABLES THAT POINT TO INSTALLATION LOCATIONS */
2298 /* Volume name of installed SYS */
2299 sprintf(varval
, "%s:", dest_Path
);
2300 SetVar("INSTALLEDSYS", varval
, strlen(varval
), GVF_GLOBAL_ONLY
);
2302 /* Volume name of installed WORK */
2303 GET(check_work
, MUIA_Selected
, &optcheck
);
2306 sprintf(varval
, "%s:", work_Path
);
2307 SetVar("INSTALLEDWORK", varval
, strlen(varval
),
2311 SetVar("INSTALLEDWORK", "", 0, GVF_GLOBAL_ONLY
);
2313 /* Path to Extras */
2314 sprintf(varval
, "%s:", extras_path
);
2315 AddPart(varval
, "Extras", 255);
2316 SetVar("INSTALLEDEXTRAS", varval
, strlen(varval
), GVF_GLOBAL_ONLY
);
2320 /* STEP : EXECUTE EXTERNAL POST-INSTALL SCRIPT */
2321 if ((BOOL
) XGET(data
->instc_options_main
->opt_copycore
, MUIA_Selected
))
2323 BPTR scriptfile
= Open(POST_INSTALL_SCRIPT
, MODE_OLDFILE
);
2327 D(bug("[INSTALLER] Running post-install script...\n"));
2328 SET(data
->label
, MUIA_Text_Contents
,
2329 "Running post-install script...");
2330 SET(data
->pageheader
, MUIA_Text_Contents
, KMsgPostInstall
);
2331 SET(data
->gauge2
, MUIA_Gauge_Current
, 0);
2332 SET(data
->actioncurrent
, MUIA_Text_Contents
,
2333 POST_INSTALL_SCRIPT
);
2336 /* Post install script (at this momement) does not allow user interaction.
2337 Set SYS_Input to opened console and SYS_Background to FALSE to allow it. */
2339 struct TagItem tags
[] = {
2340 {SYS_Input
, (IPTR
) NULL
},
2341 {SYS_Output
, (IPTR
) NULL
},
2342 {SYS_Error
, (IPTR
) NULL
},
2343 {SYS_ScriptInput
, (IPTR
) scriptfile
},
2344 {SYS_UserShell
, TRUE
},
2348 D(bug("[INSTALLER] execute: %s\n", POST_INSTALL_SCRIPT
));
2350 SystemTagList("", tags
);
2352 /* Do not close scriptfile. It was closed by SystemTagList */
2354 SET(data
->gauge2
, MUIA_Gauge_Current
, 100);
2358 bug("[INSTALLER] no post-install script\n"));
2361 /* STEP : UNDORECORD CLEANUP */
2364 ("[INSTALLER] Reached end of Install Function - cleaning up undo logs @ %p...\n",
2365 &data
->instc_undorecord
));
2367 struct InstallC_UndoRecord
*CurUndoNode
= NULL
;
2368 struct Node
*undonode_tmp
= NULL
;
2370 ForeachNodeSafe(&data
->instc_undorecord
, CurUndoNode
, undonode_tmp
)
2372 D(bug("[INSTALLER] Removing undo record @ %p\n", CurUndoNode
));
2373 Remove((struct Node
*)CurUndoNode
);
2375 switch (CurUndoNode
->undo_method
)
2377 case MUIM_IC_CopyFile
:
2378 D(bug("[INSTALLER] Deleting undo file '%s'\n",
2379 CurUndoNode
->undo_src
));
2380 DeleteFile(CurUndoNode
->undo_src
);
2382 FreeVec(CurUndoNode
->undo_dst
);
2383 FreeVec(CurUndoNode
->undo_src
);
2388 FreeMem(CurUndoNode
, sizeof(struct InstallC_UndoRecord
));
2394 IPTR
Install__MUIM_RefreshWindow(Class
* CLASS
, Object
* self
, Msg message
)
2396 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
2397 ULONG cur_width
= 0, cur_height
= 0;
2399 GET(data
->window
, MUIA_Window_Width
, &cur_width
);
2400 GET(data
->window
, MUIA_Window_Height
, &cur_height
);
2402 if ((data
->cur_width
!= cur_width
) || (data
->cur_height
!= cur_height
))
2404 DoMethod(data
->contents
, MUIM_Hide
);
2405 DoMethod(data
->contents
, MUIM_Layout
);
2406 DoMethod(data
->contents
, MUIM_Show
);
2409 MUI_Redraw(data
->contents
, MADF_DRAWOBJECT
);
2414 static LONG
FindWindowsPartition(STRPTR device
, LONG unit
)
2417 struct PartitionType type
;
2418 struct PartitionHandle
*root
, *partition
;
2419 LONG partition_no
= -1, i
= 0;
2421 if ((root
= OpenRootPartition(device
, unit
)) != NULL
)
2423 if (OpenPartitionTable(root
) == 0)
2425 /* Look for an active partition with a Windows FS */
2426 ForeachNode(&root
->table
->list
, partition
)
2428 GetPartitionAttrsTags
2430 PT_ACTIVE
, (IPTR
) & active
,
2431 PT_TYPE
, (IPTR
) & type
, TAG_DONE
);
2433 if (active
&& (id
== 0x7 || id
== 0xb || id
== 0xc))
2437 ClosePartitionTable(root
);
2439 CloseRootPartition(root
);
2442 return partition_no
;
2446 LONG
CopyDirArray(Class
* CLASS
, Object
* self
, CONST_STRPTR sourcePath
,
2447 CONST_STRPTR destinationPath
, CONST_STRPTR directories
[])
2449 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
2450 LONG numdirs
= 0, dir_count
= 0;
2453 while (directories
[numdirs
] != NULL
)
2456 numdirs
= (numdirs
- 1) / 2;
2458 D(bug("[INSTALLER.CDA] Copying %d Dirs...\n", numdirs
));
2460 while ((directories
[dir_count
] != NULL
)
2461 && (data
->inst_success
== MUIV_Inst_InProgress
))
2464 strlen(sourcePath
) + strlen(directories
[dir_count
]) + 2;
2466 strlen(destinationPath
) + strlen(directories
[dir_count
+ 1]) +
2469 TEXT srcDirs
[newSrcLen
+ strlen(".info")];
2470 TEXT dstDirs
[newDstLen
+ strlen(".info")];
2472 sprintf(srcDirs
, "%s", sourcePath
);
2473 sprintf(dstDirs
, "%s", destinationPath
);
2474 AddPart(srcDirs
, directories
[dir_count
], newSrcLen
);
2475 AddPart(dstDirs
, directories
[dir_count
+ 1], newDstLen
);
2477 SET(data
->actioncurrent
, MUIA_Text_Contents
, strchr(srcDirs
,
2480 /* OK Now copy the contents */
2481 DoMethod(self
, MUIM_IC_CopyFiles
, srcDirs
, dstDirs
, "#?", TRUE
);
2483 if (data
->inst_success
== MUIV_Inst_InProgress
)
2485 /* Check if folder has an icon */
2486 CopyMem(".info", srcDirs
+ strlen(srcDirs
),
2487 strlen(".info") + 1);
2488 CopyMem(".info", dstDirs
+ strlen(dstDirs
),
2489 strlen(".info") + 1);
2490 /* If the icon already exists in the destination, don't overwrite it.
2491 It may contain snapshotted position and/or edited tooltypes.
2492 TODO: may be consider replacing icon's image here using icon.library ? */
2493 lock
= Lock(dstDirs
, SHARED_LOCK
);
2497 if ((lock
= Lock(srcDirs
, SHARED_LOCK
)) != NULL
)
2500 DoMethod(self
, MUIM_IC_CopyFile
, srcDirs
, dstDirs
);
2509 return dir_count
/ 2; /* Return no. of copied dirs */
2512 BOOL
FormatPartition(CONST_STRPTR device
, CONST_STRPTR name
, ULONG dostype
)
2514 BOOL success
= FALSE
;
2516 if (Inhibit(device
, DOSTRUE
))
2518 success
= Format(device
, name
, dostype
);
2519 Inhibit(device
, DOSFALSE
);
2525 IPTR
Install__MUIM_Format(Class
* CLASS
, Object
* self
, Msg message
)
2527 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
2528 char dev_nametmp
[100];
2529 char vol_nametmp
[100] = SYS_VOL_NAME
;
2530 char fmt_nametmp
[100];
2531 BOOL success
= FALSE
;
2532 IPTR option
= FALSE
;
2536 if ((BOOL
) XGET(check_formatsys
, MUIA_Selected
))
2539 sprintf(fmt_nametmp
, "Formatting '%s'...", dest_Path
);
2540 D(bug("[INSTALLER] %s\n", fmt_nametmp
));
2541 SET(data
->label
, MUIA_Text_Contents
, fmt_nametmp
);
2542 SET(data
->gauge2
, MUIA_Gauge_Current
, 0);
2544 /* Change volume name if installing to a USB drive */
2545 GET(grub_device
, MUIA_String_Contents
, &option
);
2546 if (strcmp((char *)option
, "usbscsi.device") == 0)
2547 strcpy(vol_nametmp
, USB_SYS_VOL_NAME
);
2549 sprintf(dev_nametmp
, "%s:", dest_Path
);
2552 * If partition is FFS -> it will format it for FFS
2553 * If partition is SFS -> it will format it for SFS
2554 * Correct way of doing things: read type for DH0 and DH1, apply correct
2555 * type when formatting
2557 D(bug("[INSTALLER] (info) Using FormatPartition\n"));
2559 FormatPartition(dev_nametmp
, vol_nametmp
, ID_INTER_FFS_DISK
);
2562 set(data
->gauge2
, MUIA_Gauge_Current
, 100);
2565 GET(check_work
, MUIA_Selected
, &option
);
2566 if (option
&& XGET(check_formatwork
, MUIA_Selected
))
2569 sprintf(fmt_nametmp
, "Formatting '%s'...", work_Path
);
2570 D(bug("[INSTALLER] %s\n", fmt_nametmp
));
2571 SET(data
->label
, MUIA_Text_Contents
, fmt_nametmp
);
2573 SET(data
->gauge2
, MUIA_Gauge_Current
, 0);
2575 /* Change volume name if installing to a USB drive */
2576 GET(grub_device
, MUIA_String_Contents
, &option
);
2577 if (strcmp((char *)option
, "usbscsi.device") == 0)
2578 strcpy(vol_nametmp
, USB_WORK_VOL_NAME
);
2580 strcpy(vol_nametmp
, WORK_VOL_NAME
);
2582 sprintf(dev_nametmp
, "%s:", work_Path
);
2585 * If partition is FFS -> it will format it for FFS
2586 * If partition is SFS -> it will format it for SFS
2587 * Correct way of doing things: read type for DH0 and DH1, apply
2588 * correct type when formatting (ID_INTER_FFS_DISK or ID_SFS_BE_DISK)
2590 D(bug("[INSTALLER] (info) Using FormatPartition\n"));
2592 FormatPartition(dev_nametmp
, vol_nametmp
, ID_INTER_FFS_DISK
);
2596 sprintf(tmp
, "%s:", work_Path
);
2597 SET(data
->gauge2
, MUIA_Gauge_Current
, 100);
2598 lock
= Lock(tmp
, SHARED_LOCK
); /* check the dest dir exists */
2602 ("[INSTALLER] (Warning) FORMAT: Failed for chosen work partition '%s' : defaulting to sys only\n",
2604 extras_path
= dest_Path
;
2614 SET(data
->gauge2
, MUIA_Gauge_Current
, 100);
2619 BPTR
RecursiveCreateDir(CONST_STRPTR dirpath
)
2621 /* Will create directory even if top level directory does not exist */
2624 ULONG lastdirseparator
= 0;
2625 ULONG dirpathlen
= strlen(dirpath
);
2626 STRPTR tmpdirpath
= AllocVec(dirpathlen
+ 2, MEMF_CLEAR
| MEMF_PUBLIC
);
2628 CopyMem(dirpath
, tmpdirpath
, dirpathlen
);
2630 /* Recurvice directory creation */
2633 if (lastdirseparator
>= dirpathlen
)
2636 for (; lastdirseparator
< dirpathlen
; lastdirseparator
++)
2637 if (tmpdirpath
[lastdirseparator
] == '/')
2640 tmpdirpath
[lastdirseparator
] = '\0'; /* cut */
2642 /* Unlock any lock from previous interation. Last iteration lock will be returned. */
2649 /* Check if directory exists */
2650 lock
= Lock(tmpdirpath
, SHARED_LOCK
);
2653 lock
= CreateDir(tmpdirpath
);
2655 break; /* Error with creation */
2658 tmpdirpath
[lastdirseparator
] = '/'; /* restore */
2662 FreeVec(tmpdirpath
);
2666 BOOL
BackUpFile(CONST_STRPTR filepath
, CONST_STRPTR backuppath
,
2667 struct InstallC_UndoRecord
* undorecord
)
2669 ULONG filepathlen
= strlen(filepath
);
2670 ULONG backuppathlen
= strlen(backuppath
);
2673 STRPTR pathpart
= NULL
;
2674 BPTR lock
= NULL
, from
= NULL
, to
= NULL
;
2675 static TEXT buffer
[kBufSize
];
2678 if (undorecord
== NULL
)
2681 undorecord
->undo_src
=
2682 AllocVec(filepathlen
+ backuppathlen
+ 3, MEMF_CLEAR
| MEMF_PUBLIC
);
2683 undorecord
->undo_dst
=
2684 AllocVec(filepathlen
+ 2, MEMF_CLEAR
| MEMF_PUBLIC
);
2686 /* Create backup file name */
2687 tmp
= AllocVec(filepathlen
+ 2, MEMF_CLEAR
| MEMF_PUBLIC
);
2688 CopyMem(filepath
, tmp
, filepathlen
);
2689 for (i
= 0; i
< filepathlen
; i
++)
2691 tmp
[i
] = '/'; /* Substitute : with / */
2692 sprintf(undorecord
->undo_src
, "%s/%s", backuppath
, tmp
);
2695 /* Create source file name */
2696 CopyMem(filepath
, undorecord
->undo_dst
, filepathlen
);
2698 /* Create backup file path */
2700 AllocVec(strlen(undorecord
->undo_src
) + 2,
2701 MEMF_CLEAR
| MEMF_PUBLIC
);
2702 CopyMem(undorecord
->undo_src
, tmp
, strlen(undorecord
->undo_src
));
2703 pathpart
= PathPart(tmp
);
2704 if (pathpart
== NULL
)
2709 *pathpart
= '\0'; /* 'cut' string at end of path */
2711 D(bug("[INSTALLER.CF] Backup '%s' @ '%s'\n", undorecord
->undo_dst
,
2712 undorecord
->undo_src
));
2714 undorecord
->undo_method
= MUIM_IC_CopyFile
;
2716 /* Create backup directory */
2717 if ((lock
= Lock(tmp
, SHARED_LOCK
)) != NULL
)
2719 D(bug("[INSTALLER.CF] Dir '%s' Exists - no need to create\n", tmp
));
2724 lock
= RecursiveCreateDir(tmp
);
2729 D(bug("[INSTALLER.CF] Failed to create %s dir!!\n", tmp
));
2738 if ((from
= Open(undorecord
->undo_dst
, MODE_OLDFILE
)))
2740 if ((to
= Open(undorecord
->undo_src
, MODE_NEWFILE
)))
2746 if ((s
= Read(from
, buffer
, kBufSize
)) == -1)
2752 if (Write(to
, buffer
, s
) == -1)
2759 while (s
== kBufSize
&& !err
);
2770 IPTR Install__MUIM_IC_CopyFile
2771 (Class
* CLASS
, Object
* self
, struct MUIP_CopyFile
* message
)
2773 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
2774 static TEXT buffer
[kBufSize
];
2775 struct InstallC_UndoRecord
*undorecord
= NULL
;
2777 ULONG filescopied
= 0;
2778 BPTR from
= NULL
, to
= NULL
;
2780 /* Display copied file name */
2781 SET(data
->actioncurrent
, MUIA_Text_Contents
, strchr(message
->srcFile
,
2784 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
2786 /* Check if destination file exists */
2787 if ((to
= Open(message
->dstFile
, MODE_OLDFILE
)))
2794 /* Do not overwrite existing icons and preferences.
2795 TODO: May be ask about it too? */
2796 l
= strlen(message
->dstFile
);
2797 if ((l
> 4) && (!stricmp(&message
->dstFile
[l
- 5], ".info")))
2799 /* Count the file as copied because otherwise installer will warn that
2800 not everything was copied. */
2804 else if ((l
> 5) && (!stricmp(&message
->dstFile
[l
- 6], ".prefs")))
2811 switch (data
->IO_Always_overwrite
)
2813 case IIO_Overwrite_Ask
:
2815 AskRetry(CLASS
, self
,
2816 "File Already Exists\nReplace %s?", message
->dstFile
,
2817 "Yes", "Yes [Always]", "No");
2822 case 1: /* Always */
2823 data
->IO_Always_overwrite
= IIO_Overwrite_Always
;
2828 case IIO_Overwrite_Always
:
2830 case IIO_Overwrite_Never
:
2840 /* if the user has requested - backup all replaced files */
2842 if (data
->instc_copt_undoenabled
)
2845 AllocMem(sizeof(struct InstallC_UndoRecord
),
2846 MEMF_CLEAR
| MEMF_PUBLIC
)) == NULL
)
2847 DoMethod(self
, MUIM_IC_QuitInstall
);
2849 if (!BackUpFile(message
->dstFile
, INSTALLAROS_TMP_PATH
, undorecord
))
2851 data
->inst_success
= MUIV_Inst_Failed
;
2856 /* Main copy code */
2859 if ((from
= Open(message
->srcFile
, MODE_OLDFILE
)))
2861 if ((to
= Open(message
->dstFile
, MODE_NEWFILE
)))
2867 if ((s
= Read(from
, buffer
, kBufSize
)) == -1)
2869 D(bug("[INSTALLER.CF] Failed to read: %s [ioerr=%d]\n",
2870 message
->srcFile
, IoErr()));
2876 AskRetry(CLASS
, self
, "Couldn't Open %s",
2877 message
->srcFile
, "Retry", "Skip", "Cancel");
2885 DoMethod(self
, MUIM_IC_QuitInstall
);
2890 DoMethod(data
->installer
, MUIM_Application_InputBuffered
);
2892 if (Write(to
, buffer
, s
) == -1)
2895 ("[INSTALLER.CF] Failed to write: %s [%d bytes, ioerr=%d]\n",
2896 message
->dstFile
, s
, IoErr()));
2900 AskRetry(CLASS
, self
,
2901 "Couldn't Write to %s\nDisk Full!",
2902 message
->dstFile
, "Retry", "Skip", "Cancel");
2905 AskRetry(CLASS
, self
, "Couldn't Write to %s",
2906 message
->dstFile
, "Retry", "Skip", "Cancel");
2918 DoMethod(self
, MUIM_IC_QuitInstall
);
2923 while ((s
== kBufSize
)
2924 && (data
->inst_success
== MUIV_Inst_InProgress
));
2926 if (data
->inst_success
== MUIV_Inst_InProgress
)
2934 ("[INSTALLER.CF] Failed to open '%s' for writing [ioerr=%d]\n",
2935 message
->dstFile
, IoErr()));
2936 data
->inst_success
= MUIV_Inst_Failed
;
2941 /* Add the undo record */
2942 if (undorecord
!= NULL
)
2944 if (filescopied
> 0)
2947 ("[INSTALLER.CF] Adding undo record @ %x to undo list @ %x \n",
2948 undorecord
, &data
->instc_undorecord
));
2949 AddHead(&data
->instc_undorecord
, (struct Node
*)undorecord
);
2953 D(bug("[INSTALLER.CF] Freeing undo record\n"));
2954 /* remove the backup file */
2956 DeleteFile(undorecord
->undo_src
);
2958 /* remove the undo record */
2959 FreeVec(undorecord
->undo_dst
);
2960 FreeVec(undorecord
->undo_src
);
2961 FreeMem(undorecord
, sizeof(struct InstallC_UndoRecord
));
2967 D(bug("[INSTALLER.CF] Failed to open: %s [ioerr=%d]\n",
2968 message
->srcFile
, IoErr()));
2969 data
->inst_success
= MUIV_Inst_Failed
;
2975 IPTR
Install__MUIM_IC_UndoSteps(Class
* CLASS
, Object
* self
, Msg message
)
2977 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
2978 struct InstallC_UndoRecord
*CurUndoNode
= NULL
;
2980 D(bug("[INSTALLER.US] Performing UNDO steps...\n"));
2982 /* Disbale "UNDO" mode to prevent new records */
2983 data
->instc_copt_undoenabled
= FALSE
;
2985 ForeachNode(&data
->instc_undorecord
, CurUndoNode
)
2987 D(bug("[INSTALLER.US] Removing undo record @ %x\n", CurUndoNode
));
2988 Remove((struct Node
*)CurUndoNode
);
2990 switch (CurUndoNode
->undo_method
)
2992 case MUIM_IC_CopyFile
:
2993 D(bug("[INSTALLER.US] Reverting file '%s'\n",
2994 CurUndoNode
->undo_dst
));
2996 DoMethod(self
, CurUndoNode
->undo_method
, CurUndoNode
->undo_src
,
2997 CurUndoNode
->undo_dst
);
2999 D(bug("[INSTALLER.US] Deleting undo file '%s'\n",
3000 CurUndoNode
->undo_src
));
3001 DeleteFile(CurUndoNode
->undo_src
);
3003 FreeVec(CurUndoNode
->undo_dst
);
3004 FreeVec(CurUndoNode
->undo_src
);
3009 FreeMem(CurUndoNode
, sizeof(struct InstallC_UndoRecord
));
3012 D(bug("[INSTALLER.US] UNDO complete\n"));
3017 IPTR
Install__MUIM_Reboot(Class
* CLASS
, Object
* self
, Msg message
)
3019 struct Install_DATA
*data
= INST_DATA(CLASS
, self
);
3021 IPTR option
= FALSE
;
3023 /* Make sure the user wants to reboot */
3024 GET(data
->instc_options_main
->opt_reboot
, MUIA_Selected
, &option
);
3025 if (option
&& (data
->inst_success
== MUIV_Inst_InProgress
))
3027 D(bug("[INSTALLER] Cold rebooting...\n"));
3028 ShutdownA(SD_ACTION_COLDREBOOT
);
3032 D(bug("[INSTALLER] Install Finished [no reboot]...\n"));
3033 if (data
->inst_success
== MUIV_Inst_InProgress
)
3034 data
->inst_success
= MUIV_Inst_Completed
;
3035 SET(data
->window
, MUIA_Window_CloseRequest
, TRUE
);
3038 return TRUE
; /* Keep the compiler happy... */
3041 IPTR
Install__OM_SET(Class
* CLASS
, Object
* self
, struct opSet
* message
)
3043 return DoSuperMethodA(CLASS
, self
, (Msg
) message
);
3046 BOOPSI_DISPATCHER(IPTR
, Install_Dispatcher
, CLASS
, self
, message
)
3048 switch (message
->MethodID
)
3051 return Install__OM_NEW(CLASS
, self
, (struct opSet
*)message
);
3054 return Install__OM_SET(CLASS
, self
, (struct opSet
*)message
);
3056 case MUIM_FindDrives
:
3057 return Install__MUIM_FindDrives(CLASS
, self
, message
);
3059 case MUIM_IC_NextStep
:
3060 return Install__MUIM_IC_NextStep(CLASS
, self
, message
);
3062 case MUIM_IC_PrevStep
:
3063 return Install__MUIM_IC_PrevStep(CLASS
, self
, message
);
3064 //cancel control methods
3065 case MUIM_IC_CancelInstall
:
3066 return Install__MUIM_IC_CancelInstall(CLASS
, self
, message
);
3068 case MUIM_IC_ContinueInstall
:
3069 return Install__MUIM_IC_ContinueInstall(CLASS
, self
, message
);
3071 case MUIM_IC_QuitInstall
:
3072 return Install__MUIM_IC_QuitInstall(CLASS
, self
, message
);
3075 return Install__MUIM_Reboot(CLASS
, self
, message
);
3077 //This should disappear
3078 case MUIM_RefreshWindow
:
3079 return Install__MUIM_RefreshWindow(CLASS
, self
, message
);
3081 case MUIM_IC_Install
:
3082 return Install__MUIM_IC_Install(CLASS
, self
, message
);
3084 //These will be consumed by the io task
3085 case MUIM_Partition
:
3086 return Install__MUIM_Partition(CLASS
, self
, message
);
3089 return Install__MUIM_Format(CLASS
, self
, message
);
3091 case MUIM_IC_CopyFiles
:
3092 return Install__MUIM_IC_CopyFiles(CLASS
, self
,
3093 (struct MUIP_CopyFiles
*)message
);
3095 case MUIM_IC_CopyFile
:
3096 return Install__MUIM_IC_CopyFile(CLASS
, self
,
3097 (struct MUIP_CopyFile
*)message
);
3099 case MUIM_IC_UndoSteps
:
3100 return Install__MUIM_IC_UndoSteps(CLASS
, self
, message
);
3103 return DoSuperMethodA(CLASS
, self
, message
);
3108 BOOPSI_DISPATCHER_END
3110 void FindBootLoader(void)
3112 ULONG newSrcLen
= strlen(source_Path
) + BOOTLOADER_PATH_LEN
;
3113 TEXT srcFile
[newSrcLen
];
3117 for (i
= 0; BootLoaderFiles
[i
]; i
++)
3119 strcpy(srcFile
, source_Path
);
3120 AddPart(srcFile
, BootLoaderFiles
[i
], newSrcLen
);
3121 lock
= Lock(srcFile
, ACCESS_READ
);
3129 BootLoaderType
= BOOTLOADER_NONE
;
3132 #define BUTTONCOMMON \
3134 MUIA_CycleChain, 1, \
3135 MUIA_InputMode, MUIV_InputMode_Toggle, \
3136 MUIA_Image_Spec, MUII_CheckMark, \
3137 MUIA_Image_FreeVert, TRUE, \
3138 MUIA_Background, MUII_ButtonBack, \
3139 MUIA_ShowSelState, FALSE,
3141 int main(int argc
, char *argv
[])
3143 Object
*wnd
= NULL
; /* installer window objects - will get swallowed into the class eventually */
3144 Object
*wndcontents
= NULL
;
3145 Object
*page
= NULL
;
3147 Object
*welcomeMsg
= NULL
;
3148 Object
*LicenseMsg
= NULL
;
3149 Object
*doneMsg
= NULL
;
3151 Object
*pagetitle
= NULL
;
3152 Object
*pageheader
= NULL
;
3153 Object
*currentaction
= NULL
;
3155 Object
*radio_part
= NULL
;
3157 Object
*gad_back
= SimpleButton("<< _Back...");
3158 Object
*gad_proceed
= SimpleButton(KMsgProceed
);
3159 Object
*gad_cancel
= SimpleButton("_Cancel");
3161 Object
*grub_drive
= NULL
;
3162 Object
*grub_grub
= NULL
;
3164 Object
*LicenseMandGrp
= NULL
;
3165 Object
*check_license
= ImageObject
, BUTTONCOMMON
3166 MUIA_Selected
, FALSE
,
3169 Object
*check_format
= ImageObject
, BUTTONCOMMON
3170 MUIA_Selected
, TRUE
,
3173 Object
*check_locale
= ImageObject
, BUTTONCOMMON
3174 MUIA_Selected
, FALSE
,
3177 Object
*check_core
= ImageObject
, BUTTONCOMMON
3178 MUIA_Selected
, TRUE
,
3181 Object
*check_dev
= ImageObject
, BUTTONCOMMON
3182 MUIA_Selected
, FALSE
,
3185 Object
*check_extras
= ImageObject
, BUTTONCOMMON
3186 MUIA_Selected
, TRUE
,
3189 Object
*check_bootloader
;
3191 Object
*check_reboot
= ImageObject
, BUTTONCOMMON
3195 (GaugeObject
, MUIA_Gauge_InfoText
, "%ld %%", MUIA_Gauge_Horiz
, TRUE
,
3196 MUIA_Gauge_Current
, 0, End
);
3199 (GaugeObject
, MUIA_Gauge_InfoText
, "%ld %%", MUIA_Gauge_Horiz
, TRUE
,
3200 MUIA_Gauge_Current
, 0, End
);
3203 (GaugeObject
, MUIA_Gauge_InfoText
, "%ld %%", MUIA_Gauge_Horiz
, TRUE
,
3204 MUIA_Gauge_Current
, 0, End
);
3206 static char *opt_drivetypes
[] = {
3213 Object
*label
= NULL
;
3214 static char *opt_partentries
[] = {
3215 "Only use free space",
3217 "Use existing AROS partitions (on any drive)",
3220 struct Install_Options
*install_opts
= NULL
;
3221 struct Grub_Options
*grub_opts
= NULL
;
3222 char *source_path
= NULL
;
3223 char *dest_path
= NULL
;
3224 char *work_path
= NULL
;
3228 check_copytowork
= ImageObject
, BUTTONCOMMON
3229 MUIA_Disabled
, TRUE
,
3232 check_work
= ImageObject
, BUTTONCOMMON
3233 MUIA_Selected
, FALSE
,
3236 check_formatsys
= ImageObject
, BUTTONCOMMON
3237 MUIA_Selected
, TRUE
,
3240 check_formatwork
= ImageObject
, BUTTONCOMMON
3241 MUIA_Disabled
, TRUE
,
3244 check_sizesys
= ImageObject
, BUTTONCOMMON
3245 MUIA_Selected
, FALSE
,
3248 check_sizework
= ImageObject
, BUTTONCOMMON
3249 MUIA_Selected
, FALSE
,
3250 MUIA_Disabled
, TRUE
,
3253 check_creatework
= ImageObject
, BUTTONCOMMON
3254 MUIA_Selected
, FALSE
,
3255 MUIA_Disabled
, TRUE
,
3258 static char *opt_fstypes
[] = {
3264 cycle_fstypework
= CycleObject
,
3266 MUIA_Cycle_Entries
, opt_fstypes
,
3267 MUIA_Disabled
, TRUE
,
3268 MUIA_Cycle_Active
, 1,
3271 static char *opt_sizeunits
[] = {
3277 cycle_sysunits
= CycleObject
,
3279 MUIA_Cycle_Entries
, opt_sizeunits
,
3280 MUIA_Disabled
, TRUE
,
3281 MUIA_Cycle_Active
, 1,
3284 cycle_workunits
= CycleObject
,
3286 MUIA_Cycle_Entries
, opt_sizeunits
,
3287 MUIA_Disabled
, TRUE
,
3288 MUIA_Cycle_Active
, 1,
3291 static char *opt_grub2mode
[] = {
3297 Object
*cycle_grub2mode
= CycleObject
,
3299 MUIA_Cycle_Entries
, opt_grub2mode
,
3300 MUIA_Disabled
, FALSE
,
3301 MUIA_Cycle_Active
, 0,
3305 AllocMem(sizeof(struct Install_Options
), MEMF_CLEAR
| MEMF_PUBLIC
);
3308 AllocMem(sizeof(struct Grub_Options
), MEMF_CLEAR
| MEMF_PUBLIC
);
3310 source_path
= AllocVec(256, MEMF_CLEAR
| MEMF_PUBLIC
);
3311 extras_source
= AllocVec(256, MEMF_CLEAR
| MEMF_PUBLIC
);
3313 dest_path
= AllocVec(256, MEMF_CLEAR
| MEMF_PUBLIC
);
3314 work_path
= AllocVec(256, MEMF_CLEAR
| MEMF_PUBLIC
);
3318 if (!(ExpansionBase
=
3319 (struct ExpansionBase
*)OpenLibrary("expansion.library", 0)))
3322 if (!NameFromLock(GetProgramDir(), source_path
, 255))
3324 D(bug("[INST-APP] Couldn't get progdir\n"));
3327 pathend
= (IPTR
) FilePart(source_path
);
3328 pathend
= pathend
- (IPTR
) source_path
;
3330 D(bug("[INST-APP] Path length = %d bytes\n", pathend
));
3332 source_Path
= AllocVec(pathend
+ 1, MEMF_CLEAR
| MEMF_PUBLIC
);
3333 CopyMem(source_path
, source_Path
, pathend
);
3334 D(bug("[INST-APP] Launched from '%s'\n", source_Path
));
3336 /* Let GRUB text/graphics choice default to same as on boot media */
3337 source_path
[pathend
] = '\0';
3338 AddPart(source_path
, ARCH_PATH
"/"GRUB_PATH
"/unicode.pf2", 256);
3339 if ((lock
= Lock(source_path
, SHARED_LOCK
)) != BNULL
)
3341 gfx_font_exists
= TRUE
;
3342 SET(cycle_grub2mode
, MUIA_Cycle_Active
, 1);
3346 gfx_font_exists
= FALSE
;
3348 FreeVec(source_path
);
3350 /* Get source location for Extras dir */
3351 if (read_environment_variable(source_Path
, "EXTRASPATH", extras_source
,
3353 *PathPart(extras_source
) = '\0';
3355 strcpy(extras_source
, source_Path
);
3357 dest_Path
= dest_path
;
3358 sprintf(dest_Path
, "" SYS_PART_NAME
);
3360 work_Path
= work_path
;
3361 sprintf(work_Path
, "" WORK_PART_NAME
);
3364 cycle_fstypesys
= CycleObject
,
3366 MUIA_Cycle_Entries
, opt_fstypes
,
3367 MUIA_Disabled
, FALSE
,
3368 MUIA_Cycle_Active
, BootLoaderType
== BOOTLOADER_GRUB1
? 0 : 1,
3371 check_bootloader
= ImageObject
, BUTTONCOMMON
3372 MUIA_Selected
, BootLoaderType
== BOOTLOADER_NONE
? FALSE
: TRUE
,
3373 MUIA_Disabled
, BootLoaderType
== BOOTLOADER_NONE
? TRUE
: FALSE
,
3376 lock
= Lock(DEF_INSTALL_IMAGE
, ACCESS_READ
);
3379 LicenseMsg
= MUI_NewObject(MUIC_TextEditor
,
3381 MUIA_Background
, MUII_SHINE
,
3382 MUIA_TextEditor_ReadOnly
, TRUE
, TAG_DONE
);
3386 D(bug("[INST-APP] Failed to create LicenseMsg Object\n"));
3390 Object
*app
= ApplicationObject
,
3391 MUIA_Application_Title
, (IPTR
) "AROS Installer",
3392 MUIA_Application_Version
, (IPTR
) "$VER: InstallAROS 1.17 (05.12.2014)",
3393 MUIA_Application_Copyright
, (IPTR
) "Copyright © 2003-2014, The AROS Development Team. All rights reserved.",
3394 MUIA_Application_Author
, (IPTR
) "John \"Forgoil\" Gustafsson, Nick Andrews & Neil Cafferkey",
3395 MUIA_Application_Description
, (IPTR
) "Installs AROS on to a PC.",
3396 MUIA_Application_Base
, (IPTR
) "INSTALLER",
3398 SubWindow
, (IPTR
) (wnd
= WindowObject
,
3399 MUIA_Window_Title
, (IPTR
) "AROS Installer",
3400 MUIA_Window_ID
, MAKE_ID('f','o','r','g'),
3401 MUIA_Window_SizeGadget
, TRUE
,
3402 WindowContents
, (IPTR
) (wndcontents
= VGroup
,
3404 Child
, (IPTR
) VGroup
,
3405 Child
, (IPTR
) HGroup
,
3406 Child
, (IPTR
) VGroup
,
3407 MUIA_Background
, MUII_SHADOW
,
3409 Child
, (IPTR
) ImageObject
,
3410 MUIA_Frame
, MUIV_Frame_None
,
3411 MUIA_Image_Spec
, (IPTR
) "3:"DEF_INSTALL_IMAGE
,
3413 Child
, (IPTR
) HVSpace
,
3416 Child
, (IPTR
) ScrollgroupObject
,
3417 MUIA_Scrollgroup_FreeHoriz
, FALSE
,
3418 MUIA_Scrollgroup_FreeVert
, TRUE
,
3419 MUIA_Scrollgroup_Contents
, (IPTR
) (page
= VGroup
,
3420 MUIA_Group_PageMode
, TRUE
,
3423 /* each page represents an install time page... you must have one for each enumerated install progress page */
3425 Child
, (IPTR
) VGroup
,
3426 Child
, (IPTR
) VGroup
,
3427 Child
, (IPTR
) (welcomeMsg
= FreeCLabel("")),
3428 Child
, (IPTR
) HVSpace
,
3432 Child
, (IPTR
) VGroup
,
3433 Child
, (IPTR
) VGroup
,
3434 Child
, (IPTR
) LicenseMsg
,
3435 Child
, (IPTR
) (LicenseMandGrp
= HGroup
,
3436 Child
, (IPTR
) HVSpace
,
3437 Child
, (IPTR
) check_license
,
3438 Child
, (IPTR
) LLabel("Accept License Agreement?"),
3439 Child
, (IPTR
) HVSpace
,
3444 /* Partitioning options */
3445 Child
, (IPTR
) VGroup
,
3446 Child
, (IPTR
) VGroup
,
3447 Child
, (IPTR
) CLabel(KMsgPartitionOptions
),
3448 Child
, (IPTR
) HVSpace
,
3450 Child
, (IPTR
) HVSpace
,
3451 Child
, (IPTR
) (radio_part
= RadioObject
,
3454 MUIA_Radio_Entries
, (IPTR
) opt_partentries
,
3457 Child
, (IPTR
) HVSpace
,
3459 Child
, (IPTR
) LLabel(MUIX_B
"Drive:" MUIX_N
),
3460 Child
, (IPTR
) ColGroup(6),
3461 Child
, (IPTR
) LLabel("Type:"),
3462 Child
, (IPTR
) (cycle_drivetype
=
3465 MUIA_Cycle_Entries
, (IPTR
) opt_drivetypes
,
3466 MUIA_Cycle_Active
, 0,
3468 Child
, (IPTR
) HVSpace
,
3469 Child
, (IPTR
) LLabel("Device:"),
3470 Child
, (IPTR
) (dest_device
=
3473 MUIA_String_Contents
, (IPTR
) boot_Device
,
3474 MUIA_String_Reject
, " \"\'*",
3475 MUIA_Frame
, MUIV_Frame_String
,
3476 MUIA_HorizWeight
, 300,
3478 Child
, (IPTR
) LLabel("Unit:"),
3479 Child
, (IPTR
) (dest_unit
=
3482 MUIA_String_Integer
, 0,
3483 MUIA_String_Accept
, "0123456789",
3484 MUIA_Frame
, MUIV_Frame_String
,
3485 MUIA_HorizWeight
, 20,
3489 Child
, (IPTR
) HVSpace
,
3491 Child
, (IPTR
) LLabel(KMsgDestPartition
),
3492 Child
, (IPTR
) ColGroup(7),
3493 Child
, (IPTR
) LLabel("Name:"),
3494 Child
, (IPTR
) (sys_devname
= StringObject
,
3496 MUIA_String_Contents
, SYS_PART_NAME
,
3497 MUIA_Disabled
, TRUE
,
3498 MUIA_Frame
, MUIV_Frame_String
,
3500 Child
, (IPTR
) HVSpace
,
3501 Child
, (IPTR
) HVSpace
,
3502 Child
, (IPTR
) HVSpace
,
3503 Child
, (IPTR
) HVSpace
,
3504 Child
, (IPTR
) HVSpace
,
3505 Child
, (IPTR
) LLabel("Filesystem:"),
3506 Child
, (IPTR
) cycle_fstypesys
,
3507 Child
, (IPTR
) LLabel("Size:"),
3508 Child
, (IPTR
) (sys_size
= StringObject
,
3510 MUIA_String_Accept
, "0123456789",
3511 MUIA_String_Integer
, 0,
3512 MUIA_Disabled
, TRUE
,
3513 MUIA_Frame
, MUIV_Frame_String
,
3515 Child
, (IPTR
) cycle_sysunits
,
3516 Child
, (IPTR
) check_sizesys
,
3517 Child
, (IPTR
) LLabel("Specify Size"),
3520 Child
, (IPTR
) HVSpace
,
3522 Child
, (IPTR
) LLabel(KMsgWorkPartition
),
3523 Child
, (IPTR
) ColGroup(7),
3524 Child
, (IPTR
) LLabel("Name:"),
3525 Child
, (IPTR
) (work_devname
= StringObject
,
3527 MUIA_String_Contents
, WORK_PART_NAME
,
3528 MUIA_Disabled
, TRUE
,
3529 MUIA_Frame
, MUIV_Frame_String
,
3531 Child
, (IPTR
) HVSpace
,
3532 Child
, (IPTR
) HVSpace
,
3533 Child
, (IPTR
) HVSpace
,
3534 Child
, (IPTR
) check_creatework
,
3535 Child
, (IPTR
) LLabel("Create"),
3536 Child
, (IPTR
) LLabel("Filesystem:"),
3537 Child
, (IPTR
) cycle_fstypework
,
3538 Child
, (IPTR
) LLabel("Size:"),
3539 Child
, (IPTR
) (work_size
= StringObject
,
3541 MUIA_String_Accept
, "0123456789",
3542 MUIA_String_Integer
, 0,
3543 MUIA_Disabled
, TRUE
,
3544 MUIA_Frame
, MUIV_Frame_String
,
3546 Child
, (IPTR
) cycle_workunits
,
3547 Child
, (IPTR
) check_sizework
,
3548 Child
, (IPTR
) LLabel("Specify Size"),
3553 Child
, (IPTR
) VGroup
,
3554 Child
, (IPTR
) VGroup
,
3555 Child
, (IPTR
) CLabel(KMsgInstallOptions
),
3556 Child
, (IPTR
) HVSpace
,
3557 Child
, (IPTR
) ColGroup(2),
3558 Child
, (IPTR
) check_locale
,
3559 Child
, (IPTR
) LLabel("Choose Language Options"),
3560 Child
, (IPTR
) check_core
,
3561 Child
, (IPTR
) LLabel("Install AROS Core System"),
3562 Child
, (IPTR
) check_extras
,
3563 Child
, (IPTR
) LLabel("Install Extra Software"),
3564 Child
, (IPTR
) check_dev
,
3565 Child
, (IPTR
) LLabel("Install Development Software"),
3566 Child
, (IPTR
) check_bootloader
,
3567 Child
, (IPTR
) LLabel("Install Bootloader"),
3569 Child
, (IPTR
) HVSpace
,
3573 Child
, (IPTR
) VGroup
,
3574 Child
, (IPTR
) VGroup
,
3575 Child
, (IPTR
) CLabel(KMsgDestOptions
),
3576 Child
, (IPTR
) HVSpace
,
3577 Child
, (IPTR
) ColGroup(2),
3578 Child
, (IPTR
) ColGroup(2),
3579 Child
, (IPTR
) LLabel(KMsgDestVolume
),
3580 Child
, (IPTR
) HVSpace
,
3582 Child
, (IPTR
) (show_formatsys
= ColGroup(2),
3583 Child
, (IPTR
) check_formatsys
,
3584 Child
, (IPTR
) LLabel("Format Partition"),
3587 Child
, (IPTR
) HVSpace
,
3588 Child
, (IPTR
) (dest_volume
= StringObject
,
3590 MUIA_String_Contents
, (IPTR
) dest_Path
,
3591 MUIA_Frame
, MUIV_Frame_String
,
3593 Child
, (IPTR
) HVSpace
,
3594 Child
, (IPTR
) ColGroup(2),
3595 Child
, (IPTR
) check_work
,
3596 Child
, (IPTR
) LLabel("Use 'Work' Partition"),
3597 Child
, (IPTR
) check_copytowork
,
3598 Child
, (IPTR
) LLabel("Use 'Work' Partition for Extras and Developer Files"),
3600 Child
, (IPTR
) HVSpace
,
3602 Child
, (IPTR
) ColGroup(2),
3603 Child
, (IPTR
) ColGroup(2),
3604 Child
, (IPTR
) LLabel(KMsgWorkVolume
),
3605 Child
, (IPTR
) HVSpace
,
3607 Child
, (IPTR
) (show_formatwork
= ColGroup(2),
3608 Child
, (IPTR
) check_formatwork
,
3609 Child
, (IPTR
) LLabel("Format Partition"),
3612 Child
, (IPTR
) HVSpace
,
3613 Child
, (IPTR
) (work_volume
= StringObject
,
3615 MUIA_String_Contents
,
3617 MUIA_Disabled
, TRUE
,
3618 MUIA_Frame
, MUIV_Frame_String
,
3620 Child
, (IPTR
) HVSpace
,
3624 /* Bootloader options */
3625 Child
, (IPTR
) VGroup
,
3626 Child
, (IPTR
) VGroup
,
3627 Child
, (IPTR
) CLabel(KMsgGrubOptions
),
3628 Child
, (IPTR
) HVSpace
,
3629 Child
, (IPTR
) LLabel(KMsgGrubGOptions
),
3630 Child
, (IPTR
) LLabel(KMsgGrubDrive
),
3631 Child
, (IPTR
) HVSpace
,
3633 Child
, (IPTR
) ColGroup(5),
3634 Child
, (IPTR
) HVSpace
,
3635 Child
, (IPTR
) LLabel("Device:"),
3636 Child
, (IPTR
) (grub_device
= StringObject
,
3638 MUIA_String_Reject
, " \"\'*",
3639 MUIA_Frame
, MUIV_Frame_String
,
3640 MUIA_HorizWeight
, 200,
3642 Child
, (IPTR
) HVSpace
,
3643 Child
, (IPTR
) LLabel("Unit:"),
3644 Child
, (IPTR
) (grub_unit
= StringObject
,
3646 MUIA_String_Integer
, 0,
3647 MUIA_String_Accept
, "0123456789",
3648 MUIA_Frame
, MUIV_Frame_String
,
3649 MUIA_HorizWeight
, 20,
3653 Child
, (IPTR
) (grub_drive
= TextObject
,
3654 MUIA_Text_PreParse
, (IPTR
) "" MUIX_C
,
3655 MUIA_Text_Contents
, (IPTR
)" ",
3657 Child
, (IPTR
) HVSpace
,
3658 Child
, (IPTR
) LLabel(KMsgGrubGrub
),
3659 Child
, (IPTR
) HVSpace
,
3660 Child
, (IPTR
) (grub_grub
= TextObject
,
3661 MUIA_Text_PreParse
, (IPTR
) "" MUIX_C
,
3662 MUIA_Text_Contents
, (IPTR
)" ",
3664 Child
, (IPTR
) HVSpace
,
3665 Child
, (IPTR
) ColGroup(4),
3666 Child
, (IPTR
) LLabel("Menu Mode:"),
3667 Child
, (IPTR
) cycle_grub2mode
,
3668 Child
, (IPTR
) HVSpace
,
3670 Child
, (IPTR
) HVSpace
,
3674 Child
, (IPTR
) VGroup
,
3675 Child
, (IPTR
) VGroup
,
3676 Child
, (IPTR
) CLabel(KMsgPartitioning
),
3677 Child
, (IPTR
) HVSpace
,
3678 Child
, (IPTR
) VGroup
,
3680 MUIA_Background
, MUII_HSHINEBACK
,
3683 Child
, (IPTR
) ScaleObject
, End
,
3684 Child
, (IPTR
) HVSpace
,
3688 Child
, (IPTR
) VGroup
,
3689 Child
, (IPTR
) VGroup
,
3690 Child
, (IPTR
) CLabel(KMsgPartitioning
),
3691 Child
, (IPTR
) HVSpace
,
3692 Child
, (IPTR
) VGroup
,
3694 MUIA_Background
, MUII_HSHINEBACK
,
3695 Child
, (IPTR
) gauge3
,
3697 Child
, (IPTR
) ScaleObject
, End
,
3698 Child
, (IPTR
) HVSpace
,
3702 Child
, (IPTR
) VGroup
,
3703 Child
, (IPTR
) VGroup
,
3704 Child
, (IPTR
) (pagetitle
= CLabel(" ")),
3705 Child
, (IPTR
) HVSpace
,
3706 Child
, (IPTR
) (pageheader
= FreeCLabel(KMsgInstall
)),
3707 Child
, (IPTR
) HVSpace
,
3708 Child
, (IPTR
) (label
= FreeLLabel("YOU SHOULD NOT SEE THIS")),
3709 Child
, (IPTR
) HVSpace
,
3710 Child
, (IPTR
) (currentaction
= TextObject
,
3711 MUIA_Text_Contents
,(IPTR
)" ",
3713 Child
, (IPTR
) VGroup
,
3715 MUIA_Background
, MUII_HSHINEBACK
,
3718 Child
, (IPTR
) HVSpace
,
3722 /* Completed page */
3723 Child
, (IPTR
) VGroup
,
3724 Child
, (IPTR
) VGroup
,
3725 MUIA_Group_SameHeight
, FALSE
,
3726 Child
, (IPTR
) (doneMsg
= FreeCLabel(KMsgDone
)),
3727 Child
, (IPTR
) HVSpace
,
3728 Child
, (IPTR
) (reboot_group
= ColGroup(2),
3731 Child
, (IPTR
) check_reboot
,
3732 Child
, (IPTR
) LLabel("Reboot AROS now"),
3741 Child
, (IPTR
) HGroup
,
3742 Child
, (IPTR
) HVSpace
,
3743 Child
, (IPTR
) gad_back
,
3744 Child
, (IPTR
) gad_proceed
,
3745 Child
, (IPTR
) gad_cancel
,
3754 D(bug("[INST-APP] Failed to create Installer GUI\n"));
3758 /* Update GUI in response to certain user actions */
3760 /* Notifications on partitioning action */
3761 DoMethod(radio_part
, MUIM_Notify
, (IPTR
) MUIA_Radio_Active
, 0,
3762 (IPTR
) check_sizesys
, 3, MUIM_Set
, MUIA_Disabled
, FALSE
);
3763 DoMethod(radio_part
, MUIM_Notify
, (IPTR
) MUIA_Radio_Active
, 1,
3764 (IPTR
) check_sizesys
, 3, MUIM_Set
, MUIA_Disabled
, FALSE
);
3765 DoMethod(radio_part
, MUIM_Notify
, (IPTR
) MUIA_Radio_Active
, 2,
3766 (IPTR
) check_sizesys
, 3, MUIM_Set
, MUIA_Disabled
, TRUE
);
3767 DoMethod(radio_part
, MUIM_Notify
, (IPTR
) MUIA_Radio_Active
, 2,
3768 (IPTR
) check_sizesys
, 3, MUIM_Set
, MUIA_Selected
, FALSE
);
3770 /* Notifications upon selection of drive type */
3771 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 0,
3772 (IPTR
) dest_device
, 3, MUIM_Set
,
3773 MUIA_String_Contents
, "ahci.device");
3774 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 1,
3775 (IPTR
) dest_device
, 3, MUIM_Set
,
3776 MUIA_String_Contents
, "ata.device");
3777 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 2,
3778 (IPTR
) dest_device
, 3, MUIM_Set
,
3779 MUIA_String_Contents
, "usbscsi.device");
3780 DoMethod(cycle_drivetype
, MUIM_Notify
, MUIA_Cycle_Active
,
3781 MUIV_EveryTime
, (IPTR
) dest_unit
, 3, MUIM_Set
, MUIA_String_Integer
,
3783 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 0,
3784 (IPTR
) sys_devname
, 3, MUIM_Set
, MUIA_String_Contents
,
3786 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 1,
3787 (IPTR
) sys_devname
, 3, MUIM_Set
, MUIA_String_Contents
,
3789 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 2,
3790 (IPTR
) sys_devname
, 3, MUIM_Set
, MUIA_String_Contents
,
3792 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 0,
3793 (IPTR
) work_devname
, 3, MUIM_Set
, MUIA_String_Contents
,
3795 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 1,
3796 (IPTR
) work_devname
, 3, MUIM_Set
, MUIA_String_Contents
,
3798 DoMethod(cycle_drivetype
, MUIM_Notify
, (IPTR
) MUIA_Cycle_Active
, 2,
3799 (IPTR
) work_devname
, 3, MUIM_Set
, MUIA_String_Contents
,
3800 USB_WORK_PART_NAME
);
3802 /* Notifications on change of enable status of 'enter size of sys volume'
3803 * (this tells us if we are using existing partitions) */
3804 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Disabled
, MUIV_EveryTime
,
3805 (IPTR
) sys_devname
, 3, MUIM_Set
, MUIA_Disabled
, MUIV_TriggerValue
);
3806 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Disabled
, MUIV_EveryTime
,
3807 (IPTR
) cycle_drivetype
, 3, MUIM_Set
,
3808 MUIA_Disabled
, MUIV_TriggerValue
);
3809 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Disabled
, MUIV_EveryTime
,
3810 (IPTR
) dest_device
, 3, MUIM_Set
, MUIA_Disabled
, MUIV_TriggerValue
);
3811 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Disabled
, MUIV_EveryTime
,
3812 (IPTR
) dest_unit
, 3, MUIM_Set
, MUIA_Disabled
, MUIV_TriggerValue
);
3813 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Disabled
, MUIV_EveryTime
,
3814 (IPTR
) cycle_fstypesys
, 3, MUIM_Set
,
3815 MUIA_Disabled
, MUIV_TriggerValue
);
3817 /* Notifications on change of selected status of 'enter size of sys volume' */
3818 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3819 (IPTR
) check_creatework
, 3, MUIM_Set
,
3820 MUIA_Disabled
, MUIV_NotTriggerValue
);
3821 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3822 (IPTR
) sys_size
, 3, MUIM_Set
, MUIA_Disabled
, MUIV_NotTriggerValue
);
3823 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3824 (IPTR
) cycle_sysunits
, 3, MUIM_Set
,
3825 MUIA_Disabled
, MUIV_NotTriggerValue
);
3826 DoMethod(check_sizesys
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3827 (IPTR
) check_creatework
, 3, MUIM_Set
, MUIA_Selected
, FALSE
);
3829 /* Notifications on change of selected status of 'create work volume' */
3830 DoMethod(check_creatework
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3831 (IPTR
) work_devname
, 3, MUIM_Set
,
3832 MUIA_Disabled
, MUIV_NotTriggerValue
);
3833 DoMethod(check_creatework
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3834 (IPTR
) check_sizework
, 3, MUIM_Set
,
3835 MUIA_Disabled
, MUIV_NotTriggerValue
);
3836 DoMethod(check_creatework
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3837 (IPTR
) cycle_fstypework
, 3, MUIM_Set
,
3838 MUIA_Disabled
, MUIV_NotTriggerValue
);
3839 DoMethod(check_creatework
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3840 (IPTR
) check_sizework
, 3, MUIM_Set
, MUIA_Selected
, FALSE
);
3842 /* Notifications on change of selected status of 'enter size of work volume' */
3843 DoMethod(check_sizework
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3844 (IPTR
) work_size
, 3, MUIM_Set
, MUIA_Disabled
, MUIV_NotTriggerValue
);
3845 DoMethod(check_sizework
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3846 (IPTR
) cycle_workunits
, 3, MUIM_Set
,
3847 MUIA_Disabled
, MUIV_NotTriggerValue
);
3849 #if 0 /* Notification doesn't seem to work on String gadgets */
3850 DoMethod(dest_volume
, MUIM_Notify
, MUIA_String_Contents
, MUIV_EveryTime
,
3851 (IPTR
) dest_volume
, 3, MUIM_WriteString
,
3852 MUIV_TriggerValue
, dest_Path
);
3854 /* Notifications on installing bootloader */
3855 DoMethod(check_bootloader
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3856 (IPTR
) cycle_grub2mode
, 3, MUIM_Set
,
3857 MUIA_Disabled
, MUIV_NotTriggerValue
);
3859 DoMethod(check_core
, MUIM_Notify
, MUIA_Selected
, FALSE
,
3860 (IPTR
) check_formatsys
, 3, MUIM_Set
, MUIA_Selected
, FALSE
);
3861 DoMethod(check_work
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3862 (IPTR
) check_copytowork
, 3, MUIM_Set
,
3863 MUIA_Disabled
, MUIV_NotTriggerValue
);
3864 DoMethod(check_work
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3865 (IPTR
) check_copytowork
, 3, MUIM_Set
, MUIA_Selected
, FALSE
);
3866 DoMethod(check_work
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3867 (IPTR
) check_formatwork
, 3, MUIM_Set
,
3868 MUIA_Disabled
, MUIV_NotTriggerValue
);
3869 DoMethod(check_work
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3870 (IPTR
) check_formatwork
, 3, MUIM_Set
, MUIA_Selected
, FALSE
);
3871 DoMethod(check_work
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
3872 (IPTR
) work_volume
, 3, MUIM_Set
,
3873 MUIA_Disabled
, MUIV_NotTriggerValue
);
3875 install_opts
->opt_license
= check_license
;
3876 install_opts
->opt_lic_box
= LicenseMsg
;
3877 install_opts
->opt_lic_mgrp
= LicenseMandGrp
;
3879 install_opts
->opt_partmethod
= radio_part
;
3881 install_opts
->opt_format
= check_format
;
3882 install_opts
->opt_locale
= check_locale
;
3883 install_opts
->opt_copycore
= check_core
;
3884 install_opts
->opt_copyextra
= check_extras
;
3885 install_opts
->opt_development
= check_dev
;
3886 install_opts
->opt_bootloader
= check_bootloader
;
3888 install_opts
->opt_reboot
= check_reboot
;
3890 grub_opts
->gopt_drive
= grub_drive
;
3891 grub_opts
->gopt_grub
= grub_grub
;
3892 grub_opts
->gopt_grub2mode
= cycle_grub2mode
;
3894 struct MUI_CustomClass
*mcc
=
3895 MUI_CreateCustomClass(NULL
, MUIC_Notify
, NULL
,
3896 sizeof(struct Install_DATA
), Install_Dispatcher
);
3897 Object
*installer
= NewObject(mcc
->mcc_Class
, NULL
,
3899 MUIA_Page
, (IPTR
) page
,
3900 MUIA_Gauge1
, (IPTR
) gauge1
,
3901 MUIA_Gauge2
, (IPTR
) gauge2
,
3902 MUIA_Install
, (IPTR
) label
,
3904 MUIA_OBJ_Installer
, (IPTR
) app
,
3906 MUIA_WelcomeMsg
, (IPTR
) welcomeMsg
,
3907 MUIA_FinishedMsg
, (IPTR
) doneMsg
,
3909 MUIA_List_Options
, (IPTR
) install_opts
,
3910 MUIA_Grub_Options
, (IPTR
) grub_opts
,
3912 MUIA_OBJ_WindowContent
, (IPTR
) wndcontents
,
3913 MUIA_OBJ_Window
, (IPTR
) wnd
,
3915 MUIA_OBJ_PageTitle
, (IPTR
) pagetitle
,
3916 MUIA_OBJ_PageHeader
, (IPTR
) pageheader
,
3917 MUIA_OBJ_CActionStrng
, (IPTR
) currentaction
,
3918 MUIA_OBJ_Back
, (IPTR
) gad_back
,
3919 MUIA_OBJ_Proceed
, (IPTR
) gad_proceed
,
3920 MUIA_OBJ_Cancel
, (IPTR
) gad_cancel
,
3922 MUIA_IC_EnableUndo
, TRUE
,
3924 // MUIA_IC_License_File,"HELP:English/license", /* License can only be viewed by highlighting text and dragging */
3925 MUIA_IC_License_Mandatory
, TRUE
,
3929 DoMethod(wnd
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
, app
, 2,
3930 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
3932 SET(wnd
, MUIA_Window_Open
, TRUE
);
3936 while (DoMethod(app
, MUIM_Application_NewInput
,
3937 &sigs
) != MUIV_Application_ReturnID_Quit
)
3941 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
3942 if (sigs
& SIGBREAKF_CTRL_C
)
3948 D(bug("[INST-APP] Closing Window\n"));
3950 SET(wnd
, MUIA_Window_Open
, FALSE
);
3952 D(bug("[INST-APP] Disposing of Installer Object\n"));
3954 DisposeObject(installer
);
3956 D(bug("[INST-APP] Removing Custom Class\n"));
3958 MUI_DeleteCustomClass(mcc
);
3960 D(bug("[INST-APP] Removing App Object\n"));
3962 MUI_DisposeObject(app
);
3964 FreeVec(extras_source
);
3965 FreeVec(source_Path
);