fixing routing.py bug, if time is 24:00
[pywienerlinien] / bdist_hdeb.py
1 import os
2 import stdeb.util as util
3 from shutil import copy
4 from stdeb.command.sdist_dsc import sdist_dsc
5
6 from distutils.core import Command
7
8 __all__ = ['bdist_hdeb']
9
10 class bdist_hdeb(Command):
11     description = 'distutils command to create debian harmattan binary package'
12
13     user_options = [ ("aegis-manifest=", None, 'aegis manifest to use') ]
14     boolean_options = []
15
16     def initialize_options (self):
17         self.aegis_manifest = None
18
19     def finalize_options (self):
20         pass
21
22     def run(self):
23         
24         # generate .dsc source pkg
25         self.run_command('sdist_dsc')
26
27         # execute system command and read output (execute and read output of find cmd)
28         dsc_tree = 'deb_dist'
29         target_dir = None
30         for entry in os.listdir(dsc_tree):
31             fulldir = os.path.join(dsc_tree,entry)
32             if os.path.isdir(fulldir):
33                 if target_dir is not None:
34                     raise ValueError('more than one directory in deb_dist. '
35                                      'Unsure which is source directory')
36                 else:
37                     target_dir = fulldir
38         if target_dir is None:
39             raise ValueError('could not find debian source directory')        
40         
41         # inject custom logic to dh_builddeb (build digsigsums before and add aegis manifest after)
42         DEBNAME = self.distribution.get_name()+'_'+self.distribution.get_version()+'*_all.deb'
43         rules = open(target_dir+'/debian/rules', 'a')
44         rules.write('override_dh_builddeb:\n\tpython ../../digsigsums.py '+self.distribution.get_name()+\
45         '\n\tdh_builddeb')
46         if self.aegis_manifest is not None:
47             rules.write('\n\tar q ../'+DEBNAME+' _aegis')
48         
49         rules.write('\n\n')
50         rules.close()
51
52         # make aegies manifest avaiable to debian/rules
53         if self.aegis_manifest is not None:
54             copy(self.aegis_manifest, target_dir+'/_aegis')
55         
56         # define system command to execute (gen .deb binary pkg)
57         syscmd = ['dpkg-buildpackage','-rfakeroot','-uc','-b']
58
59         util.process_command(syscmd,cwd=target_dir)   
60