1
# Copyright 2007 Joe Wreschnig
3
# This software and accompanying documentation, if any, may be freely
4
# used, distributed, and/or modified, in any form and for any purpose,
5
# as long as this notice is preserved. There is no warranty, either
6
# express or implied, for this software.
10
from distutils.dep_util import newer
11
from gdist.core import GCommand
13
class build_shortcuts(GCommand):
14
"""Build .desktop files
16
Move .desktop files to the appropriate location in the build tree.
17
If there is a .desktop.in file, process it with intltool.
20
description = "build .desktop files"
24
def finalize_options(self):
25
GCommand.finalize_options(self)
26
self.shortcuts = self.distribution.shortcuts
27
self.set_undefined_options('build', ('build_base', 'build_base'))
30
basepath = os.path.join(self.build_base, 'share', 'applications')
32
for shortcut in self.shortcuts:
33
if os.path.exists(shortcut + ".in"):
34
fullpath = os.path.join(basepath, shortcut)
36
if newer(shortcut + ".in", fullpath):
37
self.spawn(["intltool-merge",
38
"-d", self.po_directory,
39
shortcut + ".in", fullpath])
41
self.copy_file(shortcut, os.path.join(basepath, shortcut))
43
class install_shortcuts(GCommand):
44
"""Install .desktop files
46
Install any .desktop files from the build tree to their final
47
location, under $prefix/share/applications.
50
description = "install .desktop files"
57
def finalize_options(self):
58
GCommand.finalize_options(self)
59
self.set_undefined_options('build', ('build_base', 'build_base'))
60
self.set_undefined_options(
62
('install_base', 'prefix'),
63
('skip_build', 'skip_build'))
65
self.set_undefined_options(
66
'build_shortcuts', ('shortcuts', 'shortcuts'))
69
if not self.skip_build:
70
self.run_command('build_shortcuts')
71
basepath = os.path.join(self.prefix, 'share', 'applications')
72
srcpath = os.path.join(self.build_base, 'share', 'applications')
74
for shortcut in self.shortcuts:
75
fullsrc = os.path.join(srcpath, shortcut)
76
fullpath = os.path.join(basepath, shortcut)
77
self.copy_file(fullsrc, fullpath)
79
__all__ = ["build_shortcuts", "install_shortcuts"]