summaryrefslogtreecommitdiff
path: root/src/core/procedures/interactive
blob: ebca22f6e47eb01d4bfe757d62ca759615e0e52c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
depend_procedure core base # esp for auto_network, intro and set_clock workers


# This is a port of the original /arch/setup script.  It doesn't use aif phases but uses it's own menu-based flow (phase) control

BLOCK_ROLLBACK_USELESS=1

# clock
HARDWARECLOCK=
TIMEZONE=

# default filesystem specs (the + is bootable flag)
# <mountpoint>:<partsize>:<fstype>[:+]
DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3"

declare -A workertitles
workertitles['select_source']='Select source'
workertitles['set_editor']='Set editor'
workertitles['runtime_network']='Setup network'
workertitles['set_clock']='Set clock'
workertitles['prepare_disks']='Prepare hard drive(s)'
workertitles['package_list']='Select packages'
workertitles['install_packages']='Install packages'
workertitles['configure_system']='Configure system'
workertitles['install_bootloader']='Install bootloader'

start_process ()
{
	#####################
	## begin execution ##

	execute worker configure
	execute worker intro
	execute worker sysprep

	default=1
	while true
	do
    		mainmenu
	done
}


mainmenu()  
{
	menu_workers=(select_source set_editor set_clock prepare_disks package_list install_packages configure_system install_bootloader)
	menu=()
	for i in ${!menu_workers[@]}
	do
		let i+=1 # we count from 1 onwards, not from 0
		worker=${menu_workers[$i]}
		title=${workertitles[$worker]}
		menu+=($i "$title")
	done
	let i+=1
	menu+=($i "Exit Install")

	ask_option $default "MAIN MENU" '' required "${menu[@]}"
	case $ANSWER_OPTION in
	"1")                                         execute worker select_source       && \
	                                             execute worker runtime_packages    && default=2 ;;
	"2")                                         execute worker set_editor          && default=3 ;;
	"3")                                         execute worker set_clock           && default=4 ;;
	"4")                                         execute worker prepare_disks       && default=5 ;;
	"5") check_depend worker prepare_disks    && \
	     check_depend worker select_source    && execute worker package_list        && default=6 ;;
	"6") check_depend worker package_list     && \
	     check_depend worker select_source    && execute worker install_packages    && default=7 ;;
	"7") check_depend worker install_packages && execute worker configure_system    && default=8 ;;
	"8") check_depend worker configure_system && execute worker install_bootloader  && default=9 ;;
	"9") notify "If the install finished successfully, you can now type 'reboot' to restart the system." && stop_installer ;;
	*)   execute worker abort_installer;;
    esac
}


worker_configure_system()
{
	interactive_configure_system
}


worker_prepare_disks()
{
	get_possible_fs
	interactive_prepare_disks
}


worker_select_source ()
{
	interactive_select_source
	local ret=$?;
	if [ $ret -eq 0 -a "$var_PKG_SOURCE_TYPE" = net ]
	then
		select_source_extras_menu || ret=$?
	fi
	# base/automatic procedure run a worker runtime_repositories, maybe we could do an interactive repo adder
	return $ret
}

select_source_extras_menu ()
{
        while true; do
                local default=no
                ask_option $default "NET (HTTP/FTP) Installation" "Make sure the network is ok and you've selected a mirror before continuing the installer" required \
                "1" "${worker_titles['runtime_network']}" \
                "2" "Select mirror" \
                "3" "Return to Main Menu" || return 1
                [ "$ANSWER_OPTION" = 1 ] && execute worker runtime_network && default=2
                [ "$ANSWER_OPTION" = 2 ] && interactive_select_mirror && default=3
                [ "$ANSWER_OPTION" = 3 ] && break
        done
	return 1
}

worker_set_editor ()
{
	seteditor force
}

worker_intro ()
{
	notify "Welcome to the Arch Linux Installation program. The install\
 process is fairly straightforward, and you should run through the options in\
 the order they are presented. If you are unfamiliar with partitioning/making\
 filesystems, you may want to consult some documentation before continuing.\
 You can view all output from commands by viewing your VC7 console (ALT-F7).\
 ALT-F1 will bring you back here.\n\n$DISCLAIMER"
}


worker_configure ()
{
	var_UI_TYPE=${arg_ui_type:-dia}
	ui_init
}


# select_packages()
# prompts the user to select packages to install
worker_package_list() {
	# if selection has been done before, warn about loss of input and let the user exit gracefully
	ended_ok worker package_list && ! ask_yesno "WARNING: Running this stage again will result in the loss of previous package selections.\n\nDo you wish to continue?" && return 0

	interactive_select_packages
}


worker_install_packages ()
{
	installpkg
}


# Hand-hold through setting up networking
worker_runtime_network() {
	interactive_runtime_network
}

worker_install_bootloader ()
{
	interactive_install_bootloader
}


worker_auto_network ()
{
	# if the user has been through networking setup, it may be useful to export the users' choices to the target system
	# networking setup could have happened in a separate process (eg partial-configure-network), so check if the settings file was created to be sure
	if [ -f $RUNTIME_DIR/aif-network-settings ]
	then
		ask_yesno "Do you want to use the network settings from the installer in rc.conf and resolv.conf?\n\nIf you used Proxy settings, they will be written to /etc/profile.d/proxy.sh" || return 0
		if ! target_configure_network
		then
			show_warning "Automatic network settings propagation failed" "Failed to import current network settings into target system"
			return 1
		fi
	fi
	return 0
}

worker_abort_installer ()
{
	ret=0
	ask_yesno "Abort Installation?" || return
	maybe_interactive_rollback_filesystems || ret=$?
	stop_installer || ret=$?
	return $ret
}