Merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/launcherlocations into lp:qtcreator-plugin-ubuntu

Proposed by Benjamin Zeller
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 281
Merged at revision: 263
Proposed branch: lp:~zeller-benjamin/qtcreator-plugin-ubuntu/launcherlocations
Merge into: lp:qtcreator-plugin-ubuntu
Diff against target: 759 lines (+237/-120)
11 files modified
share/qtcreator/templates/wizards/ubuntu/backendplustabs/CMakeLists.txt (+15/-3)
share/qtcreator/templates/wizards/ubuntu/backendplustabs/manifest.json.in (+15/-0)
share/qtcreator/templates/wizards/ubuntu/backendplustabs/wizard.xml (+3/-3)
share/qtcreator/templates/wizards/ubuntu/goproject/wizard.xml (+2/-2)
share/qtcreator/templates/wizards/ubuntu/scope/wizard.xml (+2/-2)
share/qtcreator/templates/wizards/ubuntu/simple/wizard.xml (+2/-2)
share/qtcreator/templates/wizards/ubuntu/tabs/wizard.xml (+2/-2)
share/qtcreator/templates/wizards/ubuntu/webapp/wizard.xml (+2/-2)
share/qtcreator/ubuntu/scripts/qtc_device_applaunch.py (+145/-86)
share/qtcreator/ubuntu/scripts/qtc_device_debughelper.py (+47/-14)
src/ubuntu/ubuntulocalrunconfiguration.cpp (+2/-4)
To merge this branch: bzr merge lp:~zeller-benjamin/qtcreator-plugin-ubuntu/launcherlocations
Reviewer Review Type Date Requested Status
Zoltan Balogh Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+234272@code.launchpad.net

Commit message

- Less launcher output, add prefix so its clear if the output is from launcher/app
- Use default application directories to create control files
- Native Backend template now automatically substitutes the correct architecture into the manifest file
- Make sure the wizards don't accept invalid characters

Description of the change

- Less launcher output, add prefix so its clear if the output is from launcher/app
- Use default application directories to create control files

To post a comment you must log in.
279. By Benjamin Zeller

Pack debug mode

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
280. By Benjamin Zeller

Backend template now automatically substitutes the correct architecture
into the manifest file

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
281. By Benjamin Zeller

Make sure wizard does not accept invalid characters

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

OK

review: Approve
282. By Benjamin Zeller

fix templates

283. By Benjamin Zeller

Forgot new files

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'share/qtcreator/templates/wizards/ubuntu/backendplustabs/CMakeLists.txt'
2--- share/qtcreator/templates/wizards/ubuntu/backendplustabs/CMakeLists.txt 2014-08-21 16:56:53 +0000
3+++ share/qtcreator/templates/wizards/ubuntu/backendplustabs/CMakeLists.txt 2014-09-12 10:47:38 +0000
4@@ -1,7 +1,8 @@
5 project(%ProjectName% C CXX)
6 cmake_minimum_required(VERSION 2.8.9)
7
8-set (UBUNTU_PROJECT_TYPE "ClickApp" CACHE INTERNAL "Tells QtCreator this is a Click application project")
9+#do not remove this line, its required for the correct functionality of the Ubuntu-SDK
10+set(UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Tells QtCreator location and name of the manifest file")
11 set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
12
13 find_package(Qt5Core)
14@@ -35,7 +36,17 @@
15
16 set(EXEC "qmlscene $@ ${%ProjectName:u%_DIR}/${MAIN_QML}")
17
18-install(FILES manifest.json DESTINATION ${CMAKE_INSTALL_PREFIX})
19+#This command figures out the target architecture and puts it into the manifest file
20+execute_process(
21+ COMMAND dpkg-architecture -qDEB_HOST_ARCH
22+ OUTPUT_VARIABLE CLICK_ARCH
23+ OUTPUT_STRIP_TRAILING_WHITESPACE
24+)
25+
26+configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
27+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json
28+ DESTINATION ${CMAKE_INSTALL_PREFIX})
29+
30 install(DIRECTORY "app/graphics" DESTINATION ${DATA_DIR})
31 install(FILES "%ClickHookName%.apparmor" DESTINATION ${DATA_DIR})
32
33@@ -55,4 +66,5 @@
34 DEPENDS %ProjectName%backend %ProjectName%backend-qmldir
35 WORKING_DIRECTORY ./app)
36
37-add_custom_target("%ProjectName:l%_ClickFiles" ALL SOURCES "%ClickHookName%.apparmor" "manifest.json")
38+#no op custom target for all not compiled files, so they show up in the QtCreator project tree
39+add_custom_target("%ProjectName:l%_ClickFiles" ALL SOURCES "%ClickHookName%.apparmor" "manifest.json.in")
40
41=== added file 'share/qtcreator/templates/wizards/ubuntu/backendplustabs/manifest.json.in'
42--- share/qtcreator/templates/wizards/ubuntu/backendplustabs/manifest.json.in 1970-01-01 00:00:00 +0000
43+++ share/qtcreator/templates/wizards/ubuntu/backendplustabs/manifest.json.in 2014-09-12 10:47:38 +0000
44@@ -0,0 +1,15 @@
45+{
46+ "name": "%ClickDomain:l%.%ProjectName:l%",
47+ "description": "description of %ProjectName%",
48+ "architecture": "@CLICK_ARCH@",
49+ "title": "%ProjectName%",
50+ "hooks": {
51+ "%ClickHookName%": {
52+ "apparmor": "%ClickHookName%.apparmor",
53+ "desktop": "%ClickHookName%.desktop"
54+ }
55+ },
56+ "version": "0.1",
57+ "maintainer": "%ClickMaintainer%"
58+}
59+
60
61=== modified file 'share/qtcreator/templates/wizards/ubuntu/backendplustabs/wizard.xml'
62--- share/qtcreator/templates/wizards/ubuntu/backendplustabs/wizard.xml 2014-08-18 12:29:43 +0000
63+++ share/qtcreator/templates/wizards/ubuntu/backendplustabs/wizard.xml 2014-09-12 10:47:38 +0000
64@@ -39,7 +39,7 @@
65 <file source="app/tests/autopilot/displayName/__init__.py" target="app/tests/autopilot/%ProjectName%/__init__.py" openeditor="false"/>
66 <file source="app/tests/autopilot/displayName/main/__init__.py" target="app/tests/autopilot/%ProjectName%/main/__init__.py" openeditor="false"/>
67 <file source="cmake/Click.cmake" target="cmake/Click.cmake" openeditor="false"/>
68- <file source="../share/manifest.json" target="manifest.json" openeditor="true"/>
69+ <file source="manifest.json.in" target="manifest.json.in" openeditor="true"/>
70 <file source="../share/displayName.apparmor" target="%ClickHookName%.apparmor" openeditor="false"/>
71 <file source="app/displayName.qml" target="app/%ProjectName%.qml" openeditor="true"/>
72 </files>
73@@ -48,7 +48,7 @@
74 <fieldpagetitle>Click package parameters</fieldpagetitle>
75 <fields>
76 <field mandatory="true" name="ClickDomain">
77- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
78+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
79 defaulttext="" placeholdertext="Domain"/>
80 <fielddescription>Domain:</fielddescription>
81 </field>
82@@ -58,7 +58,7 @@
83 <fielddescription>Maintainer:</fielddescription>
84 </field>
85 <field mandatory="true" name="ClickHookName">
86- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
87+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
88 defaulttext="myapp" placeholdertext="app hook name"/>
89 <fielddescription>App name:</fielddescription>
90 </field>
91
92=== modified file 'share/qtcreator/templates/wizards/ubuntu/goproject/wizard.xml'
93--- share/qtcreator/templates/wizards/ubuntu/goproject/wizard.xml 2014-08-18 15:41:55 +0000
94+++ share/qtcreator/templates/wizards/ubuntu/goproject/wizard.xml 2014-09-12 10:47:38 +0000
95@@ -22,7 +22,7 @@
96 <fieldpagetitle>Details</fieldpagetitle>
97 <fields>
98 <field mandatory="true" name="ClickDomain">
99- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
100+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
101 defaulttext="" placeholdertext="Domain"/>
102 <fielddescription>Domain:</fielddescription>
103 </field>
104@@ -32,7 +32,7 @@
105 <fielddescription>Maintainer:</fielddescription>
106 </field>
107 <field mandatory="true" name="ClickHookName">
108- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
109+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
110 defaulttext="myapp" placeholdertext="app hook name"/>
111 <fielddescription>App name:</fielddescription>
112 </field>
113
114=== modified file 'share/qtcreator/templates/wizards/ubuntu/scope/wizard.xml'
115--- share/qtcreator/templates/wizards/ubuntu/scope/wizard.xml 2014-08-18 12:29:43 +0000
116+++ share/qtcreator/templates/wizards/ubuntu/scope/wizard.xml 2014-09-12 10:47:38 +0000
117@@ -30,7 +30,7 @@
118 <fieldpagetitle>Click package parameters</fieldpagetitle>
119 <fields>
120 <field mandatory="true" name="ClickDomain">
121- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
122+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
123 defaulttext="" placeholdertext="Domain"/>
124 <fielddescription>Domain:</fielddescription>
125 </field>
126@@ -40,7 +40,7 @@
127 <fielddescription>Maintainer:</fielddescription>
128 </field>
129 <field mandatory="true" name="ClickHookName">
130- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
131+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
132 defaulttext="myscope" placeholdertext="scope hook name"/>
133 <fielddescription>Scope name:</fielddescription>
134 </field>
135
136=== modified file 'share/qtcreator/templates/wizards/ubuntu/simple/wizard.xml'
137--- share/qtcreator/templates/wizards/ubuntu/simple/wizard.xml 2014-08-19 06:39:27 +0000
138+++ share/qtcreator/templates/wizards/ubuntu/simple/wizard.xml 2014-09-12 10:47:38 +0000
139@@ -31,7 +31,7 @@
140 <fieldpagetitle>Click package parameters</fieldpagetitle>
141 <fields>
142 <field mandatory="true" name="ClickDomain">
143- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
144+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
145 defaulttext="" placeholdertext="Domain"/>
146 <fielddescription>Domain:</fielddescription>
147 </field>
148@@ -41,7 +41,7 @@
149 <fielddescription>Maintainer:</fielddescription>
150 </field>
151 <field mandatory="true" name="ClickHookName">
152- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
153+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
154 defaulttext="app" placeholdertext="app hook name"/>
155 <fielddescription>App name:</fielddescription>
156 </field>
157
158=== modified file 'share/qtcreator/templates/wizards/ubuntu/tabs/wizard.xml'
159--- share/qtcreator/templates/wizards/ubuntu/tabs/wizard.xml 2014-08-19 06:39:27 +0000
160+++ share/qtcreator/templates/wizards/ubuntu/tabs/wizard.xml 2014-09-12 10:47:38 +0000
161@@ -35,7 +35,7 @@
162 <fieldpagetitle>Click package parameters</fieldpagetitle>
163 <fields>
164 <field mandatory="true" name="ClickDomain">
165- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
166+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
167 defaulttext="" placeholdertext="Domain"/>
168 <fielddescription>Domain:</fielddescription>
169 </field>
170@@ -45,7 +45,7 @@
171 <fielddescription>Maintainer:</fielddescription>
172 </field>
173 <field mandatory="true" name="ClickHookName">
174- <fieldcontrol class="QLineEdit" validator='^[^"]+$'
175+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$'
176 defaulttext="myapp" placeholdertext="app hook name"/>
177 <fielddescription>App name:</fielddescription>
178 </field>
179
180=== modified file 'share/qtcreator/templates/wizards/ubuntu/webapp/wizard.xml'
181--- share/qtcreator/templates/wizards/ubuntu/webapp/wizard.xml 2014-08-19 06:39:27 +0000
182+++ share/qtcreator/templates/wizards/ubuntu/webapp/wizard.xml 2014-09-12 10:47:38 +0000
183@@ -17,7 +17,7 @@
184 <fieldpagetitle>Click package parameters</fieldpagetitle>
185 <fields>
186 <field mandatory="true" name="ClickDomain">
187- <fieldcontrol class="QLineEdit" validator='^[^"]+$' defaulttext="" placeholdertext="Domain"/>
188+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$' defaulttext="" placeholdertext="Domain"/>
189 <fielddescription>Domain:</fielddescription>
190 </field>
191 <field mandatory="true" name="ClickMaintainer">
192@@ -25,7 +25,7 @@
193 <fielddescription>Maintainer:</fielddescription>
194 </field>
195 <field mandatory="true" name="ClickHookName">
196- <fieldcontrol class="QLineEdit" validator='^[^"]+$' defaulttext="app" placeholdertext="app hook name"/>
197+ <fieldcontrol class="QLineEdit" validator='^[A-Za-z0-9.-]+$' defaulttext="app" placeholdertext="app hook name"/>
198 <fielddescription>App name:</fielddescription>
199 </field>
200 </fields>
201
202=== modified file 'share/qtcreator/ubuntu/scripts/qtc_device_applaunch.py'
203--- share/qtcreator/ubuntu/scripts/qtc_device_applaunch.py 2014-09-04 13:19:11 +0000
204+++ share/qtcreator/ubuntu/scripts/qtc_device_applaunch.py 2014-09-12 10:47:38 +0000
205@@ -57,11 +57,12 @@
206 @dbus.service.method("com.ubuntu.SDKAppLaunch",in_signature='si', out_signature='')
207 def ScopeLoaded(self, name, pid):
208 if(name == self.appId):
209- print("Application started: "+str(pid),flush=True)
210+ #Do NOT change this line, its interpreted by the IDE
211+ print("Sdk-Launcher> Application started: "+str(pid),flush=True)
212
213 @dbus.service.method("com.ubuntu.SDKAppLaunch",in_signature='s', out_signature='')
214 def ScopeStopped(self, name):
215- print("Scope stopped, exiting",flush=True)
216+ print("Sdk-Launcher> Scope stopped, exiting",flush=True)
217 self.loop.quit()
218
219 def launch(self):
220@@ -72,7 +73,7 @@
221 #just make the default scope visible again
222 self._dispatchUrl("scope://clickscope")
223 else:
224- print("Error: Could start the scope.",flush=True,file=sys.stderr)
225+ print("Sdk-Launcher> Error: Could start the scope.",flush=True,file=sys.stderr)
226 return 1
227 except KeyboardInterrupt:
228 pass
229@@ -84,12 +85,10 @@
230 urlDispatcher = bus.get_object('com.canonical.URLDispatcher',
231 '/com/canonical/URLDispatcher')
232
233- print("Dispatching url: "+url)
234-
235 urlDispatcher.DispatchURL(url,"",
236 dbus_interface='com.canonical.URLDispatcher')
237 except dbus.DBusException:
238- print("Error: Could not start the scope.",flush=True,file=sys.stderr)
239+ print("Sdk-Launcher> Error: Could not start the scope.",flush=True,file=sys.stderr)
240 return False
241 return True
242
243@@ -106,7 +105,7 @@
244 self.loop = loop
245
246 def on_failed(self,launched_app_id, failure_type):
247- print("Received a failed event",flush=True)
248+ print("Sdk-Launcher> Received a failed event",flush=True)
249 if launched_app_id == self.appid:
250 if failure_type == UAL.AppFailed.CRASH:
251 self.message = 'Application crashed.'
252@@ -118,32 +117,30 @@
253
254 def on_started(self,launched_app_id):
255 if launched_app_id == self.appid:
256- print("Application started: "+str(UAL.get_primary_pid(self.appid)),flush=True)
257+ #Do NOT change this line, its interpreted by the IDE
258+ print("Sdk-Launcher> Application started: "+str(UAL.get_primary_pid(self.appid)),flush=True)
259
260 def on_stopped(self,stopped_app_id):
261 if stopped_app_id == self.appid:
262- print("Stopping Application",flush=True)
263+ print("Sdk-Launcher> Stopping Application",flush=True)
264 self.exitCode = 0
265 self.loop.quit()
266
267 def on_resume(self,resumed_app_id):
268 if resumed_app_id == self.appid:
269- print("Application was resumed",flush=True)
270+ print("Sdk-Launcher> Application was resumed",flush=True)
271
272 def on_focus(self,focused_app_id):
273 if focused_app_id == self.appid:
274- print("Application was focused",flush=True)
275+ print("Sdk-Launcher> Application was focused",flush=True)
276
277 def launch(self):
278- print ("Registering hooks",flush=True)
279 UAL.observer_add_app_failed(self.on_failed)
280 UAL.observer_add_app_started(self.on_started)
281 UAL.observer_add_app_focus(self.on_focus)
282 UAL.observer_add_app_stop(self.on_stopped)
283 UAL.observer_add_app_resume(self.on_resume)
284
285- print ("Start Application",flush=True)
286-
287 #start up the application
288 UAL.start_application(self.appid)
289
290@@ -152,7 +149,7 @@
291 except KeyboardInterrupt:
292 pass
293
294- print ("The Application exited, cleaning up")
295+ print ("Sdk-Launcher> The Application exited, cleaning up")
296
297 UAL.observer_delete_app_failed(self.on_failed)
298 UAL.observer_delete_app_started(self.on_started)
299@@ -166,7 +163,7 @@
300 UAL.stop_application(self.appid)
301
302 def on_sigterm(runner):
303- print("Received exit signal, stopping application",flush=True)
304+ print("Sdk-Launcher> Received exit signal, stopping application",flush=True)
305 runner.stop()
306
307 def create_procpipe(path,callback):
308@@ -213,6 +210,31 @@
309 print (output ,file=sys.stderr,end="",flush=True)
310 return True
311
312+def is_confined (manifest_obj, hook_name):
313+ if "apparmor" not in manifest_obj['hooks'][hook_name]:
314+ raise Exception("Error: Invalid Manifest file")
315+ if "name" not in manifest_obj:
316+ raise Exception("Error: Invalid Manifest file")
317+
318+ install_dir = "/opt/click.ubuntu.com/"
319+ apparmor_path = install_dir+manifest_obj['name']+"/current/"+manifest_obj['hooks'][hook_name]["apparmor"]
320+
321+ if (not os.path.isfile(apparmor_path)):
322+ raise Exception("Error: Apparmor path is not valid: "+apparmor_path)
323+
324+ try:
325+ json_file = open(apparmor_path,"r")
326+ apparmor=json.load(json_file)
327+ json_file.close()
328+ except Exception as err:
329+ raise Exception("Error: Could not read the apparmor file "+str(err))
330+
331+ if ("template" in apparmor):
332+ return apparmor["template"] != "unconfined"
333+
334+ #without a template the app is always confined
335+ return True;
336+
337 # register options to the argument parser
338 parser = argparse.ArgumentParser(description="SDK application launcher")
339 parser.add_argument('clickPck',action="store")
340@@ -223,14 +245,16 @@
341
342 options = parser.parse_args()
343
344-print("Executing: "+options.clickPck,flush=True)
345-print("Launcher PID: "+str(os.getpid()), file=sys.stderr,flush=True)
346+print("Sdk-Launcher> Executing: "+options.clickPck,flush=True)
347+
348+#Do NOT change this line, its interpreted by the IDE
349+print("Sdk-Launcher> Launcher PID: "+str(os.getpid()), file=sys.stderr,flush=True)
350
351 needs_debug_conf=False
352 conf_obj={}
353
354 if options.environmentList is not None:
355- print("Setting env "+", ".join(options.environmentList),flush=True)
356+ print("Sdk-Launcher> Setting env "+", ".join(options.environmentList),flush=True)
357 needs_debug_conf=True
358 conf_obj['env'] = {}
359 for env in options.environmentList:
360@@ -242,12 +266,12 @@
361 if options.gdbPort is not None:
362 needs_debug_conf=True
363 conf_obj['gdbPort'] = options.gdbPort
364- print("GDB Port"+options.gdbPort,flush=True)
365+ print("Sdk-Launcher> GDB Port"+options.gdbPort,flush=True)
366
367 if options.qmlDebug is not None:
368 needs_debug_conf=True
369 conf_obj['qmlDebug'] = options.qmlDebug
370- print("QML Debug Settings:"+options.qmlDebug,flush=True)
371+ print("Sdk-Launcher> QML Debug Settings:"+options.qmlDebug,flush=True)
372
373 hook_name = None
374 package_name = None
375@@ -256,13 +280,14 @@
376 manifest = None
377 app_id = None
378 tmp_dir = "/tmp/"
379+apparmor_path = None
380
381 #get the manifest information from the click package
382 try:
383 manifest_json = subprocess.check_output(["click","info",options.clickPck])
384 manifest=json.loads(manifest_json.decode())
385 except subprocess.CalledProcessError:
386- print("Could not call click",file=sys.stderr,flush=True)
387+ print("Sdk-Launcher> Could not call click",file=sys.stderr,flush=True)
388 sys.exit(1)
389
390 #get the hook name we want to execute
391@@ -270,21 +295,22 @@
392 hook_name = list(manifest['hooks'].keys())[0]
393 else:
394 if options.targetHook is None:
395- print("There are multiple hooks in the manifest file, please specify one",flush=True,file=sys.stderr)
396+ print("Sdk-Launcher> There are multiple hooks in the manifest file, please specify one",flush=True,file=sys.stderr)
397 sys.exit(1)
398 else:
399 if options.targetHook in manifest['hooks']:
400 hook_name = options.targetHook
401+ apparmor_path = manifest['hooks'][hook_name]["apparmor"]
402 else:
403- print("Unknown hook selected",file=sys.stderr,flush=True)
404+ print("Sdk-Launcher> Unknown hook selected",file=sys.stderr,flush=True)
405 sys.exit(1)
406
407 if 'version' not in manifest:
408- print("Version key is missing from the manifest file",flush=True,file=sys.stderr)
409+ print("Sdk-Launcher> Version key is missing from the manifest file",flush=True,file=sys.stderr)
410 sys.exit(1)
411
412 if 'name' not in manifest:
413- print("Package name not in the manifest file",flush=True,file=sys.stderr)
414+ print("Sdk-Launcher> Package name not in the manifest file",flush=True,file=sys.stderr)
415 sys.exit(1)
416
417 package_name = manifest['name']
418@@ -296,7 +322,7 @@
419 package_arch = subprocess.check_output(["dpkg","-f",options.clickPck,"Architecture"])
420 package_arch = package_arch.decode()
421 except subprocess.CalledProcessError:
422- print("Could not query architecture from the package",flush=True,file=sys.stderr)
423+ print("Sdk-Launcher> Could not query architecture from the package",flush=True,file=sys.stderr)
424 sys.exit(1)
425
426 #check if the app is already installed on the device, so we do not break existing installations
427@@ -305,93 +331,126 @@
428 arr = json_array_to_python(db.get_manifests(all_versions=False))
429 for installAppManifest in arr:
430 if installAppManifest["name"] == package_name:
431- print("Error: This application is already installed on the device, uninstall it or temporarily change the name in the manifest.json file!",flush=True,file=sys.stderr)
432+ print("Sdk-Launcher> Error: This application is already installed on the device, uninstall it or temporarily change the name in the manifest.json file!",flush=True,file=sys.stderr)
433 sys.exit(1)
434
435 #build the appid
436 app_id = None
437 debug_file_name = None
438+app_mode = None
439
440 loop = GLib.MainLoop()
441 runner = None
442
443 if "scope" in manifest['hooks'][hook_name]:
444+ app_mode = False
445 app_id = package_name+"_"+hook_name
446 runner = ScopeRunner(app_id,loop)
447- tmp_dir = os.path.expanduser('~')+"/.local/share/unity-scopes/leaf-net/"+package_name+"/"
448 if(not os.path.exists(tmp_dir)):
449 os.mkdir(tmp_dir)
450
451- print("Setting the tmp dir to: "+tmp_dir)
452-
453 elif "desktop" in manifest['hooks'][hook_name]:
454+ app_mode = True
455 app_id = package_name+"_"+hook_name+"_"+package_version
456 runner = AppRunner(app_id,loop)
457 else:
458- print("Hook is not supported, only scope and app hooks can be executed",flush=True)
459- #TODO move to uninstall
460+ print("Sdk-Launcher> Hook is not supported, only scope and app hooks can be executed",flush=True)
461 sys.exit(1)
462
463-debug_file_name = tmp_dir+app_id+"_debug.json"
464-
465-print("AppId: "+app_id,flush=True)
466-print("Architecture: "+package_arch,flush=True)
467-
468-#create the debug description file if required
469-if needs_debug_conf:
470- try:
471- f = open(debug_file_name, 'w')
472- json.dump(conf_obj,f)
473- f.close()
474- except OSError:
475- print("Could not create the debug description file")
476- sys.exit(1)
477-
478+print("Sdk-Launcher> Installing application .....",flush=True)
479 #we have all informations, now install the click package
480-#@TODO check if its already installed
481-
482 success = subprocess.call(
483- ["pkcon","--allow-untrusted","install-local",options.clickPck,"-p"])
484+ ["pkcon","--allow-untrusted","install-local",options.clickPck,"-p"],stdout=subprocess.DEVNULL)
485 if success != 0:
486- print("Installing the application failed",flush=True)
487+ print("Sdk-Launcher> Installing the application failed",flush=True)
488 sys.exit(1)
489
490-print("Application installed, executing",flush=True)
491-
492-#create 2 named pipes and listen for data
493-stdoutPipeName = tmp_dir+app_id+".stdout"
494-procStdOut = create_procpipe(stdoutPipeName,on_proc_stdout)
495-
496-stderrPipeName = tmp_dir+app_id+".stderr"
497-procStdErr = create_procpipe(stderrPipeName,on_proc_stderr)
498-
499-
500-if "unix_signal_add" in dir(GLib):
501- GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGTERM, on_sigterm, runner)
502- GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGINT, on_sigterm, runner)
503- GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGHUP, on_sigterm, runner)
504-else:
505- GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGTERM, on_sigterm, runner)
506- GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, on_sigterm, runner)
507- GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGHUP, on_sigterm, runner)
508-
509-#execute the hook, this will not return before the app or scope finished to run
510-exitCode = runner.launch()
511-
512-success = subprocess.call(["pkcon","remove",package_name+";"+package_version+";"+package_arch+";local:click","-p"])
513-if success != 0:
514- print("Uninstalling the application failed",flush=True)
515-
516+print("Sdk-Launcher> Application installed successfully",flush=True)
517+
518+debug_file_name = None
519+stdoutPipeName = None
520+procStdOut = None
521+stderrPipeName = None
522+procStdErr = None
523+
524+try:
525+ confined = is_confined(manifest,hook_name)
526+
527+ if (app_mode is True and confined):
528+ tmp_dir = os.path.expanduser('~')+"/.local/share/"+package_name+"/"
529+ elif (app_mode is True and not confined):
530+ tmp_dir = os.path.expanduser('~')+"/.local/share/"+package_name+"/"
531+ elif (app_mode is False and confined):
532+ tmp_dir = os.path.expanduser('~')+"/.local/share/unity-scopes/leaf-net/"+package_name+"/"
533+ elif (app_mode is False and not confined):
534+ tmp_dir = os.path.expanduser('~')+"/.local/share/unity-scopes/unconfined/"+package_name+"/"
535+ else:
536+ #error we need to stop
537+ raise Exception("There was a error specifying the communication directory.")
538+
539+ debug_file_name = tmp_dir+app_id+"_debug.json"
540+
541+ if(not os.path.exists(tmp_dir)):
542+ os.mkdir(tmp_dir)
543+
544+ print("Sdk-Launcher> AppId: "+app_id,flush=True)
545+ print("Sdk-Launcher> Architecture: "+package_arch,flush=True,end="")
546+ print("Sdk-Launcher> Application confined: "+str(confined),flush=True)
547+ print("Sdk-Launcher> Communication directory: "+tmp_dir,flush=True)
548+
549+ #create the debug description file if required
550+ if needs_debug_conf:
551+ try:
552+ f = open(debug_file_name, 'w')
553+ json.dump(conf_obj,f)
554+ f.close()
555+ except OSError:
556+ #error we need to stop
557+ raise Exception("Could not create the debug description file")
558+
559+ #create 2 named pipes and listen for data
560+ stdoutPipeName = tmp_dir+app_id+".stdout"
561+ procStdOut = create_procpipe(stdoutPipeName,on_proc_stdout)
562+
563+ stderrPipeName = tmp_dir+app_id+".stderr"
564+ procStdErr = create_procpipe(stderrPipeName,on_proc_stderr)
565+
566+ if "unix_signal_add" in dir(GLib):
567+ GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGTERM, on_sigterm, runner)
568+ GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGINT, on_sigterm, runner)
569+ GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGHUP, on_sigterm, runner)
570+ else:
571+ GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGTERM, on_sigterm, runner)
572+ GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGINT, on_sigterm, runner)
573+ GLib.unix_signal_add_full(GLib.PRIORITY_HIGH, signal.SIGHUP, on_sigterm, runner)
574+
575+ #execute the hook, this will not return before the app or scope finished to run
576+ exitCode = runner.launch()
577+
578+except Exception as err:
579+ print(repr(err),flush=True)
580+ exitCode = 1
581+
582+#clean up the debug conf file if it still exists
583 if needs_debug_conf:
584 try:
585- if os.path.isfile(debug_file_name):
586+ if (debug_file_name != None and os.path.isfile(debug_file_name)):
587 os.remove(debug_file_name)
588 except:
589- print("Could not remove the debug description file: "+debug_file_name+"\n Please delete it manually",flush=True,file=sys.stderr)
590-
591-os.close(procStdOut)
592-os.unlink(stdoutPipeName)
593-os.close(procStdErr)
594-os.unlink(stderrPipeName)
595-
596+ print("Sdk-Launcher> Could not remove the debug description file: "+debug_file_name+"\n Please delete it manually",flush=True,file=sys.stderr)
597+
598+#close the pipes
599+if (stdoutPipeName != None and os.path.exists(stdoutPipeName)):
600+ os.close(procStdOut)
601+ os.unlink(stdoutPipeName)
602+
603+if (stderrPipeName != None and os.path.exists(stderrPipeName)):
604+ os.close(procStdErr)
605+ os.unlink(stderrPipeName)
606+
607+success = subprocess.call(["pkcon","remove",package_name+";"+package_version+";"+package_arch+";local:click","-p"],stdout=subprocess.DEVNULL)
608+if success != 0:
609+ print("Sdk-Launcher> Uninstalling the application failed",flush=True)
610+
611+print("Sdk-Launcher> Finished",flush=True)
612 sys.exit(exitCode)
613
614=== modified file 'share/qtcreator/ubuntu/scripts/qtc_device_debughelper.py'
615--- share/qtcreator/ubuntu/scripts/qtc_device_debughelper.py 2014-09-03 07:15:50 +0000
616+++ share/qtcreator/ubuntu/scripts/qtc_device_debughelper.py 2014-09-12 10:47:38 +0000
617@@ -26,26 +26,60 @@
618 import subprocess
619 import shlex
620 import shutil
621+import re
622
623+def is_confined ():
624+ test_dir = os.path.expanduser('~')+"/.local/share"
625+ try:
626+ os.listdir(test_dir)
627+ #if we reach the return statement we are not in confinement
628+ return False
629+ except:
630+ pass
631+ return True
632
633 app_id = None
634 args = None
635 tmpdir = "/tmp/"
636
637 mode = sys.argv[1]
638+confined = is_confined()
639
640 if mode == "scope":
641 app_id = sys.argv[2]
642 args = sys.argv[3:]
643
644- #i hope this works
645- packagename = app_id[:app_id.rfind("_")]
646- tmpdir = "/home/phablet/.local/share/unity-scopes/leaf-net/"+packagename+"/"
647+ regex = re.compile("_");
648+
649+ try:
650+ (packagename,hookname) = regex.split(app_id)
651+ except ValueError as err:
652+ print("Debug-helper> Invalid Application ID "+app_id+" "+repr(err),file=sys.stderr)
653+ sys.exit(1)
654+
655+ if(confined):
656+ tmpdir = os.path.expanduser('~')+"/.local/share/unity-scopes/leaf-net/"+packagename+"/"
657+ else:
658+ tmpdir = os.path.expanduser('~')+"/.local/share/unity-scopes/unconfined/"+packagename+"/"
659+
660 elif mode == "app":
661 app_id = os.environ.get('APP_ID')
662+
663+ #i hope this works
664+ pos = app_id.rfind("_")
665+ pos = app_id.rfind("_",0,pos)
666+
667+ regex = re.compile("_");
668+ try:
669+ (packagename,hookname,version) = regex.split(app_id)
670+ except ValueError as err:
671+ print("Debug-helper> Invalid Application ID "+app_id+" "+repr(err),file=sys.stderr)
672+ sys.exit(1)
673+
674 args = shlex.split(sys.argv[2])
675+ tmpdir = os.path.expanduser('~')+"/.local/share/"+packagename+"/"
676 else:
677- print("Unsupported script mode (scope|app)")
678+ print("Debug-helper> Unsupported script mode (scope|app)")
679 sys.exit(1)
680
681 stdoutPipeName = tmpdir+app_id+".stdout"
682@@ -58,10 +92,10 @@
683 newStdErr = os.open(stderrPipeName,os.O_WRONLY | os.O_NONBLOCK)
684 os.dup2(newStdErr, sys.stderr.fileno());
685
686-print ("---------- Debug helper ------------")
687-print ("Setting up environment")
688-print ("TmpDir: "+tmpdir)
689-print ("AppId: "+app_id)
690+print ("Debug-helper> Setting up environment")
691+print ("Debug-helper> TmpDir: "+tmpdir)
692+print ("Debug-helper> AppId: "+app_id)
693+print ("Debug-helper> Environment: "+("confined" if is_confined() else "unconfined"))
694
695 if (args[0][0] == "/"):
696 effective_cmd = command = args.pop(0)
697@@ -69,7 +103,7 @@
698 effective_cmd = command = shutil.which(args.pop(0))
699
700 if command is None:
701- print("Executable was not found in the PATH")
702+ print("Debug-helper> Executable was not found in the PATH")
703 sys.exit(1)
704
705 if app_id is None:
706@@ -82,7 +116,7 @@
707 try:
708 debug_settings = json.load(f)
709 except:
710- print("Could not load the settings file")
711+ print("Debug-helper> Could not load the settings file")
712 sys.exit(1)
713
714 if "qmlDebug" in debug_settings:
715@@ -91,7 +125,7 @@
716 if "gdbPort" in debug_settings:
717 effective_cmd = shutil.which("gdbserver")
718 if effective_cmd is None:
719- print("gdbserver was not found in the PATH")
720+ print("Debug-helper> gdbserver was not found in the PATH")
721 sys.exit(1)
722 args.insert(0,":"+debug_settings["gdbPort"])
723 args.insert(1,command)
724@@ -111,9 +145,8 @@
725 #execv wants the command again in the arguments
726 args.insert(0,effective_cmd)
727
728-print ("Environment initialized, starting the application")
729-print ("---------- Debug helper ------------")
730-print ("Executing "+effective_cmd+str(args))
731+print ("Debug-helper> Environment initialized, starting the application")
732+print ("Debug-helper> Executing "+effective_cmd+str(args))
733
734 #flush all descriptors
735 sys.stdout.flush()
736
737=== modified file 'src/ubuntu/ubuntulocalrunconfiguration.cpp'
738--- src/ubuntu/ubuntulocalrunconfiguration.cpp 2014-09-02 15:06:34 +0000
739+++ src/ubuntu/ubuntulocalrunconfiguration.cpp 2014-09-12 10:47:38 +0000
740@@ -311,9 +311,7 @@
741 if(!UbuntuLocalRunConfiguration::readDesktopFile(desktopFile,&command,&args,errorMessage))
742 return false;
743
744- m_workingDir = target()->activeBuildConfiguration()->buildDirectory().toString()
745- + QDir::separator()
746- + QLatin1String(Constants::UBUNTU_DEPLOY_DESTDIR);
747+ m_workingDir = target()->activeBuildConfiguration()->buildDirectory().toString();
748
749 QFileInfo commInfo(command);
750 if(commInfo.fileName().startsWith(QLatin1String("qmlscene"))) {
751@@ -457,7 +455,7 @@
752 if(usedPaths.contains(path))
753 continue;
754
755- env.appendOrSet(QLatin1String("QML2_IMPORT_PATH"),path,QString::fromLatin1(":"));
756+ env.appendOrSet(QStringLiteral("QML2_IMPORT_PATH"),path,QStringLiteral(":"));
757 usedPaths.insert(path);
758 }
759 }

Subscribers

People subscribed via source and target branches