Merge lp:~timo-jyrinki/kubuntu-packaging/qtchooser_qmlscene_fallback into lp:~kubuntu-packagers/kubuntu-packaging/qtchooser

Proposed by Timo Jyrinki
Status: Merged
Merged at revision: 17
Proposed branch: lp:~timo-jyrinki/kubuntu-packaging/qtchooser_qmlscene_fallback
Merge into: lp:~kubuntu-packagers/kubuntu-packaging/qtchooser
Diff against target: 312 lines (+152/-120)
6 files modified
debian/changelog (+7/-0)
debian/control (+2/-1)
debian/patches/Implement-fallback-mechanism.patch (+142/-0)
debian/patches/create-a-system-default-path.patch (+0/-41)
debian/patches/series (+1/-0)
debian/qtchooser.1 (+0/-78)
To merge this branch: bzr merge lp:~timo-jyrinki/kubuntu-packaging/qtchooser_qmlscene_fallback
Reviewer Review Type Date Requested Status
Kubuntu Packagers Pending
Review via email: mp+230595@code.launchpad.net

Commit message

* Add a proposed patch from upstream:
  - Implement-fallback-mechanism.patch

Description of the change

RFC, an updated upstream proposed patch not yet accepted by upstream.

Can be tested by:
sudo apt-add-repository ppa:canonical-qt5-edgers/qt5-beta1
sudo apt update
sudo apt install qtchooser

on Ubuntu 14.10.

Upstream discussion: https://codereview.qt-project.org/#/c/82702/

To post a comment you must log in.
Revision history for this message
Scott Kitterman (kitterman) wrote :

Why was it not accepted upstream?

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

I guess it can be interpreted as disagreeing on the development tools definition. Qtchooser is used to manage development tools, which includes everything but the Qt Creator according to the upstream. But Ubuntu uses qmlscene for normal users, and Kubuntu qdbus, without any other developer software installed, so there rises this subtle conflict.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

I think we should whitelist qdbus and all tools that didn't exist in Qt 4 (like qml or qtpaths). For the latter category, I think even upstream will agree to do that.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Whitelisting a bit more sounds like a good way to go, let's see what upstream has to say about that. It should a more safe approach to the problem compared to the blacklisting, so maybe upstream would accept it.

I haven't received more urgent pushing on the issue now, so we can probably wait a bit. But I believe we'd need this one way or another, since the issue seems to come up also for users on IRC every now and then. People just use their Qt:s in various ways and end up with various configurations where the tools don't anymore behave like they would assume.

19. By Timo Jyrinki

New proposal to upstream

20. By Timo Jyrinki

One line adjustment to compile against our older qtchooser version.

Revision history for this message
Scott Kitterman (kitterman) wrote :

Let's see what upstream says before uploading this.

Revision history for this message
Harald Sitter (apachelogger) wrote :

FWIW, waiting for upstream can be problematic because the qdbus thing causes issues with plasma startup in various forms and fashions depending on which packages are installed (or not)

Revision history for this message
Sebastien Bacher (seb128) wrote :

The ppa package resolves the issue and make qmlscene works out of the box in an unity8 session with qt5 examples

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Despite pinging on the upstream codereview and directly on IRC, there's no update. The difference with qtchooser to normal Qt project repositories is that there's essentially only one reviewer.

I'd like to upload this as a distro patch to Ubuntu for utopic release to have a solution for the Unity8 desktop session. It can be reverted if needed, but it should be safe and actually prevent problems compared to people installing qt5-default/qt4-default.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Now uploaded and in queue, after discussions on #kubuntu-devel with apachelogger and mitya57.

21. By Timo Jyrinki

Remove two non-used files that should have been removed during the import.

22. By Timo Jyrinki

Release ubuntu1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-08-13 08:41:01 +0000
+++ debian/changelog 2014-10-07 06:42:00 +0000
@@ -1,3 +1,10 @@
1qtchooser (39-g4717841-3ubuntu1) utopic; urgency=medium
2
3 * Add a proposed patch from upstream:
4 - Implement-fallback-mechanism.patch (LP: #1295835)
5
6 -- Timo Jyrinki <timo-jyrinki@ubuntu.com> Mon, 06 Oct 2014 16:39:42 +0300
7
1qtchooser (39-g4717841-3) unstable; urgency=medium8qtchooser (39-g4717841-3) unstable; urgency=medium
29
3 * Add a patch from Daniel Schepler to allow easier bootstraping of qtchooser10 * Add a patch from Daniel Schepler to allow easier bootstraping of qtchooser
411
=== modified file 'debian/control'
--- debian/control 2014-08-13 08:41:01 +0000
+++ debian/control 2014-10-07 06:42:00 +0000
@@ -1,7 +1,8 @@
1Source: qtchooser1Source: qtchooser
2Section: libdevel2Section: libdevel
3Priority: optional3Priority: optional
4Maintainer: Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
5XSBC-Original-Maintainer: Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
5Uploaders: Timo Jyrinki <timo@debian.org>,6Uploaders: Timo Jyrinki <timo@debian.org>,
6 Lisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>7 Lisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
7Build-Depends: debhelper (>= 9), libqt4-dev8Build-Depends: debhelper (>= 9), libqt4-dev
89
=== added file 'debian/patches/Implement-fallback-mechanism.patch'
--- debian/patches/Implement-fallback-mechanism.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/Implement-fallback-mechanism.patch 2014-10-07 06:42:00 +0000
@@ -0,0 +1,142 @@
1From bd72414b48571b294e43dec06298308a2cfa7da9 Mon Sep 17 00:00:00 2001
2From: Dmitry Shachnev <mitya57@gmail.com>
3Date: Fri, 4 Apr 2014 13:53:15 +0400
4Subject: [PATCH] Implement fallback mechanism for some tools
5
6If a tool was requested without specifying the Sdk name, and the
7default Sdk does not have that tool, fall back to any installed
8Sdk that contains that tool.
9
10Currently this is enabled only for qdbus, qmlscene, and for tools
11that are new in Qt 5.
12
13Change-Id: I19a82a06c75fe9cd624aa51b086d72e75310ba35
14---
15 src/qtchooser/main.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++-------
16 1 file changed, 50 insertions(+), 8 deletions(-)
17
18diff --git a/src/qtchooser/main.cpp b/src/qtchooser/main.cpp
19index 5e6e9cb..314b089 100644
20--- a/src/qtchooser/main.cpp
21+++ b/src/qtchooser/main.cpp
22@@ -65,10 +65,12 @@
23 #if defined(_WIN32) || defined(__WIN32__)
24 # include <process.h>
25 # define execv _execv
26+# define stat _stat
27 # define PATH_SEP "\\"
28 # define EXE_SUFFIX ".exe"
29 #else
30 # include <sys/types.h>
31+# include <sys/stat.h>
32 # include <dirent.h>
33 # include <libgen.h>
34 # include <pwd.h>
35@@ -111,8 +112,21 @@ struct Sdk
36 string librariesPath;
37
38 bool isValid() const { return !toolsPath.empty(); }
39+ bool hasTool(const string &targetTool) const;
40 };
41
42+bool Sdk::hasTool(const string &targetTool) const {
43+ struct stat st;
44+ if (toolsPath.empty())
45+ return false;
46+ if (stat((toolsPath + PATH_SEP + targetTool).c_str(), &st))
47+ return false;
48+#ifdef S_IEXEC
49+ return (st.st_mode & S_IEXEC);
50+#endif
51+ return true;
52+}
53+
54 struct ToolWrapper
55 {
56 int printHelp();
57@@ -126,8 +140,9 @@ private:
58
59 typedef bool (*VisitFunction)(const string &targetSdk, Sdk &item);
60 typedef void (*FinishFunction)(const set<string> &seenSdks);
61- Sdk iterateSdks(const string &targetSdk, VisitFunction visit, FinishFunction finish = 0);
62- Sdk selectSdk(const string &targetSdk);
63+ Sdk iterateSdks(const string &targetSdk, VisitFunction visit, FinishFunction finish = 0,
64+ const string &targetTool = "");
65+ Sdk selectSdk(const string &targetSdk, const string &targetTool = "");
66
67 static void printSdks(const set<string> &seenNames);
68 static bool matchSdk(const string &targetSdk, Sdk &sdk);
69@@ -266,7 +281,7 @@ static bool mkparentdir(string name)
70
71 int ToolWrapper::runTool(const string &targetSdk, const string &targetTool, char **argv)
72 {
73- Sdk sdk = selectSdk(targetSdk);
74+ Sdk sdk = selectSdk(targetSdk, targetTool);
75 if (!sdk.isValid())
76 return 1;
77
78@@ -454,7 +469,8 @@ vector<string> ToolWrapper::searchPaths() const
79 return paths;
80 }
81
82-Sdk ToolWrapper::iterateSdks(const string &targetSdk, VisitFunction visit, FinishFunction finish)
83+Sdk ToolWrapper::iterateSdks(const string &targetSdk, VisitFunction visit, FinishFunction finish,
84+ const string &targetTool)
85 {
86 vector<string> paths = searchPaths();
87 set<string> seenNames;
88@@ -483,11 +499,20 @@ Sdk ToolWrapper::iterateSdks(const string &targetSdk, VisitFunction visit, Finis
89 continue;
90
91 seenNames.insert(d->d_name);
92- sdk.name = d->d_name;
93- sdk.name.resize(fnamelen + 1 - sizeof confSuffix);
94+ if (targetTool.empty()) {
95+ sdk.name = d->d_name;
96+ sdk.name.resize(fnamelen + 1 - sizeof confSuffix);
97+ } else {
98+ // To make the check in matchSdk() succeed
99+ sdk.name = "default";
100+ }
101 sdk.configFile = path + PATH_SEP + d->d_name;
102- if (visit && visit(targetSdk, sdk))
103+ if (visit && visit(targetSdk, sdk)) {
104+ // If a tool was requested, but not found here, skip this sdk
105+ if (!targetTool.empty() && !sdk.hasTool(targetTool))
106+ continue;
107 return sdk;
108+ }
109 }
110
111 closedir(dir);
112@@ -499,9 +524,26 @@ Sdk ToolWrapper::iterateSdks(const string &targetSdk, VisitFunction visit, Finis
113 return Sdk();
114 }
115
116-Sdk ToolWrapper::selectSdk(const string &targetSdk)
117+// All tools that exist for only one Qt version should be
118+// here. Other tools in this list are qdbus and qmlscene.
119+bool fallbackAllowed(const string &tool)
120 {
121+ return tool == "qdbus" ||
122+ tool == "qml" ||
123+ tool == "qmlimportscanner" ||
124+ tool == "qmlscene" ||
125+ tool == "qtdiag" ||
126+ tool == "qtpaths";
127+}
128+
129+Sdk ToolWrapper::selectSdk(const string &targetSdk, const string &targetTool)
130+{
131+ // first, try the default Sdk
132 Sdk matchedSdk = iterateSdks(targetSdk, &ToolWrapper::matchSdk);
133+ if (targetSdk.empty() && !matchedSdk.hasTool(targetTool) && fallbackAllowed(targetTool)) {
134+ // if a tool was requested, fall back to any Sdk that has it
135+ matchedSdk = iterateSdks(string(), &ToolWrapper::matchSdk, 0, targetTool);
136+ }
137 if (!matchedSdk.isValid()) {
138 fprintf(stderr, "%s: could not find a Qt installation of '%s'\n", argv0, targetSdk.c_str());
139 }
140--
1412.1.0
142
0143
=== removed file 'debian/patches/create-a-system-default-path.patch'
--- debian/patches/create-a-system-default-path.patch 2013-03-20 14:03:30 +0000
+++ debian/patches/create-a-system-default-path.patch 1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
1--- a/src/qtchooser/Makefile
2+++ b/src/qtchooser/Makefile
3@@ -17,6 +17,10 @@ TARGET = qtchooser
4 OBJECTS_TEST = main-test.o
5 TARGET_TEST = test/qtchooser
6
7+ifneq ($(QTCHOOSER_GLOBAL_DIR),)
8+ QTCHOOSER_GLOBAL_DIR_VAR:=-DQTCHOOSER_GLOBAL_DIR=\"$(QTCHOOSER_GLOBAL_DIR)\"
9+endif
10+
11 first: all
12 check: $(TARGET_TEST)
13
14@@ -49,10 +53,10 @@ uninstall:
15 ####### Compile
16
17 main.o: main.cpp
18- $(CXX) -c -Wall -Wextra $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
19+ $(CXX) -c -Wall -Wextra $(QTCHOOSER_GLOBAL_DIR_VAR) $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
20
21 main-test.o: main.cpp
22- $(CXX) -c -Wall -Wextra -DQTCHOOSER_TEST_MODE -g $(CXXFLAGS) $(INCPATH) -o main-test.o main.cpp
23+ $(CXX) -c -Wall -Wextra -DQTCHOOSER_TEST_MODE $(QTCHOOSER_GLOBAL_DIR_VAR) -g $(CXXFLAGS) $(INCPATH) -o main-test.o main.cpp
24
25 ####### Install
26
27--- a/src/qtchooser/main.cpp
28+++ b/src/qtchooser/main.cpp
29@@ -265,6 +265,12 @@ vector<string> ToolWrapper::searchPaths(
30 // search the XDG config location directories
31 paths = stringSplit(qgetenv("XDG_CONFIG_DIRS", "/etc/xdg").c_str());
32
33+#if defined(QTCHOOSER_GLOBAL_DIR)
34+ // Add QTCHOOSER_GLOBAL_DIR at the beginning.
35+ vector<string> globalDir = stringSplit(QTCHOOSER_GLOBAL_DIR);
36+ paths.insert(paths.begin(), globalDir.begin(), globalDir.end());
37+#endif
38+
39 string localDir = qgetenv("XDG_CONFIG_HOME", userHome() + PATH_SEP ".config");
40 paths.push_back(localDir);
41
420
=== modified file 'debian/patches/series'
--- debian/patches/series 2014-08-13 08:41:01 +0000
+++ debian/patches/series 2014-10-07 06:42:00 +0000
@@ -1,2 +1,3 @@
1enable-tests.patch1enable-tests.patch
2Add-qmlimportscanner-qtpaths.patch2Add-qmlimportscanner-qtpaths.patch
3Implement-fallback-mechanism.patch
34
=== removed file 'debian/qtchooser.1'
--- debian/qtchooser.1 2013-02-06 12:00:59 +0000
+++ debian/qtchooser.1 1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
1.TH QTCHOOSER 1 "JANUARY 2, 2013"
2.\" Please adjust this date whenever revising the manpage.
3.SH NAME
4qtchooser \- a wrapper used to select between Qt development binary versions
5.SH SYNOPSIS
6.B qtchooser
7\fB\-list\-versions\fR
8.br
9.B qtchooser
10\fB\-print\-env\fR [\fB\-qt=\fIversion\fR]
11.br
12.B qtchooser
13\fB\-run\-tool=\fItool\fR [\fB\-qt=\fIversion\fR] [\fIprogram_arguments\fR]
14.br
15.B <executable_name>
16[\fB\-qt=\fIversion\fR] [\fIprogram_arguments\fR]
17.br
18.SH DESCRIPTION
19Qt is a cross-platform C++ application framework. Qt's primary feature
20is its rich set of widgets that provide standard GUI functionality.
21
22The Qt Chooser provides a wrapper to switch between versions of Qt
23development binaries when multiple versions like 4 and 5 are installed
24or local Qt builds are to be used.
25
26It is commonly used via a symlink from an \fIexecutable_name\fR like qmake.
27.SH OPTIONS
28The options which apply to the
29\fBqtchooser\fR
30command are:
31.PP
32\fB\-list\-versions\fR
33.RS 4
34Lists available Qt versions from the configuration files
35.RE
36.PP
37\fB\-print\-env\fR
38.RS 4
39Prints environment information
40.RE
41.PP
42\fB\-qt=\fIversion\fR
43.RS 4
44Selects \fIversion\fR as the Qt version to be used
45.RE
46.PP
47\fB\-run\-tool=\fItool\fR
48.RS 4
49Runs the selected \fItool\fR.
50.RE
51.SH ENVIRONMENT
52.TP
53.B QT_SELECT
54Same as \fB\-qt=\fIversion\fR. If set, the selected configuration is used and binaries
55symlinked to qtchooser will be executed without additional paramenters.
56.RE
57.TP
58.B XDG_CONFIG_HOME
59.TP
60.B XDG_CONFIG_DIRS
61Used as specified in
62<\fBhttp://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html\fR>
63.SH FILES
64.TP
65.I /etc/xdg/qtchooser/*.conf
66System-wide configuration files. Each has two lines, the first is the path
67to the binaries and the second is the path to the Qt libraries. If a
68\fIdefault.conf\fR is provided, the settings from it will be automatically
69used in case nothing else is selected.
70.TP
71.I \fB$HOME\fP/.config/qtchooser/*.conf
72User configuration files.
73
74.SH AUTHOR
75qtchooser was written by Thiago Macieira from Intel.
76.PP
77This manual page was written by Timo Jyrinki <timo@debian.org>,
78for the Debian project (but may be used by others).

Subscribers

People subscribed via source and target branches