2
# This file is part of Checkbox.
4
# Copyright 2012, 2013, 2014 Canonical Ltd.
6
# Zygmunt Krynicki <zygmunt.krynicki@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 as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# Checkbox is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
24
from plainbox.provider_manager import InstallCommand
25
from plainbox.provider_manager import SourceDistributionCommand
26
from plainbox.provider_manager import _logger
27
from plainbox.provider_manager import manage_py_extension
28
from plainbox.provider_manager import setup, N_, _
32
class SourceDistributionCommandExt(SourceDistributionCommand):
33
# Overridden version of SourceDistributionCommand that handles launcher/
34
__doc__ = SourceDistributionCommand.__doc__
35
_INCLUDED_ITEMS = SourceDistributionCommand._INCLUDED_ITEMS + [
36
'COPYING', 'launcher']
40
class InstallCommandExt(InstallCommand):
41
# Overridden version of InstallCommand that handles launcher/
42
__doc__ = InstallCommand.__doc__
45
def invoked(self, ns):
47
self._copy_launcher(ns)
50
def launcher_dir(self):
51
return os.path.join(self.definition.location, 'launcher')
53
def _copy_launcher(self, ns):
54
for name in os.listdir(self.launcher_dir):
55
src_file = os.path.join(self.launcher_dir, name)
56
if os.path.isfile(src_file) and name.endswith('.desktop'):
57
self._copy_desktop_file(ns, src_file)
58
elif os.path.isfile(src_file) and os.access(src_file, os.X_OK):
59
self._copy_executable(ns, src_file)
61
_logger.warning(_("unexpected file: %s"), os.path.relpath(
62
src_file, self.definition.location))
64
def _copy_desktop_file(self, ns, src_file):
65
destdir = ns.root + os.path.join(ns.prefix, 'share', 'applications')
66
os.makedirs(destdir, exist_ok=True)
67
shutil.copy(src_file, destdir)
69
def _copy_executable(self, ns, src_file):
70
destdir = ns.root + os.path.join(ns.prefix, 'bin')
71
os.makedirs(destdir, exist_ok=True)
72
shutil.copy(src_file, destdir)
74
def _copy_all_executables(self, root, prefix, layout, provider):
75
if provider.get_all_executables():
76
super()._copy_all_executables(root, prefix, layout, provider)
80
name='2013.com.canonical.certification:certification-server',
82
description=N_("Server Certification provider"),
83
gettext_domain="2013_com_canonical_certification_certification-server",