Updater: Add CMake option BUILD_UPDATER to make the updater optional

- Default: BUILD_UPDATER = NO

  To ease builds for distro packages and contributors (regardless of the specified update URL)

- Enable updater build for Drone CI and AppImage builds

Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
Michael Schuster 2020-03-09 01:48:07 +01:00
parent c812d896aa
commit e833e86da6
9 changed files with 67 additions and 22 deletions

View file

@ -22,7 +22,7 @@ steps:
source /opt/qt57/bin/qt57-env.sh && source /opt/qt57/bin/qt57-env.sh &&
mkdir build && mkdir build &&
cd build && cd build &&
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ && cmake -D NO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
make && make &&
useradd -m -s /bin/bash test && useradd -m -s /bin/bash test &&
chown -R test:test . && chown -R test:test . &&
@ -59,7 +59,7 @@ steps:
source /opt/qt58/bin/qt58-env.sh && source /opt/qt58/bin/qt58-env.sh &&
mkdir build && mkdir build &&
cd build && cd build &&
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ && cmake -D NO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
make && make &&
useradd -m -s /bin/bash test && useradd -m -s /bin/bash test &&
chown -R test:test . && chown -R test:test . &&
@ -96,7 +96,7 @@ steps:
source /opt/qt59/bin/qt59-env.sh && source /opt/qt59/bin/qt59-env.sh &&
mkdir build && mkdir build &&
cd build && cd build &&
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ && cmake -D NO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
make && make &&
useradd -m -s /bin/bash test && useradd -m -s /bin/bash test &&
chown -R test:test . && chown -R test:test . &&
@ -137,7 +137,7 @@ steps:
source /opt/qt510/bin/qt510-env.sh && source /opt/qt510/bin/qt510-env.sh &&
mkdir build && mkdir build &&
cd build && cd build &&
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ && cmake -D NO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
make && make &&
useradd -m -s /bin/bash test && useradd -m -s /bin/bash test &&
chown -R test:test . && chown -R test:test . &&
@ -178,7 +178,7 @@ steps:
source /opt/qt511/bin/qt511-env.sh && source /opt/qt511/bin/qt511-env.sh &&
mkdir build && mkdir build &&
cd build && cd build &&
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ && cmake -D NO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
make && make &&
useradd -m -s /bin/bash test && useradd -m -s /bin/bash test &&
chown -R test:test . && chown -R test:test . &&
@ -219,7 +219,7 @@ steps:
source /opt/qt511/bin/qt511-env.sh && source /opt/qt511/bin/qt511-env.sh &&
mkdir build && mkdir build &&
cd build && cd build &&
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ && cmake -D NO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
make && make &&
useradd -m -s /bin/bash test && useradd -m -s /bin/bash test &&
chown -R test:test . && chown -R test:test . &&
@ -268,7 +268,7 @@ steps:
export PKG_CONFIG_PATH=\$QT_BASE_DIR/lib/pkgconfig:\$PKG_CONFIG_PATH && export PKG_CONFIG_PATH=\$QT_BASE_DIR/lib/pkgconfig:\$PKG_CONFIG_PATH &&
mkdir build && mkdir build &&
cd build && cd build &&
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ && cmake -D NO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
make && make &&
useradd -m -s /bin/bash test && useradd -m -s /bin/bash test &&
chown -R test:test . && chown -R test:test . &&
@ -317,7 +317,7 @@ steps:
export PKG_CONFIG_PATH=\$QT_BASE_DIR/lib/pkgconfig:\$PKG_CONFIG_PATH && export PKG_CONFIG_PATH=\$QT_BASE_DIR/lib/pkgconfig:\$PKG_CONFIG_PATH &&
mkdir build && mkdir build &&
cd build && cd build &&
cmake -D NO_SHIBBOLETH=1 -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ && cmake -D NO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../ &&
make && make &&
useradd -m -s /bin/bash test && useradd -m -s /bin/bash test &&
chown -R test:test . && chown -R test:test . &&

View file

@ -123,6 +123,15 @@ if(NO_MSG_HANDLER)
add_definitions(-DNO_MSG_HANDLER=1) add_definitions(-DNO_MSG_HANDLER=1)
endif() endif()
# this option builds the updater
option(BUILD_UPDATER "BUILD_UPDATER" OFF)
if(BUILD_UPDATER)
message("Compiling with updater")
add_definitions(-DBUILD_UPDATER=1)
else()
message("Compiling without updater")
endif()
# this option builds the shell integration # this option builds the shell integration
option(BUILD_SHELL_INTEGRATION "BUILD_SHELL_INTEGRATION" ON) option(BUILD_SHELL_INTEGRATION "BUILD_SHELL_INTEGRATION" ON)
@ -172,9 +181,9 @@ if(APPLE)
endif() endif()
if(BUILD_CLIENT) if(BUILD_CLIENT)
if(APPLE) if(APPLE AND BUILD_UPDATER)
find_package(Sparkle) find_package(Sparkle)
endif(APPLE) endif()
if(UNIX) if(UNIX)
find_package(INotify REQUIRED) find_package(INotify REQUIRED)

View file

@ -24,6 +24,9 @@ option( WITH_CRASHREPORTER "Build crashreporter" OFF )
#set( CRASHREPORTER_SUBMIT_URL "https://crash-reports.owncloud.com/submit" CACHE STRING "URL for crash reporter" ) #set( CRASHREPORTER_SUBMIT_URL "https://crash-reports.owncloud.com/submit" CACHE STRING "URL for crash reporter" )
#set( CRASHREPORTER_ICON ":/owncloud-icon.png" ) #set( CRASHREPORTER_ICON ":/owncloud-icon.png" )
## Updater options
option( BUILD_UPDATER "Build updater" OFF )
option( WITH_PROVIDERS "Build with providers list" ON ) option( WITH_PROVIDERS "Build with providers list" ON )

View file

@ -38,6 +38,7 @@ mkdir build-client
cd build-client cd build-client
cmake -D CMAKE_INSTALL_PREFIX=/usr \ cmake -D CMAKE_INSTALL_PREFIX=/usr \
-D NO_SHIBBOLETH=1 \ -D NO_SHIBBOLETH=1 \
-D BUILD_UPDATER=ON \
-D QTKEYCHAIN_LIBRARY=/app/usr/lib/x86_64-linux-gnu/libqt5keychain.so \ -D QTKEYCHAIN_LIBRARY=/app/usr/lib/x86_64-linux-gnu/libqt5keychain.so \
-D QTKEYCHAIN_INCLUDE_DIR=/app/usr/include/qt5keychain/ \ -D QTKEYCHAIN_INCLUDE_DIR=/app/usr/include/qt5keychain/ \
-DMIRALL_VERSION_SUFFIX=PR-$DRONE_PULL_REQUEST \ -DMIRALL_VERSION_SUFFIX=PR-$DRONE_PULL_REQUEST \

View file

@ -3,7 +3,10 @@ find_package(Qt5 REQUIRED COMPONENTS Widgets Svg Qml Quick)
set(CMAKE_AUTOMOC TRUE) set(CMAKE_AUTOMOC TRUE)
set(CMAKE_AUTOUIC TRUE) set(CMAKE_AUTOUIC TRUE)
set(CMAKE_AUTORCC TRUE) set(CMAKE_AUTORCC TRUE)
add_subdirectory(updater)
IF(BUILD_UPDATER)
add_subdirectory(updater)
endif()
set(MIRALL_RC_SRC ../../resources.qrc) set(MIRALL_RC_SRC ../../resources.qrc)
if (EXISTS "${OEM_THEME_DIR}/theme.qrc") if (EXISTS "${OEM_THEME_DIR}/theme.qrc")
@ -139,18 +142,20 @@ IF(NOT NO_SHIBBOLETH)
) )
endif() endif()
set(updater_SRCS IF(BUILD_UPDATER)
set(updater_SRCS
updater/ocupdater.cpp updater/ocupdater.cpp
updater/updateinfo.cpp updater/updateinfo.cpp
updater/updater.cpp updater/updater.cpp
) )
endif()
IF( APPLE ) IF( APPLE )
list(APPEND client_SRCS cocoainitializer_mac.mm) list(APPEND client_SRCS cocoainitializer_mac.mm)
list(APPEND client_SRCS socketapisocket_mac.mm) list(APPEND client_SRCS socketapisocket_mac.mm)
list(APPEND client_SRCS systray.mm) list(APPEND client_SRCS systray.mm)
if(SPARKLE_FOUND) if(SPARKLE_FOUND AND BUILD_UPDATER)
# Define this, we need to check in updater.cpp # Define this, we need to check in updater.cpp
add_definitions( -DHAVE_SPARKLE ) add_definitions( -DHAVE_SPARKLE )
list(APPEND updater_SRCS updater/sparkleupdater_mac.mm) list(APPEND updater_SRCS updater/sparkleupdater_mac.mm)
@ -298,9 +303,11 @@ else()
install(FILES ${qtkeychain_I18N} DESTINATION ${QM_DIR}) install(FILES ${qtkeychain_I18N} DESTINATION ${QM_DIR})
endif() endif()
add_library(updater STATIC ${updater_SRCS}) IF(BUILD_UPDATER)
target_link_libraries(updater ${synclib_NAME} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml Qt5::WebEngineWidgets) add_library(updater STATIC ${updater_SRCS})
target_include_directories(updater PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(updater ${synclib_NAME} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml)
target_include_directories(updater PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
endif()
set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY} RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY}
@ -309,9 +316,11 @@ set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE};${CMAKE_INSTALL_RPATH}" ) INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE};${CMAKE_INSTALL_RPATH}" )
target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick) target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick Qt5::WebEngineWidgets)
target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} ) target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
target_link_libraries( ${APPLICATION_EXECUTABLE} updater ) IF(BUILD_UPDATER)
target_link_libraries( ${APPLICATION_EXECUTABLE} updater )
endif()
target_link_libraries( ${APPLICATION_EXECUTABLE} ${OS_SPECIFIC_LINK_LIBRARIES} ) target_link_libraries( ${APPLICATION_EXECUTABLE} ${OS_SPECIFIC_LINK_LIBRARIES} )
IF( LIBCLOUDPROVIDERS_FOUND ) IF( LIBCLOUDPROVIDERS_FOUND )
string(TOLOWER "${APPLICATION_VENDOR}" DBUS_VENDOR) string(TOLOWER "${APPLICATION_VENDOR}" DBUS_VENDOR)
@ -334,6 +343,7 @@ target_include_directories(${APPLICATION_EXECUTABLE} PRIVATE
${CMAKE_SOURCE_DIR}/src/3rdparty/qtsingleapplication ${CMAKE_SOURCE_DIR}/src/3rdparty/qtsingleapplication
${CMAKE_SOURCE_DIR}/src/3rdparty/kmessagewidget ${CMAKE_SOURCE_DIR}/src/3rdparty/kmessagewidget
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
) )
## handle DBUS for Fdo notifications ## handle DBUS for Fdo notifications

View file

@ -34,7 +34,11 @@
#include "sharedialog.h" #include "sharedialog.h"
#include "accountmanager.h" #include "accountmanager.h"
#include "creds/abstractcredentials.h" #include "creds/abstractcredentials.h"
#if defined(BUILD_UPDATER)
#include "updater/ocupdater.h" #include "updater/ocupdater.h"
#endif
#include "owncloudsetupwizard.h" #include "owncloudsetupwizard.h"
#include "version.h" #include "version.h"
@ -254,12 +258,14 @@ Application::Application(int &argc, char **argv)
connect(&_networkConfigurationManager, &QNetworkConfigurationManager::configurationChanged, connect(&_networkConfigurationManager, &QNetworkConfigurationManager::configurationChanged,
this, &Application::slotSystemOnlineConfigurationChanged); this, &Application::slotSystemOnlineConfigurationChanged);
#if defined(BUILD_UPDATER)
// Update checks // Update checks
UpdaterScheduler *updaterScheduler = new UpdaterScheduler(this); UpdaterScheduler *updaterScheduler = new UpdaterScheduler(this);
connect(updaterScheduler, &UpdaterScheduler::updaterAnnouncement, connect(updaterScheduler, &UpdaterScheduler::updaterAnnouncement,
_gui.data(), &ownCloudGui::slotShowTrayMessage); _gui.data(), &ownCloudGui::slotShowTrayMessage);
connect(updaterScheduler, &UpdaterScheduler::requestRestart, connect(updaterScheduler, &UpdaterScheduler::requestRestart,
_folderManager.data(), &FolderMan::slotScheduleAppRestart); _folderManager.data(), &FolderMan::slotScheduleAppRestart);
#endif
// Cleanup at Quit. // Cleanup at Quit.
connect(this, &QCoreApplication::aboutToQuit, this, &Application::slotCleanup); connect(this, &QCoreApplication::aboutToQuit, this, &Application::slotCleanup);

View file

@ -23,8 +23,11 @@
#include "accountmanager.h" #include "accountmanager.h"
#include "synclogdialog.h" #include "synclogdialog.h"
#if defined(BUILD_UPDATER)
#include "updater/updater.h" #include "updater/updater.h"
#include "updater/ocupdater.h" #include "updater/ocupdater.h"
#endif
#include "ignorelisteditor.h" #include "ignorelisteditor.h"
#include "common/utility.h" #include "common/utility.h"
@ -150,6 +153,7 @@ void GeneralSettings::loadMiscSettings()
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
} }
#if defined(BUILD_UPDATER)
void GeneralSettings::slotUpdateInfo() void GeneralSettings::slotUpdateInfo()
{ {
// Note: the sparkle-updater is not an OCUpdater // Note: the sparkle-updater is not an OCUpdater
@ -202,6 +206,7 @@ void GeneralSettings::slotToggleAutoUpdateCheck()
bool isChecked = _ui->autoCheckForUpdatesCheckBox->isChecked(); bool isChecked = _ui->autoCheckForUpdatesCheckBox->isChecked();
cfgFile.setAutoUpdateCheck(isChecked, QString()); cfgFile.setAutoUpdateCheck(isChecked, QString());
} }
#endif // defined(BUILD_UPDATER)
void GeneralSettings::saveMiscSettings() void GeneralSettings::saveMiscSettings()
{ {
@ -269,8 +274,12 @@ void GeneralSettings::customizeStyle()
Theme::replaceLinkColorStringBackgroundAware(about); Theme::replaceLinkColorStringBackgroundAware(about);
_ui->aboutLabel->setText(about); _ui->aboutLabel->setText(about);
#if defined(BUILD_UPDATER)
// updater info // updater info
slotUpdateInfo(); slotUpdateInfo();
#else
_ui->updatesGroupBox->setVisible(false);
#endif
} }
} // namespace OCC } // namespace OCC

View file

@ -50,9 +50,11 @@ private slots:
void slotIgnoreFilesEditor(); void slotIgnoreFilesEditor();
void loadMiscSettings(); void loadMiscSettings();
void slotShowLegalNotice(); void slotShowLegalNotice();
#if defined(BUILD_UPDATER)
void slotUpdateInfo(); void slotUpdateInfo();
void slotUpdateCheckNow(); void slotUpdateCheckNow();
void slotToggleAutoUpdateCheck(); void slotToggleAutoUpdateCheck();
#endif
private: private:
void customizeStyle(); void customizeStyle();

View file

@ -26,7 +26,9 @@
#include "common/utility.h" #include "common/utility.h"
#include "cocoainitializer.h" #include "cocoainitializer.h"
#if defined(BUILD_UPDATER)
#include "updater/updater.h" #include "updater/updater.h"
#endif
#include <QTimer> #include <QTimer>
#include <QMessageBox> #include <QMessageBox>
@ -103,6 +105,8 @@ int main(int argc, char **argv)
} }
} }
#endif #endif
#if defined(BUILD_UPDATER)
// if handleStartup returns true, main() // if handleStartup returns true, main()
// needs to terminate here, e.g. because // needs to terminate here, e.g. because
// the updater is triggered // the updater is triggered
@ -110,6 +114,7 @@ int main(int argc, char **argv)
if (updater && updater->handleStartup()) { if (updater && updater->handleStartup()) {
return 1; return 1;
} }
#endif
// if the application is already running, notify it. // if the application is already running, notify it.
if (app.isRunning()) { if (app.isRunning()) {