~ubuntu-branches/ubuntu/wily/samba/wily

« back to all changes in this revision

Viewing changes to buildtools/wafadmin/Tools/intltool.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-05-15 17:00:56 UTC
  • mfrom: (178.1.1 precise-security) (0.39.27 sid)
  • Revision ID: package-import@ubuntu.com-20120515170056-gludtas4257eb61q
Tags: 2:3.6.5-2ubuntu1
* Merge from Debian unstable, remaining changes: 
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Other changes now in Debian packaging.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.install: install profile.
    - debian/control: have samba suggest ufw.
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba-common-bin.install: install hook.
  + Switch to upstart:
    - Added debian/samba.{nmbd,smbd}.upstart.
    - debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
      Make upstart compatible.
* d/samba.install, d/samba-common-bin.install: Restore apport hook and ufw
  profile (LP: #999764).
* Dropped:
  + debian/patches/CVE-2012-1182-*.patch: fixed in upstream release 3.6.4.
  + debian/patches/CVE-2012-2111.patch: fixed in upstream release 3.6.5.
  + debian/patches/fix-debuglevel-name-conflict.patch: fixed upstream -
    debug_level is no longer used as a global variable name.
  + debian/patches/error-trans.fix-276472: fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# encoding: utf-8
 
3
# Thomas Nagy, 2006 (ita)
 
4
 
 
5
"intltool support"
 
6
 
 
7
import os, re
 
8
import Configure, TaskGen, Task, Utils, Runner, Options, Build, config_c
 
9
from TaskGen import feature, before, taskgen
 
10
from Logs import error
 
11
 
 
12
"""
 
13
Usage:
 
14
 
 
15
bld(features='intltool_in', source='a.po b.po', podir='po', cache='.intlcache', flags='')
 
16
 
 
17
"""
 
18
 
 
19
class intltool_in_taskgen(TaskGen.task_gen):
 
20
        """deprecated"""
 
21
        def __init__(self, *k, **kw):
 
22
                TaskGen.task_gen.__init__(self, *k, **kw)
 
23
 
 
24
@before('apply_core')
 
25
@feature('intltool_in')
 
26
def iapply_intltool_in_f(self):
 
27
        try: self.meths.remove('apply_core')
 
28
        except ValueError: pass
 
29
 
 
30
        for i in self.to_list(self.source):
 
31
                node = self.path.find_resource(i)
 
32
 
 
33
                podir = getattr(self, 'podir', 'po')
 
34
                podirnode = self.path.find_dir(podir)
 
35
                if not podirnode:
 
36
                        error("could not find the podir %r" % podir)
 
37
                        continue
 
38
 
 
39
                cache = getattr(self, 'intlcache', '.intlcache')
 
40
                self.env['INTLCACHE'] = os.path.join(self.path.bldpath(self.env), podir, cache)
 
41
                self.env['INTLPODIR'] = podirnode.srcpath(self.env)
 
42
                self.env['INTLFLAGS'] = getattr(self, 'flags', ['-q', '-u', '-c'])
 
43
 
 
44
                task = self.create_task('intltool', node, node.change_ext(''))
 
45
                task.install_path = self.install_path
 
46
 
 
47
class intltool_po_taskgen(TaskGen.task_gen):
 
48
        """deprecated"""
 
49
        def __init__(self, *k, **kw):
 
50
                TaskGen.task_gen.__init__(self, *k, **kw)
 
51
 
 
52
 
 
53
@feature('intltool_po')
 
54
def apply_intltool_po(self):
 
55
        try: self.meths.remove('apply_core')
 
56
        except ValueError: pass
 
57
 
 
58
        self.default_install_path = '${LOCALEDIR}'
 
59
        appname = getattr(self, 'appname', 'set_your_app_name')
 
60
        podir = getattr(self, 'podir', '')
 
61
 
 
62
        def install_translation(task):
 
63
                out = task.outputs[0]
 
64
                filename = out.name
 
65
                (langname, ext) = os.path.splitext(filename)
 
66
                inst_file = langname + os.sep + 'LC_MESSAGES' + os.sep + appname + '.mo'
 
67
                self.bld.install_as(os.path.join(self.install_path, inst_file), out, self.env, self.chmod)
 
68
 
 
69
        linguas = self.path.find_resource(os.path.join(podir, 'LINGUAS'))
 
70
        if linguas:
 
71
                # scan LINGUAS file for locales to process
 
72
                file = open(linguas.abspath())
 
73
                langs = []
 
74
                for line in file.readlines():
 
75
                        # ignore lines containing comments
 
76
                        if not line.startswith('#'):
 
77
                                langs += line.split()
 
78
                file.close()
 
79
                re_linguas = re.compile('[-a-zA-Z_@.]+')
 
80
                for lang in langs:
 
81
                        # Make sure that we only process lines which contain locales
 
82
                        if re_linguas.match(lang):
 
83
                                node = self.path.find_resource(os.path.join(podir, re_linguas.match(lang).group() + '.po'))
 
84
                                task = self.create_task('po')
 
85
                                task.set_inputs(node)
 
86
                                task.set_outputs(node.change_ext('.mo'))
 
87
                                if self.bld.is_install: task.install = install_translation
 
88
        else:
 
89
                Utils.pprint('RED', "Error no LINGUAS file found in po directory")
 
90
 
 
91
Task.simple_task_type('po', '${POCOM} -o ${TGT} ${SRC}', color='BLUE', shell=False)
 
92
Task.simple_task_type('intltool',
 
93
        '${INTLTOOL} ${INTLFLAGS} ${INTLCACHE} ${INTLPODIR} ${SRC} ${TGT}',
 
94
        color='BLUE', after="cc_link cxx_link", shell=False)
 
95
 
 
96
def detect(conf):
 
97
        pocom = conf.find_program('msgfmt')
 
98
        if not pocom:
 
99
                # if msgfmt should not be mandatory, catch the thrown exception in your wscript
 
100
                conf.fatal('The program msgfmt (gettext) is mandatory!')
 
101
        conf.env['POCOM'] = pocom
 
102
 
 
103
        # NOTE: it is possible to set INTLTOOL in the environment, but it must not have spaces in it
 
104
 
 
105
        intltool = conf.find_program('intltool-merge', var='INTLTOOL')
 
106
        if not intltool:
 
107
                # if intltool-merge should not be mandatory, catch the thrown exception in your wscript
 
108
                if Options.platform == 'win32':
 
109
                        perl = conf.find_program('perl', var='PERL')
 
110
                        if not perl:
 
111
                                conf.fatal('The program perl (required by intltool) could not be found')
 
112
 
 
113
                        intltooldir = Configure.find_file('intltool-merge', os.environ['PATH'].split(os.pathsep))
 
114
                        if not intltooldir:
 
115
                                conf.fatal('The program intltool-merge (intltool, gettext-devel) is mandatory!')
 
116
 
 
117
                        conf.env['INTLTOOL'] = Utils.to_list(conf.env['PERL']) + [intltooldir + os.sep + 'intltool-merge']
 
118
                        conf.check_message('intltool', '', True, ' '.join(conf.env['INTLTOOL']))
 
119
                else:
 
120
                        conf.fatal('The program intltool-merge (intltool, gettext-devel) is mandatory!')
 
121
 
 
122
        def getstr(varname):
 
123
                return getattr(Options.options, varname, '')
 
124
 
 
125
        prefix  = conf.env['PREFIX']
 
126
        datadir = getstr('datadir')
 
127
        if not datadir: datadir = os.path.join(prefix,'share')
 
128
 
 
129
        conf.define('LOCALEDIR', os.path.join(datadir, 'locale'))
 
130
        conf.define('DATADIR', datadir)
 
131
 
 
132
        if conf.env['CC'] or conf.env['CXX']:
 
133
                # Define to 1 if <locale.h> is present
 
134
                conf.check(header_name='locale.h')
 
135
 
 
136
def set_options(opt):
 
137
        opt.add_option('--want-rpath', type='int', default=1, dest='want_rpath', help='set rpath to 1 or 0 [Default 1]')
 
138
        opt.add_option('--datadir', type='string', default='', dest='datadir', help='read-only application data')
 
139