~ubuntu-branches/debian/sid/obnam/sid

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Package Import Robot
  • Author(s): Lars Wirzenius
  • Date: 2015-07-01 18:14:49 UTC
  • Revision ID: package-import@ubuntu.com-20150701181449-taxcvqg9cviw2cxo
Tags: 1.10-1
* New upstream version.
  * Fix "restore to /tmp messes up directory perms" by preventing
    restores to a non-empty directory. (Closes: #760492)
* Add build-dependency on git.
* Drop build-dependency on texlive and building of PDF form of manual.
  Texlive is an insanely large build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
 
# Copyright (C) 2008-2014  Lars Wirzenius <liw@liw.fi>
 
2
# Copyright (C) 2008-2015  Lars Wirzenius <liw@liw.fi>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License as published by
59
59
 
60
60
    def run(self):
61
61
        build.run(self)
62
 
 
63
 
        print 'building manpages'
64
 
        for x in ['obnam']:
65
 
            with open('%s.1' % x, 'w') as f:
66
 
                runcmd(['python', x, '--generate-manpage=%s.1.in' % x,
67
 
                        '--output=%s.1' % x], stdout=f)
 
62
        self.build_manpage('obnam')
 
63
 
 
64
    def build_manpage(self, program):
 
65
        print 'building manpage for %s' % program
 
66
        self.generate_troff(program)
 
67
 
 
68
    def generate_troff(self, program):
 
69
        with open('%s.1' % program, 'w') as f:
 
70
            cliapp.runcmd(
 
71
                ['python', program, '--generate-manpage=%s.1.in' % program,
 
72
                 '--output=%s.1' % program],
 
73
                stdout=f)
68
74
 
69
75
 
70
76
class BuildDocs(Command):
84
90
        print 'building yarns'
85
91
        runcmd(['make', '-C', 'yarns'])
86
92
 
 
93
        self.format_txt('obnam')
 
94
 
 
95
    def format_txt(self, program):
 
96
        env = dict(os.environ)
 
97
        env['MANWIDTH'] = '80'
 
98
        with open('%s.1.txt' % program, 'w') as f:
 
99
            cliapp.runcmd(
 
100
                ['man', '-l', '%s.1' % program],
 
101
                ['col', '-b'],
 
102
                stdout=f,
 
103
                env=env)
87
104
 
88
105
class CleanMore(clean):
89
106
 
143
160
 
144
161
    def run(self):
145
162
        if self.unit_tests:
146
 
            print "run unit tests"
147
 
            runcmd(['python', '-m', 'CoverageTestRunner',
148
 
                    '--ignore-missing-from=without-tests'])
149
 
            os.remove('.coverage')
 
163
            self.run_unit_tests()
150
164
 
151
165
        if self.yarns and got_yarn:
152
 
            runcmd(
153
 
                ['yarn', '-s', 'yarns/obnam.sh'] +
154
 
                glob.glob('yarns/*.yarn'))
 
166
            self.run_yarn()
155
167
 
156
168
        num_clients = '2'
157
169
        num_generations = '16'
158
170
 
159
171
        if self.lock_tests:
160
 
            print "run local locking tests"
161
 
            test_repo = tempfile.mkdtemp()
162
 
            runcmd(['./test-locking', num_clients,
163
 
                    num_generations, test_repo, test_repo])
164
 
            shutil.rmtree(test_repo)
 
172
            self.run_lock_test(num_clients, num_generations)
165
173
 
166
174
        if self.crash_tests:
167
 
            print "run crash test"
168
 
            runcmd(['./crash-test', '200'])
 
175
            self.run_crash_test()
169
176
 
170
177
        if self.sftp_tests:
171
 
            print "run sftp tests"
172
 
            runcmd(['./test-sftpfs'])
 
178
            self.run_sftp_test()
173
179
 
174
180
        if self.network_lock_tests:
175
 
            print "re-run locking tests using localhost networking"
176
 
            test_repo = tempfile.mkdtemp()
177
 
            repo_url = 'sftp://localhost/%s' % test_repo
178
 
            runcmd(['./test-locking', num_clients,
179
 
                    num_generations, repo_url, test_repo])
180
 
            shutil.rmtree(test_repo)
 
181
            self.run_network_lock_test(num_clients, num_generations)
181
182
 
182
183
        if self.nitpick:
 
184
            self.run_nitpick_checks()
 
185
 
 
186
        print "setup.py check done"
 
187
 
 
188
    def run_unit_tests(self):
 
189
        print "run unit tests"
 
190
        runcmd(['python', '-m', 'CoverageTestRunner',
 
191
                '--ignore-missing-from=without-tests'])
 
192
        os.remove('.coverage')
 
193
 
 
194
    def run_yarn(self):
 
195
        for repo_format in self.get_wanted_formats():
 
196
            self.run_yarn_for_repo_format(repo_format)
 
197
 
 
198
    def get_wanted_formats(self):
 
199
        if 'REPOSITORY_FORMAT' in os.environ:
 
200
            return [os.environ['REPOSITORY_FORMAT']]
 
201
        else:
 
202
            return cliapp.runcmd(['./obnam', 'list-formats']).splitlines()
 
203
 
 
204
    def run_yarn_for_repo_format(self, repo_format):
 
205
        print 'run yarn for repository format %s' % repo_format
 
206
        runcmd(
 
207
            ['yarn', '-s', 'yarns/obnam.sh'] +
 
208
            ['--env', 'REPOSITORY_FORMAT=' + repo_format] +
 
209
            glob.glob('yarns/*.yarn'))
 
210
 
 
211
    def run_lock_test(self, num_clients, num_generations):
 
212
        print "run local locking tests"
 
213
        test_repo = tempfile.mkdtemp()
 
214
        runcmd(['./test-locking', num_clients,
 
215
                num_generations, test_repo, test_repo])
 
216
        shutil.rmtree(test_repo)
 
217
 
 
218
    def run_network_lock_test(self, num_clients, num_generations):
 
219
        print "run locking tests using localhost networking"
 
220
        test_repo = tempfile.mkdtemp()
 
221
        repo_url = 'sftp://localhost/%s' % test_repo
 
222
        runcmd(['./test-locking', num_clients,
 
223
                num_generations, repo_url, test_repo])
 
224
        shutil.rmtree(test_repo)
 
225
 
 
226
    def run_crash_test(self):
 
227
        print "run crash test"
 
228
        runcmd(['./crash-test', '200'])
 
229
 
 
230
    def run_sftp_test(self):
 
231
        print "run sftp tests"
 
232
        runcmd(['./test-sftpfs'])
 
233
 
 
234
    def run_nitpick_checks(self):
 
235
        if os.path.exists('.git'):
183
236
            sources = self.find_all_source_files()
184
237
            self.check_sources_for_nitpicks(sources)
185
238
            self.check_copyright_statements(sources)
186
 
 
187
 
        print "setup.py check done"
 
239
        else:
 
240
            print "no .git, no nitpick for you"
188
241
 
189
242
    def check_sources_for_nitpicks(self, sources):
190
243
        cliapp.runcmd(['./nitpicker'] + sources, stdout=None, stderr=None)
198
251
 
199
252
    def copylint_is_available(self):
200
253
        returncode, stdout, stderr = cliapp.runcmd_unchecked(
201
 
            ['copyright-statement-lint', '--help'])
 
254
            ['sh', '-c', 'command -v copyright-statement-lint'])
202
255
        return returncode == 0
203
256
 
204
257
    def find_all_source_files(self):
235
288
 
236
289
 
237
290
setup(name='obnam',
238
 
      version='1.8',
 
291
      version='1.10',
239
292
      description='Backup software',
240
293
      author='Lars Wirzenius',
241
294
      author_email='liw@liw.fi',
242
 
      url='http://liw.fi/obnam/',
 
295
      url='http://obnam.org/',
243
296
      scripts=['obnam', 'obnam-viewprof'],
244
 
      packages=['obnamlib', 'obnamlib.plugins', 'obnamlib.fmt_6'],
 
297
      packages=[
 
298
          'obnamlib',
 
299
          'obnamlib.plugins',
 
300
          'obnamlib.fmt_6',
 
301
          'obnamlib.fmt_simple'
 
302
      ],
245
303
      ext_modules=[Extension('obnamlib._obnam', sources=['_obnammodule.c'])],
246
304
      data_files=[('share/man/man1', glob.glob('*.1'))],
247
305
      cmdclass={