def __init__(self, params, prev_page="installation_ask", next_page="summary", **kwargs): super().__init__(self, params, "zfs", prev_page, next_page, **kwargs) self.page = self.ui.get_object('zfs') self.title = _('ZFS Setup') self.disks = None self.diskdic = {} self.change_list = [] self.device_list = self.ui.get_object('treeview') self.device_list_store = self.ui.get_object('liststore') self.prepare_device_list() self.device_list.set_hexpand(True) self.installation = None self.ids = {} self.existing_pools = {} pool_name = "antergos_{0}".format(random_generator()) # Set zfs default options self.zfs_options = { "force_4k": False, "encrypt_swap": False, "encrypt_disk": False, "encrypt_password": "", "scheme": "GPT", "pool_type": "None", "swap_size": 8192, "pool_name": pool_name, "use_pool_name": False, "device_paths": [] } self.pool_types = { 0: "None", 1: "Stripe", 2: "Mirror", 3: "RAID-Z", 4: "RAID-Z2", 5: "RAID-Z3" } self.schemes = {0: "GPT", 1: "MBR"} self.devices = {} self.fs_devices = {} self.mount_devices = {} if os.path.exists("/sys/firmware/efi"): # UEFI, use GPT by default self.uefi = True self.zfs_options["scheme"] = "GPT" else: # No UEFI, use MBR by default self.uefi = False self.zfs_options["scheme"] = "MBR" # Set grub2 bootloader as default self.bootloader = "grub2" self.bootloader_entry = self.ui.get_object('bootloader_entry')
def install_efi(self): """ Install Grub2 bootloader in a UEFI system """ uefi_arch = "x86_64" spec_uefi_arch = "x64" spec_uefi_arch_caps = "X64" fpath = '/install/boot/efi/EFI/grub_reborn' bootloader_id = 'grub_reborn' if not os.path.exists(fpath) else \ 'grub_reborn_{0}'.format(random_generator()) # grub2 in efi needs efibootmgr if not os.path.exists("/usr/bin/efibootmgr"): txt = _( "Please install efibootmgr package to install Grub2 for x86_64-efi platform." ) logging.warning(txt) txt = _("GRUB(2) will NOT be installed") logging.warning(txt) self.settings.set('bootloader_installation_successful', False) return txt = _("Installing GRUB(2) UEFI {0} boot loader").format(uefi_arch) logging.info(txt) grub_install = [ 'grub-install', '--target={0}-efi'.format(uefi_arch), '--efi-directory=/install/boot/efi', '--bootloader-id={0}'.format(bootloader_id), '--boot-directory=/install/boot', '--recheck' ] load_module = ['modprobe', '-a', 'efivarfs'] call(load_module, timeout=15) call(grub_install, timeout=120) self.install_locales() # Copy grub into dirs known to be used as default by some OEMs # if they do not exist yet. grub_defaults = [ os.path.join(self.dest_dir, "boot/efi/EFI/BOOT", "BOOT{0}.efi".format(spec_uefi_arch_caps)), os.path.join(self.dest_dir, "boot/efi/EFI/Microsoft/Boot", "bootmgfw.efi") ] grub_path = os.path.join(self.dest_dir, "boot/efi/EFI/antergos_grub", "grub{0}.efi".format(spec_uefi_arch)) for grub_default in grub_defaults: path = grub_default.split()[0] if not os.path.exists(path): msg = _("No OEM loader found in %s. Copying Grub(2) into dir.") logging.info(msg, path) os.makedirs(path, mode=0o755) msg_failed = _("Copying Grub(2) into OEM dir failed: %s") try: shutil.copy(grub_path, grub_default) except FileNotFoundError: logging.warning(msg_failed, _("File not found.")) except FileExistsError: logging.warning(msg_failed, _("File already exists.")) except Exception as ex: template = "An exception of type {0} occured. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) logging.error(message) self.run_mkconfig() paths = [ os.path.join(self.dest_dir, "boot/grub/x86_64-efi/core.efi"), os.path.join(self.dest_dir, "boot/efi/EFI/{0}".format(bootloader_id), "grub{0}.efi".format(spec_uefi_arch)) ] exists = True for path in paths: if not os.path.exists(path): exists = False logging.debug("Path '%s' doesn't exist, when it should", path) if exists: logging.info("GRUB(2) UEFI install completed successfully") self.settings.set('bootloader_installation_successful', True) else: logging.warning( "GRUB(2) UEFI install may not have completed successfully.") self.settings.set('bootloader_installation_successful', False)
def install_efi(self): """ Install Grub2 bootloader in a UEFI system """ uefi_arch = "x86_64" spec_uefi_arch = "x64" spec_uefi_arch_caps = "X64" fpath = '/install/boot/efi/EFI/antergos_grub' bootloader_id = 'antergos_grub' if not os.path.exists(fpath) else \ 'antergos_grub_{0}'.format(random_generator()) txt = _("Installing GRUB(2) UEFI {0} boot loader").format(uefi_arch) logging.info(txt) grub_install = [ 'grub-install', '--target={0}-efi'.format(uefi_arch), '--efi-directory=/install/boot/efi', '--bootloader-id={0}'.format(bootloader_id), '--boot-directory=/install/boot', '--recheck'] load_module = ['modprobe', '-a', 'efivarfs'] call(load_module, timeout=15) call(grub_install, timeout=120) self.install_locales() # Copy grub into dirs known to be used as default by some OEMs # if they do not exist yet. grub_defaults = [ os.path.join( self.dest_dir, "boot/efi/EFI/BOOT", "BOOT{0}.efi".format(spec_uefi_arch_caps)), os.path.join( self.dest_dir, "boot/efi/EFI/Microsoft/Boot", "bootmgfw.efi")] grub_path = os.path.join( self.dest_dir, "boot/efi/EFI/antergos_grub", "grub{0}.efi".format(spec_uefi_arch)) for grub_default in grub_defaults: path = grub_default.split()[0] if not os.path.exists(path): msg = _("No OEM loader found in %s. Copying Grub(2) into dir.") logging.info(msg, path) os.makedirs(path, mode=0o755) msg_failed = _("Copying Grub(2) into OEM dir failed: %s") try: shutil.copy(grub_path, grub_default) except FileNotFoundError: logging.warning(msg_failed, _("File not found.")) except FileExistsError: logging.warning(msg_failed, _("File already exists.")) except Exception as ex: template = "An exception of type {0} occured. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) logging.error(message) self.run_mkconfig() paths = [ os.path.join(self.dest_dir, "boot/grub/x86_64-efi/core.efi"), os.path.join( self.dest_dir, "boot/efi/EFI/{0}".format(bootloader_id), "grub{0}.efi".format(spec_uefi_arch))] exists = True for path in paths: if not os.path.exists(path): exists = False logging.debug("Path '%s' doesn't exist, when it should", path) if exists: logging.info("GRUB(2) UEFI install completed successfully") self.settings.set('bootloader_installation_successful', True) else: logging.warning("GRUB(2) UEFI install may not have completed successfully.") self.settings.set('bootloader_installation_successful', False)
def __init__( self, params, prev_page="installation_ask", next_page="summary"): super().__init__(self, params, "zfs", prev_page, next_page) self.page = self.ui.get_object('zfs') self.disks = None self.diskdic = {} self.change_list = [] self.device_list = self.ui.get_object('treeview') self.device_list_store = self.ui.get_object('liststore') self.prepare_device_list() self.device_list.set_hexpand(True) self.installation = None self.ids = {} self.existing_pools = {} pool_name = "antergos_{0}".format(random_generator()) # Set zfs default options self.zfs_options = { "force_4k": False, "encrypt_swap": False, "encrypt_disk": False, "encrypt_password": "", "scheme": "GPT", "pool_type": "None", "swap_size": 8192, "pool_name": pool_name, "use_pool_name": False, "device_paths": [] } self.pool_types = { 0: "None", 1: "Stripe", 2: "Mirror", 3: "RAID-Z", 4: "RAID-Z2", 5: "RAID-Z3" } self.schemes = { 0: "GPT", 1: "MBR" } self.devices = {} self.fs_devices = {} self.mount_devices = {} if os.path.exists("/sys/firmware/efi"): # UEFI, use GPT by default self.uefi = True self.zfs_options["scheme"] = "GPT" else: # No UEFI, use MBR by default self.uefi = False self.zfs_options["scheme"] = "MBR" # Set grub2 bootloader as default self.bootloader = "grub2" self.bootloader_entry = self.ui.get_object('bootloader_entry')