I checked the lszdev source and for all the other fields that we are
assume are boolean, it can only output "yes" or "no". Today, at least --
not sure how to make sure this is not broken by future changes. Still
this is a help.
for https://bugs.launchpad.net/subiquity/+bug/1919420
The NAME_REGEX currently used is "[a-z_][a-z0-9_-]*" which does correctly prevent hostnames starting with a hyphen.. but also prevents otherwise perfectly valid hostnames that start with a number. (Interestingly, an underscore is not defined as a valid hostname character, but is included as valid in the regex, I'm not sure why this is included but am leaving it in for backwards compatibility)
This patch adds 0-9 as valid characters at the start of a hostname, as per https://man7.org/linux/man-pages/man7/hostname.7.html#:~:text=Valid%20characters%20for%20hostnames%20are,to%20an%20address%20for%20use.
Each element of the hostname must be from 1 to 63 characters long
and the entire hostname, including the dots, can be at most 253
characters long. Valid characters for hostnames are ASCII(7)
letters from a to z, the digits from 0 to 9, and the hyphen (-).
A hostname may not start with a hyphen.
subiquity inherits this behavior from d-i where if a the user selects a
layout that does not allow typing latin characters, the user is prompted
to choose a key to toggle between the one they selected and a related
one that does allow latin characters. This change moves the handling of
this to the server side, so the client just sees the keyboard layout the
user selects, and calls an API method to know if to ask the user about a
toggle key.
Continuing the theme of previous work, this branch parses pc105.tree
into API-friendly attr-based classes at snap build time (which also lets
us check some constraints then and not at run time).
This is a bit sideways from the real thing I'm working on which is
moving most of the logic of keyboard handling to the server side but
anyway. This also lets me check some assumptions while processing the
data rather than in the view code.
If an autoinstall storage config with the last lvm_partition
is set to use all remaining space in the volgroup (size: -1)
and it is not aligned with the lvm chunk size, lvcreate will
round it up, and that will not fit into the actual free size.
That might happen depending on the size used by the previous
(lvm) partitions (e.g., may use percentage) and size of disk.
Fix that by rounding it down to the LVM chunk size.
This passed 'make check' and 'make lint' with exit code 0.
LP: #1919053
Before:
Running command ['lvcreate', 'vg', '--name', 'lv-root', '--zero=y',
'--wipesignatures=y', '--size', '6435110912.0B'] with allowed return
codes [0] (capture=False)
Rounding up size to full physical extent <6.00 GiB
Volume group "vg" has insufficient free space (1534 extents): 1535
required.
An error occured handling 'lvm-lv-root': ProcessExecutionError -
Unexpected error while running command.
After:
Running command ['lvcreate', 'vg', '--name', 'lv-root', '--zero=y',
'--wipesignatures=y', '--size', '6434062336.0B'] with allowed return
codes [0] (capture=False)
Logical volume "lv-root" created.
Check:
$ python3 -q
>>> 6435110912 / (4*1024**2)
1534.25
>>> 6435110912 & ~(4*1024**2-1)
6434062336
>>> _ / (4*1024**2)
1534.0
Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
This adds a way of serializing objects to lists, which makes the results
much less self-documenting but also much smaller. (I want to ship
keyboard data serialized with this code with the snap, but do not really
want to ship JSON data that is way bigger than it needs to be.)
The first of these scripts mashes the current branch's code over that of
a pre-existing subiquity snap.
The second uses the first to mash the current branch's code over the
subiquity snap from an ISO and then creates a new ISO with this new
snap.
It's all a bit terrifying but being able to get your changes into a
bootable ISO in about 30s is quite a large improvement on building the
snap from scratch.