Merge lp:~3v1n0/snappy-playpen/hello-unity-fixes into lp:snappy-playpen
- hello-unity-fixes
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Michael Hall |
Approved revision: | 52 |
Merged at revision: | 48 |
Proposed branch: | lp:~3v1n0/snappy-playpen/hello-unity-fixes |
Merge into: | lp:snappy-playpen |
Diff against target: | 523 lines |
To merge this branch: | bzr merge lp:~3v1n0/snappy-playpen/hello-unity-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hall (community) | Approve | ||
Review via email: mp+294858@code.launchpad.net |
Commit message
Description of the change
Fixed hello-unity, to properly build and run in snap environment.
Since the upstream code needs some patches, I've played a little with it including an example of "quilt" plugin, which allows to use quilt patches to fix upstream code (upstream fixes parially live at lp:~3v1n0/hello-unity/sandbox-support).
- 51. By Marco Trevisan (Treviño)
-
HelloUnity: use cached files and user data around
- 52. By Marco Trevisan (Treviño)
-
HelloUnity: use snap version to chose which data or cache path use
Michael Hall (mhall119) wrote : | # |
Michael Hall (mhall119) wrote : | # |
Even installing with --devmode running the app fails:
mhall@mhall-
Traceback (most recent call last):
File "/snap/
__import_
File "/snap/
self.
File "/snap/
raise ResolutionError("No script named %r" % script_name)
pkg_resources.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Mhmhmh.... Wait, are you sure you installed this snap version? Because this should run /snap/hello-
I also had this problem, but also desktop files should actually run
/snap/
Which is a wrapper that eventually calls the script above
Michael Hall (mhall119) wrote : | # |
I removed and rebuilt everything, installed with --devmode, still getting this:
mhall@mhall-
Traceback (most recent call last):
File "/snap/
__import_
File "/snap/
self.
File "/snap/
raise ResolutionError("No script named %r" % script_name)
pkg_resources.
Jamie Strandboge (jdstrand) wrote : | # |
I get a different result. Note, I 'snap remove hello-unity' and then 'snap install ./hello-
Note I didn't install it with --devmode. When I run it I see:
Traceback (most recent call last):
File "/snap/
__boot()
File "/snap/
import os
ImportError: No module named os
and the following apparmor denials:
audit: type=1400 audit(146351378
audit: type=1400 audit(146351378
If I do:
$ grep -r 'jamie/bzr-pulls' ./*|grep -v pyc
I see a ton of absolute paths to my snap build directory rather then the snap install directory (/snap/
Michael Hall (mhall119) wrote : | # |
My mistake, I messed up my bzr merge and that was causing all of the problems. I had to use --devmode, and amd also getting some apparmor denials,but the app runs and most of the Unity API use works too, approving
Michael Hall (mhall119) wrote : | # |
Marco, can you propose these patches to the upstream project so I can merge them there?
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Michael, sure... Changes are already in lp:~3v1n0/hello-unity/sandbox-support (I planned to get these merged upstream too), but I also wanted to use this example to show how to patch upstream code.
However, we still need to include a patch (the one that changes the name of the .desktop file), so You could still merge it and update the downstream patches accordingly (remove the first two of the serie).
Preview Diff
1 | === modified file 'hello-unity/hello-unity.wrapper' (properties changed: +x to -x) | |||
2 | --- hello-unity/hello-unity.wrapper 2016-04-09 02:39:30 +0000 | |||
3 | +++ hello-unity/hello-unity.wrapper 2016-05-17 01:04:22 +0000 | |||
4 | @@ -1,6 +1,12 @@ | |||
6 | 1 | #!/bin/sh | 1 | #!/bin/bash |
7 | 2 | 2 | ||
9 | 3 | ARCH='i386-linux-gnu' | 3 | if [ "$SNAP_ARCH" == "amd64" ]; then |
10 | 4 | ARCH='x86_64-linux-gnu' | ||
11 | 5 | elif [ "$SNAP_ARCH" == "armhf" ]; then | ||
12 | 6 | ARCH="arm-linux-gnueabihf" | ||
13 | 7 | else | ||
14 | 8 | ARCH="$SNAP_ARCH-linux-gnu" | ||
15 | 9 | fi | ||
16 | 4 | 10 | ||
17 | 5 | export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH | 11 | export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH |
18 | 6 | 12 | ||
19 | @@ -12,16 +18,12 @@ | |||
20 | 12 | export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH | 18 | export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH |
21 | 13 | 19 | ||
22 | 14 | # XDG Config | 20 | # XDG Config |
25 | 15 | export XDG_CONFIG_DIRS=$SNAP/etc/xdg:$XDG_CONFIG_DIRS | 21 | export XDG_CONFIG_DIRS=$SNAP/etc:$XDG_CONFIG_DIRS |
26 | 16 | export XDG_CONFIG_DIRS=$SNAP/usr/xdg:$XDG_CONFIG_DIRS | 22 | |
27 | 17 | # Note: this doesn't seem to work, QML's LocalStorage either ignores | 23 | # Note: this doesn't seem to work, QML's LocalStorage either ignores |
28 | 18 | # or fails to use $SNAP_USER_DATA if defined here | 24 | # or fails to use $SNAP_USER_DATA if defined here |
29 | 19 | export XDG_DATA_DIRS=$SNAP_USER_DATA:$XDG_DATA_DIRS | ||
30 | 20 | export XDG_DATA_DIRS=$SNAP/usr/share:$XDG_DATA_DIRS | 25 | export XDG_DATA_DIRS=$SNAP/usr/share:$XDG_DATA_DIRS |
31 | 21 | 26 | ||
32 | 22 | # Not good, needed for fontconfig | ||
33 | 23 | export XDG_DATA_HOME=$SNAP/usr/share | ||
34 | 24 | |||
35 | 25 | # Font Config | 27 | # Font Config |
36 | 26 | export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d | 28 | export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d |
37 | 27 | export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf | 29 | export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf |
38 | @@ -32,5 +34,76 @@ | |||
39 | 32 | # Necessary for the SDK to find the translations directory | 34 | # Necessary for the SDK to find the translations directory |
40 | 33 | export APP_DIR=$SNAP | 35 | export APP_DIR=$SNAP |
41 | 34 | 36 | ||
44 | 35 | cd $SNAP | 37 | # Set XDG_DATA_HOME to local path, dependent on snap version |
45 | 36 | usr/bin/python $SNAP/usr/bin/hello-unity | 38 | export XDG_DATA_HOME=$SNAP_USER_DATA/.local-$SNAP_VERSION/share |
46 | 39 | export XDG_DATA_DIRS=$XDG_DATA_HOME:$XDG_DATA_DIRS | ||
47 | 40 | mkdir -p $XDG_DATA_HOME | ||
48 | 41 | |||
49 | 42 | # Set cache folder to local path, dependent on snap version | ||
50 | 43 | export XDG_CACHE_HOME=$SNAP_USER_DATA/.cache-$SNAP_VERSION | ||
51 | 44 | mkdir -p $XDG_CACHE_HOME | ||
52 | 45 | |||
53 | 46 | # Setup GI Repository typelibs (needed as some packages doesn't support multiarch) | ||
54 | 47 | export GI_TYPELIB_PATH=$SNAP/usr/lib/$ARCH/girepository-1.0:$SNAP/usr/lib/girepository-1.0 | ||
55 | 48 | |||
56 | 49 | # Not good, needed for fontconfig and themes | ||
57 | 50 | ln -sf $SNAP/usr/share/{fontconfig,fonts,fonts-*,themes} $XDG_DATA_HOME | ||
58 | 51 | |||
59 | 52 | # Gio modules and cache | ||
60 | 53 | export GIO_MODULE_DIR=$XDG_CACHE_HOME/gio-modules | ||
61 | 54 | |||
62 | 55 | if [ ! -d $GIO_MODULE_DIR ]; then | ||
63 | 56 | mkdir -p $GIO_MODULE_DIR | ||
64 | 57 | ln -s $SNAP/usr/lib/$ARCH/gio/modules/*.so $GIO_MODULE_DIR | ||
65 | 58 | $SNAP/usr/lib/$ARCH/glib-2.0/gio-querymodules $GIO_MODULE_DIR | ||
66 | 59 | fi | ||
67 | 60 | |||
68 | 61 | # Build mime.cache | ||
69 | 62 | if [ ! -d $XDG_DATA_HOME/mime ]; then | ||
70 | 63 | cp -a $SNAP/usr/share/mime $XDG_DATA_HOME | ||
71 | 64 | update-mime-database $XDG_DATA_HOME/mime | ||
72 | 65 | fi | ||
73 | 66 | |||
74 | 67 | # Setup GDK pixbuf loaders | ||
75 | 68 | export GDK_PIXBUF_MODULE_FILE=$XDG_CACHE_HOME/gdk-pixbuf-loaders.cache | ||
76 | 69 | export GDK_PIXBUF_MODULEDIR=$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/2.10.0/loaders | ||
77 | 70 | |||
78 | 71 | if [ ! -e $GDK_PIXBUF_MODULE_FILE ]; then | ||
79 | 72 | $SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders > $GDK_PIXBUF_MODULE_FILE | ||
80 | 73 | fi | ||
81 | 74 | |||
82 | 75 | # Keep an array of data dirs, for looping through them | ||
83 | 76 | IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS" | ||
84 | 77 | |||
85 | 78 | # Setup compiled gsettings schema | ||
86 | 79 | GS_SCHEMA_DIR=$XDG_DATA_HOME/glib-2.0/schemas | ||
87 | 80 | |||
88 | 81 | if [ ! -d $GS_SCHEMA_DIR ]; then | ||
89 | 82 | mkdir -p $GS_SCHEMA_DIR | ||
90 | 83 | for d in "${data_dirs_array[@]}"; do | ||
91 | 84 | ln -s $d/glib-2.0/schemas/*.xml $GS_SCHEMA_DIR | ||
92 | 85 | done | ||
93 | 86 | |||
94 | 87 | $SNAP/usr/lib/$ARCH/glib-2.0/glib-compile-schemas $GS_SCHEMA_DIR | ||
95 | 88 | fi | ||
96 | 89 | |||
97 | 90 | # Icon themes cache | ||
98 | 91 | if [ ! -d $XDG_DATA_HOME/icons ]; then | ||
99 | 92 | mkdir -p $XDG_DATA_HOME/icons | ||
100 | 93 | for d in "${data_dirs_array[@]}"; do | ||
101 | 94 | for i in $d/icons/*; do | ||
102 | 95 | if [ -d "$i" ]; then | ||
103 | 96 | theme_dir=$XDG_DATA_HOME/icons/$(basename "$i") | ||
104 | 97 | mkdir -p "$theme_dir" | ||
105 | 98 | ln -s $i/* "$theme_dir" | ||
106 | 99 | $SNAP/usr/sbin/update-icon-caches "$theme_dir" | ||
107 | 100 | gtk-update-icon-cache-3.0 "$theme_dir" | ||
108 | 101 | fi | ||
109 | 102 | done | ||
110 | 103 | done | ||
111 | 104 | fi | ||
112 | 105 | |||
113 | 106 | # GTK modules | ||
114 | 107 | export GTK_PATH=$SNAP/usr/lib/$ARCH/gtk-3.0 | ||
115 | 108 | |||
116 | 109 | exec $SNAP/usr/bin/python $SNAP/opt/bin/hello-unity | ||
117 | 37 | 110 | ||
118 | === added directory 'hello-unity/parts' | |||
119 | === added directory 'hello-unity/parts/plugins' | |||
120 | === added file 'hello-unity/parts/plugins/x-quilt.py' | |||
121 | --- hello-unity/parts/plugins/x-quilt.py 1970-01-01 00:00:00 +0000 | |||
122 | +++ hello-unity/parts/plugins/x-quilt.py 2016-05-17 01:04:22 +0000 | |||
123 | @@ -0,0 +1,106 @@ | |||
124 | 1 | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
125 | 2 | # | ||
126 | 3 | # Author: Marco Trevisan <marco.trevisan@canonical.com> | ||
127 | 4 | # Copyright (C) 2016 Canonical Ltd | ||
128 | 5 | # | ||
129 | 6 | # This program is free software: you can redistribute it and/or modify | ||
130 | 7 | # it under the terms of the GNU General Public License version 3 as | ||
131 | 8 | # published by the Free Software Foundation. | ||
132 | 9 | # | ||
133 | 10 | # This program is distributed in the hope that it will be useful, | ||
134 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
135 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
136 | 13 | # GNU General Public License for more details. | ||
137 | 14 | # | ||
138 | 15 | # You should have received a copy of the GNU General Public License | ||
139 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
140 | 17 | |||
141 | 18 | """A simple snapcraft plugin that allows to use quilt patches with any | ||
142 | 19 | source package. | ||
143 | 20 | |||
144 | 21 | In order to use this, the yaml file should contain: | ||
145 | 22 | - A part that only fetches the sources (you can use the copy plugin or | ||
146 | 23 | a dummy project plugin, that only extends BasePlugin) | ||
147 | 24 | - A part that uses this plugin (quilt) and that has the `after:` and | ||
148 | 25 | `target-part:` parameters containing the part defined above | ||
149 | 26 | - A part that uses the actual builder plugin for such sources, that has | ||
150 | 27 | the previous part (patches) in the `after:` list, and that uses as | ||
151 | 28 | `sources:` the sources part. | ||
152 | 29 | |||
153 | 30 | For example: | ||
154 | 31 | |||
155 | 32 | parts: | ||
156 | 33 | upstream-src: | ||
157 | 34 | plugin: copy | ||
158 | 35 | source: https://github.com/ubuntu-core/snapcraft.git | ||
159 | 36 | files: | ||
160 | 37 | README.md: docs/README.md | ||
161 | 38 | |||
162 | 39 | patches: | ||
163 | 40 | plugin: quilt | ||
164 | 41 | source: https://github.com/3v1n0/my-snapcraft-patches.git | ||
165 | 42 | target-part: upstream-src | ||
166 | 43 | after: [upstream-src] | ||
167 | 44 | |||
168 | 45 | setup: | ||
169 | 46 | plugin: python3 | ||
170 | 47 | source: ./parts/upstream-src/src/ | ||
171 | 48 | build-packages: | ||
172 | 49 | - python-distutils-extra | ||
173 | 50 | after: [patches] | ||
174 | 51 | """ | ||
175 | 52 | |||
176 | 53 | import os | ||
177 | 54 | import stat | ||
178 | 55 | |||
179 | 56 | import snapcraft | ||
180 | 57 | |||
181 | 58 | class QuiltPlugin(snapcraft.BasePlugin): | ||
182 | 59 | |||
183 | 60 | @classmethod | ||
184 | 61 | def schema(cls): | ||
185 | 62 | schema = super().schema() | ||
186 | 63 | |||
187 | 64 | schema['properties']['patches-dir'] = { | ||
188 | 65 | 'type': 'string', | ||
189 | 66 | 'default': '', | ||
190 | 67 | } | ||
191 | 68 | |||
192 | 69 | schema['properties']['target-part'] = { | ||
193 | 70 | 'type': 'string' | ||
194 | 71 | } | ||
195 | 72 | |||
196 | 73 | schema['required'].append('target-part') | ||
197 | 74 | |||
198 | 75 | return schema | ||
199 | 76 | |||
200 | 77 | def __init__(self, name, options, project): | ||
201 | 78 | super().__init__(name, options, project) | ||
202 | 79 | self.build_packages.extend(['quilt']) | ||
203 | 80 | |||
204 | 81 | self.patch_dir = os.path.join(self.sourcedir, self.options.patches_dir) | ||
205 | 82 | self.target_dir = os.path.join(self.project.parts_dir, self.options.target_part) | ||
206 | 83 | self.target_src = os.path.join(self.target_dir, "src") | ||
207 | 84 | |||
208 | 85 | def build(self): | ||
209 | 86 | super().build() | ||
210 | 87 | |||
211 | 88 | if not os.path.exists(self.target_src) or \ | ||
212 | 89 | not os.path.exists(os.path.join(self.target_dir, "state", "pull")): | ||
213 | 90 | raise EnvironmentError('Target part not fetched, fix order in yaml file: {}'.format(self.options.target_part)) | ||
214 | 91 | |||
215 | 92 | if os.path.exists(self.patch_dir): | ||
216 | 93 | os.environ['QUILT_PATCHES'] = self.patch_dir | ||
217 | 94 | self.run(['quilt', 'push', '-a'], cwd=self.target_src) | ||
218 | 95 | |||
219 | 96 | def clean_build(self): | ||
220 | 97 | super().clean_build() | ||
221 | 98 | |||
222 | 99 | if os.path.exists(self.patch_dir) and \ | ||
223 | 100 | os.path.exists(os.path.join(self.partdir, "state", "build")): | ||
224 | 101 | try: | ||
225 | 102 | os.environ['QUILT_PATCHES'] = self.patch_dir | ||
226 | 103 | self.run(['quilt', 'pop', '-a', '-f'], cwd=self.target_src) | ||
227 | 104 | except: | ||
228 | 105 | pass | ||
229 | 106 | |||
230 | 0 | 107 | ||
231 | === added directory 'hello-unity/patches' | |||
232 | === added file 'hello-unity/patches/ignore-sound-tab-if-missing-indicator.patch' | |||
233 | --- hello-unity/patches/ignore-sound-tab-if-missing-indicator.patch 1970-01-01 00:00:00 +0000 | |||
234 | +++ hello-unity/patches/ignore-sound-tab-if-missing-indicator.patch 2016-05-17 01:04:22 +0000 | |||
235 | @@ -0,0 +1,22 @@ | |||
236 | 1 | Index: hello-unity-snapped/hello_unity/window.py | ||
237 | 2 | =================================================================== | ||
238 | 3 | --- hello-unity-snapped.orig/hello_unity/window.py | ||
239 | 4 | +++ hello-unity-snapped/hello_unity/window.py | ||
240 | 5 | @@ -3,6 +3,7 @@ | ||
241 | 6 | from gettext import gettext as _ | ||
242 | 7 | |||
243 | 8 | from gi.repository import Gdk | ||
244 | 9 | +from gi.repository import Gio | ||
245 | 10 | from gi.repository import Gtk | ||
246 | 11 | from gi.repository import GtkSource | ||
247 | 12 | |||
248 | 13 | @@ -53,7 +54,8 @@ application can integrate with Ubuntu Un | ||
249 | 14 | self.add_section(_("Launcher"), HelloLauncher(self)) | ||
250 | 15 | self.add_section(_("Indicator"), HelloIndicator(self)) | ||
251 | 16 | self.add_section(_("Message Menu"), HelloMessageMenu(self)) | ||
252 | 17 | - self.add_section(_("Sound Menu"), HelloSoundMenu(self)) | ||
253 | 18 | + if Gio.SettingsSchemaSource.get_default().lookup('com.canonical.indicator.sound', False): | ||
254 | 19 | + self.add_section(_("Sound Menu"), HelloSoundMenu(self)) | ||
255 | 20 | #self.add_section(_("Dash"), hello_unity.HelloUnitySection(self)) | ||
256 | 21 | self.add_section(_("Notifications"), HelloNotifications(self)) | ||
257 | 22 | |||
258 | 0 | 23 | ||
259 | === added file 'hello-unity/patches/series' | |||
260 | --- hello-unity/patches/series 1970-01-01 00:00:00 +0000 | |||
261 | +++ hello-unity/patches/series 2016-05-17 01:04:22 +0000 | |||
262 | @@ -0,0 +1,3 @@ | |||
263 | 1 | use-xdg-dirs-to-get-file-paths.patch | ||
264 | 2 | ignore-sound-tab-if-missing-indicator.patch | ||
265 | 3 | use-snappy-desktop-id.patch | ||
266 | 0 | 4 | ||
267 | === added file 'hello-unity/patches/use-snappy-desktop-id.patch' | |||
268 | --- hello-unity/patches/use-snappy-desktop-id.patch 1970-01-01 00:00:00 +0000 | |||
269 | +++ hello-unity/patches/use-snappy-desktop-id.patch 2016-05-17 01:04:22 +0000 | |||
270 | @@ -0,0 +1,39 @@ | |||
271 | 1 | Index: hello-unity-snapped/hello_unity/launcher.py | ||
272 | 2 | =================================================================== | ||
273 | 3 | --- hello-unity-snapped.orig/hello_unity/launcher.py | ||
274 | 4 | +++ hello-unity-snapped/hello_unity/launcher.py | ||
275 | 5 | @@ -34,7 +34,7 @@ class HelloLauncher(hello_unity.HelloUni | ||
276 | 6 | |||
277 | 7 | # Get a reference to the launcher for this application. The .desktop | ||
278 | 8 | # file give Unity information about the Application's name and icon | ||
279 | 9 | - self.launcher = Unity.LauncherEntry.get_for_desktop_id("hello-unity.desktop") | ||
280 | 10 | + self.launcher = Unity.LauncherEntry.get_for_desktop_id("hello-unity_hello-unity.desktop") | ||
281 | 11 | |||
282 | 12 | # Create the quicklist menu | ||
283 | 13 | quicklist = Dbusmenu.Menuitem.new() | ||
284 | 14 | Index: hello-unity-snapped/hello_unity/messagemenu.py | ||
285 | 15 | =================================================================== | ||
286 | 16 | --- hello-unity-snapped.orig/hello_unity/messagemenu.py | ||
287 | 17 | +++ hello-unity-snapped/hello_unity/messagemenu.py | ||
288 | 18 | @@ -28,7 +28,7 @@ class HelloMessageMenu(hello_unity.Hello | ||
289 | 19 | def __init__(self, window): | ||
290 | 20 | |||
291 | 21 | # Create an "app" to represent the Hello Unity application | ||
292 | 22 | - self.app = MessagingMenu.App.new("hello-unity.desktop") | ||
293 | 23 | + self.app = MessagingMenu.App.new("hello-unity_hello-unity.desktop") | ||
294 | 24 | self.app.connect("activate-source", self.remove_indication) | ||
295 | 25 | |||
296 | 26 | # Register this app with the messaging menu | ||
297 | 27 | Index: hello-unity-snapped/hello_unity/soundmenu.py | ||
298 | 28 | =================================================================== | ||
299 | 29 | --- hello-unity-snapped.orig/hello_unity/soundmenu.py | ||
300 | 30 | +++ hello-unity-snapped/hello_unity/soundmenu.py | ||
301 | 31 | @@ -41,7 +41,7 @@ class HelloSoundMenu(hello_unity.HelloUn | ||
302 | 32 | self.sound_menu_settings.set_strv('blacklisted-media-players', [p for p in self.blacklisted_players if p != 'hello-unity']) | ||
303 | 33 | |||
304 | 34 | # Create a hello-unity music player instance | ||
305 | 35 | - self.player = Unity.MusicPlayer.new('hello-unity.desktop') | ||
306 | 36 | + self.player = Unity.MusicPlayer.new('hello-unity_hello-unity.desktop') | ||
307 | 37 | self.player.props.title = _('Hello Unity') | ||
308 | 38 | |||
309 | 39 | # What to do when the user presses the indicator buttons | ||
310 | 0 | 40 | ||
311 | === added file 'hello-unity/patches/use-xdg-dirs-to-get-file-paths.patch' | |||
312 | --- hello-unity/patches/use-xdg-dirs-to-get-file-paths.patch 1970-01-01 00:00:00 +0000 | |||
313 | +++ hello-unity/patches/use-xdg-dirs-to-get-file-paths.patch 2016-05-17 01:04:22 +0000 | |||
314 | @@ -0,0 +1,78 @@ | |||
315 | 1 | Index: hello-unity-snapped/hello_unity/__init__.py | ||
316 | 2 | =================================================================== | ||
317 | 3 | --- hello-unity-snapped.orig/hello_unity/__init__.py | ||
318 | 4 | +++ hello-unity-snapped/hello_unity/__init__.py | ||
319 | 5 | @@ -1,10 +1,20 @@ | ||
320 | 6 | import os | ||
321 | 7 | from gi.repository import Gtk | ||
322 | 8 | +from xdg.BaseDirectory import xdg_data_dirs | ||
323 | 9 | |||
324 | 10 | COLOR_ICON_PATH = 'hello-unity' | ||
325 | 11 | MONO_ICON_PATH = 'hello-unity-mono-dark' | ||
326 | 12 | ATTENTION_ICON_PATH = 'hello-unity-attention' | ||
327 | 13 | |||
328 | 14 | +def get_icon_path(basename): | ||
329 | 15 | + for dir in xdg_data_dirs: | ||
330 | 16 | + path = '%s/pixmaps/%s.svg' % (dir, basename) | ||
331 | 17 | + icon = Gtk.Image.new_from_file(path) | ||
332 | 18 | + pixbuf = icon.get_pixbuf() | ||
333 | 19 | + if pixbuf: | ||
334 | 20 | + return path | ||
335 | 21 | + | ||
336 | 22 | + | ||
337 | 23 | class HelloUnitySection(object): | ||
338 | 24 | |||
339 | 25 | def get_controls(self): | ||
340 | 26 | Index: hello-unity-snapped/hello_unity/soundmenu.py | ||
341 | 27 | =================================================================== | ||
342 | 28 | --- hello-unity-snapped.orig/hello_unity/soundmenu.py | ||
343 | 29 | +++ hello-unity-snapped/hello_unity/soundmenu.py | ||
344 | 30 | @@ -2,6 +2,7 @@ | ||
345 | 31 | |||
346 | 32 | # Used for making text translatable | ||
347 | 33 | from gettext import gettext as _ | ||
348 | 34 | +from xdg.BaseDirectory import xdg_data_dirs | ||
349 | 35 | |||
350 | 36 | # Import the base UI toolkit modules | ||
351 | 37 | from gi.repository import Gdk | ||
352 | 38 | @@ -201,7 +202,9 @@ class HelloSoundMenu(hello_unity.HelloUn | ||
353 | 39 | data.props.album = "Unity Showcase" | ||
354 | 40 | |||
355 | 41 | # You can also set the cover art for this track | ||
356 | 42 | - data.props.art_location = Gio.File.new_for_path('/usr/share/pixmaps/%s.svg' % hello_unity.ATTENTION_ICON_PATH) | ||
357 | 43 | + attention_icon = hello_unity.get_icon_path(hello_unity.ATTENTION_ICON_PATH) | ||
358 | 44 | + if attention_icon: | ||
359 | 45 | + data.props.art_location = Gio.File.new_for_path(attention_icon) | ||
360 | 46 | |||
361 | 47 | # Set the new track metadata as the current track in the sound menu | ||
362 | 48 | self.player.props.current_track = data | ||
363 | 49 | Index: hello-unity-snapped/hello_unity/window.py | ||
364 | 50 | =================================================================== | ||
365 | 51 | --- hello-unity-snapped.orig/hello_unity/window.py | ||
366 | 52 | +++ hello-unity-snapped/hello_unity/window.py | ||
367 | 53 | @@ -19,14 +19,21 @@ class HelloWindow(Gtk.Window): | ||
368 | 54 | Gtk.Window.__init__(self, title=_("Hello Unity")) | ||
369 | 55 | |||
370 | 56 | self.set_default_size(500, 500) | ||
371 | 57 | - self.color_icon = Gtk.Image.new_from_file('/usr/share/pixmaps/%s.svg' % hello_unity.COLOR_ICON_PATH) | ||
372 | 58 | - | ||
373 | 59 | - self.set_icon(self.color_icon.get_pixbuf()) | ||
374 | 60 | + | ||
375 | 61 | + icon_path = hello_unity.get_icon_path(hello_unity.COLOR_ICON_PATH) | ||
376 | 62 | + | ||
377 | 63 | + if icon_path: | ||
378 | 64 | + color_icon = Gtk.Image.new_from_file(icon_path) | ||
379 | 65 | + pixbuf = color_icon.get_pixbuf() | ||
380 | 66 | + self.set_icon(pixbuf) | ||
381 | 67 | |||
382 | 68 | self.content = Gtk.VBox() | ||
383 | 69 | |||
384 | 70 | self.header = Gtk.HBox() | ||
385 | 71 | - self.header.pack_start(Gtk.Image.new_from_pixbuf(self.color_icon.get_pixbuf().scale_simple(64, 64, 0)), False, False, 10) | ||
386 | 72 | + if icon_path: | ||
387 | 73 | + img = Gtk.Image.new_from_pixbuf(pixbuf.scale_simple(64, 64, 0)) | ||
388 | 74 | + self.header.pack_start(img, False, False, 10) | ||
389 | 75 | + | ||
390 | 76 | intro = Gtk.Label() | ||
391 | 77 | intro.set_markup(_(''' | ||
392 | 78 | <b>Hello Unity!</b> | ||
393 | 0 | 79 | ||
394 | === added directory 'hello-unity/setup' | |||
395 | === added directory 'hello-unity/setup/gui' | |||
396 | === added file 'hello-unity/setup/gui/hello-unity.desktop' | |||
397 | --- hello-unity/setup/gui/hello-unity.desktop 1970-01-01 00:00:00 +0000 | |||
398 | +++ hello-unity/setup/gui/hello-unity.desktop 2016-05-17 01:04:22 +0000 | |||
399 | @@ -0,0 +1,10 @@ | |||
400 | 1 | [Desktop Entry] | ||
401 | 2 | Name=HelloUnity | ||
402 | 3 | X-GNOME-FullName=Hello Unity | ||
403 | 4 | Comment=Unity Integration Showcase | ||
404 | 5 | Categories=GNOME;Utility; | ||
405 | 6 | Exec=hello-unity | ||
406 | 7 | Icon=${SNAP}/usr/share/pixmaps/hello-unity.svg | ||
407 | 8 | Terminal=false | ||
408 | 9 | Type=Application | ||
409 | 10 | Version=0.4 | ||
410 | 0 | 11 | ||
411 | === removed file 'hello-unity/snapcraft.log' | |||
412 | --- hello-unity/snapcraft.log 2016-04-09 02:39:30 +0000 | |||
413 | +++ hello-unity/snapcraft.log 1970-01-01 00:00:00 +0000 | |||
414 | @@ -1,40 +0,0 @@ | |||
415 | 1 | Preparing to pull hello-unity | ||
416 | 2 | |||
417 | 3 | Hit http://us.archive.ubuntu.com/ubuntu xenial InRelease | 0 | Hit http://us.archive.ubuntu.com/ubuntu xenial InRelease |
418 | 4 | |||
419 | 5 | Hit http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease | 1 | Hit http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease |
420 | 6 | |||
421 | 7 | Hit http://security.ubuntu.com/ubuntu xenial-security InRelease | 2 | Hit http://security.ubuntu.com/ubuntu xenial-security InRelease |
422 | 8 | |||
423 | 9 | Fetched 0 B in 0s (0 B/s) | 3 | Fetched 0 B in 0s (0 B/s) |
424 | 10 | Skipping blacklisted from manifest packages: ['adduser', 'apt', 'apt-utils', 'base-files', 'base-passwd', 'bash', 'bsdutils', 'coreutils', 'dash', 'debconf', 'debconf-i18n', 'debianutils', 'diffutils', 'dmsetup', 'dpkg', 'e2fslibs', 'e2fsprogs', 'file', 'findutils', 'gcc-4.9-base', 'gcc-5-base', 'gnupg', 'gpgv', 'grep', 'gzip', 'hostname', 'init', 'initscripts', 'insserv', 'libacl1', 'libapparmor1', 'libattr1', 'libaudit-common', 'libaudit1', 'libblkid1', 'libbz2-1.0', 'libc-bin', 'libc6', 'libcap2', 'libcap2-bin', 'libcomerr2', 'libcryptsetup4', 'libdb5.3', 'libdebconfclient0', 'libdevmapper1.02.1', 'libgcc1', 'libgcrypt20', 'libgpg-error0', 'libgpm2', 'libkmod2', 'liblocale-gettext-perl', 'liblzma5', 'libmagic1', 'libmount1', 'libncurses5', 'libncursesw5', 'libpam-modules', 'libpam-modules-bin', 'libpam-runtime', 'libpam0g', 'libpcre3', 'libreadline6', 'libselinux1', 'libsemanage-common', 'libsemanage1', 'libsepol1', 'libslang2', 'libsmartcols1', 'libss2', 'libstdc++6', 'libsystemd0', 'libtext-charwidth-perl', 'libtext-iconv-perl', 'libtext-wrapi18n-perl', 'libtinfo5', 'libudev1', 'libusb-0.1-4', 'libustr-1.0-1', 'libuuid1', 'locales', 'login', 'lsb-base', 'makedev', 'manpages', 'manpages-dev', 'mawk', 'mount', 'multiarch-support', 'ncurses-base', 'ncurses-bin', 'passwd', 'perl-base', 'procps', 'readline-common', 'sed', 'sensible-utils', 'systemd', 'systemd-sysv', 'sysv-rc', 'sysvinit-utils', 'tar', 'tzdata', 'ubuntu-keyring', 'udev', 'util-linux', 'zlib1g'] | ||
425 | 11 | |||
426 | 12 | Fetched 0 B in 0s (0 B/s) | 4 | Fetched 0 B in 0s (0 B/s) |
427 | 13 | Pulling hello-unity | ||
428 | 14 | No revisions or tags to pull. | ||
429 | 15 | python2 /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/bin/easy_install --prefix /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr pip | ||
430 | 16 | Searching for pip | ||
431 | 17 | Best match: pip 8.1.1 | ||
432 | 18 | Processing pip-8.1.1-py2.7.egg | ||
433 | 19 | pip 8.1.1 is already the active version in easy-install.pth | ||
434 | 20 | Installing pip script to /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/bin | ||
435 | 21 | Installing pip2.7 script to /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/bin | ||
436 | 22 | Installing pip2 script to /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/bin | ||
437 | 23 | |||
438 | 24 | Using /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/lib/python2.7/dist-packages/pip-8.1.1-py2.7.egg | ||
439 | 25 | Processing dependencies for pip | ||
440 | 26 | Finished processing dependencies for pip | ||
441 | 27 | python2 /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/bin/pip2 install --global-option=build_ext --global-option=-I/home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/include/python2.7 --target /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/lib/python2.7/site-packages . | ||
442 | 28 | Processing /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/src | ||
443 | 29 | Installing collected packages: hello-unity | ||
444 | 30 | Running setup.py install for hello-unity: started | ||
445 | 31 | Running setup.py install for hello-unity: finished with status 'error' | ||
446 | 32 | Complete output from command /home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-WmPupa-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" build_ext -I/home/mhall/projects/Ubuntu/snaps/snappy-playpen/hello-unity/parts/hello-unity/install/usr/include/python2.7 install --record /tmp/pip-GIIwsc-record/install-record.txt --single-version-externally-managed --compile --home=/tmp/tmpKTEaYf: | ||
447 | 33 | ERROR: Python module indicator not found | ||
448 | 34 | ERROR: Python module launcher not found | ||
449 | 35 | ERROR: Python module messagemenu not found | ||
450 | 36 | ERROR: Python module soundmenu not found | ||
451 | 37 | ERROR: Python module notifications not found | ||
452 | 38 | usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] | ||
453 | 39 | or: -c --help [cmd1 cmd2 ...] | ||
454 | 40 | or: -c --help-commands | ||
455 | 41 | or: -c cmd --help | ||
456 | 42 | |||
457 | 43 | error: option --single-version-externally-managed not recognized | ||
458 | 44 | |||
459 | 45 | ---------------------------------------- | ||
460 | 46 | 5 | ||
461 | === modified file 'hello-unity/snapcraft.yaml' | |||
462 | --- hello-unity/snapcraft.yaml 2016-04-14 14:47:59 +0000 | |||
463 | +++ hello-unity/snapcraft.yaml 2016-05-17 01:04:22 +0000 | |||
464 | @@ -1,5 +1,5 @@ | |||
465 | 1 | name: hello-unity | 1 | name: hello-unity |
467 | 2 | version: 0.4-snap1 | 2 | version: 0.4-snap2 |
468 | 3 | summary: Unity APIs demonstration tool | 3 | summary: Unity APIs demonstration tool |
469 | 4 | description: Simple tool for demonstrating Unity's integration APIs | 4 | description: Simple tool for demonstrating Unity's integration APIs |
470 | 5 | 5 | ||
471 | @@ -9,21 +9,54 @@ | |||
472 | 9 | plugs: [unity7] | 9 | plugs: [unity7] |
473 | 10 | 10 | ||
474 | 11 | parts: | 11 | parts: |
477 | 12 | hello-unity: | 12 | upstream-src: |
478 | 13 | plugin: python2 | 13 | plugin: copy |
479 | 14 | source: lp:hello-unity | 14 | source: lp:hello-unity |
480 | 15 | source-type: bzr | 15 | source-type: bzr |
481 | 16 | files: | ||
482 | 17 | hello-unity: opt/bin/hello-unity | ||
483 | 18 | hello-unity.svg: usr/share/pixmaps/hello-unity.svg | ||
484 | 19 | hello-unity-mono-light.svg: usr/share/pixmaps/hello-unity-mono-light.svg | ||
485 | 20 | hello-unity-attention.svg: usr/share/pixmaps/hello-unity-attention.svg | ||
486 | 21 | hello-unity-mono-dark.svg: usr/share/pixmaps/hello-unity-mono-dark.svg | ||
487 | 22 | |||
488 | 23 | patches: | ||
489 | 24 | plugin: quilt | ||
490 | 25 | source: ./patches | ||
491 | 26 | stage-packages: [python-xdg] | ||
492 | 27 | target-part: upstream-src | ||
493 | 28 | after: [upstream-src] | ||
494 | 29 | |||
495 | 30 | setup: | ||
496 | 31 | plugin: python2 | ||
497 | 32 | source: ./parts/upstream-src/src/ | ||
498 | 16 | build-packages: | 33 | build-packages: |
499 | 17 | - python-distutils-extra | 34 | - python-distutils-extra |
500 | 35 | after: [patches] | ||
501 | 36 | |||
502 | 37 | deps: | ||
503 | 38 | plugin: nil | ||
504 | 18 | stage-packages: | 39 | stage-packages: |
506 | 19 | - python-distutils-extra | 40 | - python-gi |
507 | 20 | - gir1.2-unity-5.0 | 41 | - gir1.2-unity-5.0 |
508 | 21 | - gir1.2-notify-0.7 | 42 | - gir1.2-notify-0.7 |
509 | 22 | - gir1.2-appindicator3-0.1 | 43 | - gir1.2-appindicator3-0.1 |
510 | 23 | - gir1.2-indicate-0.7 | 44 | - gir1.2-indicate-0.7 |
511 | 45 | - gir1.2-messagingmenu-1.0 | ||
512 | 24 | - gir1.2-gtk-3.0 | 46 | - gir1.2-gtk-3.0 |
513 | 25 | - gir1.2-gtksource-3.0 | 47 | - gir1.2-gtksource-3.0 |
514 | 26 | 48 | ||
515 | 49 | integration: | ||
516 | 50 | plugin: nil | ||
517 | 51 | stage-packages: | ||
518 | 52 | - dmz-cursor-theme | ||
519 | 53 | - indicator-sound | ||
520 | 54 | - light-themes | ||
521 | 55 | - ttf-ubuntu-font-family | ||
522 | 56 | snap: | ||
523 | 57 | - usr/share | ||
524 | 58 | - -usr/share/doc | ||
525 | 59 | |||
526 | 27 | environment: | 60 | environment: |
527 | 28 | plugin: copy | 61 | plugin: copy |
528 | 29 | files: | 62 | files: |
Built a snap using this, but got apparmor error when running it:
May 16 23:00:34 mhall-thinkpad kernel: [10792.749388] audit: type=1400 audit(146345763 4.502:103) : apparmor="DENIED" operation="open" profile= "snap.hello- unity.hello- unity" name="/ home/mhall/ projects/ Ubuntu/ snaps/snappy- playpen/ hello-unity/ stage/usr/ lib/python2. 7/os.py" pid=18146 comm="hello-unity" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000 4.502:104) : apparmor="DENIED" operation="open" profile= "snap.hello- unity.hello- unity" name="/ home/mhall/ projects/ Ubuntu/ snaps/snappy- playpen/ hello-unity/ stage/usr/ lib/python2. 7/os.pyc" pid=18146 comm="hello-unity" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
May 16 23:00:34 mhall-thinkpad kernel: [10792.749452] audit: type=1400 audit(146345763