FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
archinstall/archinstall/scripts/guided.py at master · archlinux/archinstall · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
archlinux
/
archinstall
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
768
Star
8.4k
Code
Issues
213
Pull requests
23
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
archinstall
/
archinstall
/
scripts
/
guided.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
259 lines (206 loc) · 8.48 KB
Breadcrumbs
archinstall
/
archinstall
/
scripts
/
guided.py
Copy path
File metadata and controls
259 lines (206 loc) · 8.48 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
import
os
import
sys
import
time
from
archinstall
.
lib
.
applications
.
application_handler
import
ApplicationHandler
from
archinstall
.
lib
.
args
import
ArchConfig
,
ArchConfigHandler
from
archinstall
.
lib
.
authentication
.
authentication_handler
import
AuthenticationHandler
from
archinstall
.
lib
.
bootloader
.
utils
import
validate_bootloader_layout
from
archinstall
.
lib
.
configuration
import
confirm_config
from
archinstall
.
lib
.
disk
.
filesystem
import
FilesystemHandler
from
archinstall
.
lib
.
disk
.
utils
import
disk_layouts
from
archinstall
.
lib
.
general
.
general_menu
import
PostInstallationAction
,
select_post_installation
from
archinstall
.
lib
.
global_menu
import
GlobalMenu
from
archinstall
.
lib
.
installer
import
Installer
,
accessibility_tools_in_use
,
run_custom_user_commands
from
archinstall
.
lib
.
log
import
debug
,
error
,
info
from
archinstall
.
lib
.
menu
.
util
import
delayed_warning
from
archinstall
.
lib
.
mirror
.
mirror_handler
import
MirrorListHandler
from
archinstall
.
lib
.
models
import
Bootloader
from
archinstall
.
lib
.
models
.
device
import
DiskLayoutType
,
EncryptionType
from
archinstall
.
lib
.
models
.
users
import
User
from
archinstall
.
lib
.
network
.
network_handler
import
install_network_config
from
archinstall
.
lib
.
packages
.
util
import
check_version_upgrade
from
archinstall
.
lib
.
profile
.
profiles_handler
import
profile_handler
from
archinstall
.
lib
.
translationhandler
import
tr
from
archinstall
.
tui
.
components
import
tui
def
show_menu
(
arch_config_handler
:
ArchConfigHandler
,
mirror_list_handler
:
MirrorListHandler
,
)
->
None
:
upgrade
=
check_version_upgrade
()
title_text
=
'Archlinux'
if
upgrade
:
text
=
tr
(
'New version available'
)
+
f':
{
upgrade
}
'
title_text
+=
f' (
{
text
}
)'
global_menu
=
GlobalMenu
(
arch_config_handler
.
config
,
mirror_list_handler
,
arch_config_handler
.
args
.
skip_boot
,
advanced
=
arch_config_handler
.
args
.
advanced
,
title
=
title_text
,
)
result
:
ArchConfig
|
None
=
tui
.
run
(
global_menu
)
if
result
is
None
:
sys
.
exit
(
0
)
def
perform_installation
(
arch_config_handler
:
ArchConfigHandler
,
mirror_list_handler
:
MirrorListHandler
,
auth_handler
:
AuthenticationHandler
,
application_handler
:
ApplicationHandler
,
)
->
None
:
"""
Performs the installation steps on a block device.
Only requirement is that the block devices are
formatted and setup prior to entering this function.
"""
start_time
=
time
.
monotonic
()
info
(
'Starting installation...'
)
mountpoint
=
arch_config_handler
.
args
.
mountpoint
config
=
arch_config_handler
.
config
if
not
config
.
disk_config
:
error
(
'No disk configuration provided'
)
return
disk_config
=
config
.
disk_config
run_mkinitcpio
=
not
config
.
bootloader_config
or
not
config
.
bootloader_config
.
uki
locale_config
=
config
.
locale_config
optional_repositories
=
config
.
mirror_config
.
optional_repositories
if
config
.
mirror_config
else
[]
mountpoint
=
disk_config
.
mountpoint
if
disk_config
.
mountpoint
else
mountpoint
with
Installer
(
mountpoint
,
disk_config
,
kernels
=
config
.
kernels
,
silent
=
arch_config_handler
.
args
.
silent
,
)
as
installation
:
# Mount all the drives to the desired mountpoint
if
disk_config
.
config_type
!=
DiskLayoutType
.
Pre_mount
:
installation
.
mount_ordered_layout
()
installation
.
sanity_check
(
arch_config_handler
.
args
.
offline
,
arch_config_handler
.
args
.
skip_ntp
,
arch_config_handler
.
args
.
skip_wkd
,
)
if
disk_config
.
config_type
!=
DiskLayoutType
.
Pre_mount
:
if
disk_config
.
disk_encryption
and
disk_config
.
disk_encryption
.
encryption_type
!=
EncryptionType
.
NO_ENCRYPTION
:
# generate encryption key files for the mounted luks devices
installation
.
generate_key_files
()
if
mirror_config
:=
config
.
mirror_config
:
installation
.
set_mirrors
(
mirror_list_handler
,
mirror_config
,
on_target
=
False
)
installation
.
minimal_installation
(
optional_repositories
=
optional_repositories
,
mkinitcpio
=
run_mkinitcpio
,
hostname
=
arch_config_handler
.
config
.
hostname
,
locale_config
=
locale_config
,
pacman_config
=
config
.
pacman_config
,
)
if
mirror_config
:=
config
.
mirror_config
:
installation
.
set_mirrors
(
mirror_list_handler
,
mirror_config
,
on_target
=
True
)
if
config
.
swap
and
config
.
swap
.
enabled
:
installation
.
setup_swap
(
algo
=
config
.
swap
.
algorithm
)
if
config
.
bootloader_config
and
config
.
bootloader_config
.
bootloader
!=
Bootloader
.
NO_BOOTLOADER
:
installation
.
add_bootloader
(
config
.
bootloader_config
.
bootloader
,
config
.
bootloader_config
.
uki
,
config
.
bootloader_config
.
removable
,
config
.
bootloader_config
.
plymouth
,
)
if
config
.
network_config
:
install_network_config
(
config
.
network_config
,
installation
,
config
.
profile_config
,
)
users
=
None
if
config
.
auth_config
:
if
config
.
auth_config
.
users
:
users
=
config
.
auth_config
.
users
installation
.
create_users
(
config
.
auth_config
.
users
)
auth_handler
.
setup_auth
(
installation
,
config
.
auth_config
,
config
.
hostname
)
if
app_config
:=
config
.
app_config
:
application_handler
.
install_applications
(
installation
,
app_config
)
if
profile_config
:=
config
.
profile_config
:
profile_handler
.
install_profile_config
(
installation
,
profile_config
)
if
config
.
packages
and
config
.
packages
[
0
]
!=
''
:
installation
.
add_additional_packages
(
config
.
packages
)
if
timezone
:=
config
.
timezone
:
installation
.
set_timezone
(
timezone
)
if
config
.
ntp
:
installation
.
activate_time_synchronization
()
if
accessibility_tools_in_use
():
installation
.
enable_espeakup
()
if
config
.
auth_config
and
config
.
auth_config
.
root_enc_password
:
root_user
=
User
(
'root'
,
config
.
auth_config
.
root_enc_password
,
False
)
installation
.
set_user_password
(
root_user
)
if
(
profile_config
:=
config
.
profile_config
)
and
profile_config
.
profile
:
profile_config
.
profile
.
post_install
(
installation
)
if
users
:
profile_config
.
profile
.
provision
(
installation
,
users
)
# If the user provided a list of services to be enabled, pass the list to the enable_service function.
# Note that while it's called enable_service, it can actually take a list of services and iterate it.
if
services
:=
config
.
services
:
installation
.
enable_service
(
services
)
if
disk_config
.
has_default_btrfs_vols
():
btrfs_options
=
disk_config
.
btrfs_options
snapshot_config
=
btrfs_options
.
snapshot_config
if
btrfs_options
else
None
snapshot_type
=
snapshot_config
.
snapshot_type
if
snapshot_config
else
None
if
snapshot_type
:
bootloader
=
config
.
bootloader_config
.
bootloader
if
config
.
bootloader_config
else
None
installation
.
setup_btrfs_snapshot
(
snapshot_type
,
bootloader
)
# If the user provided custom commands to be run post-installation, execute them now.
if
cc
:=
config
.
custom_commands
:
run_custom_user_commands
(
cc
,
installation
)
installation
.
genfstab
()
debug
(
f'Disk states after installing:
\n
{
disk_layouts
()
}
'
)
if
not
arch_config_handler
.
args
.
silent
:
elapsed_time
=
time
.
monotonic
()
-
start_time
action
:
PostInstallationAction
=
tui
.
run
(
lambda
:
select_post_installation
(
elapsed_time
))
match
action
:
case
PostInstallationAction
.
EXIT
:
pass
case
PostInstallationAction
.
REBOOT
:
_
=
os
.
system
(
'reboot'
)
# type: ignore[deprecated]
case
PostInstallationAction
.
CHROOT
:
try
:
installation
.
drop_to_shell
()
except
Exception
:
pass
def
main
(
arch_config_handler
:
ArchConfigHandler
|
None
=
None
)
->
None
:
if
arch_config_handler
is
None
:
arch_config_handler
=
ArchConfigHandler
()
mirror_list_handler
=
MirrorListHandler
(
offline
=
arch_config_handler
.
args
.
offline
,
verbose
=
arch_config_handler
.
args
.
verbose
,
)
if
not
arch_config_handler
.
args
.
silent
:
show_menu
(
arch_config_handler
,
mirror_list_handler
)
arch_config_handler
.
config
.
write_debug
()
arch_config_handler
.
config
.
save
()
# Safety net for silent/config-file flow. The TUI menu blocks Install via
# GlobalMenu._validate_bootloader() before reaching this point.
if
failure
:=
validate_bootloader_layout
(
arch_config_handler
.
config
.
bootloader_config
,
arch_config_handler
.
config
.
disk_config
,
):
error
(
failure
.
description
)
return
if
arch_config_handler
.
args
.
dry_run
:
return
if
not
arch_config_handler
.
args
.
silent
:
aborted
=
False
res
:
bool
=
tui
.
run
(
lambda
:
confirm_config
(
arch_config_handler
.
config
))
if
not
res
:
debug
(
'Installation aborted'
)
aborted
=
True
if
aborted
:
return
main
(
arch_config_handler
)
if
arch_config_handler
.
config
.
disk_config
:
fs_handler
=
FilesystemHandler
(
arch_config_handler
.
config
.
disk_config
)
if
not
delayed_warning
(
tr
(
'Starting device modifications in '
)):
return
main
()
fs_handler
.
perform_filesystem_operations
()
perform_installation
(
arch_config_handler
,
mirror_list_handler
,
AuthenticationHandler
(),
ApplicationHandler
(),
)
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL