def run (self): """ """ #Create folders and copy sources files DEBIAN_DIR = os.path.join(self.build_dir,'debian') DATA_DIR = os.path.join(self.build_dir,self.debian_package) mkpath(DEBIAN_DIR) mkpath(self.dist_dir) #mkpath(os.path.join(DATA_DIR,'usr','bin')) self.bdist_dir = DATA_DIR install = self.reinitialize_command('install', reinit_subcommands=1) install.root = self.bdist_dir if self.install_purelib is not None: install.install_purelib = self.install_purelib install.skip_build = 0 install.warn_dir = 1 self.run_command('install') #Create the debian rules rules = Rules(self.debian_package,DATA_DIR) dirs = rules.dirs open(os.path.join(DEBIAN_DIR,"rules"),"w").write(unicode(rules.getContent()).encode('utf-8')) os.chmod(os.path.join(DEBIAN_DIR,"rules"),0755) #Create the debian compat open(os.path.join(DEBIAN_DIR,"compat"),"w").write("5\n") #Create the debian dirs open(os.path.join(DEBIAN_DIR,"dirs"),"w").write("\n".join(dirs)) #Create the debian changelog d=datetime.now() self.buildDate=d.strftime("%a, %d %b %Y %H:%M:%S +0000") clog = Changelog(self.debian_package,self.version,self.buildversion,self.changelog,self.distribution.get_maintainer(),self.distribution.get_maintainer_email(),self.buildDate) open(os.path.join(DEBIAN_DIR,"changelog"),"w").write(unicode(clog.getContent()).encode('utf-8')) #Create the pre/post inst/rm Script if self.preinst is not None: self.mkscript(self.preinst ,os.path.join(DEBIAN_DIR,"preinst")) if self.postinst is not None: self.mkscript(self.postinst,os.path.join(DEBIAN_DIR,"postinst")) if self.prere is not None: self.mkscript(self.prere ,os.path.join(DEBIAN_DIR,"prerm")) if self.postre is not None: self.mkscript(self.postre ,os.path.join(DEBIAN_DIR,"postrm")) #Create the control file control = Control(self.debian_package, self.section, self.distribution.get_maintainer(), self.distribution.get_maintainer_email(), self.architecture, self.depends, self.suggests, self.description, self.long_description, self.conflicts, self.replaces, optionnal = { 'XB-Maemo-Display-Name':self.Maemo_Display_Name, 'XB-Maemo-Upgrade-Description':self.Maemo_Upgrade_Description, 'XSBC-Bugtracker':self.Maemo_Bugtracker, 'XB-Maemo-Icon-26':self.getIconContent(self.Maemo_Icon_26), 'XB-Maemo-Flags':self.Maemo_Flags, 'XB-Meego-Desktop-Entry-Filename':self.MeeGo_Desktop_Entry_Filename } ) open(os.path.join(DEBIAN_DIR,"control"),"w").write(unicode(control.getContent()).encode('utf-8')) #Create the debian licence file licence = Licence(self.copyright, self.distribution.get_maintainer(), self.distribution.get_maintainer_email(), self.buildDate, str(datetime.now().year)) open(os.path.join(DEBIAN_DIR,"copyright"),"w").write(unicode(licence.getContent()).encode('utf-8')) #Delete tar if already exist as it will made add to the same tar tarpath = os.path.join(self.dist_dir,self.debian_package+'_'+self.version+'-'+self.buildversion+'.tar.gz') if os.path.exists(tarpath): os.remove(tarpath) #Now create the tar.gz import tarfile def reset(tarinfo): tarinfo.uid = tarinfo.gid = 0 tarinfo.uname = tarinfo.gname = "root" return tarinfo tar = tarfile.open(tarpath, 'w:gz') #tar.add(self.dist_dir,'.') tar.add(self.build_dir,'.') tar.close() #Clean the build dir remove_tree(DEBIAN_DIR) remove_tree(DATA_DIR) #Create the Dsc file import locale try: old_locale,iso=locale.getlocale(locale.LC_TIME) locale.setlocale(locale.LC_TIME,'en_US') except: pass dsccontent = Dsc("%s-%s"%(self.version,self.buildversion), self.depends, (os.path.join(self.dist_dir,self.debian_package+'_'+self.version+'-'+self.buildversion+'.tar.gz'),), Format='1.0', Source=self.debian_package, Version="%s-%s"%(self.version,self.buildversion), Maintainer="%s <%s>"%(self.distribution.get_maintainer(),self.distribution.get_maintainer_email()), Architecture="%s"%self.architecture, ) f = open(os.path.join(self.dist_dir,self.debian_package+'_'+self.version+'-'+self.buildversion+'.dsc'),"wb") f.write(unicode(dsccontent._getContent()).encode('utf-8')) f.close() #Changes file changescontent = Changes( "%s <%s>"%(self.distribution.get_maintainer(),self.distribution.get_maintainer_email()), "%s"%self.description, "%s"%self.changelog, ( "%s.tar.gz"%os.path.join(self.dist_dir,self.debian_package+'_'+self.version+'-'+self.buildversion), "%s.dsc"%os.path.join(self.dist_dir,self.debian_package+'_'+self.version+'-'+self.buildversion), ), "%s"%self.section, "%s"%self.repository, Format='1.7', Date=time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()), Source="%s"%self.debian_package, Architecture="%s"%self.architecture, Version="%s-%s"%(self.version,self.buildversion), Distribution="%s"%self.repository, Urgency="%s"%self.urgency, Maintainer="%s <%s>"%(self.distribution.get_maintainer(),self.distribution.get_maintainer_email()) ) f = open(os.path.join(self.dist_dir,self.debian_package+'_'+self.version+'-'+self.buildversion+'.changes'),"wb") f.write(unicode(changescontent.getContent()).encode('utf-8')) f.close() try: locale.setlocale(locale.LC_TIME,old_locale) except: pass