[partition] Address default-labeling issues
This commit is contained in:
parent
7d89643146
commit
f4a10a313c
@ -23,7 +23,7 @@ This release contains contributions from (alphabetically by name):
|
|||||||
## Modules ##
|
## Modules ##
|
||||||
- *fstab* module correctly handles empty UUID strings. (Thanks Evan)
|
- *fstab* module correctly handles empty UUID strings. (Thanks Evan)
|
||||||
- *partition* module no longer forgets configured partition-layouts.
|
- *partition* module no longer forgets configured partition-layouts.
|
||||||
(Thanks Santosh)
|
It also respects configured partition labels better. (Thanks Santosh)
|
||||||
|
|
||||||
|
|
||||||
# 3.2.53 (2022-03-04) #
|
# 3.2.53 (2022-03-04) #
|
||||||
|
@ -941,6 +941,15 @@ PartitionCoreModule::setBootLoaderInstallPath( const QString& path )
|
|||||||
m_bootLoaderInstallPath = path;
|
m_bootLoaderInstallPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
applyDefaultLabel( Partition* p, bool ( *predicate )( const Partition* ), const QString& label )
|
||||||
|
{
|
||||||
|
if ( p->label().isEmpty() && predicate( p ) )
|
||||||
|
{
|
||||||
|
p->setLabel( label );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::layoutApply( Device* dev,
|
PartitionCoreModule::layoutApply( Device* dev,
|
||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
@ -957,25 +966,28 @@ PartitionCoreModule::layoutApply( Device* dev,
|
|||||||
// PartitionInfo::mountPoint() says where it will be mounted in the target system.
|
// PartitionInfo::mountPoint() says where it will be mounted in the target system.
|
||||||
// .. the latter is more interesting.
|
// .. the latter is more interesting.
|
||||||
//
|
//
|
||||||
// If we have a separate /boot, mark that one as bootable, otherwise mark
|
// If we have a separate /boot, mark that one as bootable,
|
||||||
// the root / as bootable.
|
// otherwise mark the root / as bootable.
|
||||||
//
|
//
|
||||||
// TODO: perhaps the partition that holds the bootloader?
|
// If the layout hasn't applied a label to the partition,
|
||||||
|
// apply a default label (to boot and root, at least).
|
||||||
|
const auto is_boot = []( const Partition* p ) -> bool
|
||||||
|
{
|
||||||
const QString boot = QStringLiteral( "/boot" );
|
const QString boot = QStringLiteral( "/boot" );
|
||||||
|
return PartitionInfo::mountPoint( p ) == boot || p->mountPoint() == boot;
|
||||||
|
};
|
||||||
|
const auto is_root = []( const Partition* p ) -> bool
|
||||||
|
{
|
||||||
const QString root = QStringLiteral( "/" );
|
const QString root = QStringLiteral( "/" );
|
||||||
const auto is_boot
|
return PartitionInfo::mountPoint( p ) == root || p->mountPoint() == root;
|
||||||
= [ & ]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == boot || p->mountPoint() == boot; };
|
};
|
||||||
const auto is_root
|
|
||||||
= [ & ]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == root || p->mountPoint() == root; };
|
|
||||||
|
|
||||||
const bool separate_boot_partition
|
const bool separate_boot_partition
|
||||||
= std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd();
|
= std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd();
|
||||||
for ( Partition* part : partList )
|
for ( Partition* part : partList )
|
||||||
{
|
{
|
||||||
if ( is_boot( part ) )
|
applyDefaultLabel( part, is_root, QStringLiteral( "root" ) );
|
||||||
{
|
applyDefaultLabel( part, is_boot, QStringLiteral( "boot" ) );
|
||||||
part->setLabel( "boot" );
|
|
||||||
}
|
|
||||||
if ( ( separate_boot_partition && is_boot( part ) ) || ( !separate_boot_partition && is_root( part ) ) )
|
if ( ( separate_boot_partition && is_boot( part ) ) || ( !separate_boot_partition && is_root( part ) ) )
|
||||||
{
|
{
|
||||||
createPartition(
|
createPartition(
|
||||||
|
Loading…
Reference in New Issue
Block a user