File project.diff of Package qml-autoreqprov

--- README.orig
+++ README
@@ -44,8 +44,8 @@ with QML files inside. The capability ha
 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 fi
 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 foun
 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
--- qml-autoreqprov.changes.orig
+++ qml-autoreqprov.changes
@@ -1,4 +1,39 @@
 -------------------------------------------------------------------
+Thu Jul 25 06:42:37 UTC 2024 - Ralf Habacker <ralf.habacker@freenet.de>
+
+- qmldir.attr:
+  * Add variable _disable_qmldir_requires to disable support
+    similar to qml.attr 
+  
+-------------------------------------------------------------------
+Mon Jan 22 14:18:20 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
+
+- Bump version to 1.4.1
+- qmldirreqprov.sh:
+  * Only generate unversioned URI provides for Qt 6+
+
+-------------------------------------------------------------------
+Sun Jan 21 12:11:19 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
+
+- Bump version to 1.4
+- qml.req:
+  * Detect Qt version based on libQtCore presence. The previous method
+    broke if /usr/libexec/qtX or kf5-filesystem were present.
+- qmldirreqprov.sh:
+  * Generate unversioned URI provides for plugin provided imports as well
+
+-------------------------------------------------------------------
+Tue Nov 14 23:57:17 UTC 2023 - Fabian Vogt <fabian@ritter-vogt.de>
+
+- 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 <fabian@ritter-vogt.de>
 
 - Bump version to 1.2
--- qml-autoreqprov.spec.orig
+++ qml-autoreqprov.spec
@@ -1,7 +1,7 @@
 #
 # spec file for package qml-autoreqprov
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           qml-autoreqprov
-Version:        1.2
+Version:        1.4.1
 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
--- qml.req.orig
+++ qml.req
@@ -1,5 +1,5 @@
 #!/bin/bash
-# SPDX-FileCopyrightText: 2020-2021 Fabian Vogt <fabian@ritter-vogt.de>
+# SPDX-FileCopyrightText: 2020-2023 Fabian Vogt <fabian@ritter-vogt.de>
 # SPDX-License-Identifier: GPL-3.0-or-later
 
 set -euo pipefail
@@ -25,7 +25,9 @@ qtver=
 [[ -n ${qtvers} ]] || qtvers="5 6 7"
 
 for ver in ${qtvers}; do
-	stat /usr/lib*/qt${ver} &>/dev/null && qtver="${qtver}${ver}"
+	if [ -e "/usr/lib/libQt${ver}Core.so.${ver}" ] || [ -e "/usr/lib64/libQt${ver}Core.so.${ver}" ]; then
+		qtver="${qtver}${ver}"
+	fi
 done
 
 # Zero or more than one version of Qt found. Abort.
@@ -37,32 +39,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
--- qmldir.attr.orig
+++ qmldir.attr
@@ -1,3 +1,5 @@
 %__qmldir_provides   %{_rpmconfigdir}/qmldirreqprov.sh --provides
 %__qmldir_requires   %{_rpmconfigdir}/qmldirreqprov.sh --requires
 %__qmldir_path       /qmldir$
+# Exclude everything if _disable_qmldir_requires is set
+%__qmldir_exclude_path  %nil%{?_disable_qmldir_requires:/qmldir$}
--- qmldirreqprov.sh.orig
+++ qmldirreqprov.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-# SPDX-FileCopyrightText: 2020-2021 Fabian Vogt <fabian@ritter-vogt.de>
+# SPDX-FileCopyrightText: 2020-2023 Fabian Vogt <fabian@ritter-vogt.de>
 # 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"
@@ -97,6 +101,9 @@ while read file; do
 					echo "Ignoring ${import}" >&2
 					continue
 				fi
+				if [[ $qtver -ge 6 ]]; then
+					moduleExports["qt${qtver}qmlimport(${import%.*})"]="" # Provides for unversioned imports
+				fi
 				foundModuleExport "qt${qtver}qmlimport(${import})" "$min"
 			done < <(qmlpluginexports-qt${qtver} "$plugin" "$module")
 		done
@@ -104,7 +111,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
openSUSE Build Service is sponsored by