Skip to content

Commit

Permalink
Merge pull request #4865 from mikhailnov/remove-hfs-on-macs
Browse files Browse the repository at this point in the history
storage: no need in HFS+ on Apple Macs
  • Loading branch information
poncovka authored Dec 14, 2023
2 parents 7b68289 + eff83af commit 60af090
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 134 deletions.
32 changes: 1 addition & 31 deletions pyanaconda/modules/storage/bootloader/efi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from pyanaconda.anaconda_loggers import get_module_logger
log = get_module_logger(__name__)

__all__ = ["EFIBase", "EFIGRUB", "Aarch64EFIGRUB", "ArmEFIGRUB", "MacEFIGRUB", "Aarch64EFISystemdBoot", "X64EFISystemdBoot"]
__all__ = ["EFIBase", "EFIGRUB", "Aarch64EFIGRUB", "ArmEFIGRUB", "Aarch64EFISystemdBoot", "X64EFISystemdBoot"]


class EFIBase(object):
Expand Down Expand Up @@ -277,33 +277,3 @@ def __init__(self):
super().__init__()
self._packages32 = ["grub2-efi-arm"]
self._is_32bit_firmware = True


class MacEFIGRUB(EFIGRUB):
def __init__(self):
super().__init__()
self._packages64.extend(["grub2-tools-efi", "mactel-boot"])

def mactel_config(self):
if os.path.exists(conf.target.system_root + "/usr/libexec/mactel-boot-setup"):
rc = util.execWithRedirect("/usr/libexec/mactel-boot-setup", [],
root=conf.target.system_root)
if rc:
log.error("failed to configure Mac boot loader")

def install(self, args=None):
super().install()
self.mactel_config()

def is_valid_stage1_device(self, device, early=False):
valid = super().is_valid_stage1_device(device, early)

# Make sure we don't pick the OSX root partition
if valid and getattr(device.format, "name", "") != "Linux HFS+ ESP":
valid = False

if hasattr(device.format, "name"):
log.debug("device.format.name is '%s'", device.format.name)

log.debug("MacEFIGRUB.is_valid_stage1_device(%s) returning %s", device.name, valid)
return valid
4 changes: 0 additions & 4 deletions pyanaconda/modules/storage/bootloader/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ def get_class_by_platform(cls, platform_class=None):
from pyanaconda.modules.storage.bootloader.efi import EFIGRUB
return EFIGRUB

if platform_class is platform.MacEFI:
from pyanaconda.modules.storage.bootloader.efi import MacEFIGRUB
return MacEFIGRUB

if platform_class is platform.PPC:
from pyanaconda.modules.storage.bootloader.grub2 import GRUB2
return GRUB2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,8 @@ def _execute_partition_data(self, storage, data, partition_data):
if partition_data.onPart:
data.onPart[kwargs["name"]] = partition_data.onPart
elif partition_data.mountpoint == "/boot/efi":
if blivet.arch.is_mactel():
ty = "macefi"
else:
ty = "EFI System Partition"
partition_data.fsopts = "defaults,uid=0,gid=0,umask=077,shortname=winnt"
ty = "EFI System Partition"
partition_data.fsopts = "defaults,uid=0,gid=0,umask=077,shortname=winnt"
else:
if partition_data.fstype != "":
ty = partition_data.fstype
Expand Down
54 changes: 1 addition & 53 deletions pyanaconda/modules/storage/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
MBR_DESCRIPTION = N_("Master Boot Record")
EFI_DESCRIPTION = N_("EFI System Partition")
PREP_BOOT_DESCRIPTION = N_("PReP Boot Partition")
APPLE_EFI_DESCRIPTION = N_("Apple EFI Boot Partition")
APPLE_BOOTSTRAP_DESCRIPTION = N_("Apple Bootstrap Partition")
DASD_DESCRIPTION = N_("DASD")
ZFCP_DESCRIPTION = N_("zFCP")
Expand Down Expand Up @@ -230,55 +229,6 @@ def _bootloader_partition(self):
)


class MacEFI(EFI):

@property
def packages(self):
"""Packages required for this platform."""
return ["mactel-boot"]

@property
def non_linux_format_types(self):
"""Format types of devices with non-linux operating systems."""
return ["macefi"]

@property
def stage1_suggestion(self):
"""The platform-specific suggestion about the stage1 device."""
return _(
"For a UEFI installation, you must include "
"a Linux HFS+ ESP on a GPT-formatted "
"disk, mounted at /boot/efi."
)

@property
def stage1_descriptions(self):
"""The platform-specific descriptions of the stage1 device."""
return {
"partition": _(APPLE_EFI_DESCRIPTION),
"mdarray": _(RAID_DESCRIPTION)
}

@property
def stage1_constraints(self):
"""The platform-specific constraints for the stage1 device."""
constraints = {
PLATFORM_FORMAT_TYPES: ["macefi"]
}
return dict(super().stage1_constraints, **constraints)

@property
def _bootloader_partition(self):
"""The default bootloader partition for this platform."""
return PartSpec(
mountpoint="/boot/efi",
fstype="macefi",
size=Size("200MiB"),
max_size=Size("600MiB"),
grow=True,
)


class Aarch64EFI(EFI):

@property
Expand Down Expand Up @@ -480,9 +430,7 @@ def get_platform():
elif arch.is_s390():
return S390()
elif arch.is_efi():
if arch.is_mactel():
return MacEFI()
elif arch.is_aarch64():
if arch.is_aarch64():
return Aarch64EFI()
elif arch.is_arm():
return ArmEFI()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from pyanaconda.modules.storage import platform
from pyanaconda.modules.storage.bootloader import BootLoaderFactory
from pyanaconda.modules.storage.bootloader.base import BootLoader
from pyanaconda.modules.storage.bootloader.efi import EFIGRUB, MacEFIGRUB, Aarch64EFIGRUB, ArmEFIGRUB
from pyanaconda.modules.storage.bootloader.efi import EFIGRUB, Aarch64EFIGRUB, ArmEFIGRUB
from pyanaconda.modules.storage.bootloader.extlinux import EXTLINUX
from pyanaconda.modules.storage.bootloader.grub2 import GRUB2, IPSeriesGRUB2, PowerNVGRUB2
from pyanaconda.modules.storage.bootloader.zipl import ZIPL
Expand Down Expand Up @@ -784,7 +784,6 @@ def test_get_class_by_platform(self):
boot_loader_by_platform = {
platform.X86: GRUB2,
platform.EFI: EFIGRUB,
platform.MacEFI: MacEFIGRUB,
platform.PPC: GRUB2,
platform.IPSeriesPPC: IPSeriesGRUB2,
platform.PowerNV: PowerNVGRUB2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from blivet.size import Size
from pyanaconda.modules.storage.partitioning.specification import PartSpec
from pyanaconda.modules.storage.platform import X86, get_platform, NewWorldPPC, IPSeriesPPC, \
PowerNV, PS3, S390, ARM, MacEFI, Aarch64EFI, EFI
PowerNV, PS3, S390, ARM, Aarch64EFI, EFI


class PlatformTestCase(unittest.TestCase):
Expand Down Expand Up @@ -204,44 +204,6 @@ def test_efi(self, arch):
)
)

@patch("pyanaconda.modules.storage.platform.arch")
def test_mac_efi(self, arch):
"""Test the Mac EFI platform."""
self._reset_arch(arch)
arch.is_efi.return_value = True
arch.is_mactel.return_value = True

self._check_platform(
platform_cls=MacEFI,
packages=["mactel-boot"],
non_linux_format_types=["macefi"],
)

self._check_partitions(
PartSpec(mountpoint="/boot/efi", fstype="macefi", grow=True,
size=Size("200MiB"), max_size=Size("600MiB")),
PartSpec(mountpoint="/boot", size=Size("1GiB")),
)

self._check_constraints(
constraints={
"format_types": ["macefi"],
"device_types": ["partition", "mdarray"],
"mountpoints": ["/boot/efi"],
"raid_levels": [raid.RAID1],
"raid_metadata": ["1.0"]
},
descriptions={
"partition": "Apple EFI Boot Partition",
"mdarray": "RAID Device"
},
error_message=str(
"For a UEFI installation, you must include "
"a Linux HFS+ ESP on a GPT-formatted "
"disk, mounted at /boot/efi."
)
)

@patch("pyanaconda.modules.storage.platform.arch")
def test_aarch64_efi(self, arch):
"""Test the Aarch64 EFI platform."""
Expand Down

0 comments on commit 60af090

Please sign in to comment.