[fsresizer] Scan for devices, list partitions

- The is just debugging output, but it's the start of what needs
   to happen to find the FS that needs resizing.
This commit is contained in:
Adriaan de Groot 2018-09-25 06:39:14 -04:00
parent 35ca813064
commit 06a00a15c6
2 changed files with 42 additions and 2 deletions

View file

@ -10,17 +10,20 @@ if ( KPMcore_FOUND )
include_directories( ${KPMCORE_INCLUDE_DIR} )
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamares )
# The PartitionIterator is a small class, and it's easiest -- but also a
# gross hack -- to just compile it again from the partition module tree.
calamares_add_plugin( fsresizer
TYPE job
EXPORT_MACRO PLUGINDLLEXPORT_PRO
SOURCES
ResizeFSJob.cpp
${PROJECT_SOURCE_DIR}/src/modules/partition/core/PartitionIterator.cpp
LINK_PRIVATE_LIBRARIES
kpmcore
calamares
SHARED_LIB
)
if( ECM_FOUND )
find_package( Qt5 COMPONENTS Test REQUIRED )
include( ECMAddTests )

View file

@ -24,6 +24,8 @@
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackendmanager.h>
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include "CalamaresVersion.h"
#include "JobQueue.h"
@ -31,6 +33,8 @@
#include "utils/Logger.h"
#include "modules/partition/core/PartitionIterator.h"
ResizeFSJob::RelativeSize::RelativeSize()
: m_value( 0 )
, m_unit( None )
@ -92,7 +96,40 @@ ResizeFSJob::exec()
if ( backend_p )
cDebug() << "KPMCore backend @" << (void *)backend_p << backend_p->id() << backend_p->version();
else
cDebug() << "No KPMCore backend";
{
cDebug() << "No KPMCore backend loaded yet";
QByteArray backendName = qgetenv( "KPMCORE_BACKEND" );
if ( !CoreBackendManager::self()->load( backendName.isEmpty() ? CoreBackendManager::defaultBackendName() : backendName ) )
{
cWarning() << "Could not load KPMCore backend.";
return Calamares::JobResult::error(
tr( "KPMCore not Available" ),
tr( "Calamares cannot start KPMCore for the file-system resize job." ) );
}
backend_p = CoreBackendManager::self()->backend();
}
if ( !backend_p )
{
cWarning() << "Could not load KPMCore backend (2).";
return Calamares::JobResult::error(
tr( "KPMCore not Available" ),
tr( "Calamares cannot start KPMCore for the file-system resize job." ) );
}
using DeviceList = QList< Device* >;
DeviceList devices = backend_p->scanDevices( false );
cDebug() << "ResizeFSJob found" << devices.count() << "devices.";
for ( DeviceList::iterator it = devices.begin(); it != devices.end(); )
{
if ( ! (*it) )
continue;
cDebug() << "ResizeFSJob found" << ( *it )->deviceNode();
for ( auto pit = PartitionIterator::begin( *it); pit != PartitionIterator::end( *it); ++pit )
{
cDebug() << ".." << ( *pit )->mountPoint();
}
}
if ( !isValid() )
return Calamares::JobResult::error(