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 aegis manifest into .deb
42 if self.aegis_manifest is not None:
43 DEBNAME = self.distribution.get_name()+'_'+self.distribution.get_version()+'*_all.deb'
44 copy(self.aegis_manifest, target_dir+'/_aegis')
45 rules = open(target_dir+'/debian/rules', 'a')
46 rules.write('override_dh_builddeb:\n\tdh_builddeb\n\tar q ../'+DEBNAME+' _aegis\n\n')
49 # define system command to execute (gen .deb binary pkg)
50 syscmd = ['dpkg-buildpackage','-rfakeroot','-uc','-b']
52 util.process_command(syscmd,cwd=target_dir)