update requires root access to the machine and there is no --simulate
option so skip it in dry-run mode.
Co-authored-by: Didier Roche <didrocks@ubuntu.com>
UDI sets the SNAP env var to '.' for development purposes.
See: https://github.com/canonical/ubuntu-desktop-installer/commit/9eb6f04
It is unlikely that under test or production that env var will
ever by just '.'. On the other hand in dry-run we want this controller
to interpret it as '/' if not properly set, thus discarding the '.'.
When refreshing the filesystem GUI, we used to set the status (i.e.,
enabled or disabled) of the "Create LVM volume group" and "Create
software RAID" buttons multiple times ; once for each disk found.
When multiple disks are listed, this creates intermediate status changes
that are not wanted, e.g.:
* "Create software RAID" button gets set to disabled after finding a first
unpartitioned disk ;
* "Create software RAID" button is set again to disabled after finding
a partitioned disk (with no unmounted partitions) ;
* "Create software RAID" button is set to enabled after finding a
second unpartitioned disk.
Fixed by evaluating the status of the buttons only once after looping
through all disks.
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This one does change behaviour in that if it has to resize a partition
to make room for the ESP it puts it before the partition, not after.
This lets us put an assertion back in an API test.
No behaviour change yet, this all assumes version 1 partitioning, i.e.
no mix of new and old partitions on a device. But it means we only have
to edit one batch of logic when that stops being true.
A useful concept in other areas of partition / gap handling has to
require a keyword for specifying if we're sending gap or a partition.
Implement that here for the partition and gap keywords, and also on the
downstream partition_disk_handler.
SUBIQUITY_REPLAY_TIMESCALE should be passed to replay-curtin-log.py,
which speeds up test_server_flow (11s -> 2s), and probably others.
For the unit test, by clearing the environment and using a known set,
we can avoid having to keep a second copy of the allow list in test.
It seemed far too much complicated find the proper way to deal with
apt Python library under the snap environment.
Opted for running the system apt command without the LD_*
customisations, similar to what an installer does when chroot into the
taget system.
This allows for running subprocess outside of the snap environment.
Both functions now receive a custom env without the LD_ related vars.
Renamed _create_user() to create_user() to make explicit that it has the
same semantic level as apply_locale().