[partition] Improve logging of device-checking
- Avoid lots of function headers between the checks applied to each individual device.
This commit is contained in:
parent
d4f28e863f
commit
1fe337d6ed
@ -72,15 +72,15 @@ getRequiredStorageGiB( bool& ok )
|
||||
}
|
||||
|
||||
bool
|
||||
canBeReplaced( Partition* candidate )
|
||||
canBeReplaced( Partition* candidate, const Logger::Once& o )
|
||||
{
|
||||
if ( !candidate )
|
||||
{
|
||||
cDebug() << "Partition* is NULL";
|
||||
cDebug() << o << "Partition* is NULL";
|
||||
return false;
|
||||
}
|
||||
|
||||
cDebug() << "Checking if" << convenienceName( candidate ) << "can be replaced.";
|
||||
cDebug() << o << "Checking if" << convenienceName( candidate ) << "can be replaced.";
|
||||
if ( candidate->isMounted() )
|
||||
{
|
||||
cDebug() << Logger::SubEntry << "NO, it is mounted.";
|
||||
@ -100,7 +100,7 @@ canBeReplaced( Partition* candidate )
|
||||
|
||||
if ( availableStorageB > requiredStorageB )
|
||||
{
|
||||
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for replace install.";
|
||||
cDebug() << o << "Partition" << convenienceName( candidate ) << "authorized for replace install.";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -117,15 +117,15 @@ canBeReplaced( Partition* candidate )
|
||||
|
||||
|
||||
bool
|
||||
canBeResized( Partition* candidate )
|
||||
canBeResized( Partition* candidate, const Logger::Once& o )
|
||||
{
|
||||
if ( !candidate )
|
||||
{
|
||||
cDebug() << "Partition* is NULL";
|
||||
cDebug() << o << "Partition* is NULL";
|
||||
return false;
|
||||
}
|
||||
|
||||
cDebug() << "Checking if" << convenienceName( candidate ) << "can be resized.";
|
||||
cDebug() << o << "Checking if" << convenienceName( candidate ) << "can be resized.";
|
||||
if ( !candidate->fileSystem().supportGrow() || !candidate->fileSystem().supportShrink() )
|
||||
{
|
||||
cDebug() << Logger::SubEntry << "NO, filesystem" << candidate->fileSystem().name()
|
||||
@ -177,7 +177,7 @@ canBeResized( Partition* candidate )
|
||||
|
||||
if ( availableStorageB > advisedStorageB )
|
||||
{
|
||||
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install.";
|
||||
cDebug() << o << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install.";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -196,9 +196,9 @@ canBeResized( Partition* candidate )
|
||||
|
||||
|
||||
bool
|
||||
canBeResized( DeviceModel* dm, const QString& partitionPath )
|
||||
canBeResized( DeviceModel* dm, const QString& partitionPath, const Logger::Once& o )
|
||||
{
|
||||
cDebug() << "Checking if" << partitionPath << "can be resized.";
|
||||
cDebug() << o << "Checking if" << partitionPath << "can be resized.";
|
||||
QString partitionWithOs = partitionPath;
|
||||
if ( partitionWithOs.startsWith( "/dev/" ) )
|
||||
{
|
||||
@ -208,7 +208,7 @@ canBeResized( DeviceModel* dm, const QString& partitionPath )
|
||||
Partition* candidate = CalamaresUtils::Partition::findPartitionByPath( { dev }, partitionWithOs );
|
||||
if ( candidate )
|
||||
{
|
||||
return canBeResized( candidate );
|
||||
return canBeResized( candidate, o );
|
||||
}
|
||||
}
|
||||
cDebug() << Logger::SubEntry << "no Partition* found for" << partitionWithOs;
|
||||
@ -357,6 +357,8 @@ findPartitionPathForMountPoint( const FstabEntryList& fstab, const QString& moun
|
||||
OsproberEntryList
|
||||
runOsprober( DeviceModel* dm )
|
||||
{
|
||||
Logger::Once o;
|
||||
|
||||
QString osproberOutput;
|
||||
QProcess osprober;
|
||||
osprober.setProgram( "os-prober" );
|
||||
@ -411,18 +413,18 @@ runOsprober( DeviceModel* dm )
|
||||
QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" );
|
||||
|
||||
osproberEntries.append(
|
||||
{ prettyName, path, file, QString(), canBeResized( dm, path ), lineColumns, fstabEntries, homePath } );
|
||||
{ prettyName, path, file, QString(), canBeResized( dm, path, o ), lineColumns, fstabEntries, homePath } );
|
||||
osproberCleanLines.append( line );
|
||||
}
|
||||
}
|
||||
|
||||
if ( osproberCleanLines.count() > 0 )
|
||||
{
|
||||
cDebug() << "os-prober lines after cleanup:" << Logger::DebugList( osproberCleanLines );
|
||||
cDebug() << o << "os-prober lines after cleanup:" << Logger::DebugList( osproberCleanLines );
|
||||
}
|
||||
else
|
||||
{
|
||||
cDebug() << "os-prober gave no output.";
|
||||
cDebug() << o << "os-prober gave no output.";
|
||||
}
|
||||
|
||||
Calamares::JobQueue::instance()->globalStorage()->insert( "osproberLines", osproberCleanLines );
|
||||
|
@ -24,6 +24,10 @@
|
||||
|
||||
class DeviceModel;
|
||||
class Partition;
|
||||
namespace Logger
|
||||
{
|
||||
class Once;
|
||||
}
|
||||
|
||||
namespace PartUtils
|
||||
{
|
||||
@ -41,26 +45,29 @@ QString convenienceName( const Partition* const candidate );
|
||||
* @brief canBeReplaced checks whether the given Partition satisfies the criteria
|
||||
* for replacing it with the new OS.
|
||||
* @param candidate the candidate partition to replace.
|
||||
* @param o applied to debug-logging.
|
||||
* @return true if the criteria are met, otherwise false.
|
||||
*/
|
||||
bool canBeReplaced( Partition* candidate );
|
||||
bool canBeReplaced( Partition* candidate, const Logger::Once& o );
|
||||
|
||||
/**
|
||||
* @brief canBeReplaced checks whether the given Partition satisfies the criteria
|
||||
* for resizing (shrinking) it to make room for a new OS.
|
||||
* @param candidate the candidate partition to resize.
|
||||
* @param o applied to debug-logging.
|
||||
* @return true if the criteria are met, otherwise false.
|
||||
*/
|
||||
bool canBeResized( Partition* candidate );
|
||||
bool canBeResized( Partition* candidate, const Logger::Once& o );
|
||||
|
||||
/**
|
||||
* @brief canBeReplaced checks whether the given Partition satisfies the criteria
|
||||
* for resizing (shrinking) it to make room for a new OS.
|
||||
* @param dm the DeviceModel instance.
|
||||
* @param partitionPath the device path of the candidate partition to resize.
|
||||
* @param o applied to debug-logging.
|
||||
* @return true if the criteria are met, otherwise false.
|
||||
*/
|
||||
bool canBeResized( DeviceModel* dm, const QString& partitionPath );
|
||||
bool canBeResized( DeviceModel* dm, const QString& partitionPath, const Logger::Once& o );
|
||||
|
||||
/**
|
||||
* @brief runOsprober executes os-prober, parses the output and writes relevant
|
||||
|
@ -986,7 +986,7 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
|
||||
|
||||
SelectionFilter filter = []( const QModelIndex& index ) {
|
||||
return PartUtils::canBeResized(
|
||||
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ) );
|
||||
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ), Logger::Once() );
|
||||
};
|
||||
m_beforePartitionBarsView->setSelectionFilter( filter );
|
||||
m_beforePartitionLabelsView->setSelectionFilter( filter );
|
||||
@ -1075,7 +1075,7 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
|
||||
{
|
||||
SelectionFilter filter = []( const QModelIndex& index ) {
|
||||
return PartUtils::canBeReplaced(
|
||||
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ) );
|
||||
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ), Logger::Once() );
|
||||
};
|
||||
m_beforePartitionBarsView->setSelectionFilter( filter );
|
||||
m_beforePartitionLabelsView->setSelectionFilter( filter );
|
||||
@ -1220,10 +1220,12 @@ operator<<( QDebug& s, PartitionIterator& it )
|
||||
void
|
||||
ChoicePage::setupActions()
|
||||
{
|
||||
Logger::Once o;
|
||||
|
||||
Device* currentDevice = selectedDevice();
|
||||
OsproberEntryList osproberEntriesForCurrentDevice = getOsproberEntriesForDevice( currentDevice );
|
||||
|
||||
cDebug() << "Setting up actions for" << currentDevice->deviceNode() << "with"
|
||||
cDebug() << o << "Setting up actions for" << currentDevice->deviceNode() << "with"
|
||||
<< osproberEntriesForCurrentDevice.count() << "entries.";
|
||||
|
||||
if ( currentDevice->partitionTable() )
|
||||
@ -1269,12 +1271,12 @@ ChoicePage::setupActions()
|
||||
|
||||
for ( auto it = PartitionIterator::begin( currentDevice ); it != PartitionIterator::end( currentDevice ); ++it )
|
||||
{
|
||||
if ( PartUtils::canBeResized( *it ) )
|
||||
if ( PartUtils::canBeResized( *it, o ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry << "contains resizable" << it;
|
||||
atLeastOneCanBeResized = true;
|
||||
}
|
||||
if ( PartUtils::canBeReplaced( *it ) )
|
||||
if ( PartUtils::canBeReplaced( *it, o ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry << "contains replaceable" << it;
|
||||
atLeastOneCanBeReplaced = true;
|
||||
|
Loading…
Reference in New Issue
Block a user