2 import stdeb.util as util
3 from shutil import copy
4 from stdeb.command.sdist_dsc import sdist_dsc
6 from distutils.core import Command
8 __all__ = ['bdist_hdeb']
10 class bdist_hdeb(Command):
11 description = 'distutils command to create debian harmattan binary package'
13 user_options = [ ("aegis-manifest=", None, 'aegis manifest to use') ]
16 def initialize_options (self):
17 self.aegis_manifest = None
19 def finalize_options (self):
24 # generate .dsc source pkg
25 self.run_command('sdist_dsc')
27 # execute system command and read output (execute and read output of find cmd)
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')
38 if target_dir is None:
39 raise ValueError('could not find debian source directory')
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()+\
46 if self.aegis_manifest is not None:
47 rules.write('\n\tar q ../'+DEBNAME+' _aegis')
52 # make aegies manifest avaiable to debian/rules
53 if self.aegis_manifest is not None:
54 copy(self.aegis_manifest, target_dir+'/_aegis')
56 # define system command to execute (gen .deb binary pkg)
57 syscmd = ['dpkg-buildpackage','-rfakeroot','-uc','-b']
59 util.process_command(syscmd,cwd=target_dir)