Merge lp:~ted/ubuntu-app-launch/click-info into lp:ubuntu-app-launch/13.10

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 76
Merged at revision: 76
Proposed branch: lp:~ted/ubuntu-app-launch/click-info
Merge into: lp:ubuntu-app-launch/13.10
Diff against target: 118 lines (+22/-16)
3 files modified
debian/control (+1/-1)
helpers.c (+18/-15)
tests/click (+3/-0)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/click-info
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+189430@code.launchpad.net

Commit message

Use 'click info' to get manifests

Description of the change

Click devs didn't like us going through and finding the files ourselves, so they made a command to help us.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Cool. Nice improvement.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-09-24 03:53:13 +0000
3+++ debian/control 2013-10-04 21:03:37 +0000
4@@ -25,7 +25,7 @@
5 Architecture: any
6 Depends: ${shlibs:Depends},
7 ${misc:Depends},
8- click,
9+ click (>= 0.4.9),
10 click-apparmor,
11 Description: Upstart Job for Launching Applications
12 Upstart Job file and associated utilities that is used to launch
13
14=== modified file 'helpers.c'
15--- helpers.c 2013-09-23 19:42:54 +0000
16+++ helpers.c 2013-10-04 21:03:37 +0000
17@@ -61,6 +61,7 @@
18 manifest_to_desktop (const gchar * app_dir, const gchar * app_id)
19 {
20 gchar * package = NULL;
21+ gchar * output = NULL;
22 gchar * application = NULL;
23 gchar * version = NULL;
24 JsonParser * parser = NULL;
25@@ -72,60 +73,63 @@
26 return NULL;
27 }
28
29- gchar * manifestfile = g_strdup_printf("%s.manifest", package);
30- gchar * manifestpath = g_build_filename(app_dir, ".click", "info", manifestfile, NULL);
31- g_free(manifestfile);
32+ gchar * cmdline = g_strdup_printf("click info \"%s\"", package);
33+ g_spawn_command_line_sync(cmdline, &output, NULL, NULL, &error);
34+ g_free(cmdline);
35
36- if (!g_file_test(manifestpath, G_FILE_TEST_EXISTS)) {
37- g_warning("Unable to find manifest file: %s", manifestpath);
38+ if (error != NULL) {
39+ g_warning("Unable to get manifest for '%s': %s", package, error->message);
40+ g_error_free(error);
41 goto manifest_out;
42 }
43
44 parser = json_parser_new();
45
46- json_parser_load_from_file(parser, manifestpath, &error);
47+ json_parser_load_from_data(parser, output, -1, &error);
48+ g_free(output);
49+
50 if (error != NULL) {
51- g_warning("Unable to load manifest file '%s': %s", manifestpath, error->message);
52+ g_warning("Unable to load manifest data '%s': %s", package, error->message);
53 g_error_free(error);
54 goto manifest_out;
55 }
56
57 JsonNode * root = json_parser_get_root(parser);
58 if (json_node_get_node_type(root) != JSON_NODE_OBJECT) {
59- g_warning("Manifest '%s' doesn't start with an object", manifestpath);
60+ g_warning("Manifest '%s' doesn't start with an object", package);
61 goto manifest_out;
62 }
63
64 JsonObject * rootobj = json_node_get_object(root);
65 if (!json_object_has_member(rootobj, "version")) {
66- g_warning("Manifest '%s' doesn't have a version", manifestpath);
67+ g_warning("Manifest '%s' doesn't have a version", package);
68 goto manifest_out;
69 }
70
71 if (g_strcmp0(json_object_get_string_member(rootobj, "version"), version) != 0) {
72- g_warning("Manifest '%s' version '%s' doesn't match AppID version '%s'", manifestpath, json_object_get_string_member(rootobj, "version"), version);
73+ g_warning("Manifest '%s' version '%s' doesn't match AppID version '%s'", package, json_object_get_string_member(rootobj, "version"), version);
74 goto manifest_out;
75 }
76
77 if (!json_object_has_member(rootobj, "hooks")) {
78- g_warning("Manifest '%s' doesn't have an hooks section", manifestpath);
79+ g_warning("Manifest '%s' doesn't have an hooks section", package);
80 goto manifest_out;
81 }
82
83 JsonObject * appsobj = json_object_get_object_member(rootobj, "hooks");
84 if (appsobj == NULL) {
85- g_warning("Manifest '%s' has an hooks section that is not a JSON object", manifestpath);
86+ g_warning("Manifest '%s' has an hooks section that is not a JSON object", package);
87 goto manifest_out;
88 }
89
90 if (!json_object_has_member(appsobj, application)) {
91- g_warning("Manifest '%s' doesn't have the application '%s' defined", manifestpath, application);
92+ g_warning("Manifest '%s' doesn't have the application '%s' defined", package, application);
93 goto manifest_out;
94 }
95
96 JsonObject * appobj = json_object_get_object_member(appsobj, application);
97 if (appobj == NULL) {
98- g_warning("Manifest '%s' has a definition for application '%s' that is not an object", manifestpath, application);
99+ g_warning("Manifest '%s' has a definition for application '%s' that is not an object", package, application);
100 goto manifest_out;
101 }
102
103@@ -147,7 +151,6 @@
104
105 manifest_out:
106 g_clear_object(&parser);
107- g_free(manifestpath);
108 g_free(package);
109 g_free(application);
110 g_free(version);
111
112=== added file 'tests/click'
113--- tests/click 1970-01-01 00:00:00 +0000
114+++ tests/click 2013-10-04 21:03:37 +0000
115@@ -0,0 +1,3 @@
116+#!/bin/bash
117+
118+/bin/cat "${XDG_DATA_DIRS}/click-app-dir/.click/info/${2}.manifest"

Subscribers

People subscribed via source and target branches