Merge lp:~ted/ubuntu-app-launch/xdg-data-dirs into lp:ubuntu-app-launch/14.04

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 86
Merged at revision: 82
Proposed branch: lp:~ted/ubuntu-app-launch/xdg-data-dirs
Merge into: lp:ubuntu-app-launch/14.04
Diff against target: 197 lines (+90/-7)
7 files modified
click-exec.c (+2/-2)
desktop-exec.c (+1/-1)
helpers.c (+9/-1)
helpers.h (+2/-1)
tests/CMakeLists.txt (+1/-0)
tests/helper-test.cc (+74/-1)
tests/initctl (+1/-1)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/xdg-data-dirs
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Chris Wayne (community) Approve
Review via email: mp+194981@code.launchpad.net

Commit message

Set the XDG Data Dirs to include the application install directory

Description of the change

This branch makes it so that we update the XDG_DATA_DIRS to include the application install path. It also fixes the tests around this function to make sure we're actually checking values.

To post a comment you must log in.
Revision history for this message
Chris Wayne (cwayne) wrote :

I just tested by pbuilding + installing on a mako, and this seems to do the trick, click apps are now translated!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

Can this be top-approved now? It seems to work

Revision history for this message
Charles Kerr (charlesk) wrote :

WfM as well.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'click-exec.c'
2--- click-exec.c 2013-09-23 19:42:54 +0000
3+++ click-exec.c 2013-11-13 04:06:57 +0000
4@@ -60,8 +60,6 @@
5 return 1;
6 }
7
8- set_confined_envvars(package);
9-
10 /* Check click to find out where the files are */
11 gchar * cmdline = g_strdup_printf("click pkgdir \"%s\"", package);
12 g_free(package);
13@@ -92,6 +90,8 @@
14 g_debug("Setting 'APP_DIR' to '%s'", output);
15 set_upstart_variable("APP_DIR", output);
16
17+ set_confined_envvars(package, output);
18+
19 gchar * desktopfile = manifest_to_desktop(output, app_id);
20 g_free(output);
21 if (desktopfile == NULL) {
22
23=== modified file 'desktop-exec.c'
24--- desktop-exec.c 2013-09-23 19:42:54 +0000
25+++ desktop-exec.c 2013-11-13 04:06:57 +0000
26@@ -64,7 +64,7 @@
27 gchar * apparmor = g_key_file_get_string(keyfile, "Desktop Entry", "X-Ubuntu-AppArmor-Profile", NULL);
28 if (apparmor != NULL) {
29 set_upstart_variable("APP_EXEC_POLICY", apparmor);
30- set_confined_envvars(app_id);
31+ set_confined_envvars(app_id, "/usr/share");
32 g_free(apparmor);
33 } else {
34 set_upstart_variable("APP_EXEC_POLICY", "unconfined");
35
36=== modified file 'helpers.c'
37--- helpers.c 2013-10-04 20:51:05 +0000
38+++ helpers.c 2013-11-13 04:06:57 +0000
39@@ -605,8 +605,11 @@
40 * https://wiki.ubuntu.com/SecurityTeam/Specifications/ApplicationConfinement
41 */
42 void
43-set_confined_envvars (const gchar * package)
44+set_confined_envvars (const gchar * package, const gchar * app_dir)
45 {
46+ g_return_if_fail(package != NULL);
47+ g_return_if_fail(app_dir != NULL);
48+
49 g_debug("Setting 'UBUNTU_APPLICATION_ISOLATION' to '1'");
50 set_upstart_variable("UBUNTU_APPLICATION_ISOLATION", "1");
51
52@@ -627,6 +630,11 @@
53 g_debug("Setting 'XDG_RUNTIME_DIR' using g_get_user_runtime_dir()");
54 set_upstart_variable("XDG_RUNTIME_DIR", g_get_user_runtime_dir());
55
56+ /* Add the application's dir to the list of sources for data */
57+ gchar * datadirs = g_strjoin(":", app_dir, g_getenv("XDG_DATA_DIRS"), NULL);
58+ set_upstart_variable("XDG_DATA_DIRS", datadirs);
59+ g_free(datadirs);
60+
61 /* Set TMPDIR to something sane and application-specific */
62 gchar * tmpdir = g_strdup_printf("%s/confined/%s", g_get_user_runtime_dir(), package);
63 g_debug("Setting 'TMPDIR' to '%s'", tmpdir);
64
65=== modified file 'helpers.h'
66--- helpers.h 2013-09-23 17:27:08 +0000
67+++ helpers.h 2013-11-13 04:06:57 +0000
68@@ -33,5 +33,6 @@
69 const gchar * uri_list);
70 GKeyFile * keyfile_for_appid (const gchar * appid,
71 gchar * * desktopfile);
72-void set_confined_envvars (const gchar * package);
73+void set_confined_envvars (const gchar * package,
74+ const gchar * app_dir);
75
76
77=== modified file 'tests/CMakeLists.txt'
78--- tests/CMakeLists.txt 2013-09-30 17:09:10 +0000
79+++ tests/CMakeLists.txt 2013-11-13 04:06:57 +0000
80@@ -13,6 +13,7 @@
81
82 add_executable (helper-test helper-test.cc)
83 add_definitions ( -DCMAKE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" )
84+add_definitions ( -DCMAKE_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" )
85 target_link_libraries (helper-test helpers gtest ${GTEST_LIBS})
86
87 add_test (helper-test helper-test)
88
89=== modified file 'tests/helper-test.cc'
90--- tests/helper-test.cc 2013-09-24 03:48:52 +0000
91+++ tests/helper-test.cc 2013-11-13 04:06:57 +0000
92@@ -18,6 +18,7 @@
93 */
94
95 #include <gtest/gtest.h>
96+#include <glib/gstdio.h>
97
98 extern "C" {
99 #include "../helpers.h"
100@@ -31,6 +32,7 @@
101 virtual void SetUp() {
102 g_setenv("XDG_DATA_DIRS", CMAKE_SOURCE_DIR, TRUE);
103 g_setenv("PATH", CMAKE_SOURCE_DIR, TRUE);
104+ g_setenv("DATA_WRITE_DIR", CMAKE_BINARY_DIR, TRUE);
105 return;
106 }
107 };
108@@ -261,8 +263,79 @@
109
110 TEST_F(HelperTest, SetConfinedEnvvars)
111 {
112+ g_unlink(CMAKE_BINARY_DIR "/initctl-output.txt");
113+
114 /* Not a test other than "don't crash" */
115- set_confined_envvars("pkg");
116+ set_confined_envvars("foo-app-pkg", "/foo/bar");
117+
118+ ASSERT_TRUE(g_file_test(CMAKE_BINARY_DIR "/initctl-output.txt", G_FILE_TEST_EXISTS));
119+
120+ gchar * contents = NULL;
121+ ASSERT_TRUE(g_file_get_contents(CMAKE_BINARY_DIR "/initctl-output.txt", &contents, NULL, NULL));
122+
123+ gchar ** lines = g_strsplit(contents, "\n", 0);
124+ g_free(contents);
125+ unsigned int i;
126+
127+ bool got_app_isolation = false;
128+ bool got_cache_home = false;
129+ bool got_config_home = false;
130+ bool got_data_home = false;
131+ bool got_runtime_dir = false;
132+ bool got_data_dirs = false;
133+ bool got_temp_dir = false;
134+ bool got_shader_dir = false;
135+
136+ for (i = 0; lines[i] != NULL; i++) {
137+ g_debug("Checking: '%s'", lines[i]);
138+ if (lines[i][0] == '\0') continue;
139+
140+ ASSERT_TRUE(g_str_has_prefix(lines[i], "set-env "));
141+
142+ gchar * var = lines[i] + strlen("set-env ");
143+ gchar * equal = g_strstr_len(var, -1, "=");
144+ ASSERT_NE(equal, nullptr);
145+
146+ equal[0] = '\0';
147+ gchar * value = &(equal[1]);
148+
149+ if (g_strcmp0(var, "UBUNTU_APPLICATION_ISOLATION") == 0) {
150+ ASSERT_STREQ(value, "1");
151+ got_app_isolation = true;
152+ } else if (g_strcmp0(var, "XDG_CACHE_HOME") == 0) {
153+ got_cache_home = true;
154+ } else if (g_strcmp0(var, "XDG_CONFIG_HOME") == 0) {
155+ got_config_home = true;
156+ } else if (g_strcmp0(var, "XDG_DATA_HOME") == 0) {
157+ got_data_home = true;
158+ } else if (g_strcmp0(var, "XDG_RUNTIME_DIR") == 0) {
159+ got_runtime_dir = true;
160+ } else if (g_strcmp0(var, "XDG_DATA_DIRS") == 0) {
161+ ASSERT_TRUE(g_str_has_prefix(value, "/foo/bar:"));
162+ got_data_dirs = true;
163+ } else if (g_strcmp0(var, "TMPDIR") == 0) {
164+ ASSERT_TRUE(g_str_has_suffix(value, "foo-app-pkg"));
165+ got_temp_dir = true;
166+ } else if (g_strcmp0(var, "__GL_SHADER_DISK_CACHE_PATH") == 0) {
167+ ASSERT_TRUE(g_str_has_suffix(value, "foo-app-pkg"));
168+ got_shader_dir = true;
169+ } else {
170+ g_warning("Unknown variable! %s", lines[i]);
171+ ASSERT_TRUE(false);
172+ }
173+ }
174+
175+ g_strfreev(lines);
176+
177+ ASSERT_TRUE(got_app_isolation);
178+ ASSERT_TRUE(got_cache_home);
179+ ASSERT_TRUE(got_config_home);
180+ ASSERT_TRUE(got_data_home);
181+ ASSERT_TRUE(got_runtime_dir);
182+ ASSERT_TRUE(got_data_dirs);
183+ ASSERT_TRUE(got_temp_dir);
184+ ASSERT_TRUE(got_shader_dir);
185+
186 return;
187 }
188
189
190=== modified file 'tests/initctl'
191--- tests/initctl 2013-09-24 02:56:22 +0000
192+++ tests/initctl 2013-11-13 04:06:57 +0000
193@@ -1,3 +1,3 @@
194 #!/bin/bash
195
196-echo $@
197+echo $@ >> ${DATA_WRITE_DIR}/initctl-output.txt

Subscribers

People subscribed via source and target branches