diff --git a/Makefile b/Makefile index 06308144..ff64d638 100644 --- a/Makefile +++ b/Makefile @@ -37,11 +37,11 @@ tarball: $(NAME)_$(VERSION).orig.tar.gz install_deps_amd64: sudo apt-get install grub-efi-amd64-signed -install_deps_$(ARCH): +install_deps: install_deps_$(ARCH) sudo apt-get install python3-urwid python3-pyudev python3-netifaces python3-nose python3-flake8 python3-yaml git bzr ubuntu-cloudimage-keyring python3-jinja2 python3-coverage ovfm shim shim-signed dryrun: probert - $(MAKE) ui-view DRYRUN="--dry-run" + $(MAKE) ui-view DRYRUN="--dry-run --uefi" ui-view: (PYTHONPATH=$(PYTHONPATH) bin/$(PYTHONSRC) $(DRYRUN) $(MACHARGS)) diff --git a/bin/subiquity b/bin/subiquity index 8b029dd3..2243afb9 100755 --- a/bin/subiquity +++ b/bin/subiquity @@ -36,6 +36,9 @@ def parse_options(argv): parser.add_argument('--machine-config', metavar='CONFIG', dest='machine_config', help="Don't Probe. Use probe data file") + parser.add_argument('--uefi', action='store_true', + dest='uefi', + help='run in uefi support mode') return parser.parse_args(argv) diff --git a/installer/geninstaller b/installer/geninstaller index 38ea7128..46ba07d4 100755 --- a/installer/geninstaller +++ b/installer/geninstaller @@ -43,7 +43,8 @@ INSTALLER_DEPS=( "python3-tornado" ) CACHEDIR="" -GRUB_MODS="configfile fat part_gpt part_msdos cat echo test search search_label search_fs_uuid boot chain linux reboot halt normal efi_gop efi_uga font gfxterm" +GRUB_MODS="configfile fat part_gpt part_msdos cat echo test search search_label search_fs_uuid boot chain linux reboot halt normal efi_gop efi_uga font gfxterm gfxterm_menu gfxterm_background gfxmenu serial" + cleanup_noexit() { [ -n "${CACHEDIR}" ] && { diff --git a/installer/resources/grub/grub.cfg b/installer/resources/grub/grub.cfg index e55ebe92..3f15da94 100644 --- a/installer/resources/grub/grub.cfg +++ b/installer/resources/grub/grub.cfg @@ -34,6 +34,7 @@ insmod part_msdos insmod png insmod probe insmod regexp +insmod serial # Set up display set gfxmode=auto diff --git a/subiquity/controllers/filesystem.py b/subiquity/controllers/filesystem.py index 1fcc9849..02a6dc97 100644 --- a/subiquity/controllers/filesystem.py +++ b/subiquity/controllers/filesystem.py @@ -14,6 +14,7 @@ # along with this program. If not, see . import logging +import os from subiquity.controller import ControllerPolicy from subiquity.models.actions import preserve_action from subiquity.models import (FilesystemModel, IscsiDiskModel, RaidModel, @@ -30,6 +31,7 @@ from subiquity.curtin import (curtin_write_storage_actions, log = logging.getLogger("subiquity.controller.filesystem") BIOS_GRUB_SIZE_BYTES = 2 * 1024 * 1024 # 2MiB +UEFI_GRUB_SIZE_BYTES = 512 * 1024 * 1024 # 512MiB EFI partition class FilesystemController(ControllerPolicy): @@ -105,12 +107,21 @@ class FilesystemController(ControllerPolicy): ''' create a gpt boot partition if one doesn't exist ''' if current_disk.parttype == 'gpt' and \ len(current_disk.disk.partitions) == 0: - log.debug('Adding grub_bios gpt partition first') - size_added = \ - current_disk.add_partition(partnum=1, - size=BIOS_GRUB_SIZE_BYTES, - fstype=None, - flag='bios_grub') + if self.is_uefi(): + log.debug('Adding EFI partition first') + size_added = \ + current_disk.add_partition(partnum=1, + size=UEFI_GRUB_SIZE_BYTES, + flag='bios_grub', + fstype='fat32', + mountpoint='/boot/efi') + else: + log.debug('Adding grub_bios gpt partition first') + size_added = \ + current_disk.add_partition(partnum=1, + size=BIOS_GRUB_SIZE_BYTES, + fstype=None, + flag='bios_grub') # adjust downward the partition size to accommodate # the offset and bios/grub partition @@ -197,3 +208,10 @@ class FilesystemController(ControllerPolicy): self.signal, result) self.ui.set_body(disk_info_view) + + def is_uefi(self): + if self.opts.dry_run and self.opts.uefi: + log.debug('forcing is_uefi True beacuse of options') + return True + return os.path.exists('/sys/firmware/efi') + diff --git a/subiquity/curtin.py b/subiquity/curtin.py index 3e6cbe19..57b657b4 100644 --- a/subiquity/curtin.py +++ b/subiquity/curtin.py @@ -113,11 +113,9 @@ storage: # 12_ds_to_none: [curtin, in-target, --, sh, '-c', "echo 'datasource_list: [ None ]' > /etc/cloud/cloud.cfg.d/ POST_INSTALL = ''' late_commands: - 10_set_hostname: curtin in-target -- sh -c 'echo $(petname) > /etc/hostname' - 11_postinst_seed: [curtin, in-target, --, sh, '-c',"/bin/echo -e '#cloud-config\\npassword: passw0rd\\nchpasswd: {{ expire: False }}\\nusers:\\n{users}' > /var/lib/cloud/seed/nocloud-net/user-data"] - 12_disable_subiquity: curtin in-target -- systemctl disable subiquity.service - 13_delete_subiquity: curtin in-target -- rm -f /lib/systemd/system/subiquity.service - 14_remove_subiquity: curtin in-target -- sh -c 'for d in probert curtin subiquity; do rm -rf /usr/local/${{d}}; rm -rf /usr/local/bin/${{d}}*; done' + 10_mkdir_seed: curtin in-target -- mkdir -p /var/lib/cloud/seed/nocloud-net + 11_postinst_metadata: [curtin, in-target, --, sh, '-c',"/bin/echo -e instance-id: inst-3011 > /var/lib/cloud/seed/nocloud-net/meta-data"] + 12_postinst_userdata: [curtin, in-target, --, sh, '-c',"/bin/echo -e '#cloud-config\\npassword: passw0rd\\nchpasswd: {{ expire: False }}\\nusers:\\n{users}' > /var/lib/cloud/seed/nocloud-net/user-data"] ''' diff --git a/subiquity/models/blockdev.py b/subiquity/models/blockdev.py index de4d9da3..9e74e763 100644 --- a/subiquity/models/blockdev.py +++ b/subiquity/models/blockdev.py @@ -296,7 +296,27 @@ class Blockdev(): self._mounts[partpath]) actions.append(mount_action) - return [action] + [a.get() for a in actions] + return self.sort_actions([action] + [a.get() for a in actions]) + + def sort_actions(self, actions): + def type_index(t): + order = ['disk', 'partition', 'format', 'mount'] + return order.index(t.get('type')) + + def path_count(p): + return p.get('path').count('/') + + def order_sort(a): + # sort by type first + score = type_index(a) + # for type==mount, count the number of dirs + if a.get('type') == 'mount': + score += path_count(a) + return score + + actions = sorted(actions, key=order_sort) + + return actions def get_fs_table(self): ''' list(mountpoint, humansize, fstype, partition_path) '''