瀏覽代碼

added support for installing in /usr/local

Malte Veerman 9 年之前
父節點
當前提交
77dee46028
共有 3 個文件被更改,包括 47 次插入6 次删除
  1. 9 5
      fancontrol-gui/src/main.cpp
  2. 7 1
      helper/CMakeLists.txt
  3. 31 0
      helper/MoveSystemFiles.cmake

+ 9 - 5
fancontrol-gui/src/main.cpp

@@ -67,13 +67,17 @@ int main(int argc, char *argv[])
     KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML"));
     package.setDefaultPackageRoot(QStringLiteral("/usr/local/share/kpackage/kcms"));
     package.setPath(QStringLiteral("kcm_fancontrol"));
-
-    if (!package.isValid())
-        package.setDefaultPackageRoot("/usr/share/kpackage/kcms");
-    
-    package.addFileDefinition("appqmlroot", "ui/Application.qml", i18n("The Application's root QML file"));
+    package.addFileDefinition("appqmlroot", QStringLiteral("ui/Application.qml"), i18n("The Application's root QML file"));
     package.setRequired("appqmlroot", true);
     
+    if (!package.isValid())
+    {
+        package.setDefaultPackageRoot(QStringLiteral("/usr/share/kpackage/kcms"));
+        package.setPath(QStringLiteral("kcm_fancontrol"));
+        package.addFileDefinition("appqmlroot", QStringLiteral("ui/Application.qml"), i18n("The Application's root QML file"));
+        package.setRequired("appqmlroot", true);
+    }
+    
     if (package.isValid())
         engine->load(QUrl::fromLocalFile(package.filePath("appqmlroot")));
 

+ 7 - 1
helper/CMakeLists.txt

@@ -15,4 +15,10 @@ target_link_libraries(fancontrol-gui-helper ${LIBRARIES})
 install(TARGETS fancontrol-gui-helper DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
 
 kauth_install_helper_files(fancontrol-gui-helper fancontrol.gui.helper root)
-kauth_install_actions(fancontrol.gui.helper fancontrol_gui.actions)
+kauth_install_actions(fancontrol.gui.helper fancontrol_gui.actions)
+
+message(STATUS "${CMAKE_INSTALL_PREFIX}")
+
+if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr") 
+    install(SCRIPT MoveSystemFiles.cmake)
+endif(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr")

+ 31 - 0
helper/MoveSystemFiles.cmake

@@ -0,0 +1,31 @@
+# file(RENAME "${CMAKE_INSTALL_PREFIX} "/etc/dbus-1/system.d/fancontrol.gui.helper.conf")
+# file(RENAME "${CMAKE_INSTALL_PREFIX}/lib/kauth/fancontrol-gui-helper" "/usr/lib/kauth/fancontrol-gui-helper")
+# file(RENAME "${CMAKE_INSTALL_PREFIX}/share/dbus-1/system-services/fancontrol.gui.helper.service" "/usr/share/dbus-1/system-services/fancontrol.gui.helper.service")
+
+set(helper_conf_file "etc/dbus-1/system.d/fancontrol.gui.helper.conf")
+set(helper_bin_file "lib/kauth/fancontrol-gui-helper")
+set(helper_service_file "share/dbus-1/system-services/fancontrol.gui.helper.service")
+
+execute_process(COMMAND ln -sf ${CMAKE_INSTALL_PREFIX}/${helper_conf_file} /${helper_conf_file} RESULT_VARIABLE result OUTPUT_VARIABLE output)
+message(STATUS "Creating symlink: /${helper_conf_file} -> ${CMAKE_INSTALL_PREFIX}/${helper_conf_file}")
+
+if(${result})
+    message(WARNING "Creation of symlink /${helper_conf_file} -> ${CMAKE_INSTALL_PREFIX}/${helper_conf_file} ${result} ${output} failed:")
+    message(WARNING "${output}")
+endif(${result})
+
+execute_process(COMMAND ln -sf ${CMAKE_INSTALL_PREFIX}/${helper_bin_file} /usr/${helper_bin_file} RESULT_VARIABLE result OUTPUT_VARIABLE output)
+message(STATUS "Creating symlink: /usr/${helper_bin_file} -> ${CMAKE_INSTALL_PREFIX}/${helper_bin_file}")
+
+if(${result})
+    message(WARNING "Creation of symlink /${helper_conf_file} -> ${CMAKE_INSTALL_PREFIX}/${helper_conf_file} ${result} ${output} failed:")
+    message(WARNING "${output}")
+endif(${result})
+
+execute_process(COMMAND ln -sf ${CMAKE_INSTALL_PREFIX}/${helper_service_file} /usr/${helper_service_file} RESULT_VARIABLE result OUTPUT_VARIABLE output)
+message(STATUS "Creating symlink: /usr/${helper_service_file} -> ${CMAKE_INSTALL_PREFIX}/${helper_service_file}")
+
+if(${result})
+    message(WARNING "Creation of symlink /${helper_conf_file} -> ${CMAKE_INSTALL_PREFIX}/${helper_conf_file} ${result} ${output} failed:")
+    message(WARNING "${output}")
+endif(${result})