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/>.
27
"destination": [ "documents"],
28
"source": [ "documents"],
29
"share": [ "documents"]
37
"content_exchange_source"
43
DESKTOP = """[Desktop Entry]
44
Name=Checkbox-${partial_id}
45
Comment=${partial_id} - confined test from Checkbox
46
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
47
Icon=checkbox-touch.svg
54
def generate_confinement(provider_name, partial_id, full_checkbox_name,
56
# generate content-hub file
57
target_dir = os.path.join('data', 'confined')
58
if not os.path.exists(target_dir):
59
os.makedirs(target_dir)
61
content_hub_path = os.path.join(target_dir, partial_id + '-ch.json')
62
with open(content_hub_path, "wt") as f:
65
# generate apparmor file
66
apparmor_path = os.path.join(target_dir, partial_id + '.apparmor')
67
with open(apparmor_path, "wt") as f:
70
# generate desktop file
71
desktop_path = os.path.join(target_dir, partial_id + '.desktop')
72
template = string.Template(DESKTOP)
73
with open(desktop_path, "wt") as f:
74
f.write(template.substitute(
75
partial_id=partial_id, provider_name=provider_name,
76
full_checkbox_name=full_checkbox_name, qml_file=qml_file))
78
base = 'providers/{provider_name}/data/confined/{partial_id}'.format(
79
provider_name=provider_name, partial_id=partial_id)
82
'apparmor': base + '.apparmor',
83
'desktop': base + '.desktop',
84
'content-hub': base + '-ch.json',
91
parser = argparse.ArgumentParser(
92
description="Generate confinement files for Checkbox")
93
parser.add_argument('--checkbox_version', action='store', type=str)
94
parser.add_argument('job_ids', nargs='+')
95
args = parser.parse_args()
96
checkbox_name = ("com.ubuntu.checkbox_checkbox-touch_" +
97
args.checkbox_version)
99
# check if current dir looks like a provider - very dumb heuristic
100
if not os.path.exists('manage.py'):
101
sys.exit("Current directory doesn't look like a plainbox provider")
102
provider_name = os.path.split(os.getcwd())[-1]
105
for job in args.job_ids:
106
hook = generate_confinement(
107
provider_name, job, checkbox_name, job + '.qml')
108
hooks += json.dumps(hook, sort_keys=True, indent=4)[1:-1]
110
print("Add following hooks to your checkbox-touch.manifest:")
114
if __name__ == '__main__':