From f5e8efd435aad3273c73d95944322f2f74c2b1ff Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Mon, 9 Dec 2013 16:35:30 +0100 Subject: [PATCH] Add build number into versioning scheme This is an enabler to improve update experience --- OwnCloudCPack.cmake | 9 +++++---- VERSION.cmake | 25 ++++++++++++++++++++----- cmake/modules/MacOSXBundleInfo.plist.in | 6 +++--- cmake/modules/NSIS.template.in | 10 +++++++--- src/CMakeLists.txt | 4 ++-- src/mirall/owncloudtheme.cpp | 2 +- src/mirall/theme.cpp | 5 +++++ src/mirall/theme.h | 5 +++++ src/mirall/updatedetector.cpp | 12 +++++------- src/mirall/version.h.in | 19 ++++++++++++------- 10 files changed, 65 insertions(+), 32 deletions(-) diff --git a/OwnCloudCPack.cmake b/OwnCloudCPack.cmake index 3b7a4ac8f..d2c4c4a17 100644 --- a/OwnCloudCPack.cmake +++ b/OwnCloudCPack.cmake @@ -9,10 +9,11 @@ else () endif() include( VERSION.cmake ) -set( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) -set( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) -set( CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH} ) -set( CPACK_PACKAGE_VERSION ${VERSION} ) +set( CPACK_PACKAGE_VERSION_MAJOR ${MIRALL_VERSION_MAJOR} ) +set( CPACK_PACKAGE_VERSION_MINOR ${MIRALL_VERSION_MINOR} ) +set( CPACK_PACKAGE_VERSION_PATCH ${MIRALL_VERSION_PATCH} ) +set( CPACK_PACKAGE_VERSION_BUILD ${MIRALL_VERSION_BUILD} ) +set( CPACK_PACKAGE_VERSION ${MIRALL_VERSION_FULL} ) if(APPLE) set( CPACK_GENERATOR "DragNDrop" ) diff --git a/VERSION.cmake b/VERSION.cmake index 6f3ed480d..0b6bc189e 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -1,6 +1,21 @@ -set( VERSION_MAJOR 1 ) -set( VERSION_MINOR 5 ) -set( VERSION_PATCH 0 ) -set( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SUFFIX}beta2") -set( SOVERSION 0 ) +set( MIRALL_VERSION_MAJOR 1 ) +set( MIRALL_VERSION_MINOR 5 ) +set( MIRALL_VERSION_PATCH 0 ) +set( MIRALL_SOVERSION 0 ) +set( MIRALL_VERSION_SUFFIX "" CACHE STRING "e.g. beta1, beta2, rc1" ) +set( MIRALL_VERSION_BUILD "0" CACHE STRING "Integer ID. Generated by the build system") + +# Composite defines +# Used e.g. for libraries Keep at x.y.z. +set( MIRALL_VERSION "${MIRALL_VERSION_MAJOR}.${MIRALL_VERSION_MINOR}.${MIRALL_VERSION_PATCH}" ) +# Version with Build ID. Used in the installer +set( MIRALL_VERSION_FULL ${MIRALL_VERSION} ) +set( MIRALL_VERSION_STRING ${MIRALL_VERSION} ) +set( MIRALL_VERSION_FULL "${MIRALL_VERSION_FULL}.${MIRALL_VERSION_BUILD}" ) + +if( MIRALL_VERSION_SUFFIX ) + set( MIRALL_VERSION_STRING "${MIRALL_VERSION} ${MIRALL_VERSION_SUFFIX} (build ${MIRALL_VERSION_BUILD})" ) +else( MIRALL_VERSION_SUFFIX ) + set( MIRALL_VERSION_STRING "${MIRALL_VERSION} (build ${MIRALL_VERSION_BUILD})" ) +endif( MIRALL_VERSION_SUFFIX ) diff --git a/cmake/modules/MacOSXBundleInfo.plist.in b/cmake/modules/MacOSXBundleInfo.plist.in index 2998885fa..e31f21eb3 100644 --- a/cmake/modules/MacOSXBundleInfo.plist.in +++ b/cmake/modules/MacOSXBundleInfo.plist.in @@ -17,15 +17,15 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString - @APPLICATION_NAME@ @VERSION@ + @APPLICATION_NAME@ @MIRALL_VERSION_FULL@ CFBundlePackageType APPL CFBundleSignature ???? CFBundleVersion - @VERSION@ + @VERSION_FULL@ CFBundleShortVersionString - @VERSION@ + @VERSION_FULL@ NSHumanReadableCopyright (C) 2012 @APPLICATION_VENDOR@ diff --git a/cmake/modules/NSIS.template.in b/cmake/modules/NSIS.template.in index 6c4c75055..73a2b7b20 100644 --- a/cmake/modules/NSIS.template.in +++ b/cmake/modules/NSIS.template.in @@ -49,7 +49,8 @@ !define VER_MAJOR "@CPACK_PACKAGE_VERSION_MAJOR@" !define VER_MINOR "@CPACK_PACKAGE_VERSION_MINOR@" -!define VER_BUILD "@CPACK_PACKAGE_VERSION_PATCH@" +!define VER_PATCH "@CPACK_PACKAGE_VERSION_PATCH@" +!define VER_BUILD "@CPACK_PACKAGE_VERSION_BUILD@" !define VERSION "@CPACK_PACKAGE_VERSION@" ;----------------------------------------------------------------------------- @@ -205,7 +206,10 @@ Function PageReinstall IntCmp $R0 ${VER_MAJOR} minor_check new_version older_version minor_check: ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionMinor" - IntCmp $R0 ${VER_MINOR} build_check new_version older_version + IntCmp $R0 ${VER_MINOR} rev_check new_version older_version + rev_check: + ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionRevision" + IntCmp $R0 ${VER_PATCH} build_check new_version older_version build_check: ReadRegDWORD $R0 HKLM "Software\${APPLICATION_NAME}" "VersionBuild" IntCmp $R0 ${VER_BUILD} same_version new_version older_version @@ -410,7 +414,7 @@ Section -post WriteRegStr HKLM "Software\${APPLICATION_NAME}" "" $INSTDIR WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionMajor" "${VER_MAJOR}" WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionMinor" "${VER_MINOR}" - WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionRevision" "${REVISION}" + WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionRevision" "${VER_PATCH}" WriteRegDWORD HKLM "Software\${APPLICATION_NAME}" "VersionBuild" "${VER_BUILD}" ;Add or Remove Programs entry. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54f24093d..4bd8b6b64 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -199,8 +199,8 @@ add_library(${synclib_NAME} SHARED ${libsync_SRCS} ${syncMoc}) qt5_use_modules(${synclib_NAME} Widgets Network Xml WebKitWidgets Sql) set_target_properties( ${synclib_NAME} PROPERTIES - VERSION ${VERSION} - SOVERSION ${SOVERSION} + VERSION ${MIRALL_VERSION} + SOVERSION ${MIRALL_SOVERSION} ) target_link_libraries(${synclib_NAME} ${libsync_LINK_TARGETS} ) diff --git a/src/mirall/owncloudtheme.cpp b/src/mirall/owncloudtheme.cpp index 8abb1346d..335bb7c9f 100644 --- a/src/mirall/owncloudtheme.cpp +++ b/src/mirall/owncloudtheme.cpp @@ -60,7 +60,7 @@ QString ownCloudTheme::about() const "Based on Mirall by Duncan Mac-Vicar P.

" "%7" ) - .arg(MIRALL_STRINGIFY(MIRALL_VERSION)) + .arg(MIRALL_VERSION_STRING) .arg("http://" MIRALL_STRINGIFY(APPLICATION_DOMAIN)) .arg(MIRALL_STRINGIFY(APPLICATION_DOMAIN)) .arg(devString); diff --git a/src/mirall/theme.cpp b/src/mirall/theme.cpp index ce6a85c74..d103041d6 100644 --- a/src/mirall/theme.cpp +++ b/src/mirall/theme.cpp @@ -193,6 +193,11 @@ bool Theme::systrayUseMonoIcons() const return _mono; } +QString Theme::updateCheckUrl() const +{ + return QLatin1String("https://updates.owncloud.com/client/"); +} + QString Theme::about() const { return QString::null; diff --git a/src/mirall/theme.h b/src/mirall/theme.h index 11a66b8cd..d819ce29f 100644 --- a/src/mirall/theme.h +++ b/src/mirall/theme.h @@ -170,6 +170,11 @@ public: */ bool systrayUseMonoIcons() const; + /** + * @brief Where to check for new Updates. + */ + virtual QString updateCheckUrl() const; + protected: QIcon themeIcon(const QString& name, bool sysTray = false) const; Theme() {} diff --git a/src/mirall/updatedetector.cpp b/src/mirall/updatedetector.cpp index 42be36d41..34192333e 100644 --- a/src/mirall/updatedetector.cpp +++ b/src/mirall/updatedetector.cpp @@ -41,8 +41,7 @@ void UpdateDetector::versionCheck( Theme *theme ) { connect(_accessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotVersionInfoArrived(QNetworkReply*)) ); - QUrl url(QLatin1String("https://download.owncloud.com/clientupdater.php")); - QString ver = QString::fromLatin1("%1.%2.%3").arg(MIRALL_VERSION_MAJOR).arg(MIRALL_VERSION_MINOR).arg(MIRALL_VERSION_MICRO); + QUrl url(Theme::instance()->updateCheckUrl()); QString platform = QLatin1String("stranger"); #ifdef Q_OS_LINUX @@ -60,7 +59,8 @@ void UpdateDetector::versionCheck( Theme *theme ) if( !sysInfo.isEmpty() ) { url.addQueryItem(QLatin1String("client"), sysInfo ); } - url.addQueryItem( QLatin1String("version"), ver ); + url.addQueryItem( QLatin1String("version"), + QLatin1String(MIRALL_STRINGIFY(MIRALL_VERSION_FULL)) ); url.addQueryItem( QLatin1String("platform"), platform ); url.addQueryItem( QLatin1String("oem"), theme->appName() ); @@ -99,9 +99,6 @@ QString UpdateDetector::getSystemInfo() void UpdateDetector::showDialog() { - // if the version tag is set, there is a newer version. - QString ver = QString::fromLatin1("%1.%2.%3") - .arg(MIRALL_VERSION_MAJOR).arg(MIRALL_VERSION_MINOR).arg(MIRALL_VERSION_MICRO); QDialog *msgBox = new QDialog; QIcon info = msgBox->style()->standardIcon(QStyle::SP_MessageBoxInformation, 0, 0); @@ -121,7 +118,8 @@ void UpdateDetector::showDialog() QLabel *lbl = new QLabel; QString txt = tr("

A new version of the %1 Client is available.

" "

%2 is available for download. The installed version is %3.

") - .arg(Theme::instance()->appNameGUI()).arg(ocClient.versionstring()).arg(ver); + .arg(Theme::instance()->appNameGUI()).arg(ocClient.versionstring()) + .arg(QLatin1String(MIRALL_STRINGIFY(MIRALL_VERSION_FULL))); lbl->setText(txt); lbl->setTextFormat(Qt::RichText); diff --git a/src/mirall/version.h.in b/src/mirall/version.h.in index 7e2cd661b..e661bd98b 100644 --- a/src/mirall/version.h.in +++ b/src/mirall/version.h.in @@ -19,17 +19,22 @@ #define MIRALL_TOSTRING(s) #s /* MIRALL version macros */ -#define MIRALL_VERSION_INT_(a, b, c) ((a) << 16 | (b) << 8 | (c)) +#define MIRALL_VERSION_INT_(a, b, c, d) ((a) << 24 | (b) << 16 | (c << 8) | (d)) /* MIRALL version */ -#define MIRALL_VERSION_MAJOR @VERSION_MAJOR@ -#define MIRALL_VERSION_MINOR @VERSION_MINOR@ -#define MIRALL_VERSION_MICRO @VERSION_PATCH@ -#define MIRALL_VERSION @VERSION@ +#define MIRALL_VERSION_MAJOR @MIRALL_VERSION_MAJOR@ +#define MIRALL_VERSION_MINOR @MIRALL_VERSION_MINOR@ +#define MIRALL_VERSION_PATCH @MIRALL_VERSION_PATCH@ +#define MIRALL_VERSION_BUILD @MIRALL_VERSION_BUILD@ + +#define MIRALL_VERSION @MIRALL_VERSION@ +#define MIRALL_VERSION_FULL @MIRALL_VERSION_FULL@ + +#define MIRALL_VERSION_STRING "@MIRALL_VERSION_STRING@" #define MIRALL_VERSION_INT MIRALL_VERSION_INT_(MIRALL_VERSION_MAJOR, \ MIRALL_VERSION_MINOR, \ - MIRALL_VERSION_MICRO) - + MIRALL_VERSION_PATCH, \ + MIRALL_VERSION_BUILD) #endif // VERSION_H