From 0a1cb1a53c58214ccc1f92e066f4505ccd9d24e572365abba7c7bb896efe3cfa Mon Sep 17 00:00:00 2001 From: Christophe Marin Date: Thu, 16 Nov 2023 09:10:29 +0000 Subject: [PATCH] Accepting request 1126738 from home:Vogtinator:qml6reqprov - Bump version to 1.3 - qml.req: * Use qtpaths instead of qmake * Generate requirements for unversioned imports - qmldirreqprov.sh: * Generate provides and requirements for unversioned imports - README.md: Fix typo OBS-URL: https://build.opensuse.org/request/show/1126738 OBS-URL: https://build.opensuse.org/package/show/KDE:Qt5/qml-autoreqprov?expand=0&rev=11 --- README | 14 +++++++++++--- qml-autoreqprov.changes | 11 +++++++++++ qml-autoreqprov.spec | 3 ++- qml.req | 36 +++++++++++++++++++++++++----------- qmldirreqprov.sh | 17 +++++++++++++---- 5 files changed, 62 insertions(+), 19 deletions(-) diff --git a/README b/README index 7dd9bc0..ff42655 100644 --- a/README +++ b/README @@ -44,8 +44,8 @@ with QML files inside. The capability has to include both the full module identifier and version. As modules with a different major version are pretty much independent, the major version is part of the capabilities' name and the minor version is used as the capabilities' version. Additionally, the system -import paths are specific to a Qt major version, this is also included. The end -result are QML modules providing capabilities like: +import paths are specific to a Qt major version, this is also included. The +end result are QML modules providing capabilities like: `Provides: qt5qmlimport(QtQuick.Controls.2) = 15` @@ -55,6 +55,14 @@ On the import side, packages with QML files get requirements like: for a statement like `import QtQuick.Controls 2.13`. The `>=` is there so that modules with a higher minor version satisfy it as well. +With Qt 6, unversioned QML import statements got introduced which import the +highest available major version (which IMO does not make sense...). +Representing those in RPM requires using separate unversioned capabilities +alongside the versioned ones: + +`Provides: qt6qmlimport(QtQuick.Controls)` +`Requires: qt6qmlimport(QtQuick.Controls)` + Generating Requires from .qml files ----------------------------------- @@ -72,7 +80,7 @@ installed. If multiple versions are found, the requires scanner aborts. This can be overwritten by setting a variable in the .spec file (unfortunately not possible per subpackage): -`%global %__qml_requires_opts --qtver 5` +`%global __qml_requires_opts --qtver 5` Currently, only .qml files directly part of the package are handled, so if those are part of a resources file embedded into an executable or library, they diff --git a/qml-autoreqprov.changes b/qml-autoreqprov.changes index 3970516..5c02892 100644 --- a/qml-autoreqprov.changes +++ b/qml-autoreqprov.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Tue Nov 14 23:57:17 UTC 2023 - Fabian Vogt + +- Bump version to 1.3 +- qml.req: + * Use qtpaths instead of qmake + * Generate requirements for unversioned imports +- qmldirreqprov.sh: + * Generate provides and requirements for unversioned imports +- README.md: Fix typo + ------------------------------------------------------------------- Tue Jul 11 09:04:16 UTC 2023 - Fabian Vogt diff --git a/qml-autoreqprov.spec b/qml-autoreqprov.spec index f0346a5..ead8c86 100644 --- a/qml-autoreqprov.spec +++ b/qml-autoreqprov.spec @@ -17,7 +17,7 @@ Name: qml-autoreqprov -Version: 1.2 +Version: 1.3 Release: 0 Summary: Automatic dependency generator for QML files and modules License: GPL-3.0-or-later @@ -35,6 +35,7 @@ BuildArch: noarch Requires: (libqt5-qtdeclarative-tools if libQtQuick5) Requires: (qmlpluginexports-qt5 if libqt5-qtdeclarative-devel) Requires: (qmlpluginexports-qt6 if qt6-qml-devel) +Requires: (qt6-base-common-devel if libQt6Qml6) Requires: (qt6-declarative-tools if libQt6Qml6) # Version 1.1 is not compatible with qt6-declarative < 6.2 Conflicts: qt6-declarative-tools < 6.2.0 diff --git a/qml.req b/qml.req index c2de624..9391769 100644 --- a/qml.req +++ b/qml.req @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-FileCopyrightText: 2020-2021 Fabian Vogt +# SPDX-FileCopyrightText: 2020-2023 Fabian Vogt # SPDX-License-Identifier: GPL-3.0-or-later set -euo pipefail @@ -37,32 +37,46 @@ fi if [[ ${qtver} == 5 ]]; then importscanner="qmlimportscanner-qt5" else - importscanner="$(qmake${qtver} -query QT_HOST_LIBEXECS)/qmlimportscanner" + importscanner="$(qtpaths${qtver} --qt-query QT_HOST_LIBEXECS)/qmlimportscanner" fi command -v "${importscanner}" &>/dev/null || echo "Failed to locate qmlimportscanner" declare -A dependencies -# foundDependency qt5qmlimport(Module.Uri.42) 69 -# In the dependencies array, it sets the version of qt5qmlimport(Module.Uri.42) to 69, if lower +# foundDependency Module.Uri 42 69 +# In the dependencies array, it sets the version of qt5qmlimport(Module.Uri.42) to 69, if lower. foundDependency() { - if [ ${dependencies[$1]:=0} -lt $2 ]; then - dependencies[$1]=$2 + uri="$1.$2" + if [ ${dependencies[$uri]:=0} -lt $3 ]; then + dependencies[$uri]=$3 fi } # TODO: Get exit status of qmlimportscanner -while read import min; do +while read import version; do + if [ -z "$version" ]; then + dependencies[$import]=0 + continue + fi + + maj="${version%.*}" + min="${version#*.}" + # For imports without minor version like "import org.kde.kirigami 2", # the minor version is reported as 255. Treat that as 0 instead. - if [ $min -eq 255 ]; then + if [ "$min" = 255 ]; then min=0 fi - foundDependency "qt${qtver}qmlimport(${import})" "$min" -done < <(grep -vE '/designer/.*\.qml' | xargs -r "$importscanner" -qmlFiles | jq -r '.[] | select(.type == "module") | .name + " " + .version' | gawk 'match($2, /^([0-9]+)\.([0-9]+)$/, ver) { printf "%s.%d %d\n", $1, ver[1], ver[2]; }') + foundDependency "$import" "$maj" "$min" +done < <(grep -vE '/designer/.*\.qml' | xargs -r "$importscanner" -qmlFiles | jq -r '.[] | select(.type == "module") | .name + " " + .version') for export in "${!dependencies[@]}"; do - echo "${export} >= ${dependencies["$export"]}" + ver="${dependencies["$export"]}" + if [ "$ver" != 0 ]; then + echo "qt${qtver}qmlimport(${export}) >= ${ver}" + else + echo "qt${qtver}qmlimport(${export})" + fi done exit $ret diff --git a/qmldirreqprov.sh b/qmldirreqprov.sh index 24be46d..d8917b5 100644 --- a/qmldirreqprov.sh +++ b/qmldirreqprov.sh @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-FileCopyrightText: 2020-2021 Fabian Vogt +# SPDX-FileCopyrightText: 2020-2023 Fabian Vogt # SPDX-License-Identifier: GPL-3.0-or-later set -euo pipefail @@ -54,11 +54,15 @@ while read file; do fi if [[ $requires ]]; then - # TODO: Handle "auto" as version. This could generate versionless qmlimport(Foo.Bar.2) for each exported major version. - gawk '$1 == "depends" && match($3, /^([0-9]+)\.([0-9]+)$/, ver) { printf "qt'${qtver}'qmlimport(%s.%d) >= %d\n", $2, ver[1], ver[2]; }' "$file" + gawk '$1 != "depends" { next } $3 == "auto" { printf "qt'${qtver}'qmlimport(%s)\n", $2; } + match($3, /^([0-9]+)\.([0-9]+)$/, ver) { printf "qt'${qtver}'qmlimport(%s.%d) >= %d\n", $2, ver[1], ver[2]; } ' "$file" fi if [[ $provides ]]; then + if [[ $qtver -ge 6 ]]; then + moduleExports["qt${qtver}qmlimport(${module})"]="" # Provides for unversioned imports + fi + # Handle regular (.qml, .js) exports while read maj min; do foundModuleExport "qt${qtver}qmlimport(${module}.${maj})" "$min" @@ -104,7 +108,12 @@ while read file; do done for export in "${!moduleExports[@]}"; do - echo "${export} = ${moduleExports["$export"]}" + ver="${moduleExports["$export"]}" + if [ -n "$ver" ]; then + echo "${export} = ${ver}" + else + echo "${export}" + fi done exit $ret