[partition] Follow 'claimed' settings for claiming swap

- By the time the GS is actually written, new (for partition state)
  is always false. So "new" is the wrong thing to track. It should
  have had a better name anyway,
- We store custom properties on the partition objects to indicate
  what happens to them; use those properties (instead of state,
  as done originally), call it "claimed" to indicate that the partition
  is part of this installation.

For now, only new (as in, formatted, created-by-us) partitions are
claimed.

- The effect here is that only "new" swap will be added to the system,
  so in erase-disk installations, or manual partitioning.
- Install-alongside and replace will now **not** claim the swap already
  on the disk; I think we'll need another UI knob for that one.

FIXES #1316
This commit is contained in:
Adriaan de Groot 2020-02-20 12:07:18 +01:00
parent 35a2db064b
commit 5247c13f98
3 changed files with 11 additions and 8 deletions

View File

@ -251,9 +251,9 @@ class FstabGenerator(object):
return None
if not mount_point:
mount_point = "swap"
# Existing swap partitins should not be used
if filesystem == "swap" and not partition["new"]:
libcalamares.utils.debug("fstab ignoring old swap {}".format(disk_name))
if filesystem == "swap" and not partition.get("claimed", None):
libcalamares.utils.debug("Ignoring foreign swap {!s} {!s}".format(disk_name, partition.get("uuid", None)))
return None
options = self.get_mount_options(filesystem, mount_point)

View File

@ -224,10 +224,10 @@ public:
*/
QList< SummaryInfo > createSummaryInfo() const;
void dumpQueue() const; // debug output
const OsproberEntryList osproberEntries() const; // os-prober data structure, cached
void dumpQueue() const; // debug output
Q_SIGNALS:
void hasRootMountPointChanged( bool value );
void isDirtyChanged( bool value );

View File

@ -100,15 +100,18 @@ mapForPartition( Partition* partition, const QString& uuid )
map[ "fs" ] = untranslatedFS( dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() );
}
map[ "uuid" ] = uuid;
map[ "new" ] = partition->state() == Partition::StateNew;
map[ "claimed" ] = PartitionInfo::format( partition ); // If we formatted it, it's ours
// Debugging for inside the loop in createPartitionList(),
// so indent a bit
Logger::CDebug deb;
using TR = Logger::DebugRow< const char* const, const QString& >;
deb << Logger::SubEntry << "mapping for" << partition->partitionPath() << partition->deviceNode()
<< TR( "mtpoint:", PartitionInfo::mountPoint( partition ) ) << TR( "fs:", map[ "fs" ].toString() )
<< TR( "fsName", map[ "fsName" ].toString() ) << TR( "uuid", uuid );
<< TR( "mtpoint:", PartitionInfo::mountPoint( partition ) )
<< TR( "fs:", map[ "fs" ].toString() )
<< TR( "fsName", map[ "fsName" ].toString() )
<< TR( "uuid", uuid )
<< TR( "claimed", map[ "claimed" ].toString() );
if ( partition->roles().has( PartitionRole::Luks ) )
{