/
gnome_3_28.py
132 lines (115 loc) · 4.8 KB
/
gnome_3_28.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2018-2019 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Import types and tell flake8 to ignore the "unused" List.
from typing import Any, Dict, Tuple
from ._extension import Extension
_PLATFORM_SNAP = dict(core18="gnome-3-28-1804")
class ExtensionImpl(Extension):
"""This extension eases creation of snaps that integrate with GNOME 3.28
At build time it ensures the right build dependencies are setup and for
the runtime it ensures the application is run in an environment catered
for GNOME applications.
It configures each application with the following plugs:
\b
- GTK3 Themes.
- Common Icon Themes.
- Common Sound Themes.
- The GNOME runtime libraries and utilities corresponding to 3.28.
For easier desktop integration, it also configures each application
entry with these additional plugs:
\b
- desktop (https://snapcraft.io/docs/desktop-interface)
- desktop-legacy (https://snapcraft.io/docs/desktop-legacy-interface)
- gsettings (https://snapcraft.io/docs/gsettings-interface)
- wayland (https://snapcraft.io/docs/wayland-interface)
- x11 (https://snapcraft.io/docs/x11-interface)
"""
@staticmethod
def get_supported_bases() -> Tuple[str, ...]:
return ("core18",)
@staticmethod
def get_supported_confinement() -> Tuple[str, ...]:
return ("strict", "devmode")
def __init__(self, *, extension_name: str, yaml_data: Dict[str, Any]) -> None:
super().__init__(extension_name=extension_name, yaml_data=yaml_data)
base: str = yaml_data["base"]
platform_snap = _PLATFORM_SNAP[base]
self.root_snippet = {
"assumes": ["snapd2.43"], # for 'snapctl is-connected'
"plugs": {
"desktop": {"mount-host-font-cache": False},
"gtk-3-themes": {
"interface": "content",
"target": "$SNAP/data-dir/themes",
"default-provider": "gtk-common-themes",
},
"icon-themes": {
"interface": "content",
"target": "$SNAP/data-dir/icons",
"default-provider": "gtk-common-themes",
},
"sound-themes": {
"interface": "content",
"target": "$SNAP/data-dir/sounds",
"default-provider": "gtk-common-themes",
},
platform_snap: {
"interface": "content",
"target": "$SNAP/gnome-platform",
"default-provider": "{snap}".format(snap=platform_snap),
},
},
"environment": {"SNAP_DESKTOP_RUNTIME": "$SNAP/gnome-platform"},
"hooks": {
"configure": {
"plugs": ["desktop"],
"command-chain": ["snap/command-chain/hooks-configure-desktop"],
}
},
"layout": {
"/usr/bin/gjs": {"symlink": "$SNAP/gnome-platform/usr/bin/gjs"},
"/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0": {
"bind": "$SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0"
},
"/usr/share/xml/iso-codes": {
"bind": "$SNAP/gnome-platform/usr/share/xml/iso-codes"
},
"/usr/share/libdrm": {"bind": "$SNAP/gnome-platform/usr/share/libdrm"},
},
}
self.app_snippet = {
"command-chain": ["snap/command-chain/desktop-launch"],
"plugs": [
"desktop",
"desktop-legacy",
"gsettings",
"opengl",
"wayland",
"x11",
],
}
self.parts = {
"gnome-3-28-extension": {
"source": "$SNAPCRAFT_EXTENSIONS_DIR/desktop",
"source-subdir": "gnome",
"plugin": "make",
"make-parameters": [
"WITH_BINDTEXTDOMAIN=1",
"PLATFORM_PLUG={plug}".format(plug=platform_snap),
],
"build-packages": ["gcc", "libgtk-3-dev"],
}
}