KDE/kdelibs
Dario Freddi
drf at kde.org
Tue Dec 22 20:45:07 CET 2009
SVN commit 1065226 by dafre:
CCMAIL: ossi at kde.org
CCMAIL: kde-buildsystem at kde.org
Fix FindPolkitQt*.cmake to avoid requiring pkgconfig to check for version. This makes trunk optdepends on the new
polkit-qt 0.9.3 and polkit-qt-1 0.95.1, which will be released shortly.
Also, the polkit-1 backend has been ported to the stable API of Polkit-qt-1 0.95.1
M +40 -15 cmake/modules/FindPolkitQt-1.cmake
M +35 -15 cmake/modules/FindPolkitQt.cmake
M +4 -2 kdecore/auth/ConfigureChecks.cmake
M +18 -16 kdecore/auth/backends/polkit-1/Polkit1Backend.cpp
--- trunk/KDE/kdelibs/cmake/modules/FindPolkitQt-1.cmake #1065225:1065226
@@ -19,7 +19,7 @@
endif (POLKITQT-1_INCLUDE_DIR AND POLKITQT-1_LIB)
if (NOT POLKITQT-1_MIN_VERSION)
- set(POLKITQT-1_MIN_VERSION "0.95.0")
+ set(POLKITQT-1_MIN_VERSION "0.95.1")
endif (NOT POLKITQT-1_MIN_VERSION)
if (NOT WIN32)
@@ -31,9 +31,41 @@
endif (NOT WIN32)
find_path( POLKITQT-1_INCLUDE_DIR
- NAMES PolkitQt/authority.h
+ NAMES polkitqt1-authority.h
PATH_SUFFIXES polkit-qt-1
)
+
+find_path( POLKITQT-1_VERSION_FILE
+ NAMES polkitqt1-version.h
+ PATH_SUFFIXES polkit-qt-1
+)
+
+set(POLKITQT-1_VERSION_OK TRUE)
+if(POLKITQT-1_VERSION_FILE)
+ file(READ ${POLKITQT-1_INCLUDE_DIR}/polkitqt1-version.h POLKITQT-1_VERSION_CONTENT)
+ string (REGEX MATCH "POLKITQT1_VERSION_STRING \".*\"\n" POLKITQT-1_VERSION_MATCH "${POLKITQT-1_VERSION_CONTENT}")
+
+ if(POLKITQT-1_VERSION_MATCH)
+ string(REGEX REPLACE "POLKITQT1_VERSION_STRING \"(.*)\"\n" "\\1" POLKITQT-1_VERSION ${POLKITQT-1_VERSION_MATCH})
+ if(POLKITQT-1_VERSION STRLESS "${POLKITQT-1_MIN_VERSION}")
+ set(POLKITQT-1_VERSION_OK FALSE)
+ if(PolkitQt-1_FIND_REQUIRED)
+ message(FATAL_ERROR "PolkitQt-1 version ${POLKITQT-1_VERSION} was found, but it is too old. Please install ${POLKITQT-1_MIN_VERSION} or newer.")
+ else(PolkitQt-1_FIND_REQUIRED)
+ message(STATUS "PolkitQt-1 version ${POLKITQT-1_VERSION} is too old. Please install ${POLKITQT-1_MIN_VERSION} or newer.")
+ endif(PolkitQt-1_FIND_REQUIRED)
+ endif(POLKITQT-1_VERSION STRLESS "${POLKITQT-1_MIN_VERSION}")
+ endif(POLKITQT-1_VERSION_MATCH)
+elseif(POLKITQT-1_INCLUDE_DIR)
+ # The version is so old that it does not even have the file
+ set(POLKITQT-1_VERSION_OK FALSE)
+ if(PolkitQt_FIND_REQUIRED)
+ message(FATAL_ERROR "It looks like PolkitQt-1 is too old. Please install PolkitQt-1 version ${POLKITQT-1_MIN_VERSION} or newer.")
+ else(PolkitQt_FIND_REQUIRED)
+ message(STATUS "It looks like PolkitQt-1 is too old. Please install PolkitQt-1 version ${POLKITQT-1_MIN_VERSION} or newer.")
+ endif(PolkitQt_FIND_REQUIRED)
+endif(POLKITQT-1_VERSION_FILE)
+
find_library( POLKITQT-1_CORE_LIBRARY
NAMES polkit-qt-core-1
HINTS ${PC_POLKITQT-1_LIBDIR}
@@ -53,22 +85,15 @@
# handle the QUIETLY and REQUIRED arguments and set POLKITQT-1_FOUND to TRUE if
# all listed variables are TRUE
-find_package_handle_standard_args(PolkitQt-1 DEFAULT_MSG POLKITQT-1_LIBRARIES POLKITQT-1_INCLUDE_DIR)
+find_package_handle_standard_args(PolkitQt-1 DEFAULT_MSG POLKITQT-1_LIBRARIES POLKITQT-1_INCLUDE_DIR POLKITQT-1_VERSION_OK)
-mark_as_advanced(POLKITQT-1_INCLUDE_DIR POLKITQT-1_CORE_LIBRARY POLKITQT-1_GUI_LIBRARY POLKITQT-1_LIBRARIES)
+mark_as_advanced(POLKITQT-1_INCLUDE_DIR POLKITQT-1_CORE_LIBRARY POLKITQT-1_GUI_LIBRARY POLKITQT-1_LIBRARIES POLKITQT-1_VERSION_OK)
if (POLKITQT-1_FOUND)
- if (PC_POLKITQT-1_VERSION VERSION_LESS POLKITQT-1_MIN_VERSION)
- message(STATUS "Found PolkitQt-1 release < ${POLKITQT-1_MIN_VERSION}")
- message(STATUS "You need PolkitQt-1 version ${POLKITQT-1_MIN_VERSION} or newer to compile this component")
- set(POLKITQT-1_FOUND FALSE)
- return()
- else (PC_POLKITQT-1_VERSION VERSION_LESS POLKITQT-1_MIN_VERSION)
- if ( NOT PC_POLKITQT-1_PREFIX STREQUAL CMAKE_INSTALL_PREFIX )
- message("WARNING: Installation prefix does not match PolicyKit install prefixes. You probably will need to move files installed "
- "in POLICY_FILES_INSTALL_DIR and by dbus_add_activation_system_service to the ${PC_POLKITQT-1_PREFIX} prefix")
- endif (NOT PC_POLKITQT-1_PREFIX STREQUAL CMAKE_INSTALL_PREFIX)
- endif (PC_POLKITQT-1_VERSION VERSION_LESS POLKITQT-1_MIN_VERSION)
+ if (NOT PC_POLKITQT-1_PREFIX STREQUAL CMAKE_INSTALL_PREFIX)
+ message("WARNING: Installation prefix does not match PolicyKit install prefixes. You probably will need to move files installed "
+ "in POLICY_FILES_INSTALL_DIR and by dbus_add_activation_system_service to the ${PC_POLKITQT-1_PREFIX} prefix")
+ endif (NOT PC_POLKITQT-1_PREFIX STREQUAL CMAKE_INSTALL_PREFIX)
endif (POLKITQT-1_FOUND)
set(POLKITQT-1_POLICY_FILES_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/polkit-1/actions)
--- trunk/KDE/kdelibs/cmake/modules/FindPolkitQt.cmake #1065225:1065226
@@ -25,7 +25,7 @@
endif (POLKITQT_INCLUDE_DIR AND POLKITQT_GUI_LIBRARY AND POLKITQT_CORE_LIBRARY)
if (NOT POLKITQT_MIN_VERSION)
- set(POLKITQT_MIN_VERSION "0.9.0")
+ set(POLKITQT_MIN_VERSION "0.9.3")
endif (NOT POLKITQT_MIN_VERSION)
if (NOT WIN32)
@@ -40,6 +40,38 @@
NAMES polkit-qt/auth.h
PATH_SUFFIXES PolicyKit
)
+
+find_path( POLKITQT_VERSION_FILE
+ NAMES polkit-qt/polkitqtversion.h
+ PATH_SUFFIXES PolicyKit
+)
+
+set(POLKITQT_VERSION_OK TRUE)
+if(POLKITQT_VERSION_FILE)
+ file(READ ${POLKITQT_INCLUDE_DIR}/polkit-qt/polkitqtversion.h POLKITQT_VERSION_CONTENT)
+ string (REGEX MATCH "POLKITQT_VERSION_STRING \".*\"\n" POLKITQT_VERSION_MATCH "${POLKITQT_VERSION_CONTENT}")
+
+ if(POLKITQT_VERSION_MATCH)
+ string(REGEX REPLACE "POLKITQT_VERSION_STRING \"(.*)\"\n" "\\1" POLKITQT_VERSION ${POLKITQT_VERSION_MATCH})
+ if(POLKITQT_VERSION STRLESS "${POLKITQT_MIN_VERSION}")
+ set(POLKITQT_VERSION_OK FALSE)
+ if(PolkitQt_FIND_REQUIRED)
+ message(FATAL_ERROR "PolkitQt version ${POLKITQT_VERSION} was found, but it is too old. Please install ${POLKITQT_MIN_VERSION} or newer.")
+ else(PolkitQt_FIND_REQUIRED)
+ message(STATUS "PolkitQt version ${POLKITQT_VERSION} is too old. Please install ${POLKITQT_MIN_VERSION} or newer.")
+ endif(PolkitQt_FIND_REQUIRED)
+ endif(POLKITQT_VERSION STRLESS "${POLKITQT_MIN_VERSION}")
+ endif(POLKITQT_VERSION_MATCH)
+elseif(POLKITQT_INCLUDE_DIR)
+ # The version is so old that it does not even have the file
+ set(POLKITQT_VERSION_OK FALSE)
+ if(PolkitQt_FIND_REQUIRED)
+ message(FATAL_ERROR "It looks like PolkitQt is too old. Please install PolkitQt version ${POLKITQT_MIN_VERSION} or newer.")
+ else(PolkitQt_FIND_REQUIRED)
+ message(STATUS "It looks like PolkitQt is too old. Please install PolkitQt version ${POLKITQT_MIN_VERSION} or newer.")
+ endif(PolkitQt_FIND_REQUIRED)
+endif(POLKITQT_VERSION_FILE)
+
find_library( POLKITQT_CORE_LIBRARY
NAMES polkit-qt-core
HINTS ${PC_POLKITQT_LIBDIR}
@@ -54,22 +86,10 @@
# handle the QUIETLY and REQUIRED arguments and set POLKITQT_FOUND to TRUE if
# all listed variables are TRUE
-find_package_handle_standard_args(PolkitQt DEFAULT_MSG POLKITQT_INCLUDE_DIR POLKITQT_GUI_LIBRARY POLKITQT_CORE_LIBRARY)
+find_package_handle_standard_args(PolkitQt DEFAULT_MSG POLKITQT_INCLUDE_DIR POLKITQT_GUI_LIBRARY POLKITQT_CORE_LIBRARY POLKITQT_VERSION_OK)
-mark_as_advanced(POLKITQT_INCLUDE_DIR POLKITQT_CORE_LIBRARY POLKITQT_GUI_LIBRARY POLKITQT_LIBRARIES)
+mark_as_advanced(POLKITQT_INCLUDE_DIR POLKITQT_CORE_LIBRARY POLKITQT_GUI_LIBRARY POLKITQT_LIBRARIES POLKITQT_VERSION_OK)
-if (POLKITQT_FOUND)
- if (PC_POLKITQT_VERSION VERSION_LESS POLKITQT_MIN_VERSION)
- if(PolkitQt_FIND_REQUIRED)
- message(FATAL_ERROR "Found Polkit-Qt release ${PC_POLKITQT_VERSION}, but at least ${POLKITQT_MIN_VERSION} is required.")
- else(PolkitQt_FIND_REQUIRED)
- message(STATUS "Found Polkit-Qt release ${PC_POLKITQT_VERSION}, but at least ${POLKITQT_MIN_VERSION} is required.")
- endif(PolkitQt_FIND_REQUIRED)
- set(POLKITQT_FOUND FALSE)
- endif (PC_POLKITQT_VERSION VERSION_LESS POLKITQT_MIN_VERSION)
-endif (POLKITQT_FOUND)
-
-
if(POLKITQT_FOUND)
get_filename_component(_POLKITQT_INSTALL_PREFIX "${POLKITQT_CORE_LIBRARY}" PATH)
get_filename_component(_POLKITQT_INSTALL_PREFIX "${_POLKITQT_INSTALL_PREFIX}" PATH)
--- trunk/KDE/kdelibs/kdecore/auth/ConfigureChecks.cmake #1065225:1065226
@@ -7,6 +7,8 @@
## we check what is the best backend to build on this system.
## 4.4: We leave polkit-0.9 having more priority over polkit-1. This will change from 4.5 on
if(NOT KAUTH_BACKEND)
+ # Look for the most appropriate backend
+ message(STATUS "No backend for KAuth was explicitely specified: probing system to find the best one available")
if (APPLE)
set (KAUTH_BACKEND "OSX")
elseif (UNIX)
@@ -18,7 +20,7 @@
FALSE "" "STRONGLY RECOMMENDED: Needed to make KAuth work (using PolicyKit < 0.90), hence to enable some workspace functionalities")
else (POLKITQT_FOUND)
macro_optional_find_package(PolkitQt-1)
-
+
if (POLKITQT-1_FOUND)
set (KAUTH_BACKEND "PolkitQt-1")
macro_log_feature(POLKITQT-1_FOUND "PolkitQt-1" "Qt Wrapper around polkit-1" "http://techbase.kde.org/Polkit-Qt-1"
@@ -41,7 +43,7 @@
else(NOT KAUTH_BACKEND)
# Case-insensitive
string(TOUPPER ${KAUTH_BACKEND} KAUTH_BACKEND)
-
+
# Check if the specified backend is valid. If it is not, we fall back to the Fake one
if (NOT KAUTH_BACKEND STREQUAL "OSX" AND NOT KAUTH_BACKEND STREQUAL "POLKITQT" AND NOT KAUTH_BACKEND STREQUAL "POLKITQT-1" AND NOT KAUTH_BACKEND STREQUAL "FAKE")
message ("WARNING: The KAuth Backend ${KAUTH_BACKEND} you specified does not exist. Falling back to Fake backend")
--- trunk/KDE/kdelibs/kdecore/auth/backends/polkit-1/Polkit1Backend.cpp #1065225:1065226
@@ -23,11 +23,9 @@
#include <QDebug>
#include <syslog.h>
-#include <PolkitQt/Authority>
-#include <PolkitQt/Subject>
+#include <PolkitQt1/Authority>
+#include <PolkitQt1/Subject>
#include <QtCore/QCoreApplication>
-//#include <polkit-qt/context.h>
-//#include <polkit-qt/auth.h>
namespace KAuth
{
@@ -39,9 +37,11 @@
Action::AuthStatus Polkit1Backend::authorizeAction(const QString &action)
{
- PolkitQt::UnixProcessSubject subject(QCoreApplication::applicationPid());
- switch (PolkitQt::Authority::instance()->checkAuthorizationSync(action, &subject, PolkitQt::Authority::AllowUserInteraction)) {
- case PolkitQt::Authority::Yes:
+ PolkitQt1::UnixProcessSubject subject(QCoreApplication::applicationPid());
+ PolkitQt1::Authority *authority = PolkitQt1::Authority::instance();
+
+ switch (authority->checkAuthorizationSync(action, &subject, PolkitQt1::Authority::AllowUserInteraction)) {
+ case PolkitQt1::Authority::Yes:
return Action::Authorized;
default:
return Action::Denied;
@@ -50,9 +50,9 @@
void Polkit1Backend::setupAction(const QString &action)
{
- connect(PolkitQt::Authority::instance(), SIGNAL(configChanged()),
+ connect(PolkitQt1::Authority::instance(), SIGNAL(configChanged()),
this, SLOT(checkForResultChanged()));
- connect(PolkitQt::Authority::instance(), SIGNAL(consoleKitDBChanged()),
+ connect(PolkitQt1::Authority::instance(), SIGNAL(consoleKitDBChanged()),
this, SLOT(checkForResultChanged()));
m_cachedResults[action] = actionStatus(action);
@@ -60,13 +60,14 @@
Action::AuthStatus Polkit1Backend::actionStatus(const QString &action)
{
- PolkitQt::UnixProcessSubject subject(QCoreApplication::applicationPid());
- PolkitQt::Authority::Result r = PolkitQt::Authority::instance()->checkAuthorizationSync(action, &subject, PolkitQt::Authority::None);
+ PolkitQt1::UnixProcessSubject subject(QCoreApplication::applicationPid());
+ PolkitQt1::Authority::Result r = PolkitQt1::Authority::instance()->checkAuthorizationSync(action, &subject,
+ PolkitQt1::Authority::None);
switch (r) {
- case PolkitQt::Authority::Yes:
+ case PolkitQt1::Authority::Yes:
return Action::Authorized;
- case PolkitQt::Authority::No:
- case PolkitQt::Authority::Unknown:
+ case PolkitQt1::Authority::No:
+ case PolkitQt1::Authority::Unknown:
return Action::Denied;
default:
return Action::AuthRequired;
@@ -89,8 +90,9 @@
s >> pid;
- PolkitQt::UnixProcessSubject subject(pid);
- return (PolkitQt::Authority::instance()->checkAuthorizationSync(action, &subject, PolkitQt::Authority::None) == PolkitQt::Authority::Yes);
+ PolkitQt1::UnixProcessSubject subject(pid);
+ return (PolkitQt1::Authority::instance()->checkAuthorizationSync(action, &subject, PolkitQt1::Authority::None) ==
+ PolkitQt1::Authority::Yes);
}
void Polkit1Backend::checkForResultChanged()
More information about the Kde-buildsystem
mailing list