2
# This file is part of Checkbox.
4
# Copyright 2015 Canonical Ltd.
6
# Maciej Kisielewski <maciej.kisielewski@canonical.com>
8
# Checkbox is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License version 3,
10
# as published by the Free Software Foundation.
12
# Checkbox is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
26
"destination": [ "documents"],
27
"source": [ "documents"],
28
"share": [ "documents"]
36
"content_exchange_source"
42
DESKTOP = """[Desktop Entry]
43
Name=Checkbox-${partial_id}
44
Comment=${partial_id} - confined test from Checkbox
45
Exec=qmlscene -I lib/py/plainbox/data/plainbox-qml-modules/ -I providers/${provider_name}/data/ --checkbox-name=${full_checkbox_name} --job ../providers/${provider_name}/data/${qml_file} $$@ confinement/plainbox-confined-shell.qml
46
Icon=checkbox-touch.svg
54
"apparmor": "providers/${provider_name}/data/confined/${partial_id}.apparmor",
55
"desktop": "providers/${provider_name}/data/confined/${partial_id}.desktop",
56
"content-hub": "providers/${provider_name}/data/confined/${partial_id}-ch.json"
60
def generate_confinement(provider_name, partial_id, full_checkbox_name, qml_file):
61
# generate content-hub file
62
target_dir = os.path.join('data', 'confined')
63
if not os.path.exists(target_dir):
64
os.makedirs(target_dir)
66
content_hub_path = os.path.join(target_dir, partial_id + '-ch.json')
67
with open(content_hub_path, "wt") as f:
70
# generate apparmor file
71
apparmor_path = os.path.join(target_dir, partial_id + '.apparmor')
72
with open(apparmor_path, "wt") as f:
76
# generate desktop file
77
desktop_path = os.path.join(target_dir, partial_id + '.desktop')
78
template = string.Template(DESKTOP)
79
with open(desktop_path, "wt") as f:
80
f.write(template.substitute(partial_id=partial_id, provider_name=provider_name, full_checkbox_name=full_checkbox_name, qml_file=qml_file))
82
def generate_hook(provider_name, partial_id):
83
return string.Template(HOOK).substitute(
84
provider_name=provider_name, partial_id=partial_id)
89
parser = argparse.ArgumentParser(
90
description="Generate confinement files for Checkbox")
91
parser.add_argument('--checkbox_version', action='store', type=str)
92
parser.add_argument('job_ids', nargs='+')
93
args = parser.parse_args()
94
checkbox_name = "com.ubuntu.checkbox_checkbox-touch_" + args.checkbox_version
96
# check if current dir looks like a provider - very dumb heuristic
97
if not os.path.exists('manage.py'):
98
sys.exit("Current directory doesn't look like a plainbox provider")
99
provider_name = os.path.split(os.getcwd())[-1]
102
for job in args.job_ids:
103
generate_confinement(provider_name, job, checkbox_name, job + '.qml')
104
hooks += generate_hook(provider_name, job)
106
print("Add following hooks to your checkbox-touch.manifest:")
110
if __name__ == '__main__':