[partition] Allow unsafe partitioning decisions

- This is a compile-time choice, and off by default. This may be useful
   for developers that need to get through installation to a different
   partition on their root drive.
 - Add an option to avoid actually doing unsafe things. This is an extra
   safeguard; you need to turn on one and turn off the other option to
   really be unsafe.
This commit is contained in:
Adriaan de Groot 2019-03-17 10:21:57 -04:00
parent 2caefce3cb
commit 62f03d8aad
2 changed files with 20 additions and 0 deletions

View File

@ -1,3 +1,18 @@
# When debugging the partitioning widget, or experimenting, you may
# want to allow unsafe partitioning choices (e.g. doing things to the
# current disk). Set DEBUG_PARTITION_UNSAFE to allow that (it turns off
# some filtering of devices).
option( DEBUG_PARTITION_UNSAFE "Allow unsafe partitioning choices." OFF )
option( DEBUG_PARTITION_LAME "Unsafe partitioning will error out on exec." ON )
set( _partition_defs )
if( DEBUG_PARTITION_UNSAFE )
if( DEBUG_PARTITION_LAME )
list( APPEND _partition_defs DEBUG_PARTITION_LAME )
endif()
list( APPEND _partition_defs DEBUG_PARTITION_UNSAFE )
endif()
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
include(KDEInstallDirs)
@ -84,6 +99,7 @@ if ( KPMcore_FOUND )
kpmcore
calamaresui
KF5::CoreAddons
COMPILE_DEFINITIONS ${_partition_defs}
SHARED_LIB
)
else()

View File

@ -109,6 +109,9 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
CoreBackend* backend = CoreBackendManager::self()->backend();
DeviceList devices = backend->scanDevices( true );
#ifdef DEBUG_PARTITION_UNSAFE
cWarning() << "Allowing unsafe partitioning choices." << devices.count() << "candidates.";
#else
cDebug() << "Removing unsuitable devices:" << devices.count() << "candidates.";
// Remove the device which contains / from the list
@ -142,6 +145,7 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
}
else
++it;
#endif
return devices;
}