From b05a22cdb517cccaedf4938ebd1671c916764c7a Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Fri, 23 May 2025 10:01:14 +0200 Subject: [PATCH 1/3] Make DiskAnalyzer#candidate_software_raid? public --- src/lib/y2storage/disk_analyzer.rb | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/lib/y2storage/disk_analyzer.rb b/src/lib/y2storage/disk_analyzer.rb index 925423763..82cc543fb 100644 --- a/src/lib/y2storage/disk_analyzer.rb +++ b/src/lib/y2storage/disk_analyzer.rb @@ -159,6 +159,23 @@ def candidate_device?(device) !device.name.match?(/^\/dev\/ram\d+$/) end + # Checks whether the given software RAID can be considered a valid candidate for a Linux + # installation + # + # Apart from matching conditions of #candidate_device?, a valid software RAID candidate must + # either, have a partition table or do not have children. + # + # See {#candidate_disks} for extra explanations (e.g. the relevance of EFI) and for + # Fate/Bugzilla references. + # + # @param md [Md] + # @return [Boolean] + def candidate_software_raid?(md) + return false unless arch.efiboot? + + (md.partition_table? || md.children.empty?) && candidate_device?(md) + end + # Look up devicegraph element by device name. # # @return [Device] @@ -259,19 +276,11 @@ def all_linux_suitable_filesystems # Finds software RAIDs that are considered valid candidates for a Linux installation # - # Apart from matching conditions of #candidate_device?, a valid software RAID candidate must - # either, have a partition table or do not have children. - # - # See {#candidate_disks} for extra explanations (e.g. the relevance of EFI) and for - # Fate/Bugzilla references. + # @see #candidate_software_raid? # # @return [Array] def candidate_software_raids - return [] unless arch.efiboot? - - devicegraph.software_raids.select do |md| - (md.partition_table? || md.children.empty?) && candidate_device?(md) - end + devicegraph.software_raids.select { |md| candidate_software_raid?(md) } end # Finds disk devices that are considered valid candidates From 89d29c2a2cd09d12743f47671191e96c4b1f9df3 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Fri, 23 May 2025 10:06:44 +0200 Subject: [PATCH 2/3] Version and changelog --- package/yast2-storage-ng.changes | 7 +++++++ package/yast2-storage-ng.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-storage-ng.changes b/package/yast2-storage-ng.changes index f28f35657..d434eb2d4 100644 --- a/package/yast2-storage-ng.changes +++ b/package/yast2-storage-ng.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri May 23 08:06:05 UTC 2025 - Ancor Gonzalez Sosa + +- Make method DiskAnalyzer#candidate_software_raid? public + (gh#agama-project/agama#2388). +- 5.0.32 + ------------------------------------------------------------------- Tue May 13 15:01:47 UTC 2025 - Stefan Schubert diff --git a/package/yast2-storage-ng.spec b/package/yast2-storage-ng.spec index 2b6c5e2d8..2960a2fc6 100644 --- a/package/yast2-storage-ng.spec +++ b/package/yast2-storage-ng.spec @@ -16,7 +16,7 @@ # Name: yast2-storage-ng -Version: 5.0.31 +Version: 5.0.32 Release: 0 Summary: YaST2 - Storage Configuration License: GPL-2.0-only OR GPL-3.0-only From 8c3112cc82bce956988a67639f2ac5be18b21899 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Fri, 23 May 2025 15:40:14 +0200 Subject: [PATCH 3/3] Reorganize DiskAnalyzer public API (from code review) --- package/yast2-storage-ng.changes | 4 ++-- src/lib/y2storage/disk_analyzer.rb | 28 +++++++++++++--------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/package/yast2-storage-ng.changes b/package/yast2-storage-ng.changes index d434eb2d4..8dd7a15b5 100644 --- a/package/yast2-storage-ng.changes +++ b/package/yast2-storage-ng.changes @@ -1,8 +1,8 @@ ------------------------------------------------------------------- Fri May 23 08:06:05 UTC 2025 - Ancor Gonzalez Sosa -- Make method DiskAnalyzer#candidate_software_raid? public - (gh#agama-project/agama#2388). +- Reorganize public methods of DiskAnalyzer (needed by + gh#agama-project/agama#2388). - 5.0.32 ------------------------------------------------------------------- diff --git a/src/lib/y2storage/disk_analyzer.rb b/src/lib/y2storage/disk_analyzer.rb index 82cc543fb..3e2de5f0d 100644 --- a/src/lib/y2storage/disk_analyzer.rb +++ b/src/lib/y2storage/disk_analyzer.rb @@ -144,36 +144,34 @@ def candidate_disks @candidate_disks end - # Checks whether a device can be used as candidate for installation + # Checks whether a device can be used for the installation # - # A device is candidate for installation if no filesystem belonging to the device is mounted and the - # device does not contain a repository for installation. + # A device is visible for installation purposes if no filesystem belonging to the device is + # mounted and the device does not contain a repository for installation. # # Moreover, RAM disks are also discarded. # # @param device [BlkDevice] # @return [Boolean] - def candidate_device?(device) + def available_device?(device) !contain_mounted_filesystem?(device) && !contain_installation_repository?(device) && !device.name.match?(/^\/dev\/ram\d+$/) end - # Checks whether the given software RAID can be considered a valid candidate for a Linux - # installation + # Checks whether it makes sense to create the boot-related partitions at the given device # - # Apart from matching conditions of #candidate_device?, a valid software RAID candidate must - # either, have a partition table or do not have children. - # - # See {#candidate_disks} for extra explanations (e.g. the relevance of EFI) and for + # Apart from the disk devices, some software RAIDs are considered as acceptable under some + # circumstances. See {#candidate_disks} for extra explanations (e.g. the relevance of EFI) and for # Fate/Bugzilla references. # - # @param md [Md] + # @param device [BlkDevice] # @return [Boolean] - def candidate_software_raid?(md) + def supports_boot_partitions?(device) + return true if device.is?(:disk_device) return false unless arch.efiboot? - (md.partition_table? || md.children.empty?) && candidate_device?(md) + device.is?(:software_raid) && (device.partition_table? || device.children.empty?) end # Look up devicegraph element by device name. @@ -280,7 +278,7 @@ def all_linux_suitable_filesystems # # @return [Array] def candidate_software_raids - devicegraph.software_raids.select { |md| candidate_software_raid?(md) } + devicegraph.software_raids.select { |md| available_device?(md) && supports_boot_partitions?(md) } end # Finds disk devices that are considered valid candidates @@ -290,7 +288,7 @@ def candidate_software_raids # @return [Array] def candidate_disk_devices rejected_disk_devices = candidate_software_raids.map(&:ancestors).flatten - candidate_disk_devices = devicegraph.disk_devices.select { |d| candidate_device?(d) } + candidate_disk_devices = devicegraph.disk_devices.select { |d| available_device?(d) } candidate_disk_devices - rejected_disk_devices end