From 2e6137c2f0be9ff5fc9bc9468115c31cb18a89de Mon Sep 17 00:00:00 2001 From: rinigus Date: Sun, 26 May 2024 14:27:08 +0300 Subject: [PATCH] Add support for new release URL macro (#285) * Use releaseMajorMinor for release URL in newer SFOS versions Fixes: #270 * Restore processing of the version before feeding it to CMake Without it, test builds fail in OBS * Add macros for SFOS version * Drop leading 0 in OBS for version * [sailfishos-chum-gui.spec] Adapt RegEx to SemVer & rectify comments --------- Co-authored-by: olf --- CMakeLists.txt | 1 + rpm/sailfishos-chum-gui.spec | 10 +++++----- src/CMakeLists.txt | 4 ++++ src/ssu.cpp | 12 +++++++++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4968d4a8..6ee5e60b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ project(sailfishos-chum-gui set(GITHUB_TOKEN "unset" CACHE STRING "GitHub access token for GraphQL queries") set(GITLAB_TOKEN "unset" CACHE STRING "GitLab access site-token pair(s) for GraphQL queries") set(FORGEJO_TOKEN "unset" CACHE STRING "Forgejo (and Gitea) access site-token pair(s) for API queries") +set(SAILFISHOS_TARGET_VERSION 0 CACHE STRING "Target Sailfish OS version") include(FindPkgConfig) diff --git a/rpm/sailfishos-chum-gui.spec b/rpm/sailfishos-chum-gui.spec index ff249e34..d9a01bdf 100644 --- a/rpm/sailfishos-chum-gui.spec +++ b/rpm/sailfishos-chum-gui.spec @@ -1,7 +1,6 @@ Name: sailfishos-chum-gui Summary: GUI application for utilising the SailfishOS:Chum community repository -# The %%{version} tag must adhere to semantic versioning: Among multiple other -# reasons due to its use for `qmake5` in line 94. See https://semver.org/ +# The %%{version} tag must adhere to semantic versioning. See https://semver.org/ Version: 0.6.7 Release: 2 # The Group tag should comprise one of the groups listed here: @@ -42,7 +41,7 @@ BuildRequires: sailfish-svg2png BuildRequires: qt5-qttools-linguist BuildRequires: sed -# Bundle YAML-C++ library (for OBS builds) only for older SFOS version targets < v4.0.0.00 +# Bundle YAML-C++ library (for OBS builds) only for older SFOS version targets < v4.0.0 %if %{defined sailfishos_version} && 0%{?sailfishos_version} < 40000 %define bundle_yaml 1 %endif @@ -92,7 +91,8 @@ Links: %build # SFOS RPM cmake macro disables RPATH -%cmake -DCHUMGUI_VERSION=%{version} \ +%cmake -DCHUMGUI_VERSION=%(echo %{version} | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+') \ + -DSAILFISHOS_TARGET_VERSION=%{!?sailfishos_version:0}%{?sailfishos_version} \ -DCMAKE_SKIP_RPATH:BOOL=OFF \ -DCMAKE_INSTALL_RPATH=%{_datadir}/%{name}/lib: \ -DGITHUB_TOKEN=%(cat %{SOURCE1}) \ @@ -114,7 +114,7 @@ cp -a %{_libdir}/libyaml-cpp.so.* %{buildroot}%{_datadir}/%{name}/lib chmod -x %{buildroot}%{_datadir}/%{name}/lib/*.so* %endif -# Rectify desktop file for older SFOS version targets < v4.0.1.00 +# Rectify desktop file for older SFOS version targets < v4.1.0 %if %{defined sailfishos_version} && 0%{?sailfishos_version} < 40100 sed -i 's/silica-qt5/generic/' %{buildroot}%{_datadir}/applications/sailfishos-chum-gui.desktop %endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a31ae966..cc6a3fbc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,6 +46,10 @@ set_source_files_properties(projectforgejo.cpp PROPERTIES COMPILE_DEFINITIONS FORGEJO_TOKEN=\"${FORGEJO_TOKEN}\" ) +set_source_files_properties(ssu.cpp PROPERTIES + COMPILE_DEFINITIONS SAILFISHOS_TARGET_VERSION=${SAILFISHOS_TARGET_VERSION} +) + target_link_libraries(${PROJECT_NAME} Qt5::Quick Qt5::DBus diff --git a/src/ssu.cpp b/src/ssu.cpp index ba4dff0c..15ac9cfc 100644 --- a/src/ssu.cpp +++ b/src/ssu.cpp @@ -4,14 +4,20 @@ #include #include +#if defined(SAILFISHOS_TARGET_VERSION) && SAILFISHOS_TARGET_VERSION >= 40600 +#define RELEASE_TAG "%(releaseMajorMinor)" +#else +#define RELEASE_TAG "%(release)" +#endif + static QString s_repo_regular( - QStringLiteral("https://repo.sailfishos.org/obs/sailfishos:/chum/%(release)_%(arch)/")); + QStringLiteral("https://repo.sailfishos.org/obs/sailfishos:/chum/" RELEASE_TAG "_%(arch)/")); static QString s_repo_regular_alias( QStringLiteral("sailfishos-chum")); static QString s_repo_regular_prefix( QStringLiteral("https://repo.sailfishos.org/obs/sailfishos:/chum/")); static QString s_repo_testing( - QStringLiteral("https://repo.sailfishos.org/obs/sailfishos:/chum:/testing/%(release)_%(arch)/")); + QStringLiteral("https://repo.sailfishos.org/obs/sailfishos:/chum:/testing/" RELEASE_TAG "_%(arch)/")); static QString s_repo_testing_alias( QStringLiteral("sailfishos-chum-testing")); static QString s_repo_testing_prefix( @@ -131,7 +137,7 @@ void Ssu::setRepo(const QString &version, bool testing) { QString url = testing ? s_repo_testing : s_repo_regular; if (!version.isEmpty()) { - url = url.replace(QLatin1String("%(release)"), version); + url = url.replace(QLatin1String(RELEASE_TAG), version); } if (rname != m_repo_name) {