mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
Merge branch 'simplify-unique'
- Use DBus service / activation to ensure uniqueness of Calamares instances, and **don't** require debug-instances to be unique.
This commit is contained in:
commit
4e3f9fb6b3
3 changed files with 47 additions and 17 deletions
|
@ -54,6 +54,7 @@ option( BUILD_TESTING "Build the testing tree." ON )
|
||||||
option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON )
|
option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON )
|
||||||
option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF )
|
option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF )
|
||||||
option( WITH_KF5Crash "Enable crash reporting with KCrash." ON )
|
option( WITH_KF5Crash "Enable crash reporting with KCrash." ON )
|
||||||
|
option( WITH_KF5DBus "Use DBus service for unique-application." ON )
|
||||||
|
|
||||||
# Possible debugging flags are:
|
# Possible debugging flags are:
|
||||||
# - DEBUG_TIMEZONES draws latitude and longitude lines on the timezone
|
# - DEBUG_TIMEZONES draws latitude and longitude lines on the timezone
|
||||||
|
@ -290,7 +291,7 @@ if( ECM_FOUND )
|
||||||
include(KDEInstallDirs)
|
include(KDEInstallDirs)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package( KF5 QUIET COMPONENTS CoreAddons Crash )
|
find_package( KF5 QUIET COMPONENTS CoreAddons Crash DBusAddons )
|
||||||
set_package_properties(
|
set_package_properties(
|
||||||
KF5::CoreAddons PROPERTIES
|
KF5::CoreAddons PROPERTIES
|
||||||
TYPE REQUIRED
|
TYPE REQUIRED
|
||||||
|
@ -299,8 +300,17 @@ set_package_properties(
|
||||||
PURPOSE "About Calamares"
|
PURPOSE "About Calamares"
|
||||||
)
|
)
|
||||||
if( NOT KF5Crash_FOUND )
|
if( NOT KF5Crash_FOUND )
|
||||||
|
if( WITH_KF5Crash )
|
||||||
|
message(WARNING "WITH_KF5Crash is set, but KF5::Crash is not available.")
|
||||||
|
endif()
|
||||||
set( WITH_KF5Crash OFF )
|
set( WITH_KF5Crash OFF )
|
||||||
endif()
|
endif()
|
||||||
|
if( NOT KF5DBusAddons_FOUND )
|
||||||
|
if( WITH_KF5DBus )
|
||||||
|
message(WARNING "WITH_KF5DBus is set, but KF5::DBusAddons is not available.")
|
||||||
|
endif()
|
||||||
|
set( WITH_KF5DBus OFF )
|
||||||
|
endif()
|
||||||
|
|
||||||
if( BUILD_TESTING )
|
if( BUILD_TESTING )
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
@ -520,6 +530,7 @@ add_feature_info(Python ${WITH_PYTHON} "Python job modules")
|
||||||
add_feature_info(PythonQt ${WITH_PYTHONQT} "Python view modules")
|
add_feature_info(PythonQt ${WITH_PYTHONQT} "Python view modules")
|
||||||
add_feature_info(Config ${INSTALL_CONFIG} "Install Calamares configuration")
|
add_feature_info(Config ${INSTALL_CONFIG} "Install Calamares configuration")
|
||||||
add_feature_info(KCrash ${WITH_KF5Crash} "Crash dumps via KCrash")
|
add_feature_info(KCrash ${WITH_KF5Crash} "Crash dumps via KCrash")
|
||||||
|
add_feature_info(KDBusAddons ${WITH_KF5DBus} "Unique-application via DBus")
|
||||||
|
|
||||||
# Add all targets to the build-tree export set
|
# Add all targets to the build-tree export set
|
||||||
set( CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Calamares" CACHE PATH "Installation directory for CMake files" )
|
set( CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Calamares" CACHE PATH "Installation directory for CMake files" )
|
||||||
|
|
|
@ -41,12 +41,13 @@ target_link_libraries( calamares_bin
|
||||||
KF5::CoreAddons
|
KF5::CoreAddons
|
||||||
)
|
)
|
||||||
if( WITH_KF5Crash )
|
if( WITH_KF5Crash )
|
||||||
target_link_libraries( calamares_bin
|
target_link_libraries( calamares_bin PRIVATE KF5::Crash )
|
||||||
PRIVATE
|
|
||||||
KF5::Crash
|
|
||||||
)
|
|
||||||
target_compile_definitions( calamares_bin PRIVATE WITH_KF5Crash )
|
target_compile_definitions( calamares_bin PRIVATE WITH_KF5Crash )
|
||||||
endif()
|
endif()
|
||||||
|
if( WITH_KF5DBus )
|
||||||
|
target_link_libraries( calamares_bin PRIVATE KF5::DBusAddons )
|
||||||
|
target_compile_definitions( calamares_bin PRIVATE WITH_KF5DBus )
|
||||||
|
endif()
|
||||||
|
|
||||||
install( TARGETS calamares_bin
|
install( TARGETS calamares_bin
|
||||||
BUNDLE DESTINATION .
|
BUNDLE DESTINATION .
|
||||||
|
|
|
@ -25,11 +25,17 @@
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
|
#ifndef WITH_KF5DBus
|
||||||
|
#warning "KDSingleApplicationGuard is deprecated"
|
||||||
#include "3rdparty/kdsingleapplicationguard/kdsingleapplicationguard.h"
|
#include "3rdparty/kdsingleapplicationguard/kdsingleapplicationguard.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <KF5/KCoreAddons/KAboutData>
|
#include <KCoreAddons/KAboutData>
|
||||||
|
#ifdef WITH_KF5DBus
|
||||||
|
#include <KDBusAddons/KDBusService>
|
||||||
|
#endif
|
||||||
#ifdef WITH_KF5Crash
|
#ifdef WITH_KF5Crash
|
||||||
#include <KF5/KCrash/KCrash>
|
#include <KCrash/KCrash>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
|
@ -63,7 +69,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 +112,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 +141,14 @@ 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() )
|
|
||||||
{
|
#ifdef WITH_KF5DBus
|
||||||
handle_args( a );
|
KDBusService service( is_debug ? KDBusService::Multiple : KDBusService::Unique );
|
||||||
return a.exec();
|
#else
|
||||||
}
|
KDSingleApplicationGuard guard( is_debug ? KDSingleApplicationGuard::NoPolicy
|
||||||
else
|
: KDSingleApplicationGuard::AutoKillOtherInstances );
|
||||||
|
if ( !is_debug && !guard.isPrimaryInstance() )
|
||||||
{
|
{
|
||||||
// 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();
|
||||||
|
@ -150,4 +163,9 @@ main( int argc, char* argv[] )
|
||||||
}
|
}
|
||||||
return 69; // EX_UNAVAILABLE on FreeBSD
|
return 69; // EX_UNAVAILABLE on FreeBSD
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Calamares::Settings::init( is_debug );
|
||||||
|
a.init();
|
||||||
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue