~ubuntu-branches/ubuntu/karmic/quodlibet/karmic

« back to all changes in this revision

Viewing changes to gdist/shortcuts.py

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2009-01-30 23:55:34 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20090130235534-l4e72ulw0vqfo17w
Tags: 2.0-1ubuntu1
* Merge from Debian experimental (LP: #276856), remaining Ubuntu changes:
  + debian/patches/40-use-music-profile.patch:
    - Use the "Music and Movies" pipeline per default.
* Refresh the above patch for new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2007 Joe Wreschnig
 
2
#
 
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.
 
7
 
 
8
import os
 
9
 
 
10
from distutils.dep_util import newer
 
11
from gdist.core import GCommand
 
12
 
 
13
class build_shortcuts(GCommand):
 
14
    """Build .desktop files
 
15
 
 
16
    Move .desktop files to the appropriate location in the build tree.
 
17
    If there is a .desktop.in file, process it with intltool.
 
18
    """
 
19
 
 
20
    description = "build .desktop files"
 
21
    user_options = []
 
22
    build_base = None
 
23
 
 
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'))
 
28
 
 
29
    def run(self):
 
30
        basepath = os.path.join(self.build_base, 'share', 'applications')
 
31
        self.mkpath(basepath)
 
32
        for shortcut in self.shortcuts:
 
33
            if os.path.exists(shortcut + ".in"):
 
34
                fullpath = os.path.join(basepath, shortcut)
 
35
                self.check_po()
 
36
                if newer(shortcut + ".in", fullpath):
 
37
                    self.spawn(["intltool-merge",
 
38
                                "-d", self.po_directory,
 
39
                                shortcut + ".in", fullpath])
 
40
            else:
 
41
                self.copy_file(shortcut, os.path.join(basepath, shortcut))
 
42
 
 
43
class install_shortcuts(GCommand):
 
44
    """Install .desktop files
 
45
 
 
46
    Install any .desktop files from the build tree to their final
 
47
    location, under $prefix/share/applications.
 
48
    """
 
49
 
 
50
    description = "install .desktop files"
 
51
 
 
52
    prefix = None
 
53
    skip_build = None
 
54
    shortcuts = None
 
55
    build_base = None
 
56
 
 
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(
 
61
            'install',
 
62
            ('install_base', 'prefix'),
 
63
            ('skip_build', 'skip_build'))
 
64
 
 
65
        self.set_undefined_options(
 
66
            'build_shortcuts', ('shortcuts', 'shortcuts'))
 
67
 
 
68
    def run(self):
 
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')
 
73
        self.mkpath(basepath)
 
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)
 
78
 
 
79
__all__ = ["build_shortcuts", "install_shortcuts"]