Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nigel Kukard
idms-linux-installer-package
Commits
88dc85dc
Commit
88dc85dc
authored
Jul 04, 2019
by
Nigel Kukard
Browse files
Fixed parsing of disk sizes and added serial support to grub
parent
fd0ae5ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/idmslinux_installer/util/blockdevices.py
View file @
88dc85dc
...
...
@@ -125,7 +125,7 @@ def parse_size(size_str: str) -> int:
size_str
)
# Grab the size
size
=
in
t
(
components
[
'num'
])
size
=
floa
t
(
components
[
'num'
])
# Check the multiplier we're going to use...
if
components
[
'multiplier'
]
==
'M'
:
...
...
@@ -138,5 +138,5 @@ def parse_size(size_str: str) -> int:
raise
ValueError
(
'Failed to parse the "multiplier" portion of
\
the block device size: %s'
%
components
[
'multiplier'
])
#
S
et the size
return
size
#
R
et
urn
the size
return
int
(
size
)
src/idmslinux_installer/util/sysgrub.py
View file @
88dc85dc
...
...
@@ -28,6 +28,7 @@ class SysGrub:
def
__init__
(
self
):
"""Initialize our class."""
# pylama:ignore=C901,R0914
def
configure
(
self
,
system_path
:
str
,
output_callback
:
Optional
[
OutputCallback
]
=
None
,
**
kwargs
):
"""Configure grub."""
...
...
@@ -40,6 +41,22 @@ class SysGrub:
if
not
output_callback
:
output_callback
=
self
.
_default_output_callback
# If we are a serial console, we need to make sure grub is configured for serial
is_serial
=
{}
# Open the /proc/cmdline file to see what options we got
with
open
(
'/proc/cmdline'
,
'r'
)
as
cmdline_file
:
# Loop with lines
for
line
in
cmdline_file
:
# Split options into a list
options
=
line
.
split
()
# For now we only support *n8 speed on the first serial port...
for
option
in
options
:
matches
=
re
.
match
(
r
'^console=ttyS(?P<unit>[0-9]),(?P<speed>[0-9]+)n8'
,
option
)
if
matches
:
is_serial
[
'unit'
]
=
matches
.
group
(
'unit'
)
is_serial
[
'speed'
]
=
matches
.
group
(
'speed'
)
# Open the config files and process
with
open
(
sys_default_grub
,
'r'
)
as
conf_file
,
open
(
sys_default_grub_new
,
'w'
)
as
conf_file_new
:
# Loop with lines
...
...
@@ -58,9 +75,29 @@ class SysGrub:
# Rebuild the line
line
=
'GRUB_PRELOAD_MODULES="'
+
' '
.
join
(
modules
)
+
'"
\n
'
# Check if this is the GRUB_CMDLINE_LINUX line
matches
=
re
.
match
(
r
'^\s*GRUB_CMDLINE_LINUX="(?P<cmdline>.*)"'
,
line
)
if
matches
:
# If we can split it into a list
options
=
matches
.
group
(
'cmdline'
).
split
()
# If we're dealing with a serial console add options
if
is_serial
:
options
.
append
(
'console=ttyS%s,%sn8'
%
(
is_serial
[
'unit'
],
is_serial
[
'speed'
]))
# Rebuild the line
line
=
'GRUB_CMDLINE_LINUX="'
+
' '
.
join
(
options
)
+
'"
\n
'
# Write out line
conf_file_new
.
write
(
line
)
# If this is a serial port add additional options
if
is_serial
:
conf_file_new
.
write
(
'# START - Serial Console
\n
'
)
conf_file_new
.
write
(
'GRUB_TERMINAL=serial
\n
'
)
conf_file_new
.
write
(
'GRUB_SERIAL_COMMAND="serial --unit=%s --speed=%s --word=8 --parity=no --stop=1"
\n
'
%
(
is_serial
[
'unit'
],
is_serial
[
'speed'
]))
conf_file_new
.
write
(
'# END - Serial Console
\n
'
)
# Close files
conf_file
.
close
()
conf_file_new
.
close
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment