File packaging.diff of Package owncloud-client

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 20a0de8be..d4eeb78b2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,16 +22,19 @@ else()
     set(APPLICATION_REV_DOMAIN_INSTALLER ${APPLICATION_REV_DOMAIN})
 endif()
 
-if (NOT DEFINED APPLICATION_SHORTNAME)
-     set ( APPLICATION_SHORTNAME ${APPLICATION_NAME} )
-endif()
-
 # For usage in XML files we preprocess
 string(REPLACE "&" "&" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME}")
 string(REPLACE "<" "&lt;" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
 string(REPLACE ">" "&gt;" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME_XML_ESCAPED}")
 
-set(PACKAGE "${APPLICATION_SHORTNAME}-client")
+if (NOT DEFINED LINUX_PACKAGE_SHORTNAME)
+    set(LINUX_PACKAGE_SHORTNAME "${APPLICATION_SHORTNAME}")
+endif()
+
+if (NOT DEFINED PACKAGE)
+    set(PACKAGE "${LINUX_PACKAGE_SHORTNAME}-client")
+endif()
+
 set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
 
 if(NOT CRASHREPORTER_EXECUTABLE)
@@ -120,7 +123,22 @@ if(NO_MSG_HANDLER)
    add_definitions(-DNO_MSG_HANDLER=1)
 endif()
 
-# this option creates only libocsync and libowncloudsync
+# this option builds the shell integration
+option(BUILD_SHELL_INTEGRATION "BUILD_SHELL_INTEGRATION" ON)
+
+# this option builds/installs the generic shell integration icons
+option(BUILD_SHELL_INTEGRATION_ICONS "BUILD_SHELL_INTEGRATION_ICONS" ON)
+
+# this options builds the dolphin integration plugin
+option(BUILD_SHELL_INTEGRATION_DOLPHIN "BUILD_SHELL_INTEGRATION_DOLPHIN" ON)
+
+# this options builds the nautilus (like) integration plugins
+option(BUILD_SHELL_INTEGRATION_NAUTILUS "BUILD_SHELL_INTEGRATION_NAUTILUS" ON)
+
+# this option builds the client
+option(BUILD_CLIENT "BUILD_CLIENT" ON)
+
+# this option creates only libocsync and libowncloudsync (NOTE: BUILD_CLIENT needs to be on)
 option(BUILD_LIBRARIES_ONLY "BUILD_LIBRARIES_ONLY" OFF)
 
 # When this option is enabled, 5xx errors are not added to the blacklist
@@ -153,30 +171,32 @@ if(APPLE)
   set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
 endif()
 
-find_package(OpenSSL 1.0.0 REQUIRED)
+if(BUILD_CLIENT)
+    find_package(OpenSSL 1.0.0 REQUIRED)
 
-if(APPLE)
-  find_package(Sparkle)
-endif(APPLE)
+    if(APPLE)
+    find_package(Sparkle)
+    endif(APPLE)
 
-if(UNIX)
-  find_package(INotify REQUIRED)
-else()
-  find_package(INotify)
-endif()
-find_package(Sphinx)
-find_package(PdfLatex)
-
-find_package(SQLite3 3.8.0 REQUIRED)
-# On some OS, we want to use our own, not the system sqlite
-if (USE_OUR_OWN_SQLITE3)
-    include_directories(BEFORE ${SQLITE3_INCLUDE_DIR})
-    if (WIN32)
-        add_definitions(-DSQLITE_API=__declspec\(dllimport\))
+    if(UNIX)
+    find_package(INotify REQUIRED)
+    else()
+    find_package(INotify)
+    endif()
+    find_package(Sphinx)
+    find_package(PdfLatex)
+
+    find_package(SQLite3 3.8.0 REQUIRED)
+    # On some OS, we want to use our own, not the system sqlite
+    if (USE_OUR_OWN_SQLITE3)
+        include_directories(BEFORE ${SQLITE3_INCLUDE_DIR})
+        if (WIN32)
+            add_definitions(-DSQLITE_API=__declspec\(dllimport\))
+        endif()
     endif()
-endif()
 
-find_package(ZLIB)
+    find_package(ZLIB)
+endif()
 
 configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
@@ -195,14 +215,19 @@ endif( WIN32 )
 file( GLOB TRANS_FILES ${CMAKE_SOURCE_DIR}/translations/client_*.ts)
 set(TRANSLATIONS ${TRANS_FILES})
 
-add_subdirectory(csync)
-add_subdirectory(src)
-if(NOT BUILD_LIBRARIES_ONLY)
-add_subdirectory(shell_integration)
-add_subdirectory(doc)
-add_subdirectory(doc/dev)
-add_subdirectory(admin)
-endif(NOT BUILD_LIBRARIES_ONLY)
+if(BUILD_CLIENT)
+    add_subdirectory(csync)
+    add_subdirectory(src)
+    if(NOT BUILD_LIBRARIES_ONLY)
+        add_subdirectory(doc)
+        add_subdirectory(doc/dev)
+        add_subdirectory(admin)
+    endif()
+endif()
+
+if(BUILD_SHELL_INTEGRATION)
+    add_subdirectory(shell_integration)
+endif()
 
 if(UNIT_TESTING)
     include(CTest)
@@ -213,7 +238,7 @@ endif(UNIT_TESTING)
 if(BUILD_OWNCLOUD_OSX_BUNDLE)
     install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
     configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
-else()
+elseif(BUILD_CLIENT)
     install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
     configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
 endif()
diff --git a/OWNCLOUD.cmake b/OWNCLOUD.cmake
index 4022212e6..3aaf84785 100644
--- a/OWNCLOUD.cmake
+++ b/OWNCLOUD.cmake
@@ -1,9 +1,12 @@
 set( APPLICATION_NAME       "ownCloud" )
+set( APPLICATION_SHORTNAME  "ownCloud" )
 set( APPLICATION_EXECUTABLE "owncloud" )
 set( APPLICATION_DOMAIN     "owncloud.com" )
 set( APPLICATION_VENDOR     "ownCloud" )
 set( APPLICATION_UPDATE_URL "https://updates.owncloud.com/client/" CACHE string "URL for updater" )
 
+set( LINUX_PACKAGE_SHORTNAME "owncloud" )
+
 set( THEME_CLASS            "ownCloudTheme" )
 set( APPLICATION_REV_DOMAIN "com.owncloud.desktopclient" )
 set( WIN_SETUP_BITMAP_PATH  "${CMAKE_SOURCE_DIR}/admin/win/nsi" )
diff --git a/OwnCloudCPack.cmake b/OwnCloudCPack.cmake
index cad12d1b9..39eee0080 100644
--- a/OwnCloudCPack.cmake
+++ b/OwnCloudCPack.cmake
@@ -48,7 +48,7 @@ if(WIN32)
     set( CPACK_PACKAGE_DESCRIPTION_FILE  "${CMAKE_SOURCE_DIR}/README.md" ) # File used as a description of a project     /path/to/project/ReadMe.txt
     set( CPACK_PACKAGE_DESCRIPTION_SUMMARY  "${APPLICATION_NAME} Syncing Client" ) #  Description summary of a project
     # CPACK_PACKAGE_EXECUTABLES   List of pairs of executables and labels. Used by the NSIS generator to create Start Menu shortcuts.     ccmake;CMake
-    set( CPACK_PACKAGE_INSTALL_DIRECTORY  ${APPLICATION_SHORTNAME} )     # Installation directory on the target system -> C:\Program Files\fellody
+    set( CPACK_PACKAGE_INSTALL_DIRECTORY  ${APPLICATION_SHORTNAME} )     # Installation directory on the target system -> C:\Program Files\${APPLICATION_SHORTNAME}
     set( CPACK_PACKAGE_INSTALL_REGISTRY_KEY ${APPLICATION_SHORTNAME} )  # Registry key used when installing this project  CMake 2.5.0
     set( CPACK_PACKAGE_NAME  ${APPLICATION_NAME} ) # Package name, defaults to the project name
     set( CPACK_PACKAGE_VENDOR  "http://${APPLICATION_DOMAIN}" )   # Package vendor name
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index ad3825223..edf096bed 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -12,10 +12,13 @@ if(SPHINX_FOUND)
     # assets
     set(LATEX_LOGO          "${CMAKE_CURRENT_SOURCE_DIR}/logo-blue.pdf")
 
-    install(DIRECTORY ${SPHINX_HTML_DIR} DESTINATION ${CMAKE_INSTALL_DOCDIR} OPTIONAL)
+    set(APPLICATION_DOC_DIR "${CMAKE_INSTALL_DOCDIR}/${PACKAGE}")
+    install(DIRECTORY ${SPHINX_HTML_DIR} DESTINATION ${APPLICATION_DOC_DIR} OPTIONAL)
+    install(DIRECTORY ${SPHINX_PDF_DIR} DESTINATION ${APPLICATION_DOC_DIR} OPTIONAL)
+    install(DIRECTORY ${SPHINX_QCH_DIR} DESTINATION ${APPLICATION_DOC_DIR} OPTIONAL)
+
     install(DIRECTORY ${SPHINX_MAN_DIR} DESTINATION ${CMAKE_INSTALL_MANDIR} OPTIONAL)
-    install(DIRECTORY ${SPHINX_PDF_DIR} DESTINATION ${CMAKE_INSTALL_DOCDIR} OPTIONAL)
-    install(DIRECTORY ${SPHINX_QCH_DIR} DESTINATION ${CMAKE_INSTALL_DOCDIR} OPTIONAL)
+
 
     configure_file("${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" conf.py @ONLY)
 
diff --git a/shell_integration/CMakeLists.txt b/shell_integration/CMakeLists.txt
index 03b2bbc34..85e539879 100644
--- a/shell_integration/CMakeLists.txt
+++ b/shell_integration/CMakeLists.txt
@@ -1,17 +1,23 @@
 if (APPLE)
   add_subdirectory(MacOSX)
 endif()
-add_subdirectory(icons)
+if(BUILD_SHELL_INTEGRATION_ICONS)
+  add_subdirectory(icons)
+endif()
 
 if( UNIX AND NOT APPLE )
-  add_subdirectory(nautilus)
+  if(BUILD_SHELL_INTEGRATION_NAUTILUS)
+    add_subdirectory(nautilus)
+  endif()
 
-  find_package(ECM 1.2.0 NO_MODULE QUIET)
-  set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-  find_package(KF5 "5.16" COMPONENTS KIO)
-  if(KF5_FOUND)
-    add_subdirectory(dolphin)
-  else()
-    message("Dolphin plugin disabled: KDE Frameworks 5.16 not found")
+  if(BUILD_SHELL_INTEGRATION_DOLPHIN)
+    find_package(ECM 1.2.0 NO_MODULE QUIET)
+    set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+    find_package(KF5 "5.16" COMPONENTS KIO)
+    if(KF5_FOUND)
+        add_subdirectory(dolphin)
+    else()
+        message("Dolphin plugin disabled: KDE Frameworks 5.16 not found")
+    endif()
   endif()
 endif()
diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp
index 553905d8e..78e2a41eb 100644
--- a/src/cmd/cmd.cpp
+++ b/src/cmd/cmd.cpp
@@ -182,8 +182,7 @@ void help()
 }
 
 void showVersion() {
-    const char *binaryName = APPLICATION_EXECUTABLE "cmd";
-    std::cout << binaryName << " version " << qPrintable(Theme::instance()->version()) << std::endl;
+    std::cout << qPrintable(Utility::executableVersionOutput(Theme::instance()));
     exit(0);
 }
 
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 25aaa06ae..f8ca24502 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -5,7 +5,7 @@ add_subdirectory(updater)
 
 #TODO Move resources files
 qt_add_resources(MIRALL_RC_SRC ../../client.qrc)
-if ( IS_DIRECTORY ${OEM_THEME_DIR} )
+if (EXISTS "${OEM_THEME_DIR}/theme.qrc")
     qt_add_resources(MIRALL_RC_SRC ${OEM_THEME_DIR}/theme.qrc)
     set(theme_dir ${OEM_THEME_DIR}/theme)
 else()
diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index 843f8bd0c..5e3f3822f 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -506,20 +506,7 @@ void Application::showHelp()
 
 void Application::showVersion()
 {
-    QString helpText;
-    QTextStream stream(&helpText);
-    stream << _theme->appName().toLatin1().constData()
-           << QLatin1String(" version ")
-           << _theme->version().toLatin1().constData() << endl;
-#ifdef GIT_SHA1
-    stream << "Git revision " << GIT_SHA1 << endl;
-#endif
-    stream << "Using Qt " << qVersion() << ", built against Qt " << QT_VERSION_STR << endl;
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-    stream << "Using '" << QSslSocket::sslLibraryVersionString() << "'" << endl;
-#endif
-
-    displayHelpText(helpText);
+    displayHelpText(Utility::executableVersionOutput(_theme));
 }
 
 void Application::showHint(std::string errorHint)
diff --git a/src/libsync/utility.cpp b/src/libsync/utility.cpp
index 2a140f89e..f6573bae9 100644
--- a/src/libsync/utility.cpp
+++ b/src/libsync/utility.cpp
@@ -18,6 +18,7 @@
 
 #include "version.h"
 #include "configfile.h"
+#include "theme.h"
 
 // Note:  This file must compile without QtGui
 #include <QCoreApplication>
@@ -31,6 +32,7 @@
 #include <QObject>
 #include <QThread>
 #include <QDateTime>
+#include <QSslSocket>
 #include <QSysInfo>
 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
 #include <QTextDocument>
@@ -484,6 +486,24 @@ QByteArray Utility::versionOfInstalledBinary( const QString& command )
     return re;
 }
 
+QString Utility::executableVersionOutput(Theme* theme)
+{
+    QString helpText;
+    QTextStream stream(&helpText);
+    stream << theme->appName().toLatin1().constData()
+           << QLatin1String(" version ")
+           << theme->version().toLatin1().constData() << endl;
+#ifdef GIT_SHA1
+    stream << "Git revision " << GIT_SHA1 << endl;
+#endif
+    stream << "Using Qt " << qVersion() << ", built against Qt " << QT_VERSION_STR << endl;
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    stream << "Using '" << QSslSocket::sslLibraryVersionString() << "'" << endl;
+#endif
+
+    return helpText;
+}
+
 QString Utility::timeAgoInWords(const QDateTime& dt, const QDateTime& from)
 {
     QDateTime now = QDateTime::currentDateTimeUtc();
diff --git a/src/libsync/utility.h b/src/libsync/utility.h
index 5fb60c729..c874930a0 100644
--- a/src/libsync/utility.h
+++ b/src/libsync/utility.h
@@ -29,6 +29,8 @@ class QSettings;
 
 namespace OCC {
 
+class Theme;
+
 /** \addtogroup libsync
  *  @{
  */
@@ -117,6 +119,9 @@ namespace Utility
     // For Mac and Windows, it returns QString()
     OWNCLOUDSYNC_EXPORT QByteArray versionOfInstalledBinary(const QString& command = QString() );
 
+    // Shared `--version` output for gui and cmd
+    OWNCLOUDSYNC_EXPORT QString executableVersionOutput(Theme* theme);
+
     OWNCLOUDSYNC_EXPORT QString fileNameForGuiUse(const QString& fName);
 
     /**
openSUSE Build Service is sponsored by