[calamares] Allow multiple instances if -d is given

- Calamares doesn't like to run multiple instances, since they would
  interfere with each other (stealing disks from each other, for instance).
  The single-application code tries to prevent that.
- For -d runs, for developers where presumably they know what they are
  doing, the single-application restriction is annoying: especially if
  you need two instances at once for some kind of visual comparison.

Drop the single-app requirement if -d is given.
This commit is contained in:
Adriaan de Groot 2020-05-08 10:37:15 +02:00
parent 401a34fcbd
commit 15cbdf2a18

View File

@ -63,7 +63,13 @@ debug_level( QCommandLineParser& parser, QCommandLineOption& levelOption )
} }
} }
static void /** @brief Handles the command-line arguments
*
* Sets up internals for Calamares based on command-line arguments like `-D`,
* `-d`, etc. Returns @c true if this is a *debug* run, i.e. if the `-d`
* command-line flag is given, @c false otherwise.
*/
static bool
handle_args( CalamaresApplication& a ) handle_args( CalamaresApplication& a )
{ {
QCommandLineOption debugOption( QStringList { "d", "debug" }, QCommandLineOption debugOption( QStringList { "d", "debug" },
@ -100,8 +106,8 @@ handle_args( CalamaresApplication& a )
CalamaresUtils::setXdgDirs(); CalamaresUtils::setXdgDirs();
} }
CalamaresUtils::setAllowLocalTranslation( parser.isSet( debugOption ) || parser.isSet( debugTxOption ) ); CalamaresUtils::setAllowLocalTranslation( parser.isSet( debugOption ) || parser.isSet( debugTxOption ) );
Calamares::Settings::init( parser.isSet( debugOption ) );
a.init(); return parser.isSet( debugOption );
} }
int int
@ -129,13 +135,13 @@ main( int argc, char* argv[] )
// TODO: umount anything in /tmp/calamares-... as an emergency save function // TODO: umount anything in /tmp/calamares-... as an emergency save function
#endif #endif
KDSingleApplicationGuard guard( KDSingleApplicationGuard::AutoKillOtherInstances ); bool is_debug = handle_args( a );
if ( guard.isPrimaryInstance() )
if ( !is_debug )
{ {
handle_args( a ); KDSingleApplicationGuard guard( KDSingleApplicationGuard::AutoKillOtherInstances );
return a.exec();
} if ( !guard.isPrimaryInstance() )
else
{ {
// Here we have not yet set-up the logger system, so qDebug() is ok // Here we have not yet set-up the logger system, so qDebug() is ok
auto instancelist = guard.instances(); auto instancelist = guard.instances();
@ -151,3 +157,8 @@ main( int argc, char* argv[] )
return 69; // EX_UNAVAILABLE on FreeBSD return 69; // EX_UNAVAILABLE on FreeBSD
} }
} }
Calamares::Settings::init( is_debug );
a.init();
return a.exec();
}